@claude-flow/cli 3.0.0-alpha.6 → 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.
Files changed (99) hide show
  1. package/.agentic-flow/intelligence.json +4 -4
  2. package/.claude-flow/agents/store.json +16 -0
  3. package/.claude-flow/daemon-state.json +123 -0
  4. package/.claude-flow/hive-mind/state.json +51 -0
  5. package/.claude-flow/metrics/codebase-map.json +11 -0
  6. package/.claude-flow/metrics/consolidation.json +6 -0
  7. package/.claude-flow/metrics/performance.json +3 -3
  8. package/.claude-flow/metrics/security-audit.json +10 -0
  9. package/.claude-flow/metrics/task-metrics.json +3 -3
  10. package/.claude-flow/metrics/test-gaps.json +6 -0
  11. package/agents/architect.yaml +1 -1
  12. package/agents/coder.yaml +1 -1
  13. package/agents/reviewer.yaml +1 -1
  14. package/agents/security-architect.yaml +1 -1
  15. package/agents/tester.yaml +1 -1
  16. package/dist/src/commands/agent.d.ts.map +1 -1
  17. package/dist/src/commands/agent.js +42 -26
  18. package/dist/src/commands/agent.js.map +1 -1
  19. package/dist/src/commands/daemon.d.ts +8 -0
  20. package/dist/src/commands/daemon.d.ts.map +1 -0
  21. package/dist/src/commands/daemon.js +351 -0
  22. package/dist/src/commands/daemon.js.map +1 -0
  23. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  24. package/dist/src/commands/hive-mind.js +252 -35
  25. package/dist/src/commands/hive-mind.js.map +1 -1
  26. package/dist/src/commands/index.d.ts +1 -0
  27. package/dist/src/commands/index.d.ts.map +1 -1
  28. package/dist/src/commands/index.js +4 -1
  29. package/dist/src/commands/index.js.map +1 -1
  30. package/dist/src/commands/start.js +2 -2
  31. package/dist/src/commands/start.js.map +1 -1
  32. package/dist/src/index.d.ts.map +1 -1
  33. package/dist/src/index.js +5 -2
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/init/settings-generator.d.ts.map +1 -1
  36. package/dist/src/init/settings-generator.js +22 -12
  37. package/dist/src/init/settings-generator.js.map +1 -1
  38. package/dist/src/mcp-client.d.ts.map +1 -1
  39. package/dist/src/mcp-client.js +13 -1
  40. package/dist/src/mcp-client.js.map +1 -1
  41. package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
  42. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  43. package/dist/src/mcp-tools/agent-tools.js +350 -14
  44. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  45. package/dist/src/mcp-tools/config-tools.d.ts +1 -1
  46. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
  47. package/dist/src/mcp-tools/config-tools.js +262 -15
  48. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  49. package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
  50. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
  51. package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
  52. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
  53. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  54. package/dist/src/mcp-tools/hooks-tools.js +46 -7
  55. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  56. package/dist/src/mcp-tools/index.d.ts +2 -0
  57. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  58. package/dist/src/mcp-tools/index.js +2 -0
  59. package/dist/src/mcp-tools/index.js.map +1 -1
  60. package/dist/src/mcp-tools/session-tools.d.ts +1 -1
  61. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
  62. package/dist/src/mcp-tools/session-tools.js +237 -22
  63. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  64. package/dist/src/mcp-tools/task-tools.d.ts +1 -1
  65. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  66. package/dist/src/mcp-tools/task-tools.js +219 -17
  67. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  68. package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
  69. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
  70. package/dist/src/mcp-tools/workflow-tools.js +481 -0
  71. package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
  72. package/dist/src/services/index.d.ts +7 -0
  73. package/dist/src/services/index.d.ts.map +1 -0
  74. package/dist/src/services/index.js +6 -0
  75. package/dist/src/services/index.js.map +1 -0
  76. package/dist/src/services/worker-daemon.d.ts +126 -0
  77. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  78. package/dist/src/services/worker-daemon.js +464 -0
  79. package/dist/src/services/worker-daemon.js.map +1 -0
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/package.json +1 -1
  82. package/src/commands/agent.ts +42 -28
  83. package/src/commands/daemon.ts +395 -0
  84. package/src/commands/hive-mind.ts +229 -63
  85. package/src/commands/index.ts +4 -1
  86. package/src/commands/start.ts +2 -2
  87. package/src/index.ts +5 -2
  88. package/src/init/settings-generator.ts +22 -12
  89. package/src/mcp-client.ts +13 -1
  90. package/src/mcp-tools/agent-tools.ts +388 -14
  91. package/src/mcp-tools/config-tools.ts +297 -15
  92. package/src/mcp-tools/hive-mind-tools.ts +521 -0
  93. package/src/mcp-tools/hooks-tools.ts +46 -7
  94. package/src/mcp-tools/index.ts +2 -0
  95. package/src/mcp-tools/session-tools.ts +280 -23
  96. package/src/mcp-tools/task-tools.ts +265 -20
  97. package/src/mcp-tools/workflow-tools.ts +573 -0
  98. package/src/services/index.ts +15 -0
  99. 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: string;
280
- status: 'active' | 'idle' | 'degraded' | 'offline';
281
- topology: string;
282
- consensus: string;
283
- queen: {
284
- id: string;
285
- status: string;
286
- load: number;
287
- tasksQueued: number;
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: Array<{
290
- id: string;
291
- type: string;
292
- status: string;
292
+ workers?: Array<{
293
+ id?: string;
294
+ agentId?: string;
295
+ type?: string;
296
+ agentType?: string;
297
+ status?: string;
293
298
  currentTask?: string;
294
- tasksCompleted: number;
295
- }>;
296
- metrics: {
297
- totalTasks: number;
298
- completedTasks: number;
299
- failedTasks: number;
300
- avgTaskTime: number;
301
- consensusRounds: number;
302
- memoryUsage: string;
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: string;
306
- queen: string;
307
- workers: string;
308
- consensus: string;
309
- memory: string;
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: ${result.hiveId}`,
325
- `Status: ${formatHiveStatus(result.status)}`,
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: ${result.queen.id}`,
330
- ` Status: ${formatAgentStatus(result.queen.status)}`,
331
- ` Load: ${(result.queen.load * 100).toFixed(1)}%`,
332
- ` Queued Tasks: ${result.queen.tasksQueued}`
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
- output.printTable({
340
- columns: [
341
- { key: 'id', header: 'ID', width: 20 },
342
- { key: 'type', header: 'Type', width: 12 },
343
- { key: 'status', header: 'Status', width: 10, format: formatAgentStatus },
344
- { key: 'currentTask', header: 'Current Task', width: 20, format: (v: unknown) => String(v || '-') },
345
- { key: 'tasksCompleted', header: 'Completed', width: 10, align: 'right' }
346
- ],
347
- data: result.workers
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: result.metrics.totalTasks },
360
- { metric: 'Completed', value: result.metrics.completedTasks },
361
- { metric: 'Failed', value: result.metrics.failedTasks },
362
- { metric: 'Avg Task Time', value: `${result.metrics.avgTaskTime.toFixed(1)}ms` },
363
- { metric: 'Consensus Rounds', value: result.metrics.consensusRounds },
364
- { metric: 'Memory Usage', value: result.metrics.memoryUsage }
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(result.health.overall)}`,
372
- `Queen: ${formatHealth(result.health.queen)}`,
373
- `Workers: ${formatHealth(result.health.workers)}`,
374
- `Consensus: ${formatHealth(result.health.consensus)}`,
375
- `Memory: ${formatHealth(result.health.memory)}`
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
  ]);
@@ -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
  /**
@@ -215,8 +215,8 @@ const startAction = async (ctx: CommandContext): Promise<CommandResult> => {
215
215
  output.writeln();
216
216
  output.printInfo('Running in daemon mode. Use "claude-flow stop" to stop.');
217
217
 
218
- // In a real implementation, this would fork a background process
219
- // For now, we simulate daemon behavior
218
+ // Store PID for daemon management
219
+ // TODO: Implement proper process forking with detached: true
220
220
  const daemonPidPath = path.join(cwd, '.claude-flow', 'daemon.pid');
221
221
  fs.writeFileSync(daemonPidPath, String(process.pid));
222
222
  }
package/src/index.ts CHANGED
@@ -106,6 +106,7 @@ export class CLI {
106
106
  let subcommandArgs = positional;
107
107
 
108
108
  // Process command path (e.g., ['hooks', 'worker', 'list'])
109
+ // Note: When parser includes subcommand in commandPath, positional already excludes it
109
110
  if (commandPath.length > 1 && command.subcommands) {
110
111
  const subcommandName = commandPath[1];
111
112
  const subcommand = command.subcommands.find(
@@ -114,7 +115,8 @@ export class CLI {
114
115
 
115
116
  if (subcommand) {
116
117
  targetCommand = subcommand;
117
- subcommandArgs = positional.slice(1);
118
+ // Parser already extracted subcommand from positional, so use as-is
119
+ subcommandArgs = positional;
118
120
 
119
121
  // Check for nested subcommand (level 2)
120
122
  if (commandPath.length > 2 && subcommand.subcommands) {
@@ -124,7 +126,8 @@ export class CLI {
124
126
  );
125
127
  if (nestedSubcommand) {
126
128
  targetCommand = nestedSubcommand;
127
- subcommandArgs = positional.slice(2);
129
+ // Parser already extracted nested subcommand too
130
+ subcommandArgs = positional;
128
131
  }
129
132
  }
130
133
  }
@@ -50,6 +50,10 @@ export function generateSettings(options: InitOptions): object {
50
50
  neural: {
51
51
  enabled: options.runtime.enableNeural,
52
52
  },
53
+ daemon: {
54
+ autoStart: true,
55
+ workers: ['map', 'audit', 'optimize', 'consolidate', 'testgaps'],
56
+ },
53
57
  };
54
58
 
55
59
  return settings;
@@ -70,7 +74,7 @@ function generateHooksConfig(config: HooksConfig): object {
70
74
  hooks: [
71
75
  {
72
76
  type: 'command',
73
- command: 'npx @claude-flow/cli hooks pre-edit --file "$TOOL_INPUT_file_path"',
77
+ command: 'npx claude-flow@v3alpha hooks pre-edit --file "$TOOL_INPUT_file_path" --intelligence',
74
78
  timeout: config.timeout,
75
79
  continueOnError: config.continueOnError,
76
80
  },
@@ -82,7 +86,7 @@ function generateHooksConfig(config: HooksConfig): object {
82
86
  hooks: [
83
87
  {
84
88
  type: 'command',
85
- command: 'npx @claude-flow/cli hooks pre-command --command "$TOOL_INPUT_command"',
89
+ command: 'npx claude-flow@v3alpha hooks pre-command --command "$TOOL_INPUT_command"',
86
90
  timeout: config.timeout,
87
91
  continueOnError: config.continueOnError,
88
92
  },
@@ -94,7 +98,7 @@ function generateHooksConfig(config: HooksConfig): object {
94
98
  hooks: [
95
99
  {
96
100
  type: 'command',
97
- command: 'npx @claude-flow/cli hooks pre-task --description "$TOOL_INPUT_prompt"',
101
+ command: 'npx claude-flow@v3alpha hooks pre-task --task-id "task-$(date +%s)" --description "$TOOL_INPUT_prompt"',
98
102
  timeout: config.timeout,
99
103
  continueOnError: config.continueOnError,
100
104
  },
@@ -106,7 +110,7 @@ function generateHooksConfig(config: HooksConfig): object {
106
110
  hooks: [
107
111
  {
108
112
  type: 'command',
109
- command: 'npx @claude-flow/cli hooks pre-search --pattern "$TOOL_INPUT_pattern"',
113
+ command: 'npx claude-flow@v3alpha hooks pre-search --pattern "$TOOL_INPUT_pattern"',
110
114
  timeout: 2000,
111
115
  continueOnError: true,
112
116
  },
@@ -124,7 +128,7 @@ function generateHooksConfig(config: HooksConfig): object {
124
128
  hooks: [
125
129
  {
126
130
  type: 'command',
127
- command: 'npx @claude-flow/cli hooks post-edit --file "$TOOL_INPUT_file_path" --success "$TOOL_SUCCESS" --train-patterns',
131
+ command: 'npx claude-flow@v3alpha hooks post-edit --file "$TOOL_INPUT_file_path" --success "$TOOL_SUCCESS" --train-patterns',
128
132
  timeout: config.timeout,
129
133
  continueOnError: config.continueOnError,
130
134
  },
@@ -136,7 +140,7 @@ function generateHooksConfig(config: HooksConfig): object {
136
140
  hooks: [
137
141
  {
138
142
  type: 'command',
139
- command: 'npx @claude-flow/cli hooks post-command --command "$TOOL_INPUT_command" --success "$TOOL_SUCCESS" --exit-code "$TOOL_EXIT_CODE"',
143
+ command: 'npx claude-flow@v3alpha hooks post-command --command "$TOOL_INPUT_command" --success "$TOOL_SUCCESS" --exit-code "$TOOL_EXIT_CODE"',
140
144
  timeout: config.timeout,
141
145
  continueOnError: config.continueOnError,
142
146
  },
@@ -148,7 +152,7 @@ function generateHooksConfig(config: HooksConfig): object {
148
152
  hooks: [
149
153
  {
150
154
  type: 'command',
151
- command: 'npx @claude-flow/cli hooks post-task --agent-id "$TOOL_RESULT_agent_id" --success "$TOOL_SUCCESS" --analyze',
155
+ command: 'npx claude-flow@v3alpha hooks post-task --agent-id "$TOOL_RESULT_agent_id" --success "$TOOL_SUCCESS" --analyze',
152
156
  timeout: config.timeout,
153
157
  continueOnError: config.continueOnError,
154
158
  },
@@ -160,7 +164,7 @@ function generateHooksConfig(config: HooksConfig): object {
160
164
  hooks: [
161
165
  {
162
166
  type: 'command',
163
- command: 'npx @claude-flow/cli hooks post-search --cache-results',
167
+ command: 'npx claude-flow@v3alpha hooks post-search --cache-results',
164
168
  timeout: 2000,
165
169
  continueOnError: true,
166
170
  },
@@ -176,7 +180,7 @@ function generateHooksConfig(config: HooksConfig): object {
176
180
  hooks: [
177
181
  {
178
182
  type: 'command',
179
- command: 'npx @claude-flow/cli hooks route --task "$PROMPT" --include-explanation',
183
+ command: 'npx claude-flow@v3alpha hooks route --task "$PROMPT" --intelligence --include-explanation',
180
184
  timeout: config.timeout,
181
185
  continueOnError: config.continueOnError,
182
186
  },
@@ -185,14 +189,20 @@ function generateHooksConfig(config: HooksConfig): object {
185
189
  ];
186
190
  }
187
191
 
188
- // SessionStart for context loading
192
+ // SessionStart for context loading and daemon auto-start
189
193
  if (config.sessionStart) {
190
194
  hooks.SessionStart = [
191
195
  {
192
196
  hooks: [
193
197
  {
194
198
  type: 'command',
195
- command: 'npx @claude-flow/cli hooks session-start --session-id "$SESSION_ID" --load-context',
199
+ command: 'npx claude-flow@v3alpha daemon start --quiet 2>/dev/null || true',
200
+ timeout: 5000,
201
+ continueOnError: true,
202
+ },
203
+ {
204
+ type: 'command',
205
+ command: 'npx claude-flow@v3alpha hooks session-start --session-id "$SESSION_ID" --load-context',
196
206
  timeout: 10000,
197
207
  continueOnError: true,
198
208
  },
@@ -227,7 +237,7 @@ Respond with {"decision": "stop"} if complete, or {"decision": "continue", "reas
227
237
  hooks: [
228
238
  {
229
239
  type: 'command',
230
- command: 'npx @claude-flow/cli hooks notify --message "$NOTIFICATION_MESSAGE" --swarm-status',
240
+ command: 'npx claude-flow@v3alpha hooks notify --message "$NOTIFICATION_MESSAGE" --swarm-status',
231
241
  timeout: 3000,
232
242
  continueOnError: true,
233
243
  },
package/src/mcp-client.ts CHANGED
@@ -18,6 +18,8 @@ import { configTools } from './mcp-tools/config-tools.js';
18
18
  import { hooksTools } from './mcp-tools/hooks-tools.js';
19
19
  import { taskTools } from './mcp-tools/task-tools.js';
20
20
  import { sessionTools } from './mcp-tools/session-tools.js';
21
+ import { hiveMindTools } from './mcp-tools/hive-mind-tools.js';
22
+ import { workflowTools } from './mcp-tools/workflow-tools.js';
21
23
 
22
24
  /**
23
25
  * MCP Tool Registry
@@ -33,7 +35,17 @@ function registerTools(tools: MCPTool[]): void {
33
35
  }
34
36
 
35
37
  // Initialize registry with all available tools
36
- registerTools([...agentTools, ...swarmTools, ...memoryTools, ...configTools, ...hooksTools, ...taskTools, ...sessionTools]);
38
+ registerTools([
39
+ ...agentTools,
40
+ ...swarmTools,
41
+ ...memoryTools,
42
+ ...configTools,
43
+ ...hooksTools,
44
+ ...taskTools,
45
+ ...sessionTools,
46
+ ...hiveMindTools,
47
+ ...workflowTools,
48
+ ]);
37
49
 
38
50
  /**
39
51
  * MCP Client Error