claude-flow 3.0.0-alpha.10 → 3.0.0-alpha.11

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 (239) hide show
  1. package/package.json +10 -23
  2. package/README.md +0 -1186
  3. package/bin/cli.js +0 -14
  4. package/dist/src/commands/agent.d.ts +0 -8
  5. package/dist/src/commands/agent.d.ts.map +0 -1
  6. package/dist/src/commands/agent.js +0 -819
  7. package/dist/src/commands/agent.js.map +0 -1
  8. package/dist/src/commands/config.d.ts +0 -8
  9. package/dist/src/commands/config.d.ts.map +0 -1
  10. package/dist/src/commands/config.js +0 -406
  11. package/dist/src/commands/config.js.map +0 -1
  12. package/dist/src/commands/daemon.d.ts +0 -8
  13. package/dist/src/commands/daemon.d.ts.map +0 -1
  14. package/dist/src/commands/daemon.js +0 -545
  15. package/dist/src/commands/daemon.js.map +0 -1
  16. package/dist/src/commands/hive-mind.d.ts +0 -8
  17. package/dist/src/commands/hive-mind.d.ts.map +0 -1
  18. package/dist/src/commands/hive-mind.js +0 -844
  19. package/dist/src/commands/hive-mind.js.map +0 -1
  20. package/dist/src/commands/hooks.d.ts +0 -8
  21. package/dist/src/commands/hooks.d.ts.map +0 -1
  22. package/dist/src/commands/hooks.js +0 -2098
  23. package/dist/src/commands/hooks.js.map +0 -1
  24. package/dist/src/commands/index.d.ts +0 -52
  25. package/dist/src/commands/index.d.ts.map +0 -1
  26. package/dist/src/commands/index.js +0 -108
  27. package/dist/src/commands/index.js.map +0 -1
  28. package/dist/src/commands/init.d.ts +0 -8
  29. package/dist/src/commands/init.d.ts.map +0 -1
  30. package/dist/src/commands/init.js +0 -532
  31. package/dist/src/commands/init.js.map +0 -1
  32. package/dist/src/commands/mcp.d.ts +0 -11
  33. package/dist/src/commands/mcp.d.ts.map +0 -1
  34. package/dist/src/commands/mcp.js +0 -662
  35. package/dist/src/commands/mcp.js.map +0 -1
  36. package/dist/src/commands/memory.d.ts +0 -8
  37. package/dist/src/commands/memory.d.ts.map +0 -1
  38. package/dist/src/commands/memory.js +0 -977
  39. package/dist/src/commands/memory.js.map +0 -1
  40. package/dist/src/commands/migrate.d.ts +0 -8
  41. package/dist/src/commands/migrate.d.ts.map +0 -1
  42. package/dist/src/commands/migrate.js +0 -398
  43. package/dist/src/commands/migrate.js.map +0 -1
  44. package/dist/src/commands/process.d.ts +0 -10
  45. package/dist/src/commands/process.d.ts.map +0 -1
  46. package/dist/src/commands/process.js +0 -641
  47. package/dist/src/commands/process.js.map +0 -1
  48. package/dist/src/commands/session.d.ts +0 -8
  49. package/dist/src/commands/session.d.ts.map +0 -1
  50. package/dist/src/commands/session.js +0 -750
  51. package/dist/src/commands/session.js.map +0 -1
  52. package/dist/src/commands/start.d.ts +0 -8
  53. package/dist/src/commands/start.d.ts.map +0 -1
  54. package/dist/src/commands/start.js +0 -398
  55. package/dist/src/commands/start.js.map +0 -1
  56. package/dist/src/commands/status.d.ts +0 -8
  57. package/dist/src/commands/status.d.ts.map +0 -1
  58. package/dist/src/commands/status.js +0 -584
  59. package/dist/src/commands/status.js.map +0 -1
  60. package/dist/src/commands/swarm.d.ts +0 -8
  61. package/dist/src/commands/swarm.d.ts.map +0 -1
  62. package/dist/src/commands/swarm.js +0 -573
  63. package/dist/src/commands/swarm.js.map +0 -1
  64. package/dist/src/commands/task.d.ts +0 -8
  65. package/dist/src/commands/task.d.ts.map +0 -1
  66. package/dist/src/commands/task.js +0 -671
  67. package/dist/src/commands/task.js.map +0 -1
  68. package/dist/src/commands/workflow.d.ts +0 -8
  69. package/dist/src/commands/workflow.d.ts.map +0 -1
  70. package/dist/src/commands/workflow.js +0 -617
  71. package/dist/src/commands/workflow.js.map +0 -1
  72. package/dist/src/config-adapter.d.ts +0 -15
  73. package/dist/src/config-adapter.d.ts.map +0 -1
  74. package/dist/src/config-adapter.js +0 -185
  75. package/dist/src/config-adapter.js.map +0 -1
  76. package/dist/src/index.d.ts +0 -55
  77. package/dist/src/index.d.ts.map +0 -1
  78. package/dist/src/index.js +0 -353
  79. package/dist/src/index.js.map +0 -1
  80. package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
  81. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
  82. package/dist/src/infrastructure/in-memory-repositories.js +0 -264
  83. package/dist/src/infrastructure/in-memory-repositories.js.map +0 -1
  84. package/dist/src/init/claudemd-generator.d.ts +0 -15
  85. package/dist/src/init/claudemd-generator.d.ts.map +0 -1
  86. package/dist/src/init/claudemd-generator.js +0 -626
  87. package/dist/src/init/claudemd-generator.js.map +0 -1
  88. package/dist/src/init/executor.d.ts +0 -11
  89. package/dist/src/init/executor.d.ts.map +0 -1
  90. package/dist/src/init/executor.js +0 -652
  91. package/dist/src/init/executor.js.map +0 -1
  92. package/dist/src/init/helpers-generator.d.ts +0 -42
  93. package/dist/src/init/helpers-generator.d.ts.map +0 -1
  94. package/dist/src/init/helpers-generator.js +0 -613
  95. package/dist/src/init/helpers-generator.js.map +0 -1
  96. package/dist/src/init/index.d.ts +0 -12
  97. package/dist/src/init/index.d.ts.map +0 -1
  98. package/dist/src/init/index.js +0 -15
  99. package/dist/src/init/index.js.map +0 -1
  100. package/dist/src/init/mcp-generator.d.ts +0 -18
  101. package/dist/src/init/mcp-generator.d.ts.map +0 -1
  102. package/dist/src/init/mcp-generator.js +0 -71
  103. package/dist/src/init/mcp-generator.js.map +0 -1
  104. package/dist/src/init/settings-generator.d.ts +0 -14
  105. package/dist/src/init/settings-generator.d.ts.map +0 -1
  106. package/dist/src/init/settings-generator.js +0 -267
  107. package/dist/src/init/settings-generator.js.map +0 -1
  108. package/dist/src/init/statusline-generator.d.ts +0 -14
  109. package/dist/src/init/statusline-generator.d.ts.map +0 -1
  110. package/dist/src/init/statusline-generator.js +0 -206
  111. package/dist/src/init/statusline-generator.js.map +0 -1
  112. package/dist/src/init/types.d.ts +0 -240
  113. package/dist/src/init/types.d.ts.map +0 -1
  114. package/dist/src/init/types.js +0 -210
  115. package/dist/src/init/types.js.map +0 -1
  116. package/dist/src/mcp-client.d.ts +0 -92
  117. package/dist/src/mcp-client.d.ts.map +0 -1
  118. package/dist/src/mcp-client.js +0 -203
  119. package/dist/src/mcp-client.js.map +0 -1
  120. package/dist/src/mcp-server.d.ts +0 -153
  121. package/dist/src/mcp-server.d.ts.map +0 -1
  122. package/dist/src/mcp-server.js +0 -453
  123. package/dist/src/mcp-server.js.map +0 -1
  124. package/dist/src/mcp-tools/agent-tools.d.ts +0 -8
  125. package/dist/src/mcp-tools/agent-tools.d.ts.map +0 -1
  126. package/dist/src/mcp-tools/agent-tools.js +0 -426
  127. package/dist/src/mcp-tools/agent-tools.js.map +0 -1
  128. package/dist/src/mcp-tools/config-tools.d.ts +0 -8
  129. package/dist/src/mcp-tools/config-tools.d.ts.map +0 -1
  130. package/dist/src/mcp-tools/config-tools.js +0 -333
  131. package/dist/src/mcp-tools/config-tools.js.map +0 -1
  132. package/dist/src/mcp-tools/hive-mind-tools.d.ts +0 -8
  133. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +0 -1
  134. package/dist/src/mcp-tools/hive-mind-tools.js +0 -447
  135. package/dist/src/mcp-tools/hive-mind-tools.js.map +0 -1
  136. package/dist/src/mcp-tools/hooks-tools.d.ts +0 -41
  137. package/dist/src/mcp-tools/hooks-tools.d.ts.map +0 -1
  138. package/dist/src/mcp-tools/hooks-tools.js +0 -1711
  139. package/dist/src/mcp-tools/hooks-tools.js.map +0 -1
  140. package/dist/src/mcp-tools/index.d.ts +0 -16
  141. package/dist/src/mcp-tools/index.d.ts.map +0 -1
  142. package/dist/src/mcp-tools/index.js +0 -15
  143. package/dist/src/mcp-tools/index.js.map +0 -1
  144. package/dist/src/mcp-tools/memory-tools.d.ts +0 -8
  145. package/dist/src/mcp-tools/memory-tools.d.ts.map +0 -1
  146. package/dist/src/mcp-tools/memory-tools.js +0 -235
  147. package/dist/src/mcp-tools/memory-tools.js.map +0 -1
  148. package/dist/src/mcp-tools/session-tools.d.ts +0 -8
  149. package/dist/src/mcp-tools/session-tools.d.ts.map +0 -1
  150. package/dist/src/mcp-tools/session-tools.js +0 -315
  151. package/dist/src/mcp-tools/session-tools.js.map +0 -1
  152. package/dist/src/mcp-tools/swarm-tools.d.ts +0 -8
  153. package/dist/src/mcp-tools/swarm-tools.d.ts.map +0 -1
  154. package/dist/src/mcp-tools/swarm-tools.js +0 -102
  155. package/dist/src/mcp-tools/swarm-tools.js.map +0 -1
  156. package/dist/src/mcp-tools/task-tools.d.ts +0 -8
  157. package/dist/src/mcp-tools/task-tools.d.ts.map +0 -1
  158. package/dist/src/mcp-tools/task-tools.js +0 -302
  159. package/dist/src/mcp-tools/task-tools.js.map +0 -1
  160. package/dist/src/mcp-tools/types.d.ts +0 -31
  161. package/dist/src/mcp-tools/types.d.ts.map +0 -1
  162. package/dist/src/mcp-tools/types.js +0 -7
  163. package/dist/src/mcp-tools/types.js.map +0 -1
  164. package/dist/src/mcp-tools/workflow-tools.d.ts +0 -8
  165. package/dist/src/mcp-tools/workflow-tools.d.ts.map +0 -1
  166. package/dist/src/mcp-tools/workflow-tools.js +0 -481
  167. package/dist/src/mcp-tools/workflow-tools.js.map +0 -1
  168. package/dist/src/output.d.ts +0 -133
  169. package/dist/src/output.d.ts.map +0 -1
  170. package/dist/src/output.js +0 -513
  171. package/dist/src/output.js.map +0 -1
  172. package/dist/src/parser.d.ts +0 -41
  173. package/dist/src/parser.d.ts.map +0 -1
  174. package/dist/src/parser.js +0 -353
  175. package/dist/src/parser.js.map +0 -1
  176. package/dist/src/prompt.d.ts +0 -44
  177. package/dist/src/prompt.d.ts.map +0 -1
  178. package/dist/src/prompt.js +0 -501
  179. package/dist/src/prompt.js.map +0 -1
  180. package/dist/src/services/index.d.ts +0 -7
  181. package/dist/src/services/index.d.ts.map +0 -1
  182. package/dist/src/services/index.js +0 -6
  183. package/dist/src/services/index.js.map +0 -1
  184. package/dist/src/services/worker-daemon.d.ts +0 -153
  185. package/dist/src/services/worker-daemon.d.ts.map +0 -1
  186. package/dist/src/services/worker-daemon.js +0 -567
  187. package/dist/src/services/worker-daemon.js.map +0 -1
  188. package/dist/src/types.d.ts +0 -198
  189. package/dist/src/types.d.ts.map +0 -1
  190. package/dist/src/types.js +0 -38
  191. package/dist/src/types.js.map +0 -1
  192. package/dist/tsconfig.tsbuildinfo +0 -1
  193. package/src/commands/agent.ts +0 -955
  194. package/src/commands/config.ts +0 -452
  195. package/src/commands/daemon.ts +0 -621
  196. package/src/commands/hive-mind.ts +0 -928
  197. package/src/commands/hooks.ts +0 -2603
  198. package/src/commands/index.ts +0 -118
  199. package/src/commands/init.ts +0 -597
  200. package/src/commands/mcp.ts +0 -753
  201. package/src/commands/memory.ts +0 -1161
  202. package/src/commands/migrate.ts +0 -447
  203. package/src/commands/process.ts +0 -695
  204. package/src/commands/session.ts +0 -891
  205. package/src/commands/start.ts +0 -457
  206. package/src/commands/status.ts +0 -736
  207. package/src/commands/swarm.ts +0 -648
  208. package/src/commands/task.ts +0 -792
  209. package/src/commands/workflow.ts +0 -742
  210. package/src/config-adapter.ts +0 -210
  211. package/src/index.ts +0 -427
  212. package/src/infrastructure/in-memory-repositories.ts +0 -310
  213. package/src/init/claudemd-generator.ts +0 -631
  214. package/src/init/executor.ts +0 -762
  215. package/src/init/helpers-generator.ts +0 -628
  216. package/src/init/index.ts +0 -60
  217. package/src/init/mcp-generator.ts +0 -83
  218. package/src/init/settings-generator.ts +0 -284
  219. package/src/init/statusline-generator.ts +0 -211
  220. package/src/init/types.ts +0 -447
  221. package/src/mcp-client.ts +0 -241
  222. package/src/mcp-server.ts +0 -577
  223. package/src/mcp-tools/agent-tools.ts +0 -466
  224. package/src/mcp-tools/config-tools.ts +0 -370
  225. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  226. package/src/mcp-tools/hooks-tools.ts +0 -1888
  227. package/src/mcp-tools/index.ts +0 -16
  228. package/src/mcp-tools/memory-tools.ts +0 -270
  229. package/src/mcp-tools/session-tools.ts +0 -359
  230. package/src/mcp-tools/swarm-tools.ts +0 -105
  231. package/src/mcp-tools/task-tools.ts +0 -347
  232. package/src/mcp-tools/types.ts +0 -33
  233. package/src/mcp-tools/workflow-tools.ts +0 -573
  234. package/src/output.ts +0 -639
  235. package/src/parser.ts +0 -417
  236. package/src/prompt.ts +0 -619
  237. package/src/services/index.ts +0 -15
  238. package/src/services/worker-daemon.ts +0 -726
  239. package/src/types.ts +0 -287
@@ -1,648 +0,0 @@
1
- /**
2
- * V3 CLI Swarm Command
3
- * Swarm coordination and management commands
4
- */
5
-
6
- import type { Command, CommandContext, CommandResult } from '../types.js';
7
- import { output } from '../output.js';
8
- import { select, confirm, multiSelect } from '../prompt.js';
9
- import { callMCPTool, MCPClientError } from '../mcp-client.js';
10
-
11
- // Swarm topologies
12
- const TOPOLOGIES = [
13
- { value: 'hierarchical', label: 'Hierarchical', hint: 'Queen-led coordination with worker agents' },
14
- { value: 'mesh', label: 'Mesh', hint: 'Fully connected peer-to-peer network' },
15
- { value: 'ring', label: 'Ring', hint: 'Circular communication pattern' },
16
- { value: 'star', label: 'Star', hint: 'Central coordinator with spoke agents' },
17
- { value: 'hybrid', label: 'Hybrid', hint: 'Hierarchical mesh for maximum flexibility' }
18
- ];
19
-
20
- // Swarm strategies
21
- const STRATEGIES = [
22
- { value: 'research', label: 'Research', hint: 'Distributed research and analysis' },
23
- { value: 'development', label: 'Development', hint: 'Collaborative code development' },
24
- { value: 'testing', label: 'Testing', hint: 'Comprehensive test coverage' },
25
- { value: 'optimization', label: 'Optimization', hint: 'Performance optimization' },
26
- { value: 'maintenance', label: 'Maintenance', hint: 'Codebase maintenance and refactoring' },
27
- { value: 'analysis', label: 'Analysis', hint: 'Code analysis and documentation' }
28
- ];
29
-
30
- // Initialize swarm
31
- const initCommand: Command = {
32
- name: 'init',
33
- description: 'Initialize a new swarm',
34
- options: [
35
- {
36
- name: 'topology',
37
- short: 't',
38
- description: 'Swarm topology',
39
- type: 'string',
40
- choices: TOPOLOGIES.map(t => t.value),
41
- default: 'hierarchical'
42
- },
43
- {
44
- name: 'max-agents',
45
- short: 'm',
46
- description: 'Maximum number of agents',
47
- type: 'number',
48
- default: 15
49
- },
50
- {
51
- name: 'auto-scale',
52
- description: 'Enable automatic scaling',
53
- type: 'boolean',
54
- default: true
55
- },
56
- {
57
- name: 'strategy',
58
- short: 's',
59
- description: 'Coordination strategy',
60
- type: 'string',
61
- choices: STRATEGIES.map(s => s.value)
62
- },
63
- {
64
- name: 'v3-mode',
65
- description: 'Enable V3 15-agent hierarchical mesh mode',
66
- type: 'boolean',
67
- default: false
68
- }
69
- ],
70
- action: async (ctx: CommandContext): Promise<CommandResult> => {
71
- let topology = ctx.flags.topology as string;
72
- const maxAgents = ctx.flags.maxAgents as number || 15;
73
- const v3Mode = ctx.flags.v3Mode as boolean;
74
-
75
- // V3 mode enables hierarchical-mesh hybrid
76
- if (v3Mode) {
77
- topology = 'hierarchical-mesh';
78
- output.printInfo('V3 Mode: Using hierarchical-mesh topology with 15-agent coordination');
79
- }
80
-
81
- // Interactive topology selection
82
- if (!topology && ctx.interactive) {
83
- topology = await select({
84
- message: 'Select swarm topology:',
85
- options: TOPOLOGIES,
86
- default: 'hierarchical'
87
- });
88
- }
89
-
90
- output.writeln();
91
- output.printInfo('Initializing swarm...');
92
-
93
- try {
94
- // Call MCP tool to initialize swarm
95
- const result = await callMCPTool<{
96
- swarmId: string;
97
- topology: string;
98
- initializedAt: string;
99
- config: {
100
- topology: string;
101
- maxAgents: number;
102
- currentAgents: number;
103
- communicationProtocol?: string;
104
- autoScaling?: boolean;
105
- };
106
- }>('swarm/init', {
107
- topology: topology as 'hierarchical' | 'mesh' | 'adaptive' | 'collective' | 'hierarchical-mesh',
108
- maxAgents,
109
- config: {
110
- communicationProtocol: 'message-bus',
111
- consensusMechanism: 'majority',
112
- failureHandling: 'retry',
113
- loadBalancing: true,
114
- autoScaling: ctx.flags.autoScale ?? true,
115
- },
116
- metadata: {
117
- v3Mode,
118
- strategy: ctx.flags.strategy || 'development',
119
- },
120
- });
121
-
122
- // Display initialization progress
123
- output.writeln(output.dim(' Creating coordination topology...'));
124
- output.writeln(output.dim(' Initializing memory namespace...'));
125
- output.writeln(output.dim(' Setting up communication channels...'));
126
-
127
- if (v3Mode) {
128
- output.writeln(output.dim(' Enabling Flash Attention (2.49x-7.47x speedup)...'));
129
- output.writeln(output.dim(' Configuring AgentDB integration (150x faster)...'));
130
- output.writeln(output.dim(' Initializing SONA learning system...'));
131
- }
132
-
133
- output.writeln();
134
- output.printTable({
135
- columns: [
136
- { key: 'property', header: 'Property', width: 20 },
137
- { key: 'value', header: 'Value', width: 35 }
138
- ],
139
- data: [
140
- { property: 'Swarm ID', value: result.swarmId },
141
- { property: 'Topology', value: result.topology },
142
- { property: 'Max Agents', value: result.config.maxAgents },
143
- { property: 'Auto Scale', value: result.config.autoScaling ? 'Enabled' : 'Disabled' },
144
- { property: 'Protocol', value: result.config.communicationProtocol || 'N/A' },
145
- { property: 'V3 Mode', value: v3Mode ? 'Enabled' : 'Disabled' }
146
- ]
147
- });
148
-
149
- output.writeln();
150
- output.printSuccess('Swarm initialized successfully');
151
-
152
- if (ctx.flags.format === 'json') {
153
- output.printJson(result);
154
- }
155
-
156
- return { success: true, data: result };
157
- } catch (error) {
158
- if (error instanceof MCPClientError) {
159
- output.printError(`Failed to initialize swarm: ${error.message}`);
160
- } else {
161
- output.printError(`Unexpected error: ${String(error)}`);
162
- }
163
- return { success: false, exitCode: 1 };
164
- }
165
- }
166
- };
167
-
168
- // Start swarm execution
169
- const startCommand: Command = {
170
- name: 'start',
171
- description: 'Start swarm execution',
172
- options: [
173
- {
174
- name: 'objective',
175
- short: 'o',
176
- description: 'Swarm objective/task',
177
- type: 'string',
178
- required: true
179
- },
180
- {
181
- name: 'strategy',
182
- short: 's',
183
- description: 'Execution strategy',
184
- type: 'string',
185
- choices: STRATEGIES.map(s => s.value)
186
- },
187
- {
188
- name: 'parallel',
189
- short: 'p',
190
- description: 'Enable parallel execution',
191
- type: 'boolean',
192
- default: true
193
- },
194
- {
195
- name: 'monitor',
196
- description: 'Enable real-time monitoring',
197
- type: 'boolean',
198
- default: true
199
- }
200
- ],
201
- examples: [
202
- { command: 'claude-flow swarm start -o "Build REST API" -s development', description: 'Start development swarm' },
203
- { command: 'claude-flow swarm start -o "Analyze codebase" --parallel', description: 'Parallel analysis' }
204
- ],
205
- action: async (ctx: CommandContext): Promise<CommandResult> => {
206
- const objective = ctx.args[0] || ctx.flags.objective as string;
207
- let strategy = ctx.flags.strategy as string;
208
-
209
- if (!objective) {
210
- output.printError('Objective is required. Use -o or provide as argument.');
211
- return { success: false, exitCode: 1 };
212
- }
213
-
214
- // Interactive strategy selection
215
- if (!strategy && ctx.interactive) {
216
- strategy = await select({
217
- message: 'Select execution strategy:',
218
- options: STRATEGIES,
219
- default: 'development'
220
- });
221
- }
222
-
223
- strategy = strategy || 'development';
224
-
225
- output.writeln();
226
- output.printInfo(`Starting swarm with objective: ${output.highlight(objective)}`);
227
- output.writeln();
228
-
229
- // Compute agent deployment plan based on strategy
230
- const agentPlan = getAgentPlan(strategy);
231
-
232
- output.writeln(output.bold('Agent Deployment Plan'));
233
- output.printTable({
234
- columns: [
235
- { key: 'role', header: 'Role', width: 20 },
236
- { key: 'type', header: 'Type', width: 15 },
237
- { key: 'count', header: 'Count', width: 8, align: 'right' },
238
- { key: 'purpose', header: 'Purpose', width: 30 }
239
- ],
240
- data: agentPlan
241
- });
242
-
243
- // Confirm execution
244
- if (ctx.interactive) {
245
- const confirmed = await confirm({
246
- message: `Deploy ${agentPlan.reduce((sum, a) => sum + a.count, 0)} agents?`,
247
- default: true
248
- });
249
-
250
- if (!confirmed) {
251
- output.printInfo('Swarm execution cancelled');
252
- return { success: true };
253
- }
254
- }
255
-
256
- output.writeln();
257
- output.printInfo('Deploying agents...');
258
-
259
- // Show deployment progress
260
- const spinner = output.createSpinner({ text: 'Initializing agents...', spinner: 'dots' });
261
- spinner.start();
262
-
263
- // Brief delay for spinner animation
264
- await new Promise(resolve => setTimeout(resolve, 500));
265
-
266
- spinner.succeed('All agents deployed');
267
-
268
- const executionState = {
269
- swarmId: `swarm-${Date.now().toString(36)}`,
270
- objective,
271
- strategy,
272
- status: 'running',
273
- agents: agentPlan.reduce((sum, a) => sum + a.count, 0),
274
- startedAt: new Date().toISOString(),
275
- parallel: ctx.flags.parallel ?? true
276
- };
277
-
278
- output.writeln();
279
- output.printSuccess('Swarm execution started');
280
- output.writeln(output.dim(` Monitor: claude-flow swarm status ${executionState.swarmId}`));
281
-
282
- return { success: true, data: executionState };
283
- }
284
- };
285
-
286
- // Swarm status
287
- const statusCommand: Command = {
288
- name: 'status',
289
- description: 'Show swarm status',
290
- action: async (ctx: CommandContext): Promise<CommandResult> => {
291
- const swarmId = ctx.args[0];
292
-
293
- // Default status (updated by MCP swarm/status when available)
294
- const status = {
295
- id: swarmId || 'swarm-current',
296
- topology: 'hybrid',
297
- status: 'running',
298
- objective: 'Build enterprise REST API with authentication',
299
- strategy: 'development',
300
- agents: {
301
- total: 15,
302
- active: 12,
303
- idle: 2,
304
- completed: 1
305
- },
306
- progress: 65,
307
- tasks: {
308
- total: 45,
309
- completed: 29,
310
- inProgress: 12,
311
- pending: 4
312
- },
313
- metrics: {
314
- tokensUsed: 234567,
315
- avgResponseTime: '1.8s',
316
- successRate: '97.2%',
317
- elapsedTime: '45m 23s'
318
- },
319
- coordination: {
320
- consensusRounds: 8,
321
- messagesSent: 1234,
322
- conflictsResolved: 3
323
- }
324
- };
325
-
326
- if (ctx.flags.format === 'json') {
327
- output.printJson(status);
328
- return { success: true, data: status };
329
- }
330
-
331
- output.writeln();
332
- output.writeln(output.bold(`Swarm Status: ${status.id}`));
333
- output.writeln();
334
-
335
- // Progress bar
336
- output.writeln(`Overall Progress: ${output.progressBar(status.progress, 100, 40)}`);
337
- output.writeln();
338
-
339
- // Agent status
340
- output.writeln(output.bold('Agents'));
341
- output.printTable({
342
- columns: [
343
- { key: 'status', header: 'Status', width: 12 },
344
- { key: 'count', header: 'Count', width: 10, align: 'right' }
345
- ],
346
- data: [
347
- { status: output.success('Active'), count: status.agents.active },
348
- { status: output.warning('Idle'), count: status.agents.idle },
349
- { status: output.dim('Completed'), count: status.agents.completed },
350
- { status: 'Total', count: status.agents.total }
351
- ]
352
- });
353
-
354
- output.writeln();
355
-
356
- // Task status
357
- output.writeln(output.bold('Tasks'));
358
- output.printTable({
359
- columns: [
360
- { key: 'status', header: 'Status', width: 12 },
361
- { key: 'count', header: 'Count', width: 10, align: 'right' }
362
- ],
363
- data: [
364
- { status: output.success('Completed'), count: status.tasks.completed },
365
- { status: output.info('In Progress'), count: status.tasks.inProgress },
366
- { status: output.dim('Pending'), count: status.tasks.pending },
367
- { status: 'Total', count: status.tasks.total }
368
- ]
369
- });
370
-
371
- output.writeln();
372
-
373
- // Metrics
374
- output.writeln(output.bold('Performance Metrics'));
375
- output.printList([
376
- `Tokens Used: ${status.metrics.tokensUsed.toLocaleString()}`,
377
- `Avg Response Time: ${status.metrics.avgResponseTime}`,
378
- `Success Rate: ${status.metrics.successRate}`,
379
- `Elapsed Time: ${status.metrics.elapsedTime}`
380
- ]);
381
-
382
- output.writeln();
383
-
384
- // Coordination stats
385
- output.writeln(output.bold('Coordination'));
386
- output.printList([
387
- `Consensus Rounds: ${status.coordination.consensusRounds}`,
388
- `Messages Sent: ${status.coordination.messagesSent}`,
389
- `Conflicts Resolved: ${status.coordination.conflictsResolved}`
390
- ]);
391
-
392
- return { success: true, data: status };
393
- }
394
- };
395
-
396
- // Stop swarm
397
- const stopCommand: Command = {
398
- name: 'stop',
399
- description: 'Stop swarm execution',
400
- options: [
401
- {
402
- name: 'force',
403
- short: 'f',
404
- description: 'Force immediate stop',
405
- type: 'boolean',
406
- default: false
407
- },
408
- {
409
- name: 'save-state',
410
- description: 'Save current state for resume',
411
- type: 'boolean',
412
- default: true
413
- }
414
- ],
415
- action: async (ctx: CommandContext): Promise<CommandResult> => {
416
- const swarmId = ctx.args[0];
417
- const force = ctx.flags.force as boolean;
418
-
419
- if (!swarmId) {
420
- output.printError('Swarm ID is required');
421
- return { success: false, exitCode: 1 };
422
- }
423
-
424
- if (ctx.interactive && !force) {
425
- const confirmed = await confirm({
426
- message: `Stop swarm ${swarmId}? Progress will be saved.`,
427
- default: false
428
- });
429
-
430
- if (!confirmed) {
431
- output.printInfo('Operation cancelled');
432
- return { success: true };
433
- }
434
- }
435
-
436
- output.printInfo(`Stopping swarm ${swarmId}...`);
437
-
438
- if (!force) {
439
- output.writeln(output.dim(' Completing in-progress tasks...'));
440
- output.writeln(output.dim(' Saving coordination state...'));
441
- output.writeln(output.dim(' Notifying agents...'));
442
- output.writeln(output.dim(' Saving memory state...'));
443
- }
444
-
445
- output.printSuccess(`Swarm ${swarmId} stopped`);
446
-
447
- return { success: true, data: { swarmId, stopped: true, force } };
448
- }
449
- };
450
-
451
- // Scale swarm
452
- const scaleCommand: Command = {
453
- name: 'scale',
454
- description: 'Scale swarm agent count',
455
- options: [
456
- {
457
- name: 'agents',
458
- short: 'a',
459
- description: 'Target number of agents',
460
- type: 'number',
461
- required: true
462
- },
463
- {
464
- name: 'type',
465
- short: 't',
466
- description: 'Agent type to scale',
467
- type: 'string'
468
- }
469
- ],
470
- action: async (ctx: CommandContext): Promise<CommandResult> => {
471
- const swarmId = ctx.args[0];
472
- const targetAgents = ctx.flags.agents as number;
473
- const agentType = ctx.flags.type as string;
474
-
475
- if (!swarmId) {
476
- output.printError('Swarm ID is required');
477
- return { success: false, exitCode: 1 };
478
- }
479
-
480
- if (!targetAgents) {
481
- output.printError('Target agent count required. Use --agents or -a');
482
- return { success: false, exitCode: 1 };
483
- }
484
-
485
- output.printInfo(`Scaling swarm ${swarmId} to ${targetAgents} agents...`);
486
-
487
- // Calculate scaling delta
488
- const currentAgents = 8;
489
- const delta = targetAgents - currentAgents;
490
-
491
- if (delta > 0) {
492
- output.writeln(output.dim(` Spawning ${delta} new agents...`));
493
- } else if (delta < 0) {
494
- output.writeln(output.dim(` Gracefully stopping ${-delta} agents...`));
495
- } else {
496
- output.printInfo('Swarm already at target size');
497
- return { success: true };
498
- }
499
-
500
- output.printSuccess(`Swarm scaled to ${targetAgents} agents`);
501
-
502
- return { success: true, data: { swarmId, agents: targetAgents, delta } };
503
- }
504
- };
505
-
506
- // Coordinate command (V3 specific)
507
- const coordinateCommand: Command = {
508
- name: 'coordinate',
509
- description: 'Execute V3 15-agent hierarchical mesh coordination',
510
- options: [
511
- {
512
- name: 'agents',
513
- description: 'Number of agents',
514
- type: 'number',
515
- default: 15
516
- },
517
- {
518
- name: 'domains',
519
- description: 'Domains to activate',
520
- type: 'array'
521
- }
522
- ],
523
- action: async (ctx: CommandContext): Promise<CommandResult> => {
524
- const agentCount = ctx.flags.agents as number || 15;
525
-
526
- output.writeln();
527
- output.writeln(output.bold('V3 15-Agent Hierarchical Mesh Coordination'));
528
- output.writeln();
529
-
530
- // V3 agent structure
531
- const v3Agents = [
532
- { id: 1, role: 'Queen Coordinator', domain: 'Orchestration', status: 'primary' },
533
- { id: 2, role: 'Security Architect', domain: 'Security', status: 'active' },
534
- { id: 3, role: 'Security Auditor', domain: 'Security', status: 'active' },
535
- { id: 4, role: 'Test Architect', domain: 'Security', status: 'active' },
536
- { id: 5, role: 'Core Architect', domain: 'Core', status: 'active' },
537
- { id: 6, role: 'Memory Specialist', domain: 'Core', status: 'active' },
538
- { id: 7, role: 'Swarm Specialist', domain: 'Core', status: 'active' },
539
- { id: 8, role: 'Integration Architect', domain: 'Integration', status: 'active' },
540
- { id: 9, role: 'Performance Engineer', domain: 'Integration', status: 'active' },
541
- { id: 10, role: 'CLI Developer', domain: 'Integration', status: 'active' },
542
- { id: 11, role: 'Hooks Developer', domain: 'Integration', status: 'active' },
543
- { id: 12, role: 'MCP Specialist', domain: 'Integration', status: 'active' },
544
- { id: 13, role: 'Project Coordinator', domain: 'Management', status: 'active' },
545
- { id: 14, role: 'Documentation Lead', domain: 'Management', status: 'standby' },
546
- { id: 15, role: 'DevOps Engineer', domain: 'Management', status: 'standby' }
547
- ].slice(0, agentCount);
548
-
549
- output.printTable({
550
- columns: [
551
- { key: 'id', header: '#', width: 3, align: 'right' },
552
- { key: 'role', header: 'Role', width: 22 },
553
- { key: 'domain', header: 'Domain', width: 15 },
554
- { key: 'status', header: 'Status', width: 10, format: (v) => {
555
- if (v === 'primary') return output.highlight(String(v));
556
- if (v === 'active') return output.success(String(v));
557
- return output.dim(String(v));
558
- }}
559
- ],
560
- data: v3Agents
561
- });
562
-
563
- output.writeln();
564
- output.printInfo('Performance Targets:');
565
- output.printList([
566
- `Flash Attention: ${output.success('2.49x-7.47x speedup')}`,
567
- `AgentDB Search: ${output.success('150x-12,500x improvement')}`,
568
- `Memory Reduction: ${output.success('50-75%')}`,
569
- `Code Reduction: ${output.success('<5,000 lines')}`
570
- ]);
571
-
572
- return { success: true, data: { agents: v3Agents, count: agentCount } };
573
- }
574
- };
575
-
576
- // Main swarm command
577
- export const swarmCommand: Command = {
578
- name: 'swarm',
579
- description: 'Swarm coordination commands',
580
- subcommands: [initCommand, startCommand, statusCommand, stopCommand, scaleCommand, coordinateCommand],
581
- options: [],
582
- examples: [
583
- { command: 'claude-flow swarm init --v3-mode', description: 'Initialize V3 swarm' },
584
- { command: 'claude-flow swarm start -o "Build API" -s development', description: 'Start development swarm' },
585
- { command: 'claude-flow swarm coordinate --agents 15', description: 'V3 coordination' }
586
- ],
587
- action: async (ctx: CommandContext): Promise<CommandResult> => {
588
- output.writeln();
589
- output.writeln(output.bold('Swarm Coordination Commands'));
590
- output.writeln();
591
- output.writeln('Usage: claude-flow swarm <subcommand> [options]');
592
- output.writeln();
593
- output.writeln('Subcommands:');
594
- output.printList([
595
- `${output.highlight('init')} - Initialize a new swarm`,
596
- `${output.highlight('start')} - Start swarm execution`,
597
- `${output.highlight('status')} - Show swarm status`,
598
- `${output.highlight('stop')} - Stop swarm execution`,
599
- `${output.highlight('scale')} - Scale swarm agent count`,
600
- `${output.highlight('coordinate')} - V3 15-agent coordination`
601
- ]);
602
-
603
- return { success: true };
604
- }
605
- };
606
-
607
- // Helper function
608
- function getAgentPlan(strategy: string): Array<{ role: string; type: string; count: number; purpose: string }> {
609
- const plans: Record<string, Array<{ role: string; type: string; count: number; purpose: string }>> = {
610
- development: [
611
- { role: 'Coordinator', type: 'coordinator', count: 1, purpose: 'Orchestrate workflow' },
612
- { role: 'Architect', type: 'architect', count: 1, purpose: 'System design' },
613
- { role: 'Coder', type: 'coder', count: 3, purpose: 'Implementation' },
614
- { role: 'Tester', type: 'tester', count: 2, purpose: 'Quality assurance' },
615
- { role: 'Reviewer', type: 'reviewer', count: 1, purpose: 'Code review' }
616
- ],
617
- research: [
618
- { role: 'Coordinator', type: 'coordinator', count: 1, purpose: 'Research coordination' },
619
- { role: 'Researcher', type: 'researcher', count: 4, purpose: 'Data gathering' },
620
- { role: 'Analyst', type: 'analyst', count: 2, purpose: 'Analysis and synthesis' }
621
- ],
622
- testing: [
623
- { role: 'Test Lead', type: 'tester', count: 1, purpose: 'Test strategy' },
624
- { role: 'Unit Tester', type: 'tester', count: 2, purpose: 'Unit tests' },
625
- { role: 'Integration Tester', type: 'tester', count: 2, purpose: 'Integration tests' },
626
- { role: 'QA Reviewer', type: 'reviewer', count: 1, purpose: 'Quality review' }
627
- ],
628
- optimization: [
629
- { role: 'Performance Lead', type: 'optimizer', count: 1, purpose: 'Performance strategy' },
630
- { role: 'Profiler', type: 'analyst', count: 2, purpose: 'Profiling' },
631
- { role: 'Optimizer', type: 'coder', count: 2, purpose: 'Optimization' }
632
- ],
633
- maintenance: [
634
- { role: 'Coordinator', type: 'coordinator', count: 1, purpose: 'Maintenance planning' },
635
- { role: 'Refactorer', type: 'coder', count: 2, purpose: 'Code cleanup' },
636
- { role: 'Documenter', type: 'researcher', count: 1, purpose: 'Documentation' }
637
- ],
638
- analysis: [
639
- { role: 'Analyst Lead', type: 'analyst', count: 1, purpose: 'Analysis coordination' },
640
- { role: 'Code Analyst', type: 'analyst', count: 2, purpose: 'Code analysis' },
641
- { role: 'Security Analyst', type: 'reviewer', count: 1, purpose: 'Security review' }
642
- ]
643
- };
644
-
645
- return plans[strategy] || plans.development;
646
- }
647
-
648
- export default swarmCommand;