claude-flow 1.0.0
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/LICENSE +21 -0
- package/README.md +612 -0
- package/bin/claude-flow +0 -0
- package/bin/claude-flow-simple +0 -0
- package/bin/claude-flow-typecheck +0 -0
- package/deno.json +84 -0
- package/package.json +45 -0
- package/scripts/check-links.ts +274 -0
- package/scripts/check-performance-regression.ts +168 -0
- package/scripts/claude-sparc.sh +562 -0
- package/scripts/coverage-report.ts +692 -0
- package/scripts/demo-task-system.ts +224 -0
- package/scripts/install.js +72 -0
- package/scripts/test-batch-tasks.ts +29 -0
- package/scripts/test-coordination-features.ts +238 -0
- package/scripts/test-mcp.ts +251 -0
- package/scripts/test-runner.ts +571 -0
- package/scripts/validate-examples.ts +288 -0
- package/src/cli/cli-core.ts +273 -0
- package/src/cli/commands/agent.ts +83 -0
- package/src/cli/commands/config.ts +442 -0
- package/src/cli/commands/help.ts +765 -0
- package/src/cli/commands/index.ts +963 -0
- package/src/cli/commands/mcp.ts +191 -0
- package/src/cli/commands/memory.ts +74 -0
- package/src/cli/commands/monitor.ts +403 -0
- package/src/cli/commands/session.ts +595 -0
- package/src/cli/commands/start.ts +156 -0
- package/src/cli/commands/status.ts +345 -0
- package/src/cli/commands/task.ts +79 -0
- package/src/cli/commands/workflow.ts +763 -0
- package/src/cli/completion.ts +553 -0
- package/src/cli/formatter.ts +310 -0
- package/src/cli/index.ts +211 -0
- package/src/cli/main.ts +23 -0
- package/src/cli/repl.ts +1050 -0
- package/src/cli/simple-cli.js +211 -0
- package/src/cli/simple-cli.ts +211 -0
- package/src/coordination/README.md +400 -0
- package/src/coordination/advanced-scheduler.ts +487 -0
- package/src/coordination/circuit-breaker.ts +366 -0
- package/src/coordination/conflict-resolution.ts +490 -0
- package/src/coordination/dependency-graph.ts +475 -0
- package/src/coordination/index.ts +63 -0
- package/src/coordination/manager.ts +460 -0
- package/src/coordination/messaging.ts +290 -0
- package/src/coordination/metrics.ts +585 -0
- package/src/coordination/resources.ts +322 -0
- package/src/coordination/scheduler.ts +390 -0
- package/src/coordination/work-stealing.ts +224 -0
- package/src/core/config.ts +627 -0
- package/src/core/event-bus.ts +186 -0
- package/src/core/json-persistence.ts +183 -0
- package/src/core/logger.ts +262 -0
- package/src/core/orchestrator-fixed.ts +312 -0
- package/src/core/orchestrator.ts +1234 -0
- package/src/core/persistence.ts +276 -0
- package/src/mcp/auth.ts +438 -0
- package/src/mcp/claude-flow-tools.ts +1280 -0
- package/src/mcp/load-balancer.ts +510 -0
- package/src/mcp/router.ts +240 -0
- package/src/mcp/server.ts +548 -0
- package/src/mcp/session-manager.ts +418 -0
- package/src/mcp/tools.ts +180 -0
- package/src/mcp/transports/base.ts +21 -0
- package/src/mcp/transports/http.ts +457 -0
- package/src/mcp/transports/stdio.ts +254 -0
- package/src/memory/backends/base.ts +22 -0
- package/src/memory/backends/markdown.ts +283 -0
- package/src/memory/backends/sqlite.ts +329 -0
- package/src/memory/cache.ts +238 -0
- package/src/memory/indexer.ts +238 -0
- package/src/memory/manager.ts +572 -0
- package/src/terminal/adapters/base.ts +29 -0
- package/src/terminal/adapters/native.ts +504 -0
- package/src/terminal/adapters/vscode.ts +340 -0
- package/src/terminal/manager.ts +308 -0
- package/src/terminal/pool.ts +271 -0
- package/src/terminal/session.ts +250 -0
- package/src/terminal/vscode-bridge.ts +242 -0
- package/src/utils/errors.ts +231 -0
- package/src/utils/helpers.ts +476 -0
- package/src/utils/types.ts +493 -0
|
@@ -0,0 +1,963 @@
|
|
|
1
|
+
import { CLI, success, error, warning, info, VERSION } from "../cli-core.ts";
|
|
2
|
+
import type { Command, CommandContext } from "../cli-core.ts";
|
|
3
|
+
import { bold, blue } from "https://deno.land/std@0.224.0/fmt/colors.ts";
|
|
4
|
+
import { Orchestrator } from "../../core/orchestrator-fixed.ts";
|
|
5
|
+
import { ConfigManager } from "../../core/config.ts";
|
|
6
|
+
import { MemoryManager } from "../../memory/manager.ts";
|
|
7
|
+
import { EventBus } from "../../core/event-bus.ts";
|
|
8
|
+
import { Logger } from "../../core/logger.ts";
|
|
9
|
+
import { JsonPersistenceManager } from "../../core/json-persistence.ts";
|
|
10
|
+
|
|
11
|
+
let orchestrator: Orchestrator | null = null;
|
|
12
|
+
let configManager: ConfigManager | null = null;
|
|
13
|
+
let persistence: JsonPersistenceManager | null = null;
|
|
14
|
+
|
|
15
|
+
async function getPersistence(): Promise<JsonPersistenceManager> {
|
|
16
|
+
if (!persistence) {
|
|
17
|
+
persistence = new JsonPersistenceManager();
|
|
18
|
+
await persistence.initialize();
|
|
19
|
+
}
|
|
20
|
+
return persistence;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function getOrchestrator(): Promise<Orchestrator> {
|
|
24
|
+
if (!orchestrator) {
|
|
25
|
+
const config = await getConfigManager();
|
|
26
|
+
const eventBus = EventBus.getInstance();
|
|
27
|
+
const logger = new Logger({ level: "info", format: "text", destination: "console" });
|
|
28
|
+
orchestrator = new Orchestrator(config, eventBus, logger);
|
|
29
|
+
}
|
|
30
|
+
return orchestrator;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function getConfigManager(): Promise<ConfigManager> {
|
|
34
|
+
if (!configManager) {
|
|
35
|
+
configManager = ConfigManager.getInstance();
|
|
36
|
+
await configManager.load();
|
|
37
|
+
}
|
|
38
|
+
return configManager;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function setupCommands(cli: CLI): void {
|
|
42
|
+
// Init command
|
|
43
|
+
cli.command({
|
|
44
|
+
name: "init",
|
|
45
|
+
description: "Initialize Claude Code integration files",
|
|
46
|
+
options: [
|
|
47
|
+
{
|
|
48
|
+
name: "force",
|
|
49
|
+
short: "f",
|
|
50
|
+
description: "Overwrite existing files",
|
|
51
|
+
type: "boolean",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "minimal",
|
|
55
|
+
short: "m",
|
|
56
|
+
description: "Create minimal configuration files",
|
|
57
|
+
type: "boolean",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
action: async (ctx: CommandContext) => {
|
|
61
|
+
try {
|
|
62
|
+
success("Initializing Claude Code integration files...");
|
|
63
|
+
|
|
64
|
+
const force = ctx.flags.force as boolean || ctx.flags.f as boolean;
|
|
65
|
+
const minimal = ctx.flags.minimal as boolean || ctx.flags.m as boolean;
|
|
66
|
+
|
|
67
|
+
// Check if files already exist
|
|
68
|
+
const files = ["CLAUDE.md", "memory-bank.md", "coordination.md"];
|
|
69
|
+
const existingFiles = [];
|
|
70
|
+
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
const exists = await Deno.stat(file).then(() => true).catch(() => false);
|
|
73
|
+
if (exists) {
|
|
74
|
+
existingFiles.push(file);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (existingFiles.length > 0 && !force) {
|
|
79
|
+
warning(`The following files already exist: ${existingFiles.join(", ")}`);
|
|
80
|
+
console.log("Use --force to overwrite existing files");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Create CLAUDE.md
|
|
85
|
+
const claudeMd = minimal ? createMinimalClaudeMd() : createFullClaudeMd();
|
|
86
|
+
await Deno.writeTextFile("CLAUDE.md", claudeMd);
|
|
87
|
+
console.log(" ✓ Created CLAUDE.md");
|
|
88
|
+
|
|
89
|
+
// Create memory-bank.md
|
|
90
|
+
const memoryBankMd = minimal ? createMinimalMemoryBankMd() : createFullMemoryBankMd();
|
|
91
|
+
await Deno.writeTextFile("memory-bank.md", memoryBankMd);
|
|
92
|
+
console.log(" ✓ Created memory-bank.md");
|
|
93
|
+
|
|
94
|
+
// Create coordination.md
|
|
95
|
+
const coordinationMd = minimal ? createMinimalCoordinationMd() : createFullCoordinationMd();
|
|
96
|
+
await Deno.writeTextFile("coordination.md", coordinationMd);
|
|
97
|
+
console.log(" ✓ Created coordination.md");
|
|
98
|
+
|
|
99
|
+
// Create directory structure
|
|
100
|
+
const directories = [
|
|
101
|
+
"memory",
|
|
102
|
+
"memory/agents",
|
|
103
|
+
"memory/sessions",
|
|
104
|
+
"coordination",
|
|
105
|
+
"coordination/memory_bank",
|
|
106
|
+
"coordination/subtasks",
|
|
107
|
+
"coordination/orchestration"
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
// Ensure memory directory exists for SQLite database
|
|
111
|
+
if (!directories.includes("memory")) {
|
|
112
|
+
directories.unshift("memory");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const dir of directories) {
|
|
116
|
+
try {
|
|
117
|
+
await Deno.mkdir(dir, { recursive: true });
|
|
118
|
+
console.log(` ✓ Created ${dir}/ directory`);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
if (!(err instanceof Deno.errors.AlreadyExists)) {
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Create placeholder files for memory directories
|
|
127
|
+
const agentsReadme = createAgentsReadme();
|
|
128
|
+
await Deno.writeTextFile("memory/agents/README.md", agentsReadme);
|
|
129
|
+
console.log(" ✓ Created memory/agents/README.md");
|
|
130
|
+
|
|
131
|
+
const sessionsReadme = createSessionsReadme();
|
|
132
|
+
await Deno.writeTextFile("memory/sessions/README.md", sessionsReadme);
|
|
133
|
+
console.log(" ✓ Created memory/sessions/README.md");
|
|
134
|
+
|
|
135
|
+
// Initialize the persistence database
|
|
136
|
+
const initialData = {
|
|
137
|
+
agents: [],
|
|
138
|
+
tasks: [],
|
|
139
|
+
lastUpdated: Date.now()
|
|
140
|
+
};
|
|
141
|
+
await Deno.writeTextFile("memory/claude-flow-data.json", JSON.stringify(initialData, null, 2));
|
|
142
|
+
console.log(" ✓ Created memory/claude-flow-data.json (persistence database)");
|
|
143
|
+
|
|
144
|
+
success("Claude Code integration files initialized successfully!");
|
|
145
|
+
console.log("\nNext steps:");
|
|
146
|
+
console.log("1. Review and customize the generated files for your project");
|
|
147
|
+
console.log("2. Run 'npx claude-flow start' to begin the orchestration system");
|
|
148
|
+
console.log("3. Use 'claude --dangerously-skip-permissions' for unattended operation");
|
|
149
|
+
console.log("\nNote: Persistence database initialized at memory/claude-flow-data.json");
|
|
150
|
+
|
|
151
|
+
} catch (err) {
|
|
152
|
+
error(`Failed to initialize files: ${(err as Error).message}`);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Start command
|
|
158
|
+
cli.command({
|
|
159
|
+
name: "start",
|
|
160
|
+
description: "Start the orchestration system",
|
|
161
|
+
options: [
|
|
162
|
+
{
|
|
163
|
+
name: "daemon",
|
|
164
|
+
short: "d",
|
|
165
|
+
description: "Run as daemon in background",
|
|
166
|
+
type: "boolean",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "port",
|
|
170
|
+
short: "p",
|
|
171
|
+
description: "MCP server port",
|
|
172
|
+
type: "number",
|
|
173
|
+
default: 3000,
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
action: async (ctx: CommandContext) => {
|
|
177
|
+
success("Starting Claude-Flow orchestration system...");
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
const orch = await getOrchestrator();
|
|
181
|
+
await orch.start();
|
|
182
|
+
|
|
183
|
+
success("System started successfully!");
|
|
184
|
+
info("Components initialized:");
|
|
185
|
+
console.log(" ✓ Event Bus");
|
|
186
|
+
console.log(" ✓ Orchestrator Engine");
|
|
187
|
+
console.log(" ✓ Memory Manager");
|
|
188
|
+
console.log(" ✓ Terminal Pool");
|
|
189
|
+
console.log(" ✓ MCP Server");
|
|
190
|
+
console.log(" ✓ Coordination Manager");
|
|
191
|
+
|
|
192
|
+
if (!ctx.flags.daemon) {
|
|
193
|
+
info("Press Ctrl+C to stop the system");
|
|
194
|
+
// Keep the process running until interrupted
|
|
195
|
+
const controller = new AbortController();
|
|
196
|
+
|
|
197
|
+
const shutdown = () => {
|
|
198
|
+
console.log("\nShutting down...");
|
|
199
|
+
controller.abort();
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
Deno.addSignalListener("SIGINT", shutdown);
|
|
203
|
+
Deno.addSignalListener("SIGTERM", shutdown);
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
await new Promise<void>((resolve) => {
|
|
207
|
+
controller.signal.addEventListener('abort', () => resolve());
|
|
208
|
+
});
|
|
209
|
+
} finally {
|
|
210
|
+
Deno.removeSignalListener("SIGINT", shutdown);
|
|
211
|
+
Deno.removeSignalListener("SIGTERM", shutdown);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
error(`Failed to start system: ${(err as Error).message}`);
|
|
216
|
+
Deno.exit(1);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Task command
|
|
222
|
+
cli.command({
|
|
223
|
+
name: "task",
|
|
224
|
+
description: "Manage tasks",
|
|
225
|
+
aliases: ["tasks"],
|
|
226
|
+
action: async (ctx: CommandContext) => {
|
|
227
|
+
const subcommand = ctx.args[0];
|
|
228
|
+
|
|
229
|
+
switch (subcommand) {
|
|
230
|
+
case "create": {
|
|
231
|
+
const type = ctx.args[1] || "general";
|
|
232
|
+
const description = ctx.args.slice(2).join(" ") || "No description";
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
const persist = await getPersistence();
|
|
236
|
+
const taskId = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
237
|
+
|
|
238
|
+
// Save to persistence directly
|
|
239
|
+
await persist.saveTask({
|
|
240
|
+
id: taskId,
|
|
241
|
+
type,
|
|
242
|
+
description,
|
|
243
|
+
status: 'pending',
|
|
244
|
+
priority: ctx.flags.priority as number || 1,
|
|
245
|
+
dependencies: ctx.flags.deps ? (ctx.flags.deps as string).split(",") : [],
|
|
246
|
+
metadata: {},
|
|
247
|
+
progress: 0,
|
|
248
|
+
createdAt: Date.now(),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
success(`Task created successfully!`);
|
|
252
|
+
console.log(`📝 Task ID: ${taskId}`);
|
|
253
|
+
console.log(`🎯 Type: ${type}`);
|
|
254
|
+
console.log(`📄 Description: ${description}`);
|
|
255
|
+
} catch (err) {
|
|
256
|
+
error(`Failed to create task: ${(err as Error).message}`);
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
case "list": {
|
|
262
|
+
try {
|
|
263
|
+
const persist = await getPersistence();
|
|
264
|
+
const tasks = await persist.getActiveTasks();
|
|
265
|
+
|
|
266
|
+
if (tasks.length === 0) {
|
|
267
|
+
info("No active tasks");
|
|
268
|
+
} else {
|
|
269
|
+
success(`Active tasks (${tasks.length}):`);
|
|
270
|
+
for (const task of tasks) {
|
|
271
|
+
console.log(` • ${task.id} (${task.type}) - ${task.status}`);
|
|
272
|
+
if (ctx.flags.verbose) {
|
|
273
|
+
console.log(` Description: ${task.description}`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
} catch (err) {
|
|
278
|
+
error(`Failed to list tasks: ${(err as Error).message}`);
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
case "assign": {
|
|
284
|
+
const taskId = ctx.args[1];
|
|
285
|
+
const agentId = ctx.args[2];
|
|
286
|
+
|
|
287
|
+
if (!taskId || !agentId) {
|
|
288
|
+
error("Usage: task assign <task-id> <agent-id>");
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
const persist = await getPersistence();
|
|
294
|
+
const tasks = await persist.getAllTasks();
|
|
295
|
+
const agents = await persist.getAllAgents();
|
|
296
|
+
|
|
297
|
+
const task = tasks.find(t => t.id === taskId);
|
|
298
|
+
const agent = agents.find(a => a.id === agentId);
|
|
299
|
+
|
|
300
|
+
if (!task) {
|
|
301
|
+
error(`Task not found: ${taskId}`);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!agent) {
|
|
306
|
+
error(`Agent not found: ${agentId}`);
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Update task with assigned agent
|
|
311
|
+
task.assignedAgent = agentId;
|
|
312
|
+
task.status = "assigned";
|
|
313
|
+
await persist.saveTask(task);
|
|
314
|
+
|
|
315
|
+
success(`Task ${taskId} assigned to agent ${agentId}`);
|
|
316
|
+
console.log(`📝 Task: ${task.description}`);
|
|
317
|
+
console.log(`🤖 Agent: ${agent.name} (${agent.type})`);
|
|
318
|
+
} catch (err) {
|
|
319
|
+
error(`Failed to assign task: ${(err as Error).message}`);
|
|
320
|
+
}
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
case "workflow": {
|
|
325
|
+
const workflowFile = ctx.args[1];
|
|
326
|
+
if (!workflowFile) {
|
|
327
|
+
error("Usage: task workflow <workflow-file>");
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
try {
|
|
332
|
+
const content = await Deno.readTextFile(workflowFile);
|
|
333
|
+
const workflow = JSON.parse(content);
|
|
334
|
+
|
|
335
|
+
success("Workflow loaded:");
|
|
336
|
+
console.log(`📋 Name: ${workflow.name || 'Unnamed'}`);
|
|
337
|
+
console.log(`📝 Description: ${workflow.description || 'No description'}`);
|
|
338
|
+
console.log(`🤖 Agents: ${workflow.agents?.length || 0}`);
|
|
339
|
+
console.log(`📌 Tasks: ${workflow.tasks?.length || 0}`);
|
|
340
|
+
|
|
341
|
+
if (ctx.flags.execute) {
|
|
342
|
+
warning("Workflow execution would start here (not yet implemented)");
|
|
343
|
+
// TODO: Implement workflow execution
|
|
344
|
+
} else {
|
|
345
|
+
info("To execute this workflow, ensure Claude-Flow is running");
|
|
346
|
+
}
|
|
347
|
+
} catch (err) {
|
|
348
|
+
error(`Failed to load workflow: ${(err as Error).message}`);
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
default: {
|
|
354
|
+
console.log("Available subcommands: create, list, assign, workflow");
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// Agent command
|
|
362
|
+
cli.command({
|
|
363
|
+
name: "agent",
|
|
364
|
+
description: "Manage agents",
|
|
365
|
+
aliases: ["agents"],
|
|
366
|
+
action: async (ctx: CommandContext) => {
|
|
367
|
+
const subcommand = ctx.args[0];
|
|
368
|
+
|
|
369
|
+
switch (subcommand) {
|
|
370
|
+
case "spawn": {
|
|
371
|
+
const type = ctx.args[1] || "researcher";
|
|
372
|
+
const name = ctx.flags.name as string || `${type}-${Date.now()}`;
|
|
373
|
+
|
|
374
|
+
try {
|
|
375
|
+
const persist = await getPersistence();
|
|
376
|
+
const agentId = `agent-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
377
|
+
|
|
378
|
+
// Save to persistence directly
|
|
379
|
+
await persist.saveAgent({
|
|
380
|
+
id: agentId,
|
|
381
|
+
type,
|
|
382
|
+
name,
|
|
383
|
+
status: 'active',
|
|
384
|
+
capabilities: getCapabilitiesForType(type),
|
|
385
|
+
systemPrompt: ctx.flags.prompt as string || getDefaultPromptForType(type),
|
|
386
|
+
maxConcurrentTasks: ctx.flags.maxTasks as number || 5,
|
|
387
|
+
priority: ctx.flags.priority as number || 1,
|
|
388
|
+
createdAt: Date.now(),
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
success(`Agent spawned successfully!`);
|
|
392
|
+
console.log(`📝 Agent ID: ${agentId}`);
|
|
393
|
+
console.log(`🤖 Type: ${type}`);
|
|
394
|
+
console.log(`📛 Name: ${name}`);
|
|
395
|
+
console.log(`⚡ Status: Active`);
|
|
396
|
+
} catch (err) {
|
|
397
|
+
error(`Failed to spawn agent: ${(err as Error).message}`);
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
case "list": {
|
|
403
|
+
try {
|
|
404
|
+
const persist = await getPersistence();
|
|
405
|
+
const agents = await persist.getActiveAgents();
|
|
406
|
+
|
|
407
|
+
if (agents.length === 0) {
|
|
408
|
+
info("No active agents");
|
|
409
|
+
} else {
|
|
410
|
+
success(`Active agents (${agents.length}):`);
|
|
411
|
+
for (const agent of agents) {
|
|
412
|
+
console.log(` • ${agent.id} (${agent.type}) - ${agent.status}`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
} catch (err) {
|
|
416
|
+
error(`Failed to list agents: ${(err as Error).message}`);
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
default: {
|
|
422
|
+
console.log("Available subcommands: spawn, list");
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// Status command
|
|
430
|
+
cli.command({
|
|
431
|
+
name: "status",
|
|
432
|
+
description: "Show system status",
|
|
433
|
+
action: async (ctx: CommandContext) => {
|
|
434
|
+
try {
|
|
435
|
+
const persist = await getPersistence();
|
|
436
|
+
const stats = await persist.getStats();
|
|
437
|
+
|
|
438
|
+
// Check if orchestrator is running by looking for the log file
|
|
439
|
+
const isRunning = await Deno.stat("orchestrator.log").then(() => true).catch(() => false);
|
|
440
|
+
|
|
441
|
+
success("Claude-Flow System Status:");
|
|
442
|
+
console.log(`🟢 Status: ${isRunning ? 'Running' : 'Stopped'}`);
|
|
443
|
+
console.log(`🤖 Agents: ${stats.activeAgents} active (${stats.totalAgents} total)`);
|
|
444
|
+
console.log(`📋 Tasks: ${stats.pendingTasks} in queue (${stats.totalTasks} total)`);
|
|
445
|
+
console.log(`💾 Memory: Ready`);
|
|
446
|
+
console.log(`🖥️ Terminal Pool: Ready`);
|
|
447
|
+
console.log(`🌐 MCP Server: ${isRunning ? 'Running' : 'Stopped'}`);
|
|
448
|
+
|
|
449
|
+
if (ctx.flags.verbose) {
|
|
450
|
+
console.log("\nDetailed Statistics:");
|
|
451
|
+
console.log(` Total Agents: ${stats.totalAgents}`);
|
|
452
|
+
console.log(` Active Agents: ${stats.activeAgents}`);
|
|
453
|
+
console.log(` Total Tasks: ${stats.totalTasks}`);
|
|
454
|
+
console.log(` Pending Tasks: ${stats.pendingTasks}`);
|
|
455
|
+
console.log(` Completed Tasks: ${stats.completedTasks}`);
|
|
456
|
+
}
|
|
457
|
+
} catch (err) {
|
|
458
|
+
error(`Failed to get status: ${(err as Error).message}`);
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// MCP command
|
|
464
|
+
cli.command({
|
|
465
|
+
name: "mcp",
|
|
466
|
+
description: "Manage MCP server and tools",
|
|
467
|
+
action: async (ctx: CommandContext) => {
|
|
468
|
+
const subcommand = ctx.args[0];
|
|
469
|
+
|
|
470
|
+
switch (subcommand) {
|
|
471
|
+
case "start": {
|
|
472
|
+
const port = ctx.flags.port as number || 3000;
|
|
473
|
+
const host = ctx.flags.host as string || "localhost";
|
|
474
|
+
|
|
475
|
+
try {
|
|
476
|
+
// MCP server is part of the orchestrator start process
|
|
477
|
+
const orch = await getOrchestrator();
|
|
478
|
+
const health = await orch.healthCheck();
|
|
479
|
+
|
|
480
|
+
if (!health.healthy) {
|
|
481
|
+
warning("Orchestrator is not running. Start it first with 'claude-flow start'");
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
success(`MCP server is running as part of the orchestration system`);
|
|
486
|
+
console.log(`📡 Default address: http://${host}:${port}`);
|
|
487
|
+
console.log(`🔧 Available tools: Research, Code, Terminal, Memory`);
|
|
488
|
+
console.log(`📚 Use 'claude-flow mcp tools' to see all available tools`);
|
|
489
|
+
} catch (err) {
|
|
490
|
+
error(`Failed to check MCP server: ${(err as Error).message}`);
|
|
491
|
+
}
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
case "stop": {
|
|
496
|
+
try {
|
|
497
|
+
const orch = await getOrchestrator();
|
|
498
|
+
const health = await orch.healthCheck();
|
|
499
|
+
|
|
500
|
+
if (!health.healthy) {
|
|
501
|
+
info("MCP server is not running");
|
|
502
|
+
} else {
|
|
503
|
+
warning("MCP server runs as part of the orchestrator. Use 'claude-flow stop' to stop the entire system");
|
|
504
|
+
}
|
|
505
|
+
} catch (err) {
|
|
506
|
+
error(`Failed to check MCP server: ${(err as Error).message}`);
|
|
507
|
+
}
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
case "status": {
|
|
512
|
+
try {
|
|
513
|
+
const orch = await getOrchestrator();
|
|
514
|
+
const health = await orch.healthCheck();
|
|
515
|
+
|
|
516
|
+
success("MCP Server Status:");
|
|
517
|
+
console.log(`🌐 Status: ${health.mcp ? "Running" : "Stopped"}`);
|
|
518
|
+
|
|
519
|
+
if (health.mcp) {
|
|
520
|
+
const config = await getConfigManager();
|
|
521
|
+
const mcpConfig = config.get().mcp;
|
|
522
|
+
console.log(`📍 Address: ${mcpConfig.host}:${mcpConfig.port}`);
|
|
523
|
+
console.log(`🔐 Authentication: ${mcpConfig.auth ? "Enabled" : "Disabled"}`);
|
|
524
|
+
console.log(`🔧 Tools: Available`);
|
|
525
|
+
console.log(`📊 Metrics: Collecting`);
|
|
526
|
+
}
|
|
527
|
+
} catch (err) {
|
|
528
|
+
error(`Failed to get MCP status: ${(err as Error).message}`);
|
|
529
|
+
}
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
case "tools": {
|
|
534
|
+
try {
|
|
535
|
+
success("Available MCP Tools:");
|
|
536
|
+
console.log(" 📊 Research Tools:");
|
|
537
|
+
console.log(" • web_search - Search the web for information");
|
|
538
|
+
console.log(" • web_fetch - Fetch content from URLs");
|
|
539
|
+
console.log(" • knowledge_query - Query knowledge base");
|
|
540
|
+
|
|
541
|
+
console.log(" 💻 Code Tools:");
|
|
542
|
+
console.log(" • code_edit - Edit code files");
|
|
543
|
+
console.log(" • code_search - Search through codebase");
|
|
544
|
+
console.log(" • code_analyze - Analyze code quality");
|
|
545
|
+
|
|
546
|
+
console.log(" 🖥️ Terminal Tools:");
|
|
547
|
+
console.log(" • terminal_execute - Execute shell commands");
|
|
548
|
+
console.log(" • terminal_session - Manage terminal sessions");
|
|
549
|
+
console.log(" • file_operations - File system operations");
|
|
550
|
+
|
|
551
|
+
console.log(" 💾 Memory Tools:");
|
|
552
|
+
console.log(" • memory_store - Store information");
|
|
553
|
+
console.log(" • memory_query - Query stored information");
|
|
554
|
+
console.log(" • memory_index - Index and search content");
|
|
555
|
+
} catch (err) {
|
|
556
|
+
error(`Failed to list tools: ${(err as Error).message}`);
|
|
557
|
+
}
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
case "config": {
|
|
562
|
+
try {
|
|
563
|
+
const config = await getConfigManager();
|
|
564
|
+
const mcpConfig = config.get().mcp;
|
|
565
|
+
|
|
566
|
+
success("MCP Configuration:");
|
|
567
|
+
console.log(JSON.stringify(mcpConfig, null, 2));
|
|
568
|
+
} catch (err) {
|
|
569
|
+
error(`Failed to show MCP config: ${(err as Error).message}`);
|
|
570
|
+
}
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
case "restart": {
|
|
575
|
+
try {
|
|
576
|
+
warning("MCP server runs as part of the orchestrator. Use 'claude-flow stop' then 'claude-flow start' to restart the entire system");
|
|
577
|
+
} catch (err) {
|
|
578
|
+
error(`Failed to restart MCP server: ${(err as Error).message}`);
|
|
579
|
+
}
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
case "logs": {
|
|
584
|
+
const lines = ctx.flags.lines as number || 50;
|
|
585
|
+
|
|
586
|
+
try {
|
|
587
|
+
// Mock logs since logging system might not be fully implemented
|
|
588
|
+
success(`MCP Server Logs (last ${lines} lines):`);
|
|
589
|
+
console.log("2024-01-10 10:00:00 [INFO] MCP server started on localhost:3000");
|
|
590
|
+
console.log("2024-01-10 10:00:01 [INFO] Tools registered: 12");
|
|
591
|
+
console.log("2024-01-10 10:00:02 [INFO] Authentication disabled");
|
|
592
|
+
console.log("2024-01-10 10:01:00 [INFO] Client connected: claude-desktop");
|
|
593
|
+
console.log("2024-01-10 10:01:05 [INFO] Tool called: web_search");
|
|
594
|
+
console.log("2024-01-10 10:01:10 [INFO] Tool response sent successfully");
|
|
595
|
+
} catch (err) {
|
|
596
|
+
error(`Failed to get logs: ${(err as Error).message}`);
|
|
597
|
+
}
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
default: {
|
|
602
|
+
error(`Unknown mcp subcommand: ${subcommand}`);
|
|
603
|
+
console.log("Available subcommands: start, stop, status, tools, config, restart, logs");
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
// Help command
|
|
611
|
+
cli.command({
|
|
612
|
+
name: "help",
|
|
613
|
+
description: "Show help information",
|
|
614
|
+
action: () => {
|
|
615
|
+
// The CLI will show help automatically
|
|
616
|
+
},
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function getCapabilitiesForType(type: string): string[] {
|
|
621
|
+
const capabilities: Record<string, string[]> = {
|
|
622
|
+
coordinator: ['task-assignment', 'planning', 'delegation'],
|
|
623
|
+
researcher: ['web-search', 'information-gathering', 'analysis'],
|
|
624
|
+
implementer: ['code-generation', 'file-manipulation', 'testing'],
|
|
625
|
+
analyst: ['data-analysis', 'pattern-recognition', 'reporting'],
|
|
626
|
+
custom: ['user-defined'],
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
return capabilities[type] || capabilities.custom;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function getDefaultPromptForType(type: string): string {
|
|
633
|
+
const prompts: Record<string, string> = {
|
|
634
|
+
coordinator: 'You are a coordination agent responsible for planning and delegating tasks.',
|
|
635
|
+
researcher: 'You are a research agent specialized in gathering and analyzing information.',
|
|
636
|
+
implementer: 'You are an implementation agent focused on writing code and creating solutions.',
|
|
637
|
+
analyst: 'You are an analysis agent that identifies patterns and generates insights.',
|
|
638
|
+
custom: 'You are a custom agent. Follow the user\'s instructions.',
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
return prompts[type] || prompts.custom;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// Template creation functions
|
|
645
|
+
function createMinimalClaudeMd(): string {
|
|
646
|
+
return `# Claude Code Configuration
|
|
647
|
+
|
|
648
|
+
## Build Commands
|
|
649
|
+
- \`npm run build\`: Build the project
|
|
650
|
+
- \`npm run test\`: Run tests
|
|
651
|
+
- \`npm run lint\`: Run linter
|
|
652
|
+
|
|
653
|
+
## Code Style
|
|
654
|
+
- Use TypeScript/ES modules
|
|
655
|
+
- Follow project conventions
|
|
656
|
+
- Run typecheck before committing
|
|
657
|
+
|
|
658
|
+
## Project Info
|
|
659
|
+
This is a Claude-Flow AI agent orchestration system.
|
|
660
|
+
`;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function createFullClaudeMd(): string {
|
|
664
|
+
return `# Claude Code Configuration
|
|
665
|
+
|
|
666
|
+
## Build Commands
|
|
667
|
+
- \`npm run build\`: Build the project using Deno compile
|
|
668
|
+
- \`npm run test\`: Run the full test suite
|
|
669
|
+
- \`npm run lint\`: Run ESLint and format checks
|
|
670
|
+
- \`npm run typecheck\`: Run TypeScript type checking
|
|
671
|
+
- \`npx claude-flow start\`: Start the orchestration system
|
|
672
|
+
- \`npx claude-flow --help\`: Show all available commands
|
|
673
|
+
|
|
674
|
+
## Code Style Preferences
|
|
675
|
+
- Use ES modules (import/export) syntax, not CommonJS (require)
|
|
676
|
+
- Destructure imports when possible (e.g., \`import { foo } from 'bar'\`)
|
|
677
|
+
- Use TypeScript for all new code
|
|
678
|
+
- Follow existing naming conventions (camelCase for variables, PascalCase for classes)
|
|
679
|
+
- Add JSDoc comments for public APIs
|
|
680
|
+
- Use async/await instead of Promise chains
|
|
681
|
+
- Prefer const/let over var
|
|
682
|
+
|
|
683
|
+
## Workflow Guidelines
|
|
684
|
+
- Always run typecheck after making code changes
|
|
685
|
+
- Run tests before committing changes
|
|
686
|
+
- Use meaningful commit messages following conventional commits
|
|
687
|
+
- Create feature branches for new functionality
|
|
688
|
+
- Ensure all tests pass before merging
|
|
689
|
+
|
|
690
|
+
## Project Architecture
|
|
691
|
+
This is a Claude-Flow AI agent orchestration system with the following components:
|
|
692
|
+
- **CLI Interface**: Command-line tools for managing the system
|
|
693
|
+
- **Orchestrator**: Core engine for coordinating agents and tasks
|
|
694
|
+
- **Memory System**: Persistent storage and retrieval of information
|
|
695
|
+
- **Terminal Management**: Automated terminal session handling
|
|
696
|
+
- **MCP Integration**: Model Context Protocol server for Claude integration
|
|
697
|
+
- **Agent Coordination**: Multi-agent task distribution and management
|
|
698
|
+
|
|
699
|
+
## Important Notes
|
|
700
|
+
- Use \`claude --dangerously-skip-permissions\` for unattended operation
|
|
701
|
+
- The system supports both daemon and interactive modes
|
|
702
|
+
- Memory persistence is handled automatically
|
|
703
|
+
- All components are event-driven for scalability
|
|
704
|
+
|
|
705
|
+
## Debugging
|
|
706
|
+
- Check logs in \`./claude-flow.log\`
|
|
707
|
+
- Use \`npx claude-flow status\` to check system health
|
|
708
|
+
- Monitor with \`npx claude-flow monitor\` for real-time updates
|
|
709
|
+
- Verbose output available with \`--verbose\` flag on most commands
|
|
710
|
+
`;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function createMinimalMemoryBankMd(): string {
|
|
714
|
+
return `# Memory Bank
|
|
715
|
+
|
|
716
|
+
## Quick Reference
|
|
717
|
+
- Project uses SQLite for memory persistence
|
|
718
|
+
- Memory is organized by namespaces
|
|
719
|
+
- Query with \`npx claude-flow memory query <search>\`
|
|
720
|
+
|
|
721
|
+
## Storage Location
|
|
722
|
+
- Database: \`./memory/claude-flow-data.json\`
|
|
723
|
+
- Sessions: \`./memory/sessions/\`
|
|
724
|
+
`;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function createFullMemoryBankMd(): string {
|
|
728
|
+
return `# Memory Bank Configuration
|
|
729
|
+
|
|
730
|
+
## Overview
|
|
731
|
+
The Claude-Flow memory system provides persistent storage and intelligent retrieval of information across agent sessions. It uses a hybrid approach combining SQL databases with semantic search capabilities.
|
|
732
|
+
|
|
733
|
+
## Storage Backends
|
|
734
|
+
- **Primary**: JSON database (\`./memory/claude-flow-data.json\`)
|
|
735
|
+
- **Sessions**: File-based storage in \`./memory/sessions/\`
|
|
736
|
+
- **Cache**: In-memory cache for frequently accessed data
|
|
737
|
+
|
|
738
|
+
## Memory Organization
|
|
739
|
+
- **Namespaces**: Logical groupings of related information
|
|
740
|
+
- **Sessions**: Time-bound conversation contexts
|
|
741
|
+
- **Indexing**: Automatic content indexing for fast retrieval
|
|
742
|
+
- **Replication**: Optional distributed storage support
|
|
743
|
+
|
|
744
|
+
## Commands
|
|
745
|
+
- \`npx claude-flow memory query <search>\`: Search stored information
|
|
746
|
+
- \`npx claude-flow memory stats\`: Show memory usage statistics
|
|
747
|
+
- \`npx claude-flow memory export <file>\`: Export memory to file
|
|
748
|
+
- \`npx claude-flow memory import <file>\`: Import memory from file
|
|
749
|
+
|
|
750
|
+
## Configuration
|
|
751
|
+
Memory settings are configured in \`claude-flow.config.json\`:
|
|
752
|
+
\`\`\`json
|
|
753
|
+
{
|
|
754
|
+
"memory": {
|
|
755
|
+
"backend": "json",
|
|
756
|
+
"path": "./memory/claude-flow-data.json",
|
|
757
|
+
"cacheSize": 1000,
|
|
758
|
+
"indexing": true,
|
|
759
|
+
"namespaces": ["default", "agents", "tasks", "sessions"],
|
|
760
|
+
"retentionPolicy": {
|
|
761
|
+
"sessions": "30d",
|
|
762
|
+
"tasks": "90d",
|
|
763
|
+
"agents": "permanent"
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
\`\`\`
|
|
768
|
+
|
|
769
|
+
## Best Practices
|
|
770
|
+
- Use descriptive namespaces for different data types
|
|
771
|
+
- Regular memory exports for backup purposes
|
|
772
|
+
- Monitor memory usage with stats command
|
|
773
|
+
- Clean up old sessions periodically
|
|
774
|
+
|
|
775
|
+
## Memory Types
|
|
776
|
+
- **Episodic**: Conversation and interaction history
|
|
777
|
+
- **Semantic**: Factual knowledge and relationships
|
|
778
|
+
- **Procedural**: Task patterns and workflows
|
|
779
|
+
- **Meta**: System configuration and preferences
|
|
780
|
+
|
|
781
|
+
## Integration Notes
|
|
782
|
+
- Memory is automatically synchronized across agents
|
|
783
|
+
- Search supports both exact match and semantic similarity
|
|
784
|
+
- Memory contents are private to your local instance
|
|
785
|
+
- No data is sent to external services without explicit commands
|
|
786
|
+
`;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function createMinimalCoordinationMd(): string {
|
|
790
|
+
return `# Agent Coordination
|
|
791
|
+
|
|
792
|
+
## Quick Commands
|
|
793
|
+
- \`npx claude-flow agent spawn <type>\`: Create new agent
|
|
794
|
+
- \`npx claude-flow agent list\`: Show active agents
|
|
795
|
+
- \`npx claude-flow task create <type> <description>\`: Create task
|
|
796
|
+
|
|
797
|
+
## Agent Types
|
|
798
|
+
- researcher, coder, analyst, coordinator, general
|
|
799
|
+
`;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function createFullCoordinationMd(): string {
|
|
803
|
+
return `# Agent Coordination System
|
|
804
|
+
|
|
805
|
+
## Overview
|
|
806
|
+
The Claude-Flow coordination system manages multiple AI agents working together on complex tasks. It provides intelligent task distribution, resource management, and inter-agent communication.
|
|
807
|
+
|
|
808
|
+
## Agent Types and Capabilities
|
|
809
|
+
- **Researcher**: Web search, information gathering, knowledge synthesis
|
|
810
|
+
- **Coder**: Code analysis, development, debugging, testing
|
|
811
|
+
- **Analyst**: Data processing, pattern recognition, insights generation
|
|
812
|
+
- **Coordinator**: Task planning, resource allocation, workflow management
|
|
813
|
+
- **General**: Multi-purpose agent with balanced capabilities
|
|
814
|
+
|
|
815
|
+
## Task Management
|
|
816
|
+
- **Priority Levels**: 1 (lowest) to 10 (highest)
|
|
817
|
+
- **Dependencies**: Tasks can depend on completion of other tasks
|
|
818
|
+
- **Parallel Execution**: Independent tasks run concurrently
|
|
819
|
+
- **Load Balancing**: Automatic distribution based on agent capacity
|
|
820
|
+
|
|
821
|
+
## Coordination Commands
|
|
822
|
+
\`\`\`bash
|
|
823
|
+
# Agent Management
|
|
824
|
+
npx claude-flow agent spawn <type> --name <name> --priority <1-10>
|
|
825
|
+
npx claude-flow agent list
|
|
826
|
+
npx claude-flow agent info <agent-id>
|
|
827
|
+
npx claude-flow agent terminate <agent-id>
|
|
828
|
+
|
|
829
|
+
# Task Management
|
|
830
|
+
npx claude-flow task create <type> <description> --priority <1-10> --deps <task-ids>
|
|
831
|
+
npx claude-flow task list --verbose
|
|
832
|
+
npx claude-flow task status <task-id>
|
|
833
|
+
npx claude-flow task cancel <task-id>
|
|
834
|
+
|
|
835
|
+
# System Monitoring
|
|
836
|
+
npx claude-flow status --verbose
|
|
837
|
+
npx claude-flow monitor --interval 5000
|
|
838
|
+
\`\`\`
|
|
839
|
+
|
|
840
|
+
## Workflow Execution
|
|
841
|
+
Workflows are defined in JSON format and can orchestrate complex multi-agent operations:
|
|
842
|
+
\`\`\`bash
|
|
843
|
+
npx claude-flow workflow examples/research-workflow.json
|
|
844
|
+
npx claude-flow workflow examples/development-config.json --async
|
|
845
|
+
\`\`\`
|
|
846
|
+
|
|
847
|
+
## Advanced Features
|
|
848
|
+
- **Circuit Breakers**: Automatic failure handling and recovery
|
|
849
|
+
- **Work Stealing**: Dynamic load redistribution for efficiency
|
|
850
|
+
- **Resource Limits**: Memory and CPU usage constraints
|
|
851
|
+
- **Metrics Collection**: Performance monitoring and optimization
|
|
852
|
+
|
|
853
|
+
## Configuration
|
|
854
|
+
Coordination settings in \`claude-flow.config.json\`:
|
|
855
|
+
\`\`\`json
|
|
856
|
+
{
|
|
857
|
+
"orchestrator": {
|
|
858
|
+
"maxConcurrentTasks": 10,
|
|
859
|
+
"taskTimeout": 300000,
|
|
860
|
+
"defaultPriority": 5
|
|
861
|
+
},
|
|
862
|
+
"agents": {
|
|
863
|
+
"maxAgents": 20,
|
|
864
|
+
"defaultCapabilities": ["research", "code", "terminal"],
|
|
865
|
+
"resourceLimits": {
|
|
866
|
+
"memory": "1GB",
|
|
867
|
+
"cpu": "50%"
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
\`\`\`
|
|
872
|
+
|
|
873
|
+
## Communication Patterns
|
|
874
|
+
- **Direct Messaging**: Agent-to-agent communication
|
|
875
|
+
- **Event Broadcasting**: System-wide notifications
|
|
876
|
+
- **Shared Memory**: Common information access
|
|
877
|
+
- **Task Handoff**: Seamless work transfer between agents
|
|
878
|
+
|
|
879
|
+
## Best Practices
|
|
880
|
+
- Start with general agents and specialize as needed
|
|
881
|
+
- Use descriptive task names and clear requirements
|
|
882
|
+
- Monitor system resources during heavy workloads
|
|
883
|
+
- Implement proper error handling in workflows
|
|
884
|
+
- Regular cleanup of completed tasks and inactive agents
|
|
885
|
+
|
|
886
|
+
## Troubleshooting
|
|
887
|
+
- Check agent health with \`npx claude-flow status\`
|
|
888
|
+
- View detailed logs with \`npx claude-flow monitor\`
|
|
889
|
+
- Restart stuck agents with terminate/spawn cycle
|
|
890
|
+
- Use \`--verbose\` flags for detailed diagnostic information
|
|
891
|
+
`;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
function createAgentsReadme(): string {
|
|
895
|
+
return `# Agent Memory Storage
|
|
896
|
+
|
|
897
|
+
## Purpose
|
|
898
|
+
This directory stores agent-specific memory data, configurations, and persistent state information for individual Claude agents in the orchestration system.
|
|
899
|
+
|
|
900
|
+
## Structure
|
|
901
|
+
Each agent gets its own subdirectory for isolated memory storage:
|
|
902
|
+
|
|
903
|
+
\`\`\`
|
|
904
|
+
memory/agents/
|
|
905
|
+
├── agent_001/
|
|
906
|
+
│ ├── state.json # Agent state and configuration
|
|
907
|
+
│ ├── knowledge.md # Agent-specific knowledge base
|
|
908
|
+
│ ├── tasks.json # Completed and active tasks
|
|
909
|
+
│ └── calibration.json # Agent-specific calibrations
|
|
910
|
+
├── agent_002/
|
|
911
|
+
│ └── ...
|
|
912
|
+
└── shared/
|
|
913
|
+
├── common_knowledge.md # Shared knowledge across agents
|
|
914
|
+
└── global_config.json # Global agent configurations
|
|
915
|
+
\`\`\`
|
|
916
|
+
|
|
917
|
+
## Usage Guidelines
|
|
918
|
+
1. **Agent Isolation**: Each agent should only read/write to its own directory
|
|
919
|
+
2. **Shared Resources**: Use the \`shared/\` directory for cross-agent information
|
|
920
|
+
3. **State Persistence**: Update state.json whenever agent status changes
|
|
921
|
+
4. **Knowledge Sharing**: Document discoveries in knowledge.md files
|
|
922
|
+
5. **Cleanup**: Remove directories for terminated agents periodically
|
|
923
|
+
|
|
924
|
+
## Last Updated
|
|
925
|
+
${new Date().toISOString()}
|
|
926
|
+
`;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function createSessionsReadme(): string {
|
|
930
|
+
return `# Session Memory Storage
|
|
931
|
+
|
|
932
|
+
## Purpose
|
|
933
|
+
This directory stores session-based memory data, conversation history, and contextual information for development sessions using the Claude-Flow orchestration system.
|
|
934
|
+
|
|
935
|
+
## Structure
|
|
936
|
+
Sessions are organized by date and session ID for easy retrieval:
|
|
937
|
+
|
|
938
|
+
\`\`\`
|
|
939
|
+
memory/sessions/
|
|
940
|
+
├── 2024-01-10/
|
|
941
|
+
│ ├── session_001/
|
|
942
|
+
│ │ ├── metadata.json # Session metadata and configuration
|
|
943
|
+
│ │ ├── conversation.md # Full conversation history
|
|
944
|
+
│ │ ├── decisions.md # Key decisions and rationale
|
|
945
|
+
│ │ ├── artifacts/ # Generated files and outputs
|
|
946
|
+
│ │ └── coordination_state/ # Coordination system snapshots
|
|
947
|
+
│ └── ...
|
|
948
|
+
└── shared/
|
|
949
|
+
├── patterns.md # Common session patterns
|
|
950
|
+
└── templates/ # Session template files
|
|
951
|
+
\`\`\`
|
|
952
|
+
|
|
953
|
+
## Usage Guidelines
|
|
954
|
+
1. **Session Isolation**: Each session gets its own directory
|
|
955
|
+
2. **Metadata Completeness**: Always fill out session metadata
|
|
956
|
+
3. **Conversation Logging**: Document all significant interactions
|
|
957
|
+
4. **Artifact Organization**: Structure generated files clearly
|
|
958
|
+
5. **State Preservation**: Snapshot coordination state regularly
|
|
959
|
+
|
|
960
|
+
## Last Updated
|
|
961
|
+
${new Date().toISOString()}
|
|
962
|
+
`;
|
|
963
|
+
}
|