mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-25 06:36:49 +09:00
commit
637859dee9
15 files changed
+1611
-21
No files matched your search
+15
-3
@@ -13,7 +13,19 @@ fi
|
||||
|
||||
# Get the directory of this script
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SWARM_DEMO="$SCRIPT_DIR/../swarm-demo.ts"
|
||||
|
||||
# Run the swarm demo with all arguments
|
||||
exec "$DENO_PATH" run --allow-all "$SWARM_DEMO" "$@"
|
||||
# Try to find swarm implementation in different locations
|
||||
if [ -f "$SCRIPT_DIR/../swarm-demo.ts" ]; then
|
||||
# Local development path
|
||||
SWARM_IMPL="$SCRIPT_DIR/../swarm-demo.ts"
|
||||
elif [ -f "$SCRIPT_DIR/../src/cli/swarm-standalone.js" ]; then
|
||||
# Installed via npm - use the standalone JavaScript version
|
||||
SWARM_IMPL="$SCRIPT_DIR/../src/cli/swarm-standalone.js"
|
||||
else
|
||||
echo "Error: Unable to find swarm implementation files"
|
||||
echo "Please ensure claude-flow is properly installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run the swarm implementation with all arguments
|
||||
exec "$DENO_PATH" run --allow-all "$SWARM_IMPL" "$@"
|
||||
@@ -44,9 +44,9 @@
|
||||
},
|
||||
{
|
||||
"key": "test-key",
|
||||
"value": "Testing memory storage",
|
||||
"value": "Test value from CLI test",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749772000742
|
||||
"timestamp": 1749836389246
|
||||
}
|
||||
]
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "claude-flow",
|
||||
"version": "1.0.43",
|
||||
"version": "1.0.49",
|
||||
"description": "Advanced AI agent orchestration system for Claude Code",
|
||||
"main": "src/cli/main.ts",
|
||||
"bin": {
|
||||
|
||||
@@ -239,7 +239,7 @@ async function getSystemStatus(): Promise<any> {
|
||||
// Mock status for now - in production, this would call the orchestrator API
|
||||
return {
|
||||
overall: 'healthy',
|
||||
version: '1.0.0',
|
||||
version: '1.0.49',
|
||||
uptime: Date.now() - (Date.now() - 3600000), // 1 hour ago
|
||||
startTime: new Date(Date.now() - 3600000),
|
||||
components: {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
import { CLI } from "./cli-core.ts";
|
||||
import { setupCommands } from "./commands/index.ts";
|
||||
|
||||
const VERSION = "1.0.43";
|
||||
const VERSION = "1.0.49";
|
||||
|
||||
async function main() {
|
||||
const cli = new CLI("claude-flow", "Advanced AI Agent Orchestration System");
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from './command-registry.js';
|
||||
import { parseFlags } from './utils.js';
|
||||
|
||||
const VERSION = '1.0.43';
|
||||
const VERSION = '1.0.49';
|
||||
|
||||
function printHelp() {
|
||||
console.log(`
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This version avoids import assertion issues while maintaining functionality
|
||||
*/
|
||||
|
||||
const VERSION = '1.0.43';
|
||||
const VERSION = '1.0.49';
|
||||
|
||||
function printHelp() {
|
||||
console.log(`
|
||||
|
||||
@@ -0,0 +1,437 @@
|
||||
// claude-flow-commands.js - Claude-Flow specific slash commands
|
||||
|
||||
// Create Claude-Flow specific commands
|
||||
export async function createClaudeFlowCommands(workingDir) {
|
||||
// Help command
|
||||
const helpCommand = `---
|
||||
name: claude-flow-help
|
||||
description: Show Claude-Flow commands and usage
|
||||
---
|
||||
|
||||
# Claude-Flow Commands
|
||||
|
||||
## 🌊 Claude-Flow: Agent Orchestration Platform
|
||||
|
||||
Claude-Flow is the ultimate multi-terminal orchestration platform that revolutionizes how you work with Claude Code.
|
||||
|
||||
## Core Commands
|
||||
|
||||
### 🚀 System Management
|
||||
- \`./claude-flow start\` - Start orchestration system
|
||||
- \`./claude-flow start --ui\` - Start with interactive process management UI
|
||||
- \`./claude-flow status\` - Check system status
|
||||
- \`./claude-flow monitor\` - Real-time monitoring
|
||||
- \`./claude-flow stop\` - Stop orchestration
|
||||
|
||||
### 🤖 Agent Management
|
||||
- \`./claude-flow agent spawn <type>\` - Create new agent
|
||||
- \`./claude-flow agent list\` - List active agents
|
||||
- \`./claude-flow agent info <id>\` - Agent details
|
||||
- \`./claude-flow agent terminate <id>\` - Stop agent
|
||||
|
||||
### 📋 Task Management
|
||||
- \`./claude-flow task create <type> "description"\` - Create task
|
||||
- \`./claude-flow task list\` - List all tasks
|
||||
- \`./claude-flow task status <id>\` - Task status
|
||||
- \`./claude-flow task cancel <id>\` - Cancel task
|
||||
- \`./claude-flow task workflow <file>\` - Execute workflow
|
||||
|
||||
### 🧠 Memory Operations
|
||||
- \`./claude-flow memory store "key" "value"\` - Store data
|
||||
- \`./claude-flow memory query "search"\` - Search memory
|
||||
- \`./claude-flow memory stats\` - Memory statistics
|
||||
- \`./claude-flow memory export <file>\` - Export memory
|
||||
- \`./claude-flow memory import <file>\` - Import memory
|
||||
|
||||
### ⚡ SPARC Development
|
||||
- \`./claude-flow sparc "task"\` - Run SPARC orchestrator
|
||||
- \`./claude-flow sparc modes\` - List all 17+ SPARC modes
|
||||
- \`./claude-flow sparc run <mode> "task"\` - Run specific mode
|
||||
- \`./claude-flow sparc tdd "feature"\` - TDD workflow
|
||||
- \`./claude-flow sparc info <mode>\` - Mode details
|
||||
|
||||
### 🐝 Swarm Coordination
|
||||
- \`./claude-flow swarm "task" --strategy <type>\` - Start swarm
|
||||
- \`./claude-flow swarm "task" --background\` - Long-running swarm
|
||||
- \`./claude-flow swarm "task" --monitor\` - With monitoring
|
||||
- \`./claude-flow swarm "task" --ui\` - Interactive UI
|
||||
- \`./claude-flow swarm "task" --distributed\` - Distributed coordination
|
||||
|
||||
### 🌍 MCP Integration
|
||||
- \`./claude-flow mcp status\` - MCP server status
|
||||
- \`./claude-flow mcp tools\` - List available tools
|
||||
- \`./claude-flow mcp config\` - Show configuration
|
||||
- \`./claude-flow mcp logs\` - View MCP logs
|
||||
|
||||
### 🤖 Claude Integration
|
||||
- \`./claude-flow claude spawn "task"\` - Spawn Claude with enhanced guidance
|
||||
- \`./claude-flow claude batch <file>\` - Execute workflow configuration
|
||||
|
||||
## 🌟 Quick Examples
|
||||
|
||||
### Initialize with SPARC:
|
||||
\`\`\`bash
|
||||
npx -y claude-flow@latest init --sparc
|
||||
\`\`\`
|
||||
|
||||
### Start a development swarm:
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Build REST API" --strategy development --monitor --review
|
||||
\`\`\`
|
||||
|
||||
### Run TDD workflow:
|
||||
\`\`\`bash
|
||||
./claude-flow sparc tdd "user authentication"
|
||||
\`\`\`
|
||||
|
||||
### Store project context:
|
||||
\`\`\`bash
|
||||
./claude-flow memory store "project_requirements" "e-commerce platform specs" --namespace project
|
||||
\`\`\`
|
||||
|
||||
### Spawn specialized agents:
|
||||
\`\`\`bash
|
||||
./claude-flow agent spawn researcher --name "Senior Researcher" --priority 8
|
||||
./claude-flow agent spawn developer --name "Lead Developer" --priority 9
|
||||
\`\`\`
|
||||
|
||||
## 🎯 Best Practices
|
||||
- Use \`./claude-flow\` instead of \`npx claude-flow\` after initialization
|
||||
- Store important context in memory for cross-session persistence
|
||||
- Use swarm mode for complex tasks requiring multiple agents
|
||||
- Enable monitoring for real-time progress tracking
|
||||
- Use background mode for tasks > 30 minutes
|
||||
|
||||
## 📚 Resources
|
||||
- Documentation: https://github.com/ruvnet/claude-code-flow/docs
|
||||
- Examples: https://github.com/ruvnet/claude-code-flow/examples
|
||||
- Issues: https://github.com/ruvnet/claude-code-flow/issues
|
||||
`;
|
||||
|
||||
await Deno.writeTextFile(`${workingDir}/.claude/commands/claude-flow-help.md`, helpCommand);
|
||||
console.log(' ✓ Created slash command: /claude-flow-help');
|
||||
|
||||
// Memory command
|
||||
const memoryCommand = `---
|
||||
name: claude-flow-memory
|
||||
description: Interact with Claude-Flow memory system
|
||||
---
|
||||
|
||||
# 🧠 Claude-Flow Memory System
|
||||
|
||||
The memory system provides persistent storage for cross-session and cross-agent collaboration with CRDT-based conflict resolution.
|
||||
|
||||
## Store Information
|
||||
\`\`\`bash
|
||||
# Store with default namespace
|
||||
./claude-flow memory store "key" "value"
|
||||
|
||||
# Store with specific namespace
|
||||
./claude-flow memory store "architecture_decisions" "microservices with API gateway" --namespace arch
|
||||
\`\`\`
|
||||
|
||||
## Query Memory
|
||||
\`\`\`bash
|
||||
# Search across all namespaces
|
||||
./claude-flow memory query "authentication"
|
||||
|
||||
# Search with filters
|
||||
./claude-flow memory query "API design" --namespace arch --limit 10
|
||||
\`\`\`
|
||||
|
||||
## Memory Statistics
|
||||
\`\`\`bash
|
||||
# Show overall statistics
|
||||
./claude-flow memory stats
|
||||
|
||||
# Show namespace-specific stats
|
||||
./claude-flow memory stats --namespace project
|
||||
\`\`\`
|
||||
|
||||
## Export/Import
|
||||
\`\`\`bash
|
||||
# Export all memory
|
||||
./claude-flow memory export full-backup.json
|
||||
|
||||
# Export specific namespace
|
||||
./claude-flow memory export project-backup.json --namespace project
|
||||
|
||||
# Import memory
|
||||
./claude-flow memory import backup.json
|
||||
\`\`\`
|
||||
|
||||
## Cleanup Operations
|
||||
\`\`\`bash
|
||||
# Clean entries older than 30 days
|
||||
./claude-flow memory cleanup --days 30
|
||||
|
||||
# Clean specific namespace
|
||||
./claude-flow memory cleanup --namespace temp --days 7
|
||||
\`\`\`
|
||||
|
||||
## 🗂️ Namespaces
|
||||
- **default** - General storage
|
||||
- **agents** - Agent-specific data and state
|
||||
- **tasks** - Task information and results
|
||||
- **sessions** - Session history and context
|
||||
- **swarm** - Swarm coordination and objectives
|
||||
- **project** - Project-specific context
|
||||
- **spec** - Requirements and specifications
|
||||
- **arch** - Architecture decisions
|
||||
- **impl** - Implementation notes
|
||||
- **test** - Test results and coverage
|
||||
- **debug** - Debug logs and fixes
|
||||
|
||||
## 🎯 Best Practices
|
||||
|
||||
### Naming Conventions
|
||||
- Use descriptive, searchable keys
|
||||
- Include timestamp for time-sensitive data
|
||||
- Prefix with component name for clarity
|
||||
|
||||
### Organization
|
||||
- Use namespaces to categorize data
|
||||
- Store related data together
|
||||
- Keep values concise but complete
|
||||
|
||||
### Maintenance
|
||||
- Regular backups with export
|
||||
- Clean old data periodically
|
||||
- Monitor storage statistics
|
||||
- Compress large values
|
||||
|
||||
## Examples
|
||||
|
||||
### Store SPARC context:
|
||||
\`\`\`bash
|
||||
./claude-flow memory store "spec_auth_requirements" "OAuth2 + JWT with refresh tokens" --namespace spec
|
||||
./claude-flow memory store "arch_api_design" "RESTful microservices with GraphQL gateway" --namespace arch
|
||||
./claude-flow memory store "test_coverage_auth" "95% coverage, all tests passing" --namespace test
|
||||
\`\`\`
|
||||
|
||||
### Query project decisions:
|
||||
\`\`\`bash
|
||||
./claude-flow memory query "authentication" --namespace arch --limit 5
|
||||
./claude-flow memory query "test results" --namespace test
|
||||
\`\`\`
|
||||
|
||||
### Backup project memory:
|
||||
\`\`\`bash
|
||||
./claude-flow memory export project-$(date +%Y%m%d).json --namespace project
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
await Deno.writeTextFile(`${workingDir}/.claude/commands/claude-flow-memory.md`, memoryCommand);
|
||||
console.log(' ✓ Created slash command: /claude-flow-memory');
|
||||
|
||||
// Swarm command
|
||||
const swarmCommand = `---
|
||||
name: claude-flow-swarm
|
||||
description: Coordinate multi-agent swarms for complex tasks
|
||||
---
|
||||
|
||||
# 🐝 Claude-Flow Swarm Coordination
|
||||
|
||||
Advanced multi-agent coordination system with timeout-free execution, distributed memory sharing, and intelligent load balancing.
|
||||
|
||||
## Basic Usage
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "your complex task" --strategy <type> [options]
|
||||
\`\`\`
|
||||
|
||||
## 🎯 Swarm Strategies
|
||||
- **auto** - Automatic strategy selection based on task analysis
|
||||
- **development** - Code implementation with review and testing
|
||||
- **research** - Information gathering and synthesis
|
||||
- **analysis** - Data processing and pattern identification
|
||||
- **testing** - Comprehensive quality assurance
|
||||
- **optimization** - Performance tuning and refactoring
|
||||
- **maintenance** - System updates and bug fixes
|
||||
|
||||
## 🤖 Agent Types
|
||||
- **coordinator** - Plans and delegates tasks to other agents
|
||||
- **developer** - Writes code and implements solutions
|
||||
- **researcher** - Gathers and analyzes information
|
||||
- **analyzer** - Identifies patterns and generates insights
|
||||
- **tester** - Creates and runs tests for quality assurance
|
||||
- **reviewer** - Performs code and design reviews
|
||||
- **documenter** - Creates documentation and guides
|
||||
- **monitor** - Tracks performance and system health
|
||||
- **specialist** - Domain-specific expert agents
|
||||
|
||||
## 🔄 Coordination Modes
|
||||
- **centralized** - Single coordinator manages all agents (default)
|
||||
- **distributed** - Multiple coordinators share management
|
||||
- **hierarchical** - Tree structure with nested coordination
|
||||
- **mesh** - Peer-to-peer agent collaboration
|
||||
- **hybrid** - Mixed coordination strategies
|
||||
|
||||
## ⚙️ Common Options
|
||||
- \`--strategy <type>\` - Execution strategy
|
||||
- \`--mode <type>\` - Coordination mode
|
||||
- \`--max-agents <n>\` - Maximum concurrent agents (default: 5)
|
||||
- \`--timeout <minutes>\` - Timeout in minutes (default: 60)
|
||||
- \`--background\` - Run in background for tasks > 30 minutes
|
||||
- \`--monitor\` - Enable real-time monitoring
|
||||
- \`--ui\` - Launch terminal UI interface
|
||||
- \`--parallel\` - Enable parallel execution
|
||||
- \`--distributed\` - Enable distributed coordination
|
||||
- \`--review\` - Enable peer review process
|
||||
- \`--testing\` - Include automated testing
|
||||
- \`--encryption\` - Enable data encryption
|
||||
- \`--verbose\` - Detailed logging output
|
||||
- \`--dry-run\` - Show configuration without executing
|
||||
|
||||
## 🌟 Examples
|
||||
|
||||
### Development Swarm with Review
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Build e-commerce REST API" \\
|
||||
--strategy development \\
|
||||
--monitor \\
|
||||
--review \\
|
||||
--testing
|
||||
\`\`\`
|
||||
|
||||
### Long-Running Research Swarm
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Analyze AI market trends 2024-2025" \\
|
||||
--strategy research \\
|
||||
--background \\
|
||||
--distributed \\
|
||||
--max-agents 8
|
||||
\`\`\`
|
||||
|
||||
### Performance Optimization Swarm
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Optimize database queries and API performance" \\
|
||||
--strategy optimization \\
|
||||
--testing \\
|
||||
--parallel \\
|
||||
--monitor
|
||||
\`\`\`
|
||||
|
||||
### Enterprise Development Swarm
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Implement secure payment processing system" \\
|
||||
--strategy development \\
|
||||
--mode distributed \\
|
||||
--max-agents 10 \\
|
||||
--parallel \\
|
||||
--monitor \\
|
||||
--review \\
|
||||
--testing \\
|
||||
--encryption \\
|
||||
--verbose
|
||||
\`\`\`
|
||||
|
||||
### Testing and QA Swarm
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Comprehensive security audit and testing" \\
|
||||
--strategy testing \\
|
||||
--review \\
|
||||
--verbose \\
|
||||
--max-agents 6
|
||||
\`\`\`
|
||||
|
||||
## 📊 Monitoring and Control
|
||||
|
||||
### Real-time monitoring:
|
||||
\`\`\`bash
|
||||
# Monitor swarm activity
|
||||
./claude-flow monitor
|
||||
|
||||
# Monitor specific component
|
||||
./claude-flow monitor --focus swarm
|
||||
\`\`\`
|
||||
|
||||
### Check swarm status:
|
||||
\`\`\`bash
|
||||
# Overall system status
|
||||
./claude-flow status
|
||||
|
||||
# Detailed swarm status
|
||||
./claude-flow status --verbose
|
||||
\`\`\`
|
||||
|
||||
### View agent activity:
|
||||
\`\`\`bash
|
||||
# List all agents
|
||||
./claude-flow agent list
|
||||
|
||||
# Agent details
|
||||
./claude-flow agent info <agent-id>
|
||||
\`\`\`
|
||||
|
||||
## 💾 Memory Integration
|
||||
|
||||
Swarms automatically use distributed memory for collaboration:
|
||||
|
||||
\`\`\`bash
|
||||
# Store swarm objectives
|
||||
./claude-flow memory store "swarm_objective" "Build scalable API" --namespace swarm
|
||||
|
||||
# Query swarm progress
|
||||
./claude-flow memory query "swarm_progress" --namespace swarm
|
||||
|
||||
# Export swarm memory
|
||||
./claude-flow memory export swarm-results.json --namespace swarm
|
||||
\`\`\`
|
||||
|
||||
## 🎯 Key Features
|
||||
|
||||
### Timeout-Free Execution
|
||||
- Background mode for long-running tasks
|
||||
- State persistence across sessions
|
||||
- Automatic checkpoint recovery
|
||||
|
||||
### Work Stealing & Load Balancing
|
||||
- Dynamic task redistribution
|
||||
- Automatic agent scaling
|
||||
- Resource-aware scheduling
|
||||
|
||||
### Circuit Breakers & Fault Tolerance
|
||||
- Automatic retry with exponential backoff
|
||||
- Graceful degradation
|
||||
- Health monitoring and recovery
|
||||
|
||||
### Real-Time Collaboration
|
||||
- Cross-agent communication
|
||||
- Shared memory access
|
||||
- Event-driven coordination
|
||||
|
||||
### Enterprise Security
|
||||
- Role-based access control
|
||||
- Audit logging
|
||||
- Data encryption
|
||||
- Input validation
|
||||
|
||||
## 🔧 Advanced Configuration
|
||||
|
||||
### Dry run to preview:
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "Test task" --dry-run --strategy development
|
||||
\`\`\`
|
||||
|
||||
### Custom quality thresholds:
|
||||
\`\`\`bash
|
||||
./claude-flow swarm "High quality API" \\
|
||||
--strategy development \\
|
||||
--quality-threshold 0.95
|
||||
\`\`\`
|
||||
|
||||
### Scheduling algorithms:
|
||||
- FIFO (First In, First Out)
|
||||
- Priority-based
|
||||
- Deadline-driven
|
||||
- Shortest Job First
|
||||
- Critical Path
|
||||
- Resource-aware
|
||||
- Adaptive
|
||||
|
||||
For detailed documentation, see: https://github.com/ruvnet/claude-code-flow/docs/swarm-system.md
|
||||
`;
|
||||
|
||||
await Deno.writeTextFile(`${workingDir}/.claude/commands/claude-flow-swarm.md`, swarmCommand);
|
||||
console.log(' ✓ Created slash command: /claude-flow-swarm');
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
// sparc-commands.js - SPARC-specific slash commands
|
||||
|
||||
// Create SPARC mode slash command
|
||||
export function createSparcSlashCommand(mode) {
|
||||
// Extract the full description without truncation
|
||||
const fullDescription = mode.roleDefinition.length > 100
|
||||
? `${mode.roleDefinition.substring(0, 97)}...`
|
||||
: mode.roleDefinition;
|
||||
|
||||
return `---
|
||||
name: sparc-${mode.slug}
|
||||
description: ${mode.name} - ${fullDescription}
|
||||
---
|
||||
|
||||
# ${mode.name}
|
||||
|
||||
## Role Definition
|
||||
${mode.roleDefinition}
|
||||
|
||||
## Custom Instructions
|
||||
${mode.customInstructions}
|
||||
|
||||
## Available Tools
|
||||
${Array.isArray(mode.groups) ? mode.groups.map(g => {
|
||||
if (typeof g === 'string') {
|
||||
return `- **${g}**: ${getToolDescription(g)}`;
|
||||
} else if (Array.isArray(g)) {
|
||||
return `- **${g[0]}**: ${g[1]?.description || getToolDescription(g[0])} ${g[1]?.fileRegex ? `(Files matching: ${g[1].fileRegex})` : ''}`;
|
||||
}
|
||||
return `- ${JSON.stringify(g)}`;
|
||||
}).join('\n') : 'None'}
|
||||
|
||||
## Usage
|
||||
|
||||
To use this SPARC mode, you can:
|
||||
|
||||
1. **Run directly**: \`./claude-flow sparc run ${mode.slug} "your task"\`
|
||||
2. **TDD shorthand** (if applicable): \`./claude-flow sparc ${mode.slug} "your task"\`
|
||||
3. **Use in workflow**: Include \`${mode.slug}\` in your SPARC workflow
|
||||
4. **Delegate tasks**: Use \`new_task\` to assign work to this mode
|
||||
|
||||
## Example Commands
|
||||
|
||||
\`\`\`bash
|
||||
# Run this specific mode
|
||||
./claude-flow sparc run ${mode.slug} "${getExampleTask(mode.slug)}"
|
||||
|
||||
# Use with memory namespace
|
||||
./claude-flow sparc run ${mode.slug} "your task" --namespace ${mode.slug}
|
||||
|
||||
# Non-interactive mode for automation
|
||||
./claude-flow sparc run ${mode.slug} "your task" --non-interactive
|
||||
\`\`\`
|
||||
|
||||
## Memory Integration
|
||||
|
||||
\`\`\`bash
|
||||
# Store mode-specific context
|
||||
./claude-flow memory store "${mode.slug}_context" "important decisions" --namespace ${mode.slug}
|
||||
|
||||
# Query previous work
|
||||
./claude-flow memory query "${mode.slug}" --limit 5
|
||||
\`\`\`
|
||||
`;
|
||||
}
|
||||
|
||||
// Helper function to get tool descriptions
|
||||
function getToolDescription(tool) {
|
||||
const toolDescriptions = {
|
||||
'read': 'File reading and viewing',
|
||||
'edit': 'File modification and creation',
|
||||
'browser': 'Web browsing capabilities',
|
||||
'mcp': 'Model Context Protocol tools',
|
||||
'command': 'Command execution'
|
||||
};
|
||||
return toolDescriptions[tool] || 'Tool access';
|
||||
}
|
||||
|
||||
// Helper function to get example tasks
|
||||
function getExampleTask(slug) {
|
||||
const examples = {
|
||||
'architect': 'design microservices architecture',
|
||||
'code': 'implement REST API endpoints',
|
||||
'tdd': 'create user authentication tests',
|
||||
'debug': 'fix memory leak in service',
|
||||
'security-review': 'audit API security',
|
||||
'docs-writer': 'create API documentation',
|
||||
'integration': 'connect payment service',
|
||||
'post-deployment-monitoring-mode': 'monitor production metrics',
|
||||
'refinement-optimization-mode': 'optimize database queries',
|
||||
'devops': 'deploy to AWS Lambda',
|
||||
'supabase-admin': 'create user authentication schema',
|
||||
'spec-pseudocode': 'define payment flow requirements',
|
||||
'mcp': 'integrate with external API',
|
||||
'swarm': 'build complete feature with tests',
|
||||
'sparc': 'orchestrate authentication system',
|
||||
'ask': 'help me choose the right mode',
|
||||
'tutorial': 'guide me through SPARC methodology'
|
||||
};
|
||||
return examples[slug] || 'implement feature';
|
||||
}
|
||||
|
||||
// Create main SPARC command
|
||||
export function createMainSparcCommand(modes) {
|
||||
const modeList = modes.map(m => `- \`/sparc-${m.slug}\` - ${m.name}`).join('\n');
|
||||
|
||||
// Find the sparc orchestrator mode for its full description
|
||||
const sparcMode = modes.find(m => m.slug === 'sparc');
|
||||
const sparcDescription = sparcMode ? sparcMode.roleDefinition : 'SPARC orchestrator for complex workflows';
|
||||
const sparcInstructions = sparcMode ? sparcMode.customInstructions : '';
|
||||
|
||||
return `---
|
||||
name: sparc
|
||||
description: Execute SPARC methodology workflows with Claude-Flow
|
||||
---
|
||||
|
||||
# ⚡️ SPARC Development Methodology
|
||||
|
||||
${sparcDescription}
|
||||
|
||||
## SPARC Workflow
|
||||
|
||||
${sparcInstructions.split('\n').slice(0, 10).join('\n')}
|
||||
|
||||
## Available SPARC Modes
|
||||
|
||||
${modeList}
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Run SPARC orchestrator (default):
|
||||
\`\`\`bash
|
||||
./claude-flow sparc "build complete authentication system"
|
||||
\`\`\`
|
||||
|
||||
### Run a specific mode:
|
||||
\`\`\`bash
|
||||
./claude-flow sparc run <mode> "your task"
|
||||
./claude-flow sparc run architect "design API structure"
|
||||
./claude-flow sparc run tdd "implement user service"
|
||||
\`\`\`
|
||||
|
||||
### Execute full TDD workflow:
|
||||
\`\`\`bash
|
||||
./claude-flow sparc tdd "implement user authentication"
|
||||
\`\`\`
|
||||
|
||||
### List all modes with details:
|
||||
\`\`\`bash
|
||||
./claude-flow sparc modes --verbose
|
||||
\`\`\`
|
||||
|
||||
## SPARC Methodology Phases
|
||||
|
||||
1. **📋 Specification**: Define requirements, constraints, and acceptance criteria
|
||||
2. **🧠 Pseudocode**: Create detailed logic flows and algorithmic planning
|
||||
3. **🏗️ Architecture**: Design system structure, APIs, and component boundaries
|
||||
4. **🔄 Refinement**: Implement with TDD (Red-Green-Refactor cycle)
|
||||
5. **✅ Completion**: Integrate, document, and validate against requirements
|
||||
|
||||
## Memory Integration
|
||||
|
||||
Use memory commands to persist context across SPARC sessions:
|
||||
\`\`\`bash
|
||||
# Store specifications
|
||||
./claude-flow memory store "spec_auth" "OAuth2 + JWT requirements" --namespace spec
|
||||
|
||||
# Store architectural decisions
|
||||
./claude-flow memory store "arch_api" "RESTful microservices design" --namespace arch
|
||||
|
||||
# Query previous work
|
||||
./claude-flow memory query "authentication" --limit 10
|
||||
|
||||
# Export project memory
|
||||
./claude-flow memory export sparc-project-backup.json
|
||||
\`\`\`
|
||||
|
||||
## Advanced Swarm Mode
|
||||
|
||||
For complex tasks requiring multiple agents with timeout-free execution:
|
||||
\`\`\`bash
|
||||
# Development swarm with monitoring
|
||||
./claude-flow swarm "Build e-commerce platform" --strategy development --monitor --review
|
||||
|
||||
# Background optimization swarm
|
||||
./claude-flow swarm "Optimize system performance" --strategy optimization --background
|
||||
|
||||
# Distributed research swarm
|
||||
./claude-flow swarm "Analyze market trends" --strategy research --distributed --ui
|
||||
\`\`\`
|
||||
|
||||
## Non-Interactive Mode
|
||||
|
||||
For CI/CD integration and automation:
|
||||
\`\`\`bash
|
||||
./claude-flow sparc run code "implement API" --non-interactive
|
||||
./claude-flow sparc tdd "user tests" --non-interactive --enable-permissions
|
||||
\`\`\`
|
||||
|
||||
## Best Practices
|
||||
|
||||
✅ **Modular Design**: Keep files under 500 lines
|
||||
✅ **Environment Safety**: Never hardcode secrets or env values
|
||||
✅ **Test-First**: Always write tests before implementation
|
||||
✅ **Memory Usage**: Store important decisions and context
|
||||
✅ **Task Completion**: All tasks should end with \`attempt_completion\`
|
||||
|
||||
See \`/claude-flow-help\` for all available commands.
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// help.js - Help text for init command
|
||||
|
||||
export function showInitHelp() {
|
||||
console.log('Initialize Claude Code integration files');
|
||||
console.log();
|
||||
console.log('Usage: claude-flow init [options]');
|
||||
console.log();
|
||||
console.log('Options:');
|
||||
console.log(' --sparc, -s Initialize with SPARC development environment (recommended)');
|
||||
console.log(' --minimal, -m Create minimal configuration files');
|
||||
console.log(' --force, -f Overwrite existing files');
|
||||
console.log(' --help, -h Show this help message');
|
||||
console.log();
|
||||
console.log('Examples:');
|
||||
console.log(' npx claude-flow@latest init --sparc # Recommended first-time setup');
|
||||
console.log(' claude-flow init --sparc # Initialize with SPARC modes');
|
||||
console.log(' claude-flow init --minimal # Minimal setup');
|
||||
console.log(' claude-flow init --force # Overwrite existing files');
|
||||
console.log();
|
||||
console.log('What --sparc creates:');
|
||||
console.log(' • .claude/commands/ directory with 20+ Claude Code slash commands');
|
||||
console.log(' • CLAUDE.md with SPARC-enhanced project instructions');
|
||||
console.log(' • memory/ directory for persistent context storage');
|
||||
console.log(' • coordination/ directory for agent orchestration');
|
||||
console.log(' • ./claude-flow local executable wrapper');
|
||||
console.log(' • Pre-configured for TDD, architecture, and code generation');
|
||||
console.log();
|
||||
console.log('Claude Code Slash Commands Created:');
|
||||
console.log(' • /sparc - Execute SPARC methodology workflows');
|
||||
console.log(' • /sparc-<mode> - Run specific SPARC modes (17+ modes)');
|
||||
console.log(' • /claude-flow-help - Show all claude-flow commands');
|
||||
console.log(' • /claude-flow-memory - Interact with memory system');
|
||||
console.log(' • /claude-flow-swarm - Coordinate multi-agent swarms');
|
||||
console.log();
|
||||
console.log('Available SPARC modes:');
|
||||
console.log(' • architect - System design and architecture');
|
||||
console.log(' • code - Clean, modular implementation');
|
||||
console.log(' • tdd - Test-driven development');
|
||||
console.log(' • debug - Advanced debugging and optimization');
|
||||
console.log(' • security-review - Security analysis and hardening');
|
||||
console.log(' • docs-writer - Documentation creation');
|
||||
console.log(' • integration - System integration');
|
||||
console.log(' • swarm - Multi-agent coordination');
|
||||
console.log(' • spec-pseudocode - Requirements and specifications');
|
||||
console.log(' • devops - Deployment and infrastructure');
|
||||
console.log(' • And 7+ more specialized modes...');
|
||||
console.log();
|
||||
console.log('Learn more: https://github.com/ruvnet/claude-code-flow');
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
// claude-md.js - CLAUDE.md templates
|
||||
|
||||
export function createMinimalClaudeMd() {
|
||||
return `# Claude Code Configuration
|
||||
|
||||
## Build Commands
|
||||
- \`npm run build\`: Build the project
|
||||
- \`npm run test\`: Run tests
|
||||
- \`npm run lint\`: Run linter
|
||||
|
||||
## Code Style
|
||||
- Use TypeScript/ES modules
|
||||
- Follow project conventions
|
||||
- Run typecheck before committing
|
||||
|
||||
## Project Info
|
||||
This is a Claude-Flow AI agent orchestration system.
|
||||
`;
|
||||
}
|
||||
|
||||
export function createFullClaudeMd() {
|
||||
return `# Claude Code Configuration
|
||||
|
||||
## Build Commands
|
||||
- \`npm run build\`: Build the project using Deno compile
|
||||
- \`npm run test\`: Run the full test suite
|
||||
- \`npm run lint\`: Run ESLint and format checks
|
||||
- \`npm run typecheck\`: Run TypeScript type checking
|
||||
- \`./claude-flow start\`: Start the orchestration system
|
||||
- \`./claude-flow --help\`: Show all available commands
|
||||
|
||||
## Code Style Preferences
|
||||
- Use ES modules (import/export) syntax, not CommonJS (require)
|
||||
- Destructure imports when possible (e.g., \`import { foo } from 'bar'\`)
|
||||
- Use TypeScript for all new code
|
||||
- Follow existing naming conventions (camelCase for variables, PascalCase for classes)
|
||||
- Add JSDoc comments for public APIs
|
||||
- Use async/await instead of Promise chains
|
||||
- Prefer const/let over var
|
||||
|
||||
## Workflow Guidelines
|
||||
- Always run typecheck after making code changes
|
||||
- Run tests before committing changes
|
||||
- Use meaningful commit messages following conventional commits
|
||||
- Create feature branches for new functionality
|
||||
- Ensure all tests pass before merging
|
||||
|
||||
## Project Architecture
|
||||
This is a Claude-Flow AI agent orchestration system with the following components:
|
||||
- **CLI Interface**: Command-line tools for managing the system
|
||||
- **Orchestrator**: Core engine for coordinating agents and tasks
|
||||
- **Memory System**: Persistent storage and retrieval of information
|
||||
- **Terminal Management**: Automated terminal session handling
|
||||
- **MCP Integration**: Model Context Protocol server for Claude integration
|
||||
- **Agent Coordination**: Multi-agent task distribution and management
|
||||
|
||||
## Important Notes
|
||||
- Use \`claude --dangerously-skip-permissions\` for unattended operation
|
||||
- The system supports both daemon and interactive modes
|
||||
- Memory persistence is handled automatically
|
||||
- All components are event-driven for scalability
|
||||
|
||||
## Debugging
|
||||
- Check logs in \`./claude-flow.log\`
|
||||
- Use \`./claude-flow status\` to check system health
|
||||
- Monitor with \`./claude-flow monitor\` for real-time updates
|
||||
- Verbose output available with \`--verbose\` flag on most commands
|
||||
`;
|
||||
}
|
||||
|
||||
export function createSparcClaudeMd() {
|
||||
return `# Claude Code Configuration - SPARC Development Environment
|
||||
|
||||
## Project Overview
|
||||
This project uses the SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) methodology for systematic Test-Driven Development with AI assistance through Claude-Flow orchestration.
|
||||
|
||||
## SPARC Development Commands
|
||||
|
||||
### Core SPARC Commands
|
||||
- \`./claude-flow sparc modes\`: List all available SPARC development modes
|
||||
- \`./claude-flow sparc run <mode> "<task>"\`: Execute specific SPARC mode for a task
|
||||
- \`./claude-flow sparc tdd "<feature>"\`: Run complete TDD workflow using SPARC methodology
|
||||
- \`./claude-flow sparc info <mode>\`: Get detailed information about a specific mode
|
||||
|
||||
### Standard Build Commands
|
||||
- \`npm run build\`: Build the project
|
||||
- \`npm run test\`: Run the test suite
|
||||
- \`npm run lint\`: Run linter and format checks
|
||||
- \`npm run typecheck\`: Run TypeScript type checking
|
||||
|
||||
## SPARC Methodology Workflow
|
||||
|
||||
### 1. Specification Phase
|
||||
\`\`\`bash
|
||||
# Create detailed specifications and requirements
|
||||
./claude-flow sparc run spec-pseudocode "Define user authentication requirements"
|
||||
\`\`\`
|
||||
- Define clear functional requirements
|
||||
- Document edge cases and constraints
|
||||
- Create user stories and acceptance criteria
|
||||
- Establish non-functional requirements
|
||||
|
||||
### 2. Pseudocode Phase
|
||||
\`\`\`bash
|
||||
# Develop algorithmic logic and data flows
|
||||
./claude-flow sparc run spec-pseudocode "Create authentication flow pseudocode"
|
||||
\`\`\`
|
||||
- Break down complex logic into steps
|
||||
- Define data structures and interfaces
|
||||
- Plan error handling and edge cases
|
||||
- Create modular, testable components
|
||||
|
||||
### 3. Architecture Phase
|
||||
\`\`\`bash
|
||||
# Design system architecture and component structure
|
||||
./claude-flow sparc run architect "Design authentication service architecture"
|
||||
\`\`\`
|
||||
- Create system diagrams and component relationships
|
||||
- Define API contracts and interfaces
|
||||
- Plan database schemas and data flows
|
||||
- Establish security and scalability patterns
|
||||
|
||||
### 4. Refinement Phase (TDD Implementation)
|
||||
\`\`\`bash
|
||||
# Execute Test-Driven Development cycle
|
||||
./claude-flow sparc tdd "implement user authentication system"
|
||||
\`\`\`
|
||||
|
||||
**TDD Cycle:**
|
||||
1. **Red**: Write failing tests first
|
||||
2. **Green**: Implement minimal code to pass tests
|
||||
3. **Refactor**: Optimize and clean up code
|
||||
4. **Repeat**: Continue until feature is complete
|
||||
|
||||
### 5. Completion Phase
|
||||
\`\`\`bash
|
||||
# Integration, documentation, and validation
|
||||
./claude-flow sparc run integration "integrate authentication with user management"
|
||||
\`\`\`
|
||||
- Integrate all components
|
||||
- Perform end-to-end testing
|
||||
- Create comprehensive documentation
|
||||
- Validate against original requirements
|
||||
|
||||
## SPARC Mode Reference
|
||||
|
||||
### Development Modes
|
||||
- **\`architect\`**: System design and architecture planning
|
||||
- **\`code\`**: Clean, modular code implementation
|
||||
- **\`tdd\`**: Test-driven development and testing
|
||||
- **\`spec-pseudocode\`**: Requirements and algorithmic planning
|
||||
- **\`integration\`**: System integration and coordination
|
||||
|
||||
### Quality Assurance Modes
|
||||
- **\`debug\`**: Troubleshooting and bug resolution
|
||||
- **\`security-review\`**: Security analysis and vulnerability assessment
|
||||
- **\`refinement-optimization-mode\`**: Performance optimization and refactoring
|
||||
|
||||
### Support Modes
|
||||
- **\`docs-writer\`**: Documentation creation and maintenance
|
||||
- **\`devops\`**: Deployment and infrastructure management
|
||||
- **\`mcp\`**: External service integration
|
||||
- **\`swarm\`**: Multi-agent coordination for complex tasks
|
||||
|
||||
## Claude Code Slash Commands
|
||||
|
||||
Claude Code slash commands are available in \`.claude/commands/\`:
|
||||
|
||||
### Project Commands
|
||||
- \`/sparc\`: Execute SPARC methodology workflows
|
||||
- \`/sparc-<mode>\`: Run specific SPARC mode (e.g., /sparc-architect)
|
||||
- \`/claude-flow-help\`: Show all Claude-Flow commands
|
||||
- \`/claude-flow-memory\`: Interact with memory system
|
||||
- \`/claude-flow-swarm\`: Coordinate multi-agent swarms
|
||||
|
||||
### Using Slash Commands
|
||||
1. Type \`/\` in Claude Code to see available commands
|
||||
2. Select a command or type its name
|
||||
3. Commands are context-aware and project-specific
|
||||
4. Custom commands can be added to \`.claude/commands/\`
|
||||
|
||||
## Code Style and Best Practices
|
||||
|
||||
### SPARC Development Principles
|
||||
- **Modular Design**: Keep files under 500 lines, break into logical components
|
||||
- **Environment Safety**: Never hardcode secrets or environment-specific values
|
||||
- **Test-First**: Always write tests before implementation (Red-Green-Refactor)
|
||||
- **Clean Architecture**: Separate concerns, use dependency injection
|
||||
- **Documentation**: Maintain clear, up-to-date documentation
|
||||
|
||||
### Coding Standards
|
||||
- Use TypeScript for type safety and better tooling
|
||||
- Follow consistent naming conventions (camelCase for variables, PascalCase for classes)
|
||||
- Implement proper error handling and logging
|
||||
- Use async/await for asynchronous operations
|
||||
- Prefer composition over inheritance
|
||||
|
||||
### Memory and State Management
|
||||
- Use claude-flow memory system for persistent state across sessions
|
||||
- Store progress and findings using namespaced keys
|
||||
- Query previous work before starting new tasks
|
||||
- Export/import memory for backup and sharing
|
||||
|
||||
## SPARC Memory Integration
|
||||
|
||||
### Memory Commands for SPARC Development
|
||||
\`\`\`bash
|
||||
# Store project specifications
|
||||
./claude-flow memory store spec_auth "User authentication requirements and constraints"
|
||||
|
||||
# Store architectural decisions
|
||||
./claude-flow memory store arch_decisions "Database schema and API design choices"
|
||||
|
||||
# Store test results and coverage
|
||||
./claude-flow memory store test_coverage "Authentication module: 95% coverage, all tests passing"
|
||||
|
||||
# Query previous work
|
||||
./claude-flow memory query auth_implementation
|
||||
|
||||
# Export project memory
|
||||
./claude-flow memory export project_backup.json
|
||||
\`\`\`
|
||||
|
||||
### Memory Namespaces
|
||||
- **\`spec\`**: Requirements and specifications
|
||||
- **\`arch\`**: Architecture and design decisions
|
||||
- **\`impl\`**: Implementation notes and code patterns
|
||||
- **\`test\`**: Test results and coverage reports
|
||||
- **\`debug\`**: Bug reports and resolution notes
|
||||
|
||||
## Workflow Examples
|
||||
|
||||
### Feature Development Workflow
|
||||
\`\`\`bash
|
||||
# 1. Start with specification
|
||||
./claude-flow sparc run spec-pseudocode "User profile management feature"
|
||||
|
||||
# 2. Design architecture
|
||||
./claude-flow sparc run architect "Profile service architecture with data validation"
|
||||
|
||||
# 3. Implement with TDD
|
||||
./claude-flow sparc tdd "user profile CRUD operations"
|
||||
|
||||
# 4. Security review
|
||||
./claude-flow sparc run security-review "profile data access and validation"
|
||||
|
||||
# 5. Integration testing
|
||||
./claude-flow sparc run integration "profile service with authentication system"
|
||||
|
||||
# 6. Documentation
|
||||
./claude-flow sparc run docs-writer "profile service API documentation"
|
||||
\`\`\`
|
||||
|
||||
### Bug Fix Workflow
|
||||
\`\`\`bash
|
||||
# 1. Debug and analyze
|
||||
./claude-flow sparc run debug "authentication token expiration issue"
|
||||
|
||||
# 2. Write regression tests
|
||||
./claude-flow sparc run tdd "token refresh mechanism tests"
|
||||
|
||||
# 3. Implement fix
|
||||
./claude-flow sparc run code "fix token refresh in authentication service"
|
||||
|
||||
# 4. Security review
|
||||
./claude-flow sparc run security-review "token handling security implications"
|
||||
\`\`\`
|
||||
|
||||
## Configuration Files
|
||||
|
||||
### Claude Code Integration
|
||||
- **\`.claude/commands/\`**: Claude Code slash commands for all SPARC modes
|
||||
- **\`.claude/logs/\`**: Conversation and session logs
|
||||
|
||||
### SPARC Configuration
|
||||
- **\`.roomodes\`**: SPARC mode definitions and configurations (auto-generated)
|
||||
- **\`.roo/\`**: SPARC templates and workflows (auto-generated)
|
||||
|
||||
### Claude-Flow Configuration
|
||||
- **\`memory/\`**: Persistent memory and session data
|
||||
- **\`coordination/\`**: Multi-agent coordination settings
|
||||
- **\`CLAUDE.md\`**: Project instructions for Claude Code
|
||||
|
||||
## Git Workflow Integration
|
||||
|
||||
### Commit Strategy with SPARC
|
||||
- **Specification commits**: After completing requirements analysis
|
||||
- **Architecture commits**: After design phase completion
|
||||
- **TDD commits**: After each Red-Green-Refactor cycle
|
||||
- **Integration commits**: After successful component integration
|
||||
- **Documentation commits**: After completing documentation updates
|
||||
|
||||
### Branch Strategy
|
||||
- **\`feature/sparc-<feature-name>\`**: Feature development with SPARC methodology
|
||||
- **\`hotfix/sparc-<issue>\`**: Bug fixes using SPARC debugging workflow
|
||||
- **\`refactor/sparc-<component>\`**: Refactoring using optimization mode
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common SPARC Issues
|
||||
- **Mode not found**: Check \`.roomodes\` file exists and is valid JSON
|
||||
- **Memory persistence**: Ensure \`memory/\` directory has write permissions
|
||||
- **Tool access**: Verify required tools are available for the selected mode
|
||||
- **Namespace conflicts**: Use unique memory namespaces for different features
|
||||
|
||||
### Debug Commands
|
||||
\`\`\`bash
|
||||
# Check SPARC configuration
|
||||
./claude-flow sparc modes
|
||||
|
||||
# Verify memory system
|
||||
./claude-flow memory stats
|
||||
|
||||
# Check system status
|
||||
./claude-flow status
|
||||
|
||||
# View detailed mode information
|
||||
./claude-flow sparc info <mode-name>
|
||||
\`\`\`
|
||||
|
||||
## Project Architecture
|
||||
|
||||
This SPARC-enabled project follows a systematic development approach:
|
||||
- **Clear separation of concerns** through modular design
|
||||
- **Test-driven development** ensuring reliability and maintainability
|
||||
- **Iterative refinement** for continuous improvement
|
||||
- **Comprehensive documentation** for team collaboration
|
||||
- **AI-assisted development** through specialized SPARC modes
|
||||
|
||||
## Important Notes
|
||||
|
||||
- Always run tests before committing (\`npm run test\`)
|
||||
- Use SPARC memory system to maintain context across sessions
|
||||
- Follow the Red-Green-Refactor cycle during TDD phases
|
||||
- Document architectural decisions in memory for future reference
|
||||
- Regular security reviews for any authentication or data handling code
|
||||
- Claude Code slash commands provide quick access to SPARC modes
|
||||
|
||||
For more information about SPARC methodology, see: https://github.com/ruvnet/claude-code-flow/docs/sparc.md
|
||||
`;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export async function statusCommand(subArgs, flags) {
|
||||
async function getSystemStatus(verbose = false) {
|
||||
const status = {
|
||||
timestamp: Date.now(),
|
||||
version: '1.0.43',
|
||||
version: '1.0.49',
|
||||
orchestrator: {
|
||||
running: false,
|
||||
uptime: 0,
|
||||
|
||||
@@ -3,9 +3,85 @@
|
||||
* Swarm command wrapper for simple CLI
|
||||
*/
|
||||
|
||||
function showSwarmHelp() {
|
||||
console.log(`
|
||||
🐝 Claude Flow Advanced Swarm System
|
||||
|
||||
USAGE:
|
||||
claude-flow swarm <objective> [options]
|
||||
|
||||
EXAMPLES:
|
||||
claude-flow swarm "Build a REST API" --strategy development
|
||||
claude-flow swarm "Research cloud architecture" --strategy research --ui
|
||||
claude-flow swarm "Analyze data trends" --strategy analysis --parallel
|
||||
claude-flow swarm "Optimize performance" --distributed --monitor
|
||||
|
||||
REMOTE EXECUTION:
|
||||
When running via npx, swarm will use Claude wrapper if available:
|
||||
npx claude-flow swarm "Build app" --auto # Auto-approve Claude permissions
|
||||
|
||||
This provides full swarm capabilities through Claude's tool access
|
||||
|
||||
STRATEGIES:
|
||||
auto Automatically determine best approach (default)
|
||||
research Research and information gathering
|
||||
development Software development and coding
|
||||
analysis Data analysis and insights
|
||||
testing Testing and quality assurance
|
||||
optimization Performance optimization
|
||||
maintenance System maintenance
|
||||
|
||||
MODES:
|
||||
centralized Single coordinator (default)
|
||||
distributed Multiple coordinators
|
||||
hierarchical Tree structure coordination
|
||||
mesh Peer-to-peer coordination
|
||||
hybrid Mixed coordination strategies
|
||||
|
||||
KEY FEATURES:
|
||||
🤖 Intelligent agent management with specialized types
|
||||
⚡ Timeout-free background task execution
|
||||
🧠 Distributed memory sharing between agents
|
||||
🔄 Work stealing and advanced load balancing
|
||||
🛡️ Circuit breaker patterns for fault tolerance
|
||||
📊 Real-time monitoring and comprehensive metrics
|
||||
🎛️ Multiple coordination strategies and algorithms
|
||||
💾 Persistent state with backup and recovery
|
||||
🔒 Security features with encryption options
|
||||
🖥️ Interactive terminal UI for management
|
||||
|
||||
OPTIONS:
|
||||
--strategy <type> Execution strategy (default: auto)
|
||||
--mode <type> Coordination mode (default: centralized)
|
||||
--max-agents <n> Maximum agents (default: 5)
|
||||
--timeout <minutes> Timeout in minutes (default: 60)
|
||||
--parallel Enable parallel execution
|
||||
--distributed Enable distributed coordination
|
||||
--monitor Enable real-time monitoring
|
||||
--ui Launch terminal UI interface
|
||||
--background Run in background mode
|
||||
--review Enable peer review
|
||||
--testing Enable automated testing
|
||||
--encryption Enable encryption
|
||||
--verbose Enable detailed logging
|
||||
--dry-run Show configuration without executing
|
||||
|
||||
ADVANCED OPTIONS:
|
||||
--quality-threshold <n> Quality threshold 0-1 (default: 0.8)
|
||||
--memory-namespace <name> Memory namespace (default: swarm)
|
||||
--agent-selection <type> Agent selection strategy
|
||||
--task-scheduling <type> Task scheduling algorithm
|
||||
--load-balancing <type> Load balancing method
|
||||
--fault-tolerance <type> Fault tolerance strategy
|
||||
|
||||
For complete documentation and examples:
|
||||
https://github.com/ruvnet/claude-code-flow/docs/swarm.md
|
||||
`);
|
||||
}
|
||||
|
||||
export async function swarmCommand(args, flags) {
|
||||
try {
|
||||
// Import the new comprehensive swarm action
|
||||
// Try to load the TypeScript module directly (works in Deno and local dev)
|
||||
const { swarmAction } = await import('../commands/swarm-new.ts');
|
||||
|
||||
// Create command context compatible with TypeScript version
|
||||
@@ -17,6 +93,199 @@ export async function swarmCommand(args, flags) {
|
||||
|
||||
await swarmAction(ctx);
|
||||
} catch (error) {
|
||||
// If TypeScript import fails (e.g., in node_modules), provide inline implementation
|
||||
if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING') {
|
||||
// Provide a basic swarm implementation that works without TypeScript imports
|
||||
const objective = (args || []).join(' ').trim();
|
||||
|
||||
if (!objective) {
|
||||
console.error("❌ Usage: swarm <objective>");
|
||||
showSwarmHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
// Provide a basic inline swarm implementation for npm packages
|
||||
console.log('🐝 Launching swarm system...');
|
||||
console.log(`📋 Objective: ${objective}`);
|
||||
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
||||
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
||||
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
||||
console.log();
|
||||
|
||||
// Generate swarm ID
|
||||
const swarmId = `swarm_${Math.random().toString(36).substring(2, 11)}_${Math.random().toString(36).substring(2, 11)}`;
|
||||
|
||||
if (flags['dry-run']) {
|
||||
console.log(`🆔 Swarm ID: ${swarmId}`);
|
||||
console.log(`📊 Max Tasks: ${flags['max-tasks'] || 100}`);
|
||||
console.log(`⏰ Timeout: ${flags.timeout || 60} minutes`);
|
||||
console.log(`🔄 Parallel: ${flags.parallel || false}`);
|
||||
console.log(`🌐 Distributed: ${flags.distributed || false}`);
|
||||
console.log(`🔍 Monitoring: ${flags.monitor || false}`);
|
||||
console.log(`👥 Review Mode: ${flags.review || false}`);
|
||||
console.log(`🧪 Testing: ${flags.testing || false}`);
|
||||
console.log(`🧠 Memory Namespace: ${flags['memory-namespace'] || 'swarm'}`);
|
||||
console.log(`💾 Persistence: ${flags.persistence !== false}`);
|
||||
console.log(`🔒 Encryption: ${flags.encryption || false}`);
|
||||
console.log(`📊 Quality Threshold: ${flags['quality-threshold'] || 0.8}`);
|
||||
console.log();
|
||||
console.log('🎛️ Coordination Strategy:');
|
||||
console.log(` • Agent Selection: ${flags['agent-selection'] || 'capability-based'}`);
|
||||
console.log(` • Task Scheduling: ${flags['task-scheduling'] || 'priority'}`);
|
||||
console.log(` • Load Balancing: ${flags['load-balancing'] || 'work-stealing'}`);
|
||||
console.log(` • Fault Tolerance: ${flags['fault-tolerance'] || 'retry'}`);
|
||||
console.log(` • Communication: ${flags.communication || 'event-driven'}`);
|
||||
console.log('⚠️ DRY RUN - Advanced Swarm Configuration');
|
||||
return;
|
||||
}
|
||||
|
||||
// For actual execution in npm context, try to find and run swarm-demo.ts
|
||||
try {
|
||||
const path = await import('path');
|
||||
const { fileURLToPath } = await import('url');
|
||||
const fs = await import('fs');
|
||||
const { spawn } = await import('child_process');
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// Look for swarm-demo.ts in the package
|
||||
const possiblePaths = [
|
||||
path.join(__dirname, '../../../swarm-demo.ts'),
|
||||
path.join(__dirname, '../../swarm-demo.ts'),
|
||||
];
|
||||
|
||||
let swarmDemoPath = null;
|
||||
for (const p of possiblePaths) {
|
||||
if (fs.existsSync(p)) {
|
||||
swarmDemoPath = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (swarmDemoPath && Deno) {
|
||||
// Run swarm-demo.ts directly with Deno
|
||||
const swarmArgs = [objective];
|
||||
for (const [key, value] of Object.entries(flags || {})) {
|
||||
swarmArgs.push(`--${key}`);
|
||||
if (value !== true) {
|
||||
swarmArgs.push(String(value));
|
||||
}
|
||||
}
|
||||
|
||||
console.log('🚀 Starting advanced swarm execution...');
|
||||
const swarmProcess = spawn(Deno.execPath(), ['run', '--allow-all', swarmDemoPath, ...swarmArgs], {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
swarmProcess.on('error', (err) => {
|
||||
console.error('❌ Failed to launch swarm:', err.message);
|
||||
});
|
||||
|
||||
swarmProcess.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error(`❌ Swarm exited with code ${code}`);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// Fallback to basic message if can't run swarm-demo.ts
|
||||
}
|
||||
|
||||
// Try to use Claude wrapper approach like SPARC does
|
||||
try {
|
||||
const { execSync } = await import('child_process');
|
||||
|
||||
// Check if claude command exists
|
||||
try {
|
||||
execSync('which claude', { stdio: 'ignore' });
|
||||
} catch (e) {
|
||||
// Claude not found, show fallback message
|
||||
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
||||
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
||||
console.log('Install Claude: https://claude.ai/code');
|
||||
console.log('Or install locally: npm install -g claude-flow@latest');
|
||||
console.log('\nThe swarm system would coordinate the following:');
|
||||
console.log('1. Agent spawning and task distribution');
|
||||
console.log('2. Parallel execution of subtasks');
|
||||
console.log('3. Memory sharing between agents');
|
||||
console.log('4. Progress monitoring and reporting');
|
||||
console.log('5. Result aggregation and quality checks');
|
||||
return;
|
||||
}
|
||||
|
||||
// Claude is available, use it to run swarm
|
||||
console.log('🚀 Launching swarm via Claude wrapper...');
|
||||
|
||||
// Build the prompt for Claude
|
||||
const swarmPrompt = `Execute a swarm coordination task with the following configuration:
|
||||
|
||||
Objective: ${objective}
|
||||
Strategy: ${flags.strategy || 'auto'}
|
||||
Mode: ${flags.mode || 'centralized'}
|
||||
Max Agents: ${flags['max-agents'] || 5}
|
||||
Max Tasks: ${flags['max-tasks'] || 100}
|
||||
Timeout: ${flags.timeout || 60} minutes
|
||||
Parallel: ${flags.parallel || false}
|
||||
Distributed: ${flags.distributed || false}
|
||||
Monitor: ${flags.monitor || false}
|
||||
Review: ${flags.review || false}
|
||||
Testing: ${flags.testing || false}
|
||||
Memory Namespace: ${flags['memory-namespace'] || 'swarm'}
|
||||
Quality Threshold: ${flags['quality-threshold'] || 0.8}
|
||||
|
||||
Coordination Strategy:
|
||||
- Agent Selection: ${flags['agent-selection'] || 'capability-based'}
|
||||
- Task Scheduling: ${flags['task-scheduling'] || 'priority'}
|
||||
- Load Balancing: ${flags['load-balancing'] || 'work-stealing'}
|
||||
- Fault Tolerance: ${flags['fault-tolerance'] || 'retry'}
|
||||
- Communication: ${flags.communication || 'event-driven'}
|
||||
|
||||
Please coordinate this swarm task by:
|
||||
1. Breaking down the objective into subtasks
|
||||
2. Assigning tasks to appropriate agent types
|
||||
3. Managing parallel execution where applicable
|
||||
4. Monitoring progress and handling failures
|
||||
5. Aggregating results and ensuring quality
|
||||
|
||||
Use all available tools including file operations, web search, and code execution as needed.`;
|
||||
|
||||
// Execute Claude with the swarm prompt
|
||||
const claudeArgs = [];
|
||||
|
||||
// Add auto-permission flag if requested
|
||||
if (flags.auto || flags['dangerously-skip-permissions']) {
|
||||
claudeArgs.push('--dangerously-skip-permissions');
|
||||
}
|
||||
|
||||
// Build the command - pass the prompt as the last argument
|
||||
const promptEscaped = swarmPrompt.replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/`/g, '\\`');
|
||||
const command = `claude ${claudeArgs.join(' ')} "${promptEscaped}"`;
|
||||
|
||||
// Execute with stdio inherit to see output in real-time
|
||||
execSync(command, {
|
||||
stdio: 'inherit',
|
||||
shell: true
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
// Fallback if Claude execution fails
|
||||
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
||||
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
||||
console.log('Install Claude: https://claude.ai/code');
|
||||
console.log('Or install locally: npm install -g claude-flow@latest');
|
||||
console.log('\nThe swarm system would coordinate the following:');
|
||||
console.log('1. Agent spawning and task distribution');
|
||||
console.log('2. Parallel execution of subtasks');
|
||||
console.log('3. Memory sharing between agents');
|
||||
console.log('4. Progress monitoring and reporting');
|
||||
console.log('5. Result aggregation and quality checks');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('Swarm command error:', error);
|
||||
|
||||
// Fallback to comprehensive help if there's an import error
|
||||
@@ -92,14 +361,16 @@ https://github.com/ruvnet/claude-code-flow/docs/swarm.md
|
||||
|
||||
// Allow direct execution
|
||||
if (import.meta.main) {
|
||||
const args = Deno.args.slice(1); // Skip the command name
|
||||
// When called directly as a script, parse all arguments
|
||||
const args = [];
|
||||
const flags = {};
|
||||
|
||||
// Parse basic flags
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i].startsWith('--')) {
|
||||
const flagName = args[i].substring(2);
|
||||
const nextArg = args[i + 1];
|
||||
// Parse arguments and flags
|
||||
for (let i = 0; i < Deno.args.length; i++) {
|
||||
const arg = Deno.args[i];
|
||||
if (arg.startsWith('--')) {
|
||||
const flagName = arg.substring(2);
|
||||
const nextArg = Deno.args[i + 1];
|
||||
|
||||
if (nextArg && !nextArg.startsWith('--')) {
|
||||
flags[flagName] = nextArg;
|
||||
@@ -107,12 +378,14 @@ if (import.meta.main) {
|
||||
} else {
|
||||
flags[flagName] = true;
|
||||
}
|
||||
} else {
|
||||
args.push(arg);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out flags from args to get the objective
|
||||
const objective = args.filter(arg => !arg.startsWith('--') &&
|
||||
!Object.values(flags).includes(arg)).join(' ');
|
||||
// The objective is all non-flag arguments joined
|
||||
const objective = args.join(' ');
|
||||
|
||||
// Execute the swarm command
|
||||
await swarmCommand([objective], flags);
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
#!/usr/bin/env -S deno run --allow-all
|
||||
/**
|
||||
* Standalone swarm executable for npm package
|
||||
* This handles swarm execution when installed via npm
|
||||
*/
|
||||
|
||||
import { spawn } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { existsSync } from 'node:fs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
// Parse arguments
|
||||
const args = [];
|
||||
const flags = {};
|
||||
|
||||
for (let i = 0; i < Deno.args.length; i++) {
|
||||
const arg = Deno.args[i];
|
||||
if (arg.startsWith('--')) {
|
||||
const flagName = arg.substring(2);
|
||||
const nextArg = Deno.args[i + 1];
|
||||
|
||||
if (nextArg && !nextArg.startsWith('--')) {
|
||||
flags[flagName] = nextArg;
|
||||
i++; // Skip the next argument
|
||||
} else {
|
||||
flags[flagName] = true;
|
||||
}
|
||||
} else {
|
||||
args.push(arg);
|
||||
}
|
||||
}
|
||||
|
||||
const objective = args.join(' ');
|
||||
|
||||
if (!objective && !flags.help) {
|
||||
console.error("❌ Usage: swarm <objective>");
|
||||
console.log(`
|
||||
🐝 Claude Flow Advanced Swarm System
|
||||
|
||||
USAGE:
|
||||
claude-flow swarm <objective> [options]
|
||||
|
||||
EXAMPLES:
|
||||
claude-flow swarm "Build a REST API" --strategy development
|
||||
claude-flow swarm "Research cloud architecture" --strategy research --ui
|
||||
claude-flow swarm "Analyze data trends" --strategy analysis --parallel
|
||||
claude-flow swarm "Optimize performance" --distributed --monitor
|
||||
|
||||
Run 'claude-flow swarm --help' for full options
|
||||
`);
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
// Try to find the swarm implementation
|
||||
const possiblePaths = [
|
||||
join(__dirname, '../../swarm-demo.ts'),
|
||||
join(__dirname, '../../swarm-demo-enhanced.ts'),
|
||||
join(__dirname, '../../../swarm-demo.ts'),
|
||||
];
|
||||
|
||||
let swarmPath = null;
|
||||
for (const path of possiblePaths) {
|
||||
if (existsSync(path)) {
|
||||
swarmPath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!swarmPath) {
|
||||
// Fallback to inline implementation without calling back to swarm.js
|
||||
console.log('🐝 Launching swarm system...');
|
||||
console.log(`📋 Objective: ${objective}`);
|
||||
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
||||
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
||||
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
||||
console.log();
|
||||
|
||||
// Generate swarm ID
|
||||
const swarmId = `swarm_${Math.random().toString(36).substring(2, 11)}_${Math.random().toString(36).substring(2, 11)}`;
|
||||
|
||||
if (flags['dry-run']) {
|
||||
console.log(`🆔 Swarm ID: ${swarmId}`);
|
||||
console.log(`📊 Max Tasks: ${flags['max-tasks'] || 100}`);
|
||||
console.log(`⏰ Timeout: ${flags.timeout || 60} minutes`);
|
||||
console.log(`🔄 Parallel: ${flags.parallel || false}`);
|
||||
console.log(`🌐 Distributed: ${flags.distributed || false}`);
|
||||
console.log(`🔍 Monitoring: ${flags.monitor || false}`);
|
||||
console.log(`👥 Review Mode: ${flags.review || false}`);
|
||||
console.log(`🧪 Testing: ${flags.testing || false}`);
|
||||
console.log(`🧠 Memory Namespace: ${flags['memory-namespace'] || 'swarm'}`);
|
||||
console.log(`💾 Persistence: ${flags.persistence !== false}`);
|
||||
console.log(`🔒 Encryption: ${flags.encryption || false}`);
|
||||
console.log(`📊 Quality Threshold: ${flags['quality-threshold'] || 0.8}`);
|
||||
console.log();
|
||||
console.log('🎛️ Coordination Strategy:');
|
||||
console.log(` • Agent Selection: ${flags['agent-selection'] || 'capability-based'}`);
|
||||
console.log(` • Task Scheduling: ${flags['task-scheduling'] || 'priority'}`);
|
||||
console.log(` • Load Balancing: ${flags['load-balancing'] || 'work-stealing'}`);
|
||||
console.log(` • Fault Tolerance: ${flags['fault-tolerance'] || 'retry'}`);
|
||||
console.log(` • Communication: ${flags.communication || 'event-driven'}`);
|
||||
console.log('⚠️ DRY RUN - Advanced Swarm Configuration');
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
// Try to use Claude wrapper approach
|
||||
try {
|
||||
const { execSync } = await import('child_process');
|
||||
|
||||
// Check if claude command exists
|
||||
try {
|
||||
execSync('which claude', { stdio: 'ignore' });
|
||||
} catch (e) {
|
||||
// Claude not found, show fallback message
|
||||
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
||||
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
||||
console.log('Install Claude: https://claude.ai/code');
|
||||
console.log('Or install locally: npm install -g claude-flow@latest');
|
||||
console.log('\nThe swarm system would coordinate the following:');
|
||||
console.log('1. Agent spawning and task distribution');
|
||||
console.log('2. Parallel execution of subtasks');
|
||||
console.log('3. Memory sharing between agents');
|
||||
console.log('4. Progress monitoring and reporting');
|
||||
console.log('5. Result aggregation and quality checks');
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
// Claude is available, use it to run swarm
|
||||
console.log('🚀 Launching swarm via Claude wrapper...');
|
||||
|
||||
// Build the prompt for Claude
|
||||
const swarmPrompt = `Execute a swarm coordination task with the following configuration:
|
||||
|
||||
Objective: ${objective}
|
||||
Strategy: ${flags.strategy || 'auto'}
|
||||
Mode: ${flags.mode || 'centralized'}
|
||||
Max Agents: ${flags['max-agents'] || 5}
|
||||
Max Tasks: ${flags['max-tasks'] || 100}
|
||||
Timeout: ${flags.timeout || 60} minutes
|
||||
Parallel: ${flags.parallel || false}
|
||||
Distributed: ${flags.distributed || false}
|
||||
Monitor: ${flags.monitor || false}
|
||||
Review: ${flags.review || false}
|
||||
Testing: ${flags.testing || false}
|
||||
Memory Namespace: ${flags['memory-namespace'] || 'swarm'}
|
||||
Quality Threshold: ${flags['quality-threshold'] || 0.8}
|
||||
|
||||
Coordination Strategy:
|
||||
- Agent Selection: ${flags['agent-selection'] || 'capability-based'}
|
||||
- Task Scheduling: ${flags['task-scheduling'] || 'priority'}
|
||||
- Load Balancing: ${flags['load-balancing'] || 'work-stealing'}
|
||||
- Fault Tolerance: ${flags['fault-tolerance'] || 'retry'}
|
||||
- Communication: ${flags.communication || 'event-driven'}
|
||||
|
||||
Please coordinate this swarm task by:
|
||||
1. Breaking down the objective into subtasks
|
||||
2. Assigning tasks to appropriate agent types
|
||||
3. Managing parallel execution where applicable
|
||||
4. Monitoring progress and handling failures
|
||||
5. Aggregating results and ensuring quality
|
||||
|
||||
Use all available tools including file operations, web search, and code execution as needed.`;
|
||||
|
||||
// Execute Claude with the swarm prompt
|
||||
const claudeArgs = [];
|
||||
|
||||
// Add auto-permission flag if requested
|
||||
if (flags.auto || flags['dangerously-skip-permissions']) {
|
||||
claudeArgs.push('--dangerously-skip-permissions');
|
||||
}
|
||||
|
||||
// Build the command - pass the prompt as the last argument
|
||||
const promptEscaped = swarmPrompt.replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/`/g, '\\`');
|
||||
const command = `claude ${claudeArgs.join(' ')} "${promptEscaped}"`;
|
||||
|
||||
// Execute with stdio inherit to see output in real-time
|
||||
execSync(command, {
|
||||
stdio: 'inherit',
|
||||
shell: true
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
// Fallback if Claude execution fails
|
||||
console.log(`✅ Swarm initialized with ID: ${swarmId}`);
|
||||
console.log('\n⚠️ Note: Advanced swarm features require Claude or local installation.');
|
||||
console.log('Install Claude: https://claude.ai/code');
|
||||
console.log('Or install locally: npm install -g claude-flow@latest');
|
||||
console.log('\nThe swarm system would coordinate the following:');
|
||||
console.log('1. Agent spawning and task distribution');
|
||||
console.log('2. Parallel execution of subtasks');
|
||||
console.log('3. Memory sharing between agents');
|
||||
console.log('4. Progress monitoring and reporting');
|
||||
console.log('5. Result aggregation and quality checks');
|
||||
}
|
||||
|
||||
Deno.exit(0);
|
||||
} else {
|
||||
// Run the swarm demo directly
|
||||
const swarmArgs = [objective];
|
||||
for (const [key, value] of Object.entries(flags)) {
|
||||
swarmArgs.push(`--${key}`);
|
||||
if (value !== true) {
|
||||
swarmArgs.push(String(value));
|
||||
}
|
||||
}
|
||||
|
||||
const deno = spawn(Deno.execPath(), ['run', '--allow-all', swarmPath, ...swarmArgs], {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
deno.on('exit', (code) => {
|
||||
Deno.exit(code || 0);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"default": [
|
||||
{
|
||||
"key": "research_findings",
|
||||
"value": "Important research about authentication patterns",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749614503887
|
||||
},
|
||||
{
|
||||
"key": "previous_work",
|
||||
"value": "Completed user authentication module with JWT",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749614509644
|
||||
},
|
||||
{
|
||||
"key": "test_key",
|
||||
"value": "This is a test value",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749614834714
|
||||
},
|
||||
{
|
||||
"key": "code_requirements",
|
||||
"value": "Simple Calculator App Requirements:\n1. Basic arithmetic operations: addition (+), subtraction (-), multiplication (*), division (/)\n2. Support for decimal numbers\n3. Clear/reset functionality\n4. Error handling for division by zero\n5. Command-line interface for easy interaction\n6. Modular, testable code structure\n7. Support for operation chaining (e.g., 2 + 3 * 4)\n8. Memory functions (store, recall, clear)\nTarget: Node.js application with clean architecture",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749667276110
|
||||
},
|
||||
{
|
||||
"key": "code_pseudocode",
|
||||
"value": "Calculator Pseudocode:\n\n1. Expression Parser:\n - tokenize(expression) -> [tokens]\n - parse tokens following order of operations\n - evaluate expression tree\n\n2. Calculator Core:\n - add(a, b) -> a + b\n - subtract(a, b) -> a - b\n - multiply(a, b) -> a * b\n - divide(a, b) -> check b != 0, then a / b\n \n3. Memory Management:\n - memory = 0\n - memoryStore(value) -> memory = value\n - memoryRecall() -> return memory\n - memoryClear() -> memory = 0\n\n4. Main Interface:\n - prompt user for expression\n - parse and evaluate\n - display result\n - handle errors gracefully",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749667293563
|
||||
},
|
||||
{
|
||||
"key": "code_architecture",
|
||||
"value": "Calculator Architecture:\n\ncalculator-app/\n├── package.json # Node.js project config\n├── README.md # Project documentation\n├── src/\n│ ├── index.js # Main entry point\n│ ├── core/\n│ │ ├── Calculator.js # Core calculator operations\n│ │ └── ExpressionParser.js # Expression parsing logic\n│ └── utils/\n│ └── validators.js # Input validation utilities\n├── tests/\n│ ├── Calculator.test.js\n│ └── ExpressionParser.test.js\n└── docs/\n └── usage.md # Usage examples\n\nKey Design Decisions:\n- Separation of concerns: parsing vs calculation\n- Modular design for easy testing\n- No hardcoded values\n- Clean error handling",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749667316258
|
||||
},
|
||||
{
|
||||
"key": "code_implementation",
|
||||
"value": "Created hello world shell script in /hello-world/hello.sh. Script is executable and displays hostname, date, and user info. Ready for SSH execution.",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749674078738
|
||||
},
|
||||
{
|
||||
"key": "test-key",
|
||||
"value": "Test value from CLI test",
|
||||
"namespace": "default",
|
||||
"timestamp": 1749836389246
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user