claude-flow 1.0.46 → 1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/claude-flow-swarm +15 -3
- package/package.json +1 -1
- package/src/cli/commands/status.ts +1 -1
- package/src/cli/main.ts +1 -1
- package/src/cli/simple-cli.js +1 -1
- package/src/cli/simple-cli.ts +1 -1
- package/src/cli/simple-commands/status.js +1 -1
- package/src/cli/simple-commands/swarm.js +146 -10
- package/src/cli/swarm-standalone.js +106 -0
package/bin/claude-flow-swarm
CHANGED
|
@@ -13,7 +13,19 @@ fi
|
|
|
13
13
|
|
|
14
14
|
# Get the directory of this script
|
|
15
15
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
16
|
-
SWARM_DEMO="$SCRIPT_DIR/../swarm-demo.ts"
|
|
17
16
|
|
|
18
|
-
#
|
|
19
|
-
|
|
17
|
+
# Try to find swarm implementation in different locations
|
|
18
|
+
if [ -f "$SCRIPT_DIR/../swarm-demo.ts" ]; then
|
|
19
|
+
# Local development path
|
|
20
|
+
SWARM_IMPL="$SCRIPT_DIR/../swarm-demo.ts"
|
|
21
|
+
elif [ -f "$SCRIPT_DIR/../src/cli/swarm-standalone.js" ]; then
|
|
22
|
+
# Installed via npm - use the standalone JavaScript version
|
|
23
|
+
SWARM_IMPL="$SCRIPT_DIR/../src/cli/swarm-standalone.js"
|
|
24
|
+
else
|
|
25
|
+
echo "Error: Unable to find swarm implementation files"
|
|
26
|
+
echo "Please ensure claude-flow is properly installed"
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Run the swarm implementation with all arguments
|
|
31
|
+
exec "$DENO_PATH" run --allow-all "$SWARM_IMPL" "$@"
|
package/package.json
CHANGED
|
@@ -239,7 +239,7 @@ async function getSystemStatus(): Promise<any> {
|
|
|
239
239
|
// Mock status for now - in production, this would call the orchestrator API
|
|
240
240
|
return {
|
|
241
241
|
overall: 'healthy',
|
|
242
|
-
version: '1.0.
|
|
242
|
+
version: '1.0.48',
|
|
243
243
|
uptime: Date.now() - (Date.now() - 3600000), // 1 hour ago
|
|
244
244
|
startTime: new Date(Date.now() - 3600000),
|
|
245
245
|
components: {
|
package/src/cli/main.ts
CHANGED
package/src/cli/simple-cli.js
CHANGED
package/src/cli/simple-cli.ts
CHANGED
|
@@ -3,9 +3,79 @@
|
|
|
3
3
|
* Swarm command wrapper for simple CLI
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
function showSwarmHelp() {
|
|
7
|
+
console.log(`
|
|
8
|
+
🐝 Claude Flow Advanced Swarm System
|
|
9
|
+
|
|
10
|
+
USAGE:
|
|
11
|
+
claude-flow swarm <objective> [options]
|
|
12
|
+
|
|
13
|
+
EXAMPLES:
|
|
14
|
+
claude-flow swarm "Build a REST API" --strategy development
|
|
15
|
+
claude-flow swarm "Research cloud architecture" --strategy research --ui
|
|
16
|
+
claude-flow swarm "Analyze data trends" --strategy analysis --parallel
|
|
17
|
+
claude-flow swarm "Optimize performance" --distributed --monitor
|
|
18
|
+
|
|
19
|
+
STRATEGIES:
|
|
20
|
+
auto Automatically determine best approach (default)
|
|
21
|
+
research Research and information gathering
|
|
22
|
+
development Software development and coding
|
|
23
|
+
analysis Data analysis and insights
|
|
24
|
+
testing Testing and quality assurance
|
|
25
|
+
optimization Performance optimization
|
|
26
|
+
maintenance System maintenance
|
|
27
|
+
|
|
28
|
+
MODES:
|
|
29
|
+
centralized Single coordinator (default)
|
|
30
|
+
distributed Multiple coordinators
|
|
31
|
+
hierarchical Tree structure coordination
|
|
32
|
+
mesh Peer-to-peer coordination
|
|
33
|
+
hybrid Mixed coordination strategies
|
|
34
|
+
|
|
35
|
+
KEY FEATURES:
|
|
36
|
+
🤖 Intelligent agent management with specialized types
|
|
37
|
+
⚡ Timeout-free background task execution
|
|
38
|
+
🧠 Distributed memory sharing between agents
|
|
39
|
+
🔄 Work stealing and advanced load balancing
|
|
40
|
+
🛡️ Circuit breaker patterns for fault tolerance
|
|
41
|
+
📊 Real-time monitoring and comprehensive metrics
|
|
42
|
+
🎛️ Multiple coordination strategies and algorithms
|
|
43
|
+
💾 Persistent state with backup and recovery
|
|
44
|
+
🔒 Security features with encryption options
|
|
45
|
+
🖥️ Interactive terminal UI for management
|
|
46
|
+
|
|
47
|
+
OPTIONS:
|
|
48
|
+
--strategy <type> Execution strategy (default: auto)
|
|
49
|
+
--mode <type> Coordination mode (default: centralized)
|
|
50
|
+
--max-agents <n> Maximum agents (default: 5)
|
|
51
|
+
--timeout <minutes> Timeout in minutes (default: 60)
|
|
52
|
+
--parallel Enable parallel execution
|
|
53
|
+
--distributed Enable distributed coordination
|
|
54
|
+
--monitor Enable real-time monitoring
|
|
55
|
+
--ui Launch terminal UI interface
|
|
56
|
+
--background Run in background mode
|
|
57
|
+
--review Enable peer review
|
|
58
|
+
--testing Enable automated testing
|
|
59
|
+
--encryption Enable encryption
|
|
60
|
+
--verbose Enable detailed logging
|
|
61
|
+
--dry-run Show configuration without executing
|
|
62
|
+
|
|
63
|
+
ADVANCED OPTIONS:
|
|
64
|
+
--quality-threshold <n> Quality threshold 0-1 (default: 0.8)
|
|
65
|
+
--memory-namespace <name> Memory namespace (default: swarm)
|
|
66
|
+
--agent-selection <type> Agent selection strategy
|
|
67
|
+
--task-scheduling <type> Task scheduling algorithm
|
|
68
|
+
--load-balancing <type> Load balancing method
|
|
69
|
+
--fault-tolerance <type> Fault tolerance strategy
|
|
70
|
+
|
|
71
|
+
For complete documentation and examples:
|
|
72
|
+
https://github.com/ruvnet/claude-code-flow/docs/swarm.md
|
|
73
|
+
`);
|
|
74
|
+
}
|
|
75
|
+
|
|
6
76
|
export async function swarmCommand(args, flags) {
|
|
7
77
|
try {
|
|
8
|
-
//
|
|
78
|
+
// Try to load the TypeScript module directly (works in Deno and local dev)
|
|
9
79
|
const { swarmAction } = await import('../commands/swarm-new.ts');
|
|
10
80
|
|
|
11
81
|
// Create command context compatible with TypeScript version
|
|
@@ -17,6 +87,68 @@ export async function swarmCommand(args, flags) {
|
|
|
17
87
|
|
|
18
88
|
await swarmAction(ctx);
|
|
19
89
|
} catch (error) {
|
|
90
|
+
// If TypeScript import fails (e.g., in node_modules), provide inline implementation
|
|
91
|
+
if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING') {
|
|
92
|
+
// Provide a basic swarm implementation that works without TypeScript imports
|
|
93
|
+
const objective = (args || []).join(' ').trim();
|
|
94
|
+
|
|
95
|
+
if (!objective) {
|
|
96
|
+
console.error("❌ Usage: swarm <objective>");
|
|
97
|
+
showSwarmHelp();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Basic swarm execution using child process
|
|
102
|
+
const { spawn } = await import('child_process');
|
|
103
|
+
const path = await import('path');
|
|
104
|
+
const { fileURLToPath } = await import('url');
|
|
105
|
+
|
|
106
|
+
// Get the directory of this file
|
|
107
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
108
|
+
const __dirname = path.dirname(__filename);
|
|
109
|
+
|
|
110
|
+
// Try to find the swarm binary
|
|
111
|
+
const swarmBinPath = path.join(__dirname, '../../../bin/claude-flow-swarm');
|
|
112
|
+
|
|
113
|
+
// Check if the binary exists
|
|
114
|
+
const fs = await import('fs');
|
|
115
|
+
if (!fs.existsSync(swarmBinPath)) {
|
|
116
|
+
console.error('❌ Swarm binary not found. Please ensure claude-flow is properly installed.');
|
|
117
|
+
showSwarmHelp();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Execute the swarm binary with arguments
|
|
122
|
+
const swarmArgs = [objective];
|
|
123
|
+
|
|
124
|
+
// Add flags
|
|
125
|
+
for (const [key, value] of Object.entries(flags || {})) {
|
|
126
|
+
swarmArgs.push(`--${key}`);
|
|
127
|
+
if (value !== true) {
|
|
128
|
+
swarmArgs.push(String(value));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log('🐝 Launching swarm via binary...');
|
|
133
|
+
|
|
134
|
+
const swarmProcess = spawn(swarmBinPath, swarmArgs, {
|
|
135
|
+
stdio: 'inherit',
|
|
136
|
+
shell: true
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
swarmProcess.on('error', (err) => {
|
|
140
|
+
console.error('❌ Failed to launch swarm:', err.message);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
swarmProcess.on('exit', (code) => {
|
|
144
|
+
if (code !== 0) {
|
|
145
|
+
console.error(`❌ Swarm exited with code ${code}`);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
20
152
|
console.error('Swarm command error:', error);
|
|
21
153
|
|
|
22
154
|
// Fallback to comprehensive help if there's an import error
|
|
@@ -92,14 +224,16 @@ https://github.com/ruvnet/claude-code-flow/docs/swarm.md
|
|
|
92
224
|
|
|
93
225
|
// Allow direct execution
|
|
94
226
|
if (import.meta.main) {
|
|
95
|
-
|
|
227
|
+
// When called directly as a script, parse all arguments
|
|
228
|
+
const args = [];
|
|
96
229
|
const flags = {};
|
|
97
230
|
|
|
98
|
-
// Parse
|
|
99
|
-
for (let i = 0; i < args.length; i++) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
231
|
+
// Parse arguments and flags
|
|
232
|
+
for (let i = 0; i < Deno.args.length; i++) {
|
|
233
|
+
const arg = Deno.args[i];
|
|
234
|
+
if (arg.startsWith('--')) {
|
|
235
|
+
const flagName = arg.substring(2);
|
|
236
|
+
const nextArg = Deno.args[i + 1];
|
|
103
237
|
|
|
104
238
|
if (nextArg && !nextArg.startsWith('--')) {
|
|
105
239
|
flags[flagName] = nextArg;
|
|
@@ -107,12 +241,14 @@ if (import.meta.main) {
|
|
|
107
241
|
} else {
|
|
108
242
|
flags[flagName] = true;
|
|
109
243
|
}
|
|
244
|
+
} else {
|
|
245
|
+
args.push(arg);
|
|
110
246
|
}
|
|
111
247
|
}
|
|
112
248
|
|
|
113
|
-
//
|
|
114
|
-
const objective = args.
|
|
115
|
-
!Object.values(flags).includes(arg)).join(' ');
|
|
249
|
+
// The objective is all non-flag arguments joined
|
|
250
|
+
const objective = args.join(' ');
|
|
116
251
|
|
|
252
|
+
// Execute the swarm command
|
|
117
253
|
await swarmCommand([objective], flags);
|
|
118
254
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env -S deno run --allow-all
|
|
2
|
+
/**
|
|
3
|
+
* Standalone swarm executable for npm package
|
|
4
|
+
* This handles swarm execution when installed via npm
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
// Parse arguments
|
|
16
|
+
const args = [];
|
|
17
|
+
const flags = {};
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < Deno.args.length; i++) {
|
|
20
|
+
const arg = Deno.args[i];
|
|
21
|
+
if (arg.startsWith('--')) {
|
|
22
|
+
const flagName = arg.substring(2);
|
|
23
|
+
const nextArg = Deno.args[i + 1];
|
|
24
|
+
|
|
25
|
+
if (nextArg && !nextArg.startsWith('--')) {
|
|
26
|
+
flags[flagName] = nextArg;
|
|
27
|
+
i++; // Skip the next argument
|
|
28
|
+
} else {
|
|
29
|
+
flags[flagName] = true;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
args.push(arg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const objective = args.join(' ');
|
|
37
|
+
|
|
38
|
+
if (!objective && !flags.help) {
|
|
39
|
+
console.error("❌ Usage: swarm <objective>");
|
|
40
|
+
console.log(`
|
|
41
|
+
🐝 Claude Flow Advanced Swarm System
|
|
42
|
+
|
|
43
|
+
USAGE:
|
|
44
|
+
claude-flow swarm <objective> [options]
|
|
45
|
+
|
|
46
|
+
EXAMPLES:
|
|
47
|
+
claude-flow swarm "Build a REST API" --strategy development
|
|
48
|
+
claude-flow swarm "Research cloud architecture" --strategy research --ui
|
|
49
|
+
claude-flow swarm "Analyze data trends" --strategy analysis --parallel
|
|
50
|
+
claude-flow swarm "Optimize performance" --distributed --monitor
|
|
51
|
+
|
|
52
|
+
Run 'claude-flow swarm --help' for full options
|
|
53
|
+
`);
|
|
54
|
+
Deno.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Try to find the swarm implementation
|
|
58
|
+
const possiblePaths = [
|
|
59
|
+
join(__dirname, '../../swarm-demo.ts'),
|
|
60
|
+
join(__dirname, '../../swarm-demo-enhanced.ts'),
|
|
61
|
+
join(__dirname, '../../../swarm-demo.ts'),
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
let swarmPath = null;
|
|
65
|
+
for (const path of possiblePaths) {
|
|
66
|
+
if (existsSync(path)) {
|
|
67
|
+
swarmPath = path;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!swarmPath) {
|
|
73
|
+
// Fallback to inline implementation
|
|
74
|
+
console.log('🐝 Launching swarm system...');
|
|
75
|
+
console.log(`📋 Objective: ${objective}`);
|
|
76
|
+
console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`);
|
|
77
|
+
console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`);
|
|
78
|
+
console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`);
|
|
79
|
+
|
|
80
|
+
// Import and run the swarm command
|
|
81
|
+
try {
|
|
82
|
+
const { swarmCommand } = await import('./simple-commands/swarm.js');
|
|
83
|
+
await swarmCommand([objective], flags);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('❌ Failed to launch swarm:', error.message);
|
|
86
|
+
console.error('\nPlease ensure claude-flow is properly installed');
|
|
87
|
+
Deno.exit(1);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
// Run the swarm demo directly
|
|
91
|
+
const swarmArgs = [objective];
|
|
92
|
+
for (const [key, value] of Object.entries(flags)) {
|
|
93
|
+
swarmArgs.push(`--${key}`);
|
|
94
|
+
if (value !== true) {
|
|
95
|
+
swarmArgs.push(String(value));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const deno = spawn(Deno.execPath(), ['run', '--allow-all', swarmPath, ...swarmArgs], {
|
|
100
|
+
stdio: 'inherit'
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
deno.on('exit', (code) => {
|
|
104
|
+
Deno.exit(code || 0);
|
|
105
|
+
});
|
|
106
|
+
}
|