claude-flow 1.1.0 ā 1.1.1
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 +18 -0
- package/package.json +2 -1
- package/swarm-demo.ts +242 -0
package/bin/claude-flow
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Claude-Flow CLI wrapper
|
|
4
|
+
# This script runs the Claude-Flow CLI using Deno
|
|
5
|
+
|
|
6
|
+
# Get the directory where this script is located
|
|
7
|
+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
8
|
+
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
|
|
9
|
+
|
|
10
|
+
# Check if first argument is "swarm"
|
|
11
|
+
if [ "$1" = "swarm" ]; then
|
|
12
|
+
# Use the swarm demo script
|
|
13
|
+
shift # Remove "swarm" from arguments
|
|
14
|
+
exec deno run --allow-all "$PROJECT_ROOT/swarm-demo.ts" "$@"
|
|
15
|
+
else
|
|
16
|
+
# Use the main CLI
|
|
17
|
+
exec deno run --allow-all --no-check "$PROJECT_ROOT/src/cli/main.ts" "$@"
|
|
18
|
+
fi
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Advanced AI agent orchestration system for Claude Code",
|
|
5
5
|
"main": "src/cli/main.ts",
|
|
6
6
|
"bin": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"bin/claude-flow",
|
|
39
39
|
"src/",
|
|
40
40
|
"scripts/install.js",
|
|
41
|
+
"swarm-demo.ts",
|
|
41
42
|
"README.md",
|
|
42
43
|
"LICENSE",
|
|
43
44
|
"deno.json"
|
package/swarm-demo.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#!/usr/bin/env -S deno run --allow-all
|
|
2
|
+
|
|
3
|
+
// Simplified swarm demo that bypasses the Cliffy import issues
|
|
4
|
+
|
|
5
|
+
const args = Deno.args;
|
|
6
|
+
|
|
7
|
+
// Parse command line arguments
|
|
8
|
+
let objective = "";
|
|
9
|
+
let dryRun = false;
|
|
10
|
+
let maxAgents = 5;
|
|
11
|
+
let strategy = "auto";
|
|
12
|
+
let coordinator = false;
|
|
13
|
+
let research = false;
|
|
14
|
+
let parallel = false;
|
|
15
|
+
let review = false;
|
|
16
|
+
let verbose = false;
|
|
17
|
+
|
|
18
|
+
// Simple argument parsing
|
|
19
|
+
for (let i = 0; i < args.length; i++) {
|
|
20
|
+
const arg = args[i];
|
|
21
|
+
|
|
22
|
+
if (arg.startsWith("--")) {
|
|
23
|
+
switch (arg) {
|
|
24
|
+
case "--dry-run":
|
|
25
|
+
case "-d":
|
|
26
|
+
dryRun = true;
|
|
27
|
+
break;
|
|
28
|
+
case "--coordinator":
|
|
29
|
+
coordinator = true;
|
|
30
|
+
break;
|
|
31
|
+
case "--research":
|
|
32
|
+
research = true;
|
|
33
|
+
break;
|
|
34
|
+
case "--parallel":
|
|
35
|
+
parallel = true;
|
|
36
|
+
break;
|
|
37
|
+
case "--review":
|
|
38
|
+
review = true;
|
|
39
|
+
break;
|
|
40
|
+
case "--verbose":
|
|
41
|
+
case "-v":
|
|
42
|
+
verbose = true;
|
|
43
|
+
break;
|
|
44
|
+
case "--max-agents":
|
|
45
|
+
maxAgents = parseInt(args[++i]) || 5;
|
|
46
|
+
break;
|
|
47
|
+
case "--strategy":
|
|
48
|
+
case "-s":
|
|
49
|
+
strategy = args[++i] || "auto";
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
} else if (!objective) {
|
|
53
|
+
objective = arg;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!objective) {
|
|
58
|
+
console.log("Usage: ./swarm-demo.ts <objective> [options]");
|
|
59
|
+
console.log("\nOptions:");
|
|
60
|
+
console.log(" --dry-run, -d Preview swarm configuration");
|
|
61
|
+
console.log(" --max-agents <n> Maximum number of agents (default: 5)");
|
|
62
|
+
console.log(" --strategy <s> Strategy: auto, research, development, analysis");
|
|
63
|
+
console.log(" --coordinator Spawn dedicated coordinator");
|
|
64
|
+
console.log(" --research Enable research capabilities");
|
|
65
|
+
console.log(" --parallel Enable parallel execution");
|
|
66
|
+
console.log(" --review Enable peer review");
|
|
67
|
+
console.log(" --verbose, -v Verbose output");
|
|
68
|
+
Deno.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Generate swarm ID
|
|
72
|
+
const swarmId = `swarm-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
73
|
+
|
|
74
|
+
console.log(`š Initializing Claude Swarm: ${swarmId}`);
|
|
75
|
+
console.log(`š Objective: ${objective}`);
|
|
76
|
+
|
|
77
|
+
// Build orchestration prompt
|
|
78
|
+
const strategies = {
|
|
79
|
+
auto: 'Automatically determine the best approach',
|
|
80
|
+
research: 'Focus on research and information gathering',
|
|
81
|
+
development: 'Focus on implementation and coding',
|
|
82
|
+
analysis: 'Focus on analysis and insights'
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const orchestrationPrompt = `
|
|
86
|
+
# Claude Swarm Orchestration Task
|
|
87
|
+
|
|
88
|
+
You are the Master Orchestrator for a Claude agent swarm. Your objective is to coordinate multiple specialized agents to achieve the following goal:
|
|
89
|
+
|
|
90
|
+
**OBJECTIVE**: ${objective}
|
|
91
|
+
|
|
92
|
+
## Orchestration Parameters:
|
|
93
|
+
- Strategy: ${strategies[strategy as keyof typeof strategies] || strategies.auto}
|
|
94
|
+
- Maximum Agents: ${maxAgents}
|
|
95
|
+
- Maximum Delegation Depth: 3
|
|
96
|
+
- Parallel Execution: ${parallel ? 'Enabled' : 'Disabled'}
|
|
97
|
+
- Peer Review: ${review ? 'Enabled' : 'Disabled'}
|
|
98
|
+
- Research Capabilities: ${research ? 'Enabled' : 'Disabled'}
|
|
99
|
+
|
|
100
|
+
## Your Responsibilities:
|
|
101
|
+
|
|
102
|
+
1. **Task Decomposition**: Break down the objective into subtasks
|
|
103
|
+
2. **Agent Spawning**: Create specialized agents for each subtask
|
|
104
|
+
3. **Resource Allocation**: Assign appropriate tools and permissions
|
|
105
|
+
4. **Coordination**: Manage dependencies and communication
|
|
106
|
+
5. **Quality Control**: ${review ? 'Implement peer review processes' : 'Monitor task quality'}
|
|
107
|
+
6. **Progress Tracking**: Monitor and report on swarm progress
|
|
108
|
+
|
|
109
|
+
## Available Agent Types:
|
|
110
|
+
- **Researcher**: Information gathering, web research, analysis
|
|
111
|
+
- **Developer**: Code implementation, testing, debugging
|
|
112
|
+
- **Analyst**: Data analysis, pattern recognition, insights
|
|
113
|
+
- **Reviewer**: Code review, quality assurance, validation
|
|
114
|
+
- **Coordinator**: Sub-task coordination, dependency management
|
|
115
|
+
|
|
116
|
+
## Swarm Execution Process:
|
|
117
|
+
|
|
118
|
+
1. Analyze the objective and create a detailed execution plan
|
|
119
|
+
2. Identify required agent types and their responsibilities
|
|
120
|
+
3. Spawn agents with appropriate configurations
|
|
121
|
+
4. Create tasks and assign them to agents
|
|
122
|
+
5. Monitor progress and adjust as needed
|
|
123
|
+
6. ${review ? 'Implement peer review cycles between agents' : 'Validate outputs'}
|
|
124
|
+
7. Synthesize results and report completion
|
|
125
|
+
|
|
126
|
+
Begin by analyzing the objective and presenting your execution plan.
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
if (dryRun) {
|
|
130
|
+
console.log("\n" + "=".repeat(50));
|
|
131
|
+
console.log("DRY RUN - Swarm Configuration:");
|
|
132
|
+
console.log("=".repeat(50));
|
|
133
|
+
console.log(`Swarm ID: ${swarmId}`);
|
|
134
|
+
console.log(`Objective: ${objective}`);
|
|
135
|
+
console.log(`Strategy: ${strategy}`);
|
|
136
|
+
console.log(`Max Agents: ${maxAgents}`);
|
|
137
|
+
console.log(`Max Depth: 3`);
|
|
138
|
+
console.log(`Research: ${research}`);
|
|
139
|
+
console.log(`Parallel: ${parallel}`);
|
|
140
|
+
console.log(`Review Mode: ${review}`);
|
|
141
|
+
console.log(`Coordinator: ${coordinator}`);
|
|
142
|
+
|
|
143
|
+
if (verbose) {
|
|
144
|
+
console.log("\nOrchestration Prompt Preview:");
|
|
145
|
+
console.log("-".repeat(50));
|
|
146
|
+
console.log(orchestrationPrompt);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
console.log("\nā
Configuration validated. Remove --dry-run to execute.");
|
|
150
|
+
Deno.exit(0);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Build tools list
|
|
154
|
+
const tools = [
|
|
155
|
+
"View",
|
|
156
|
+
"Edit",
|
|
157
|
+
"Replace",
|
|
158
|
+
"GlobTool",
|
|
159
|
+
"GrepTool",
|
|
160
|
+
"LS",
|
|
161
|
+
"Bash",
|
|
162
|
+
"dispatch_agent"
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
if (research) {
|
|
166
|
+
tools.push("WebFetchTool");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (parallel) {
|
|
170
|
+
tools.push("BatchTool");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
console.log(`\nšÆ Spawning Master Orchestrator...`);
|
|
174
|
+
console.log(`š§ Tools: ${tools.join(", ")}`);
|
|
175
|
+
|
|
176
|
+
// Build Claude command
|
|
177
|
+
const claudeCmd = [
|
|
178
|
+
"claude",
|
|
179
|
+
orchestrationPrompt,
|
|
180
|
+
"--allowedTools", tools.join(",")
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
// Check if Claude CLI exists
|
|
184
|
+
try {
|
|
185
|
+
const checkCmd = new Deno.Command("which", { args: ["claude"] });
|
|
186
|
+
const { success } = await checkCmd.output();
|
|
187
|
+
|
|
188
|
+
if (!success) {
|
|
189
|
+
console.error("\nā Error: Claude CLI not found. Please install Claude CLI first.");
|
|
190
|
+
console.log("\nTo install Claude CLI:");
|
|
191
|
+
console.log("1. Visit: https://claude.ai/");
|
|
192
|
+
console.log("2. Install the Claude desktop app");
|
|
193
|
+
console.log("3. Ensure 'claude' command is in your PATH");
|
|
194
|
+
Deno.exit(1);
|
|
195
|
+
}
|
|
196
|
+
} catch (err) {
|
|
197
|
+
console.error("\nā Error checking for Claude CLI:", err);
|
|
198
|
+
Deno.exit(1);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
console.log("\nš Launching orchestrator with Claude...");
|
|
202
|
+
|
|
203
|
+
// Execute Claude with orchestration prompt
|
|
204
|
+
const command = new Deno.Command("claude", {
|
|
205
|
+
args: claudeCmd.slice(1),
|
|
206
|
+
env: {
|
|
207
|
+
...Deno.env.toObject(),
|
|
208
|
+
CLAUDE_SWARM_ID: swarmId,
|
|
209
|
+
CLAUDE_SWARM_MODE: "orchestrator",
|
|
210
|
+
CLAUDE_SWARM_OBJECTIVE: objective,
|
|
211
|
+
CLAUDE_SWARM_STRATEGY: strategy,
|
|
212
|
+
CLAUDE_SWARM_MAX_AGENTS: maxAgents.toString(),
|
|
213
|
+
CLAUDE_SWARM_MAX_DEPTH: "3",
|
|
214
|
+
CLAUDE_SWARM_MEMORY_NS: "swarm",
|
|
215
|
+
},
|
|
216
|
+
stdin: "piped",
|
|
217
|
+
stdout: "inherit",
|
|
218
|
+
stderr: "inherit",
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
const process = command.spawn();
|
|
223
|
+
|
|
224
|
+
// Send the prompt via stdin
|
|
225
|
+
const writer = process.stdin.getWriter();
|
|
226
|
+
await writer.write(new TextEncoder().encode(orchestrationPrompt));
|
|
227
|
+
await writer.close();
|
|
228
|
+
|
|
229
|
+
console.log("ā
Master Orchestrator spawned successfully");
|
|
230
|
+
console.log("š Swarm is now active and self-orchestrating...\n");
|
|
231
|
+
|
|
232
|
+
const status = await process.status;
|
|
233
|
+
|
|
234
|
+
if (status.success) {
|
|
235
|
+
console.log("\nā
Swarm completed successfully");
|
|
236
|
+
} else {
|
|
237
|
+
console.error(`\nā Swarm exited with code ${status.code}`);
|
|
238
|
+
}
|
|
239
|
+
} catch (err) {
|
|
240
|
+
console.error("\nā Error spawning Claude orchestrator:", err);
|
|
241
|
+
Deno.exit(1);
|
|
242
|
+
}
|