@claude-flow/cli 3.0.0-alpha.2 → 3.0.0-alpha.7
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/.agentic-flow/intelligence.json +4 -3
- package/.claude-flow/agents/store.json +16 -0
- package/.claude-flow/daemon-state.json +123 -0
- package/.claude-flow/hive-mind/state.json +51 -0
- package/.claude-flow/metrics/codebase-map.json +11 -0
- package/.claude-flow/metrics/consolidation.json +6 -0
- package/.claude-flow/metrics/performance.json +3 -3
- package/.claude-flow/metrics/security-audit.json +10 -0
- package/.claude-flow/metrics/task-metrics.json +3 -3
- package/.claude-flow/metrics/test-gaps.json +6 -0
- package/agents/architect.yaml +11 -0
- package/agents/coder.yaml +11 -0
- package/agents/reviewer.yaml +10 -0
- package/agents/security-architect.yaml +10 -0
- package/agents/tester.yaml +10 -0
- package/bin/cli.js +0 -0
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +43 -27
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/config.js +2 -2
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts +8 -0
- package/dist/src/commands/daemon.d.ts.map +1 -0
- package/dist/src/commands/daemon.js +351 -0
- package/dist/src/commands/daemon.js.map +1 -0
- package/dist/src/commands/hive-mind.d.ts.map +1 -1
- package/dist/src/commands/hive-mind.js +252 -35
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +1 -1
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp.js +1 -1
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +234 -168
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +1 -1
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/process.d.ts.map +1 -1
- package/dist/src/commands/process.js +95 -20
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/start.js +2 -2
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +26 -2
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +6 -6
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +5 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +22 -12
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +15 -1
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +5 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +350 -14
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +262 -15
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +80 -15
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +4 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +4 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +157 -9
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.d.ts +8 -0
- package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/session-tools.js +315 -0
- package/dist/src/mcp-tools/session-tools.js.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +37 -2
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts +8 -0
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/task-tools.js +302 -0
- package/dist/src/mcp-tools/task-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.js +481 -0
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
- package/dist/src/services/index.d.ts +7 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +6 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/worker-daemon.d.ts +126 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +464 -0
- package/dist/src/services/worker-daemon.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/commands/agent.ts +43 -29
- package/src/commands/config.ts +2 -2
- package/src/commands/daemon.ts +395 -0
- package/src/commands/hive-mind.ts +229 -63
- package/src/commands/hooks.ts +1 -1
- package/src/commands/index.ts +4 -1
- package/src/commands/mcp.ts +1 -1
- package/src/commands/memory.ts +279 -181
- package/src/commands/migrate.ts +1 -1
- package/src/commands/process.ts +98 -20
- package/src/commands/start.ts +2 -2
- package/src/commands/status.ts +33 -2
- package/src/commands/swarm.ts +6 -6
- package/src/index.ts +23 -3
- package/src/init/executor.ts +6 -0
- package/src/init/settings-generator.ts +22 -12
- package/src/mcp-client.ts +15 -1
- package/src/mcp-server.ts +6 -0
- package/src/mcp-tools/agent-tools.ts +388 -14
- package/src/mcp-tools/config-tools.ts +297 -15
- package/src/mcp-tools/hive-mind-tools.ts +521 -0
- package/src/mcp-tools/hooks-tools.ts +84 -15
- package/src/mcp-tools/index.ts +4 -0
- package/src/mcp-tools/memory-tools.ts +190 -9
- package/src/mcp-tools/session-tools.ts +359 -0
- package/src/mcp-tools/swarm-tools.ts +38 -2
- package/src/mcp-tools/task-tools.ts +347 -0
- package/src/mcp-tools/workflow-tools.ts +573 -0
- package/src/services/index.ts +15 -0
- package/src/services/worker-daemon.ts +594 -0
|
@@ -125,13 +125,13 @@ const initCommand: Command = {
|
|
|
125
125
|
output.writeln();
|
|
126
126
|
output.printBox(
|
|
127
127
|
[
|
|
128
|
-
`Hive ID: ${result.hiveId}`,
|
|
129
|
-
`Queen ID: ${result.queenId}`,
|
|
130
|
-
`Topology: ${result.topology}`,
|
|
131
|
-
`Consensus: ${result.consensus}`,
|
|
128
|
+
`Hive ID: ${result.hiveId ?? 'default'}`,
|
|
129
|
+
`Queen ID: ${result.queenId ?? 'N/A'}`,
|
|
130
|
+
`Topology: ${result.topology ?? config.topology}`,
|
|
131
|
+
`Consensus: ${result.consensus ?? config.consensus}`,
|
|
132
132
|
`Max Agents: ${config.maxAgents}`,
|
|
133
133
|
`Memory: ${config.memoryBackend}`,
|
|
134
|
-
`Status: ${output.success(result.status)}`
|
|
134
|
+
`Status: ${output.success(result.status ?? 'initialized')}`
|
|
135
135
|
].join('\n'),
|
|
136
136
|
'Hive Mind Configuration'
|
|
137
137
|
);
|
|
@@ -276,37 +276,42 @@ const statusCommand: Command = {
|
|
|
276
276
|
|
|
277
277
|
try {
|
|
278
278
|
const result = await callMCPTool<{
|
|
279
|
-
hiveId
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
hiveId?: string;
|
|
280
|
+
id?: string;
|
|
281
|
+
initialized?: boolean;
|
|
282
|
+
status?: 'active' | 'idle' | 'degraded' | 'offline' | 'running' | 'stopped';
|
|
283
|
+
topology?: string;
|
|
284
|
+
consensus?: string;
|
|
285
|
+
queen?: {
|
|
286
|
+
id?: string;
|
|
287
|
+
agentId?: string;
|
|
288
|
+
status?: string;
|
|
289
|
+
load?: number;
|
|
290
|
+
tasksQueued?: number;
|
|
288
291
|
};
|
|
289
|
-
workers
|
|
290
|
-
id
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
workers?: Array<{
|
|
293
|
+
id?: string;
|
|
294
|
+
agentId?: string;
|
|
295
|
+
type?: string;
|
|
296
|
+
agentType?: string;
|
|
297
|
+
status?: string;
|
|
293
298
|
currentTask?: string;
|
|
294
|
-
tasksCompleted
|
|
295
|
-
}>;
|
|
296
|
-
metrics
|
|
297
|
-
totalTasks
|
|
298
|
-
completedTasks
|
|
299
|
-
failedTasks
|
|
300
|
-
avgTaskTime
|
|
301
|
-
consensusRounds
|
|
302
|
-
memoryUsage
|
|
299
|
+
tasksCompleted?: number;
|
|
300
|
+
} | string>;
|
|
301
|
+
metrics?: {
|
|
302
|
+
totalTasks?: number;
|
|
303
|
+
completedTasks?: number;
|
|
304
|
+
failedTasks?: number;
|
|
305
|
+
avgTaskTime?: number;
|
|
306
|
+
consensusRounds?: number;
|
|
307
|
+
memoryUsage?: string;
|
|
303
308
|
};
|
|
304
|
-
health
|
|
305
|
-
overall
|
|
306
|
-
queen
|
|
307
|
-
workers
|
|
308
|
-
consensus
|
|
309
|
-
memory
|
|
309
|
+
health?: {
|
|
310
|
+
overall?: string;
|
|
311
|
+
queen?: string;
|
|
312
|
+
workers?: string;
|
|
313
|
+
consensus?: string;
|
|
314
|
+
memory?: string;
|
|
310
315
|
};
|
|
311
316
|
}>('hive-mind/status', {
|
|
312
317
|
includeMetrics: detailed,
|
|
@@ -318,36 +323,68 @@ const statusCommand: Command = {
|
|
|
318
323
|
return { success: true, data: result };
|
|
319
324
|
}
|
|
320
325
|
|
|
326
|
+
// Handle both simple and complex response formats - cast to flexible type
|
|
327
|
+
const flexResult = result as Record<string, unknown>;
|
|
328
|
+
const hiveId = result.hiveId ?? (flexResult.id as string) ?? 'default';
|
|
329
|
+
const status = result.status ?? ((flexResult.initialized as boolean) ? 'running' : 'stopped');
|
|
330
|
+
const queen = result.queen ?? { id: 'N/A', status: 'unknown', load: 0, tasksQueued: 0 };
|
|
331
|
+
const flexQueen = queen as Record<string, unknown>;
|
|
332
|
+
const queenId = typeof queen === 'object' ? (queen.id ?? (flexQueen.agentId as string) ?? 'N/A') : String(queen);
|
|
333
|
+
const queenLoad = typeof queen === 'object' ? (queen.load ?? 0) : 0;
|
|
334
|
+
const queenTasks = typeof queen === 'object' ? (queen.tasksQueued ?? 0) : 0;
|
|
335
|
+
const queenStatus = typeof queen === 'object' ? (queen.status ?? 'active') : 'active';
|
|
336
|
+
|
|
321
337
|
output.writeln();
|
|
322
338
|
output.printBox(
|
|
323
339
|
[
|
|
324
|
-
`Hive ID: ${
|
|
325
|
-
`Status: ${formatHiveStatus(
|
|
326
|
-
`Topology: ${result.topology}`,
|
|
327
|
-
`Consensus: ${result.consensus}`,
|
|
340
|
+
`Hive ID: ${hiveId}`,
|
|
341
|
+
`Status: ${formatHiveStatus(String(status))}`,
|
|
342
|
+
`Topology: ${result.topology ?? 'mesh'}`,
|
|
343
|
+
`Consensus: ${result.consensus ?? 'byzantine'}`,
|
|
328
344
|
'',
|
|
329
|
-
`Queen: ${
|
|
330
|
-
` Status: ${formatAgentStatus(
|
|
331
|
-
` Load: ${(
|
|
332
|
-
` Queued Tasks: ${
|
|
345
|
+
`Queen: ${queenId}`,
|
|
346
|
+
` Status: ${formatAgentStatus(queenStatus)}`,
|
|
347
|
+
` Load: ${(queenLoad * 100).toFixed(1)}%`,
|
|
348
|
+
` Queued Tasks: ${queenTasks}`
|
|
333
349
|
].join('\n'),
|
|
334
350
|
'Hive Mind Status'
|
|
335
351
|
);
|
|
336
352
|
|
|
353
|
+
// Handle workers array - could be worker objects or just IDs
|
|
354
|
+
const workers = result.workers ?? [];
|
|
355
|
+
const workerData = Array.isArray(workers) ? workers.map(w => {
|
|
356
|
+
if (typeof w === 'string') {
|
|
357
|
+
return { id: w, type: 'worker', status: 'idle', currentTask: '-', tasksCompleted: 0 };
|
|
358
|
+
}
|
|
359
|
+
const flexWorker = w as Record<string, unknown>;
|
|
360
|
+
return {
|
|
361
|
+
id: w.id ?? (flexWorker.agentId as string) ?? 'unknown',
|
|
362
|
+
type: w.type ?? (flexWorker.agentType as string) ?? 'worker',
|
|
363
|
+
status: w.status ?? 'idle',
|
|
364
|
+
currentTask: w.currentTask ?? '-',
|
|
365
|
+
tasksCompleted: w.tasksCompleted ?? 0
|
|
366
|
+
};
|
|
367
|
+
}) : [];
|
|
368
|
+
|
|
337
369
|
output.writeln();
|
|
338
370
|
output.writeln(output.bold('Worker Agents'));
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
371
|
+
if (workerData.length === 0) {
|
|
372
|
+
output.printInfo('No workers in hive. Use "claude-flow hive-mind spawn" to add workers.');
|
|
373
|
+
} else {
|
|
374
|
+
output.printTable({
|
|
375
|
+
columns: [
|
|
376
|
+
{ key: 'id', header: 'ID', width: 20 },
|
|
377
|
+
{ key: 'type', header: 'Type', width: 12 },
|
|
378
|
+
{ key: 'status', header: 'Status', width: 10, format: formatAgentStatus },
|
|
379
|
+
{ key: 'currentTask', header: 'Current Task', width: 20, format: (v: unknown) => String(v || '-') },
|
|
380
|
+
{ key: 'tasksCompleted', header: 'Completed', width: 10, align: 'right' }
|
|
381
|
+
],
|
|
382
|
+
data: workerData
|
|
383
|
+
});
|
|
384
|
+
}
|
|
349
385
|
|
|
350
386
|
if (detailed) {
|
|
387
|
+
const metrics = result.metrics ?? { totalTasks: 0, completedTasks: 0, failedTasks: 0, avgTaskTime: 0, consensusRounds: 0, memoryUsage: '0 MB' };
|
|
351
388
|
output.writeln();
|
|
352
389
|
output.writeln(output.bold('Metrics'));
|
|
353
390
|
output.printTable({
|
|
@@ -356,23 +393,24 @@ const statusCommand: Command = {
|
|
|
356
393
|
{ key: 'value', header: 'Value', width: 15, align: 'right' }
|
|
357
394
|
],
|
|
358
395
|
data: [
|
|
359
|
-
{ metric: 'Total Tasks', value:
|
|
360
|
-
{ metric: 'Completed', value:
|
|
361
|
-
{ metric: 'Failed', value:
|
|
362
|
-
{ metric: 'Avg Task Time', value: `${
|
|
363
|
-
{ metric: 'Consensus Rounds', value:
|
|
364
|
-
{ metric: 'Memory Usage', value:
|
|
396
|
+
{ metric: 'Total Tasks', value: metrics.totalTasks ?? 0 },
|
|
397
|
+
{ metric: 'Completed', value: metrics.completedTasks ?? 0 },
|
|
398
|
+
{ metric: 'Failed', value: metrics.failedTasks ?? 0 },
|
|
399
|
+
{ metric: 'Avg Task Time', value: `${(metrics.avgTaskTime ?? 0).toFixed(1)}ms` },
|
|
400
|
+
{ metric: 'Consensus Rounds', value: metrics.consensusRounds ?? 0 },
|
|
401
|
+
{ metric: 'Memory Usage', value: metrics.memoryUsage ?? '0 MB' }
|
|
365
402
|
]
|
|
366
403
|
});
|
|
367
404
|
|
|
405
|
+
const health = result.health ?? { overall: 'healthy', queen: 'healthy', workers: 'healthy', consensus: 'healthy', memory: 'healthy' };
|
|
368
406
|
output.writeln();
|
|
369
407
|
output.writeln(output.bold('Health'));
|
|
370
408
|
output.printList([
|
|
371
|
-
`Overall: ${formatHealth(
|
|
372
|
-
`Queen: ${formatHealth(
|
|
373
|
-
`Workers: ${formatHealth(
|
|
374
|
-
`Consensus: ${formatHealth(
|
|
375
|
-
`Memory: ${formatHealth(
|
|
409
|
+
`Overall: ${formatHealth(health.overall ?? 'healthy')}`,
|
|
410
|
+
`Queen: ${formatHealth(health.queen ?? 'healthy')}`,
|
|
411
|
+
`Workers: ${formatHealth(health.workers ?? 'healthy')}`,
|
|
412
|
+
`Consensus: ${formatHealth(health.consensus ?? 'healthy')}`,
|
|
413
|
+
`Memory: ${formatHealth(health.memory ?? 'healthy')}`
|
|
376
414
|
]);
|
|
377
415
|
}
|
|
378
416
|
|
|
@@ -577,6 +615,129 @@ const optimizeMemoryCommand: Command = {
|
|
|
577
615
|
}
|
|
578
616
|
};
|
|
579
617
|
|
|
618
|
+
// Join subcommand
|
|
619
|
+
const joinCommand: Command = {
|
|
620
|
+
name: 'join',
|
|
621
|
+
description: 'Join an agent to the hive mind',
|
|
622
|
+
options: [
|
|
623
|
+
{ name: 'agent-id', short: 'a', description: 'Agent ID to join', type: 'string' },
|
|
624
|
+
{ name: 'role', short: 'r', description: 'Agent role (worker, specialist, scout)', type: 'string', default: 'worker' }
|
|
625
|
+
],
|
|
626
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
627
|
+
const agentId = ctx.args[0] || ctx.flags['agent-id'] as string || ctx.flags.agentId as string;
|
|
628
|
+
if (!agentId) {
|
|
629
|
+
output.printError('Agent ID is required. Use --agent-id or -a flag, or provide as argument.');
|
|
630
|
+
return { success: false, exitCode: 1 };
|
|
631
|
+
}
|
|
632
|
+
try {
|
|
633
|
+
const result = await callMCPTool<{ success: boolean; agentId: string; totalWorkers: number; error?: string }>('hive-mind/join', { agentId, role: ctx.flags.role });
|
|
634
|
+
if (!result.success) { output.printError(result.error || 'Failed'); return { success: false, exitCode: 1 }; }
|
|
635
|
+
output.printSuccess(`Agent ${agentId} joined hive (${result.totalWorkers} workers)`);
|
|
636
|
+
return { success: true, data: result };
|
|
637
|
+
} catch (error) { output.printError(`Join error: ${error instanceof MCPClientError ? error.message : String(error)}`); return { success: false, exitCode: 1 }; }
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// Leave subcommand
|
|
642
|
+
const leaveCommand: Command = {
|
|
643
|
+
name: 'leave',
|
|
644
|
+
description: 'Remove an agent from the hive mind',
|
|
645
|
+
options: [{ name: 'agent-id', short: 'a', description: 'Agent ID to remove', type: 'string' }],
|
|
646
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
647
|
+
const agentId = ctx.args[0] || ctx.flags['agent-id'] as string || ctx.flags.agentId as string;
|
|
648
|
+
if (!agentId) { output.printError('Agent ID required.'); return { success: false, exitCode: 1 }; }
|
|
649
|
+
try {
|
|
650
|
+
const result = await callMCPTool<{ success: boolean; agentId: string; remainingWorkers: number; error?: string }>('hive-mind/leave', { agentId });
|
|
651
|
+
if (!result.success) { output.printError(result.error || 'Failed'); return { success: false, exitCode: 1 }; }
|
|
652
|
+
output.printSuccess(`Agent ${agentId} left hive (${result.remainingWorkers} remaining)`);
|
|
653
|
+
return { success: true, data: result };
|
|
654
|
+
} catch (error) { output.printError(`Leave error: ${error instanceof MCPClientError ? error.message : String(error)}`); return { success: false, exitCode: 1 }; }
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// Consensus subcommand
|
|
659
|
+
const consensusCommand: Command = {
|
|
660
|
+
name: 'consensus',
|
|
661
|
+
description: 'Manage consensus proposals and voting',
|
|
662
|
+
options: [
|
|
663
|
+
{ name: 'action', short: 'a', description: 'Consensus action', type: 'string', choices: ['propose', 'vote', 'status', 'list'], default: 'list' },
|
|
664
|
+
{ name: 'proposal-id', short: 'p', description: 'Proposal ID', type: 'string' },
|
|
665
|
+
{ name: 'type', short: 't', description: 'Proposal type', type: 'string' },
|
|
666
|
+
{ name: 'value', description: 'Proposal value', type: 'string' },
|
|
667
|
+
{ name: 'vote', short: 'v', description: 'Vote (yes/no)', type: 'string' },
|
|
668
|
+
{ name: 'voter-id', description: 'Voter agent ID', type: 'string' }
|
|
669
|
+
],
|
|
670
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
671
|
+
const action = ctx.flags.action as string || 'list';
|
|
672
|
+
try {
|
|
673
|
+
const result = await callMCPTool<Record<string, unknown>>('hive-mind/consensus', { action, proposalId: ctx.flags.proposalId, type: ctx.flags.type, value: ctx.flags.value, vote: ctx.flags.vote === 'yes', voterId: ctx.flags.voterId });
|
|
674
|
+
if (ctx.flags.format === 'json') { output.printJson(result); return { success: true, data: result }; }
|
|
675
|
+
if (action === 'list') {
|
|
676
|
+
output.writeln(output.bold('\nPending Proposals'));
|
|
677
|
+
const pending = (result.pending as Array<Record<string, unknown>>) || [];
|
|
678
|
+
if (pending.length === 0) output.printInfo('No pending proposals');
|
|
679
|
+
else output.printTable({ columns: [{ key: 'proposalId', header: 'ID', width: 30 }, { key: 'type', header: 'Type', width: 12 }], data: pending });
|
|
680
|
+
} else if (action === 'propose') { output.printSuccess(`Proposal created: ${result.proposalId}`); }
|
|
681
|
+
else if (action === 'vote') { output.printSuccess(`Vote recorded (For: ${result.votesFor}, Against: ${result.votesAgainst})`); }
|
|
682
|
+
return { success: true, data: result };
|
|
683
|
+
} catch (error) { output.printError(`Consensus error: ${error instanceof MCPClientError ? error.message : String(error)}`); return { success: false, exitCode: 1 }; }
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
// Broadcast subcommand
|
|
688
|
+
const broadcastCommand: Command = {
|
|
689
|
+
name: 'broadcast',
|
|
690
|
+
description: 'Broadcast a message to all workers in the hive',
|
|
691
|
+
options: [
|
|
692
|
+
{ name: 'message', short: 'm', description: 'Message to broadcast', type: 'string', required: true },
|
|
693
|
+
{ name: 'priority', short: 'p', description: 'Message priority', type: 'string', choices: ['low', 'normal', 'high', 'critical'], default: 'normal' },
|
|
694
|
+
{ name: 'from', short: 'f', description: 'Sender agent ID', type: 'string' }
|
|
695
|
+
],
|
|
696
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
697
|
+
const message = ctx.args.join(' ') || ctx.flags.message as string;
|
|
698
|
+
if (!message) { output.printError('Message required. Use --message or -m flag.'); return { success: false, exitCode: 1 }; }
|
|
699
|
+
try {
|
|
700
|
+
const result = await callMCPTool<{ success: boolean; messageId: string; recipients: number; error?: string }>('hive-mind/broadcast', { message, priority: ctx.flags.priority, fromId: ctx.flags.from });
|
|
701
|
+
if (!result.success) { output.printError(result.error || 'Failed'); return { success: false, exitCode: 1 }; }
|
|
702
|
+
output.printSuccess(`Message broadcast to ${result.recipients} workers (ID: ${result.messageId})`);
|
|
703
|
+
return { success: true, data: result };
|
|
704
|
+
} catch (error) { output.printError(`Broadcast error: ${error instanceof MCPClientError ? error.message : String(error)}`); return { success: false, exitCode: 1 }; }
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
// Memory subcommand
|
|
709
|
+
const memorySubCommand: Command = {
|
|
710
|
+
name: 'memory',
|
|
711
|
+
description: 'Access hive shared memory',
|
|
712
|
+
options: [
|
|
713
|
+
{ name: 'action', short: 'a', description: 'Memory action', type: 'string', choices: ['get', 'set', 'delete', 'list'], default: 'list' },
|
|
714
|
+
{ name: 'key', short: 'k', description: 'Memory key', type: 'string' },
|
|
715
|
+
{ name: 'value', short: 'v', description: 'Value to store', type: 'string' }
|
|
716
|
+
],
|
|
717
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
718
|
+
const action = ctx.flags.action as string || 'list';
|
|
719
|
+
const key = ctx.flags.key as string;
|
|
720
|
+
const value = ctx.flags.value as string;
|
|
721
|
+
if ((action === 'get' || action === 'delete') && !key) { output.printError('Key required for get/delete.'); return { success: false, exitCode: 1 }; }
|
|
722
|
+
if (action === 'set' && (!key || value === undefined)) { output.printError('Key and value required for set.'); return { success: false, exitCode: 1 }; }
|
|
723
|
+
try {
|
|
724
|
+
const result = await callMCPTool<Record<string, unknown>>('hive-mind/memory', { action, key, value });
|
|
725
|
+
if (ctx.flags.format === 'json') { output.printJson(result); return { success: true, data: result }; }
|
|
726
|
+
if (action === 'list') {
|
|
727
|
+
const keys = (result.keys as string[]) || [];
|
|
728
|
+
output.writeln(output.bold(`\nShared Memory (${result.count} keys)`));
|
|
729
|
+
if (keys.length === 0) output.printInfo('No keys in shared memory');
|
|
730
|
+
else output.printList(keys.map(k => output.highlight(k)));
|
|
731
|
+
} else if (action === 'get') {
|
|
732
|
+
output.writeln(output.bold(`\nKey: ${key}`));
|
|
733
|
+
output.writeln(result.exists ? `Value: ${JSON.stringify(result.value, null, 2)}` : 'Key not found');
|
|
734
|
+
} else if (action === 'set') { output.printSuccess(`Set ${key} in shared memory`); }
|
|
735
|
+
else if (action === 'delete') { output.printSuccess(result.deleted ? `Deleted ${key}` : `Key ${key} did not exist`); }
|
|
736
|
+
return { success: true, data: result };
|
|
737
|
+
} catch (error) { output.printError(`Memory error: ${error instanceof MCPClientError ? error.message : String(error)}`); return { success: false, exitCode: 1 }; }
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
|
|
580
741
|
// Shutdown subcommand
|
|
581
742
|
const shutdownCommand: Command = {
|
|
582
743
|
name: 'shutdown',
|
|
@@ -656,7 +817,7 @@ export const hiveMindCommand: Command = {
|
|
|
656
817
|
name: 'hive-mind',
|
|
657
818
|
aliases: ['hive'],
|
|
658
819
|
description: 'Queen-led consensus-based multi-agent coordination',
|
|
659
|
-
subcommands: [initCommand, spawnCommand, statusCommand, taskCommand, optimizeMemoryCommand, shutdownCommand],
|
|
820
|
+
subcommands: [initCommand, spawnCommand, statusCommand, taskCommand, joinCommand, leaveCommand, consensusCommand, broadcastCommand, memorySubCommand, optimizeMemoryCommand, shutdownCommand],
|
|
660
821
|
options: [],
|
|
661
822
|
examples: [
|
|
662
823
|
{ command: 'claude-flow hive-mind init -t hierarchical-mesh', description: 'Initialize hive' },
|
|
@@ -675,6 +836,11 @@ export const hiveMindCommand: Command = {
|
|
|
675
836
|
`${output.highlight('spawn')} - Spawn worker agents`,
|
|
676
837
|
`${output.highlight('status')} - Show hive status`,
|
|
677
838
|
`${output.highlight('task')} - Submit task to hive`,
|
|
839
|
+
`${output.highlight('join')} - Join an agent to the hive`,
|
|
840
|
+
`${output.highlight('leave')} - Remove an agent from the hive`,
|
|
841
|
+
`${output.highlight('consensus')} - Manage consensus proposals`,
|
|
842
|
+
`${output.highlight('broadcast')} - Broadcast message to workers`,
|
|
843
|
+
`${output.highlight('memory')} - Access shared memory`,
|
|
678
844
|
`${output.highlight('optimize-memory')} - Optimize patterns and memory`,
|
|
679
845
|
`${output.highlight('shutdown')} - Shutdown the hive`
|
|
680
846
|
]);
|
package/src/commands/hooks.ts
CHANGED
|
@@ -784,7 +784,7 @@ const pretrainCommand: Command = {
|
|
|
784
784
|
try {
|
|
785
785
|
spinner.start();
|
|
786
786
|
|
|
787
|
-
//
|
|
787
|
+
// Display progress for each step
|
|
788
788
|
for (const step of steps) {
|
|
789
789
|
spinner.setText(`${step.name}: ${step.desc}`);
|
|
790
790
|
await new Promise(resolve => setTimeout(resolve, 800));
|
package/src/commands/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { startCommand } from './start.js';
|
|
|
20
20
|
import { statusCommand } from './status.js';
|
|
21
21
|
import { taskCommand } from './task.js';
|
|
22
22
|
import { sessionCommand } from './session.js';
|
|
23
|
+
import { daemonCommand } from './daemon.js';
|
|
23
24
|
|
|
24
25
|
// Export all commands
|
|
25
26
|
export { agentCommand } from './agent.js';
|
|
@@ -38,6 +39,7 @@ export { startCommand } from './start.js';
|
|
|
38
39
|
export { statusCommand } from './status.js';
|
|
39
40
|
export { taskCommand } from './task.js';
|
|
40
41
|
export { sessionCommand } from './session.js';
|
|
42
|
+
export { daemonCommand } from './daemon.js';
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* All available commands
|
|
@@ -59,7 +61,8 @@ export const commands: Command[] = [
|
|
|
59
61
|
hooksCommand,
|
|
60
62
|
workflowCommand,
|
|
61
63
|
hiveMindCommand,
|
|
62
|
-
processCommand
|
|
64
|
+
processCommand,
|
|
65
|
+
daemonCommand
|
|
63
66
|
];
|
|
64
67
|
|
|
65
68
|
/**
|
package/src/commands/mcp.ts
CHANGED
|
@@ -636,7 +636,7 @@ const logsCommand: Command = {
|
|
|
636
636
|
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
637
637
|
const lines = ctx.flags.lines as number;
|
|
638
638
|
|
|
639
|
-
//
|
|
639
|
+
// Default logs (loaded from actual log file when available)
|
|
640
640
|
const logs = [
|
|
641
641
|
{ time: new Date().toISOString(), level: 'info', message: 'MCP Server started on stdio' },
|
|
642
642
|
{ time: new Date().toISOString(), level: 'info', message: 'Registered 27 tools' },
|