claude-flow 2.0.0-alpha.79 β†’ 2.0.0-alpha.80

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 (1012) hide show
  1. package/.claude/checkpoints/1753906298.json +12 -0
  2. package/.claude/checkpoints/1753906353.json +8 -0
  3. package/.claude/checkpoints/1753906370.json +8 -0
  4. package/.claude/checkpoints/summary-session-20250730-220658.md +182 -0
  5. package/.claude/checkpoints/summary-session-20250730-220954.md +187 -0
  6. package/.claude/checkpoints/summary-session-20250730-222733.md +199 -0
  7. package/.claude/checkpoints/task-1753913133.json +7 -0
  8. package/.claude/checkpoints/task-1753913281.json +7 -0
  9. package/.claude/checkpoints/task-1753913468.json +7 -0
  10. package/.claude/commands/analysis/README.md +9 -0
  11. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  12. package/.claude/commands/analysis/performance-report.md +25 -0
  13. package/.claude/commands/analysis/token-usage.md +25 -0
  14. package/.claude/commands/automation/README.md +9 -0
  15. package/.claude/commands/automation/auto-agent.md +122 -0
  16. package/.claude/commands/automation/smart-spawn.md +25 -0
  17. package/.claude/commands/automation/workflow-select.md +25 -0
  18. package/.claude/commands/coordination/README.md +9 -0
  19. package/.claude/commands/coordination/agent-spawn.md +25 -0
  20. package/.claude/commands/coordination/swarm-init.md +85 -0
  21. package/.claude/commands/coordination/task-orchestrate.md +25 -0
  22. package/.claude/commands/github/README.md +11 -0
  23. package/.claude/commands/github/code-review.md +25 -0
  24. package/.claude/commands/github/github-swarm.md +121 -0
  25. package/.claude/commands/github/issue-triage.md +25 -0
  26. package/.claude/commands/github/pr-enhance.md +26 -0
  27. package/.claude/commands/github/repo-analyze.md +25 -0
  28. package/.claude/commands/hooks/README.md +11 -0
  29. package/.claude/commands/hooks/post-edit.md +117 -0
  30. package/.claude/commands/hooks/post-task.md +112 -0
  31. package/.claude/commands/hooks/pre-edit.md +113 -0
  32. package/.claude/commands/hooks/pre-task.md +111 -0
  33. package/.claude/commands/hooks/session-end.md +118 -0
  34. package/.claude/commands/memory/README.md +9 -0
  35. package/.claude/commands/memory/memory-persist.md +25 -0
  36. package/.claude/commands/memory/memory-search.md +25 -0
  37. package/.claude/commands/memory/memory-usage.md +25 -0
  38. package/.claude/commands/monitoring/README.md +9 -0
  39. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  40. package/.claude/commands/monitoring/real-time-view.md +25 -0
  41. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  42. package/.claude/commands/optimization/README.md +9 -0
  43. package/.claude/commands/optimization/cache-manage.md +25 -0
  44. package/.claude/commands/optimization/parallel-execute.md +25 -0
  45. package/.claude/commands/optimization/topology-optimize.md +25 -0
  46. package/.claude/commands/training/README.md +9 -0
  47. package/.claude/commands/training/model-update.md +25 -0
  48. package/.claude/commands/training/neural-train.md +25 -0
  49. package/.claude/commands/training/pattern-learn.md +25 -0
  50. package/.claude/commands/workflows/README.md +9 -0
  51. package/.claude/commands/workflows/workflow-create.md +25 -0
  52. package/.claude/commands/workflows/workflow-execute.md +25 -0
  53. package/.claude/commands/workflows/workflow-export.md +25 -0
  54. package/.claude/helpers/checkpoint-hooks.sh +187 -0
  55. package/.claude/helpers/checkpoint-manager.sh +251 -0
  56. package/.claude/helpers/github-checkpoint-hooks.sh +218 -0
  57. package/.claude/helpers/github-safe.js +106 -0
  58. package/.claude/helpers/github-setup.sh +28 -0
  59. package/.claude/helpers/quick-start.sh +19 -0
  60. package/.claude/helpers/setup-checkpoints.sh +75 -0
  61. package/.claude/helpers/setup-mcp.sh +18 -0
  62. package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
  63. package/.claude/settings-checkpoint-example.json +29 -0
  64. package/.claude/settings-checkpoint-simple.json +24 -0
  65. package/.claude/settings-complete.json +138 -0
  66. package/.claude/settings.json +10 -10
  67. package/.claude/settings.local.json +1 -10
  68. package/CHANGELOG.md +54 -0
  69. package/README.md +20 -0
  70. package/bin/claude-flow +1 -1
  71. package/package.json +1 -1
  72. package/src/cli/command-registry.js +12 -1
  73. package/src/cli/commands/status.ts +1 -1
  74. package/src/cli/help-text.js +15 -6
  75. package/src/cli/index-remote.ts +1 -1
  76. package/src/cli/index.ts +1 -1
  77. package/src/cli/simple-cli.js +1 -1
  78. package/src/cli/simple-cli.ts +1 -1
  79. package/src/cli/simple-commands/agent.js +5 -0
  80. package/src/cli/simple-commands/analysis.js +370 -108
  81. package/src/cli/simple-commands/github/init.js +529 -0
  82. package/src/cli/simple-commands/github.js +15 -0
  83. package/src/cli/simple-commands/init/help.js +2 -0
  84. package/src/cli/simple-commands/init/index.js +112 -1
  85. package/src/cli/simple-commands/init/template-copier.js +1 -1
  86. package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
  87. package/src/cli/simple-commands/init/templates/enhanced-templates.js +642 -2
  88. package/src/cli/simple-commands/init/templates/settings.json +6 -2
  89. package/src/cli/simple-commands/performance-hooks.js +173 -0
  90. package/src/cli/simple-commands/performance-metrics.js +592 -0
  91. package/src/cli/simple-commands/process-ui-enhanced.js +2 -2
  92. package/src/cli/simple-commands/status.js +1 -1
  93. package/dist/agents/agent-loader.d.ts +0 -90
  94. package/dist/agents/agent-loader.d.ts.map +0 -1
  95. package/dist/agents/agent-loader.js +0 -195
  96. package/dist/agents/agent-loader.js.map +0 -1
  97. package/dist/agents/agent-manager.d.ts +0 -191
  98. package/dist/agents/agent-manager.d.ts.map +0 -1
  99. package/dist/agents/agent-manager.js +0 -1405
  100. package/dist/agents/agent-manager.js.map +0 -1
  101. package/dist/api/claude-api-errors.d.ts +0 -115
  102. package/dist/api/claude-api-errors.d.ts.map +0 -1
  103. package/dist/api/claude-api-errors.js +0 -198
  104. package/dist/api/claude-api-errors.js.map +0 -1
  105. package/dist/api/claude-client.d.ts +0 -197
  106. package/dist/api/claude-client.d.ts.map +0 -1
  107. package/dist/api/claude-client.js +0 -525
  108. package/dist/api/claude-client.js.map +0 -1
  109. package/dist/cli/cli-core.d.ts +0 -52
  110. package/dist/cli/cli-core.d.ts.map +0 -1
  111. package/dist/cli/cli-core.js +0 -264
  112. package/dist/cli/cli-core.js.map +0 -1
  113. package/dist/cli/command-registry.d.ts +0 -10
  114. package/dist/cli/command-registry.d.ts.map +0 -1
  115. package/dist/cli/command-registry.js +0 -758
  116. package/dist/cli/command-registry.js.map +0 -1
  117. package/dist/cli/commands/agent.d.ts +0 -7
  118. package/dist/cli/commands/agent.d.ts.map +0 -1
  119. package/dist/cli/commands/agent.js +0 -382
  120. package/dist/cli/commands/agent.js.map +0 -1
  121. package/dist/cli/commands/config.d.ts +0 -5
  122. package/dist/cli/commands/config.d.ts.map +0 -1
  123. package/dist/cli/commands/config.js +0 -88
  124. package/dist/cli/commands/config.js.map +0 -1
  125. package/dist/cli/commands/enterprise.d.ts +0 -3
  126. package/dist/cli/commands/enterprise.d.ts.map +0 -1
  127. package/dist/cli/commands/enterprise.js +0 -1506
  128. package/dist/cli/commands/enterprise.js.map +0 -1
  129. package/dist/cli/commands/help.d.ts +0 -7
  130. package/dist/cli/commands/help.d.ts.map +0 -1
  131. package/dist/cli/commands/help.js +0 -936
  132. package/dist/cli/commands/help.js.map +0 -1
  133. package/dist/cli/commands/hive-mind/index.d.ts +0 -19
  134. package/dist/cli/commands/hive-mind/index.d.ts.map +0 -1
  135. package/dist/cli/commands/hive-mind/index.js +0 -30
  136. package/dist/cli/commands/hive-mind/index.js.map +0 -1
  137. package/dist/cli/commands/hive-mind/init.d.ts +0 -10
  138. package/dist/cli/commands/hive-mind/init.d.ts.map +0 -1
  139. package/dist/cli/commands/hive-mind/init.js +0 -68
  140. package/dist/cli/commands/hive-mind/init.js.map +0 -1
  141. package/dist/cli/commands/hive-mind/pause.d.ts +0 -9
  142. package/dist/cli/commands/hive-mind/pause.d.ts.map +0 -1
  143. package/dist/cli/commands/hive-mind/pause.js +0 -81
  144. package/dist/cli/commands/hive-mind/pause.js.map +0 -1
  145. package/dist/cli/commands/hive-mind/ps.d.ts +0 -9
  146. package/dist/cli/commands/hive-mind/ps.d.ts.map +0 -1
  147. package/dist/cli/commands/hive-mind/ps.js +0 -120
  148. package/dist/cli/commands/hive-mind/ps.js.map +0 -1
  149. package/dist/cli/commands/hive-mind/resume.d.ts +0 -9
  150. package/dist/cli/commands/hive-mind/resume.d.ts.map +0 -1
  151. package/dist/cli/commands/hive-mind/resume.js +0 -62
  152. package/dist/cli/commands/hive-mind/resume.js.map +0 -1
  153. package/dist/cli/commands/hive-mind/spawn.d.ts +0 -10
  154. package/dist/cli/commands/hive-mind/spawn.d.ts.map +0 -1
  155. package/dist/cli/commands/hive-mind/spawn.js +0 -174
  156. package/dist/cli/commands/hive-mind/spawn.js.map +0 -1
  157. package/dist/cli/commands/hive-mind/status.d.ts +0 -10
  158. package/dist/cli/commands/hive-mind/status.d.ts.map +0 -1
  159. package/dist/cli/commands/hive-mind/status.js +0 -204
  160. package/dist/cli/commands/hive-mind/status.js.map +0 -1
  161. package/dist/cli/commands/hive-mind/stop.d.ts +0 -9
  162. package/dist/cli/commands/hive-mind/stop.d.ts.map +0 -1
  163. package/dist/cli/commands/hive-mind/stop.js +0 -125
  164. package/dist/cli/commands/hive-mind/stop.js.map +0 -1
  165. package/dist/cli/commands/hive-mind/task.d.ts +0 -10
  166. package/dist/cli/commands/hive-mind/task.d.ts.map +0 -1
  167. package/dist/cli/commands/hive-mind/task.js +0 -294
  168. package/dist/cli/commands/hive-mind/task.js.map +0 -1
  169. package/dist/cli/commands/hive-mind/wizard.d.ts +0 -10
  170. package/dist/cli/commands/hive-mind/wizard.d.ts.map +0 -1
  171. package/dist/cli/commands/hive-mind/wizard.js +0 -531
  172. package/dist/cli/commands/hive-mind/wizard.js.map +0 -1
  173. package/dist/cli/commands/hive.d.ts +0 -6
  174. package/dist/cli/commands/hive.d.ts.map +0 -1
  175. package/dist/cli/commands/hive.js +0 -409
  176. package/dist/cli/commands/hive.js.map +0 -1
  177. package/dist/cli/commands/index.d.ts +0 -3
  178. package/dist/cli/commands/index.d.ts.map +0 -1
  179. package/dist/cli/commands/index.js +0 -2532
  180. package/dist/cli/commands/index.js.map +0 -1
  181. package/dist/cli/commands/mcp.d.ts +0 -5
  182. package/dist/cli/commands/mcp.d.ts.map +0 -1
  183. package/dist/cli/commands/mcp.js +0 -169
  184. package/dist/cli/commands/mcp.js.map +0 -1
  185. package/dist/cli/commands/memory.d.ts +0 -30
  186. package/dist/cli/commands/memory.d.ts.map +0 -1
  187. package/dist/cli/commands/memory.js +0 -225
  188. package/dist/cli/commands/memory.js.map +0 -1
  189. package/dist/cli/commands/migrate.d.ts +0 -6
  190. package/dist/cli/commands/migrate.d.ts.map +0 -1
  191. package/dist/cli/commands/migrate.js +0 -139
  192. package/dist/cli/commands/migrate.js.map +0 -1
  193. package/dist/cli/commands/monitor.d.ts +0 -6
  194. package/dist/cli/commands/monitor.d.ts.map +0 -1
  195. package/dist/cli/commands/monitor.js +0 -493
  196. package/dist/cli/commands/monitor.js.map +0 -1
  197. package/dist/cli/commands/session.d.ts +0 -6
  198. package/dist/cli/commands/session.d.ts.map +0 -1
  199. package/dist/cli/commands/session.js +0 -548
  200. package/dist/cli/commands/session.js.map +0 -1
  201. package/dist/cli/commands/sparc.d.ts +0 -3
  202. package/dist/cli/commands/sparc.d.ts.map +0 -1
  203. package/dist/cli/commands/sparc.js +0 -472
  204. package/dist/cli/commands/sparc.js.map +0 -1
  205. package/dist/cli/commands/start/event-emitter.d.ts +0 -13
  206. package/dist/cli/commands/start/event-emitter.d.ts.map +0 -1
  207. package/dist/cli/commands/start/event-emitter.js +0 -35
  208. package/dist/cli/commands/start/event-emitter.js.map +0 -1
  209. package/dist/cli/commands/start/index.d.ts +0 -10
  210. package/dist/cli/commands/start/index.d.ts.map +0 -1
  211. package/dist/cli/commands/start/index.js +0 -9
  212. package/dist/cli/commands/start/index.js.map +0 -1
  213. package/dist/cli/commands/start/process-manager.d.ts +0 -31
  214. package/dist/cli/commands/start/process-manager.d.ts.map +0 -1
  215. package/dist/cli/commands/start/process-manager.js +0 -283
  216. package/dist/cli/commands/start/process-manager.js.map +0 -1
  217. package/dist/cli/commands/start/process-ui-simple.d.ts +0 -29
  218. package/dist/cli/commands/start/process-ui-simple.d.ts.map +0 -1
  219. package/dist/cli/commands/start/process-ui-simple.js +0 -334
  220. package/dist/cli/commands/start/process-ui-simple.js.map +0 -1
  221. package/dist/cli/commands/start/process-ui.d.ts +0 -5
  222. package/dist/cli/commands/start/process-ui.d.ts.map +0 -1
  223. package/dist/cli/commands/start/process-ui.js +0 -5
  224. package/dist/cli/commands/start/process-ui.js.map +0 -1
  225. package/dist/cli/commands/start/start-command.d.ts +0 -2
  226. package/dist/cli/commands/start/start-command.d.ts.map +0 -1
  227. package/dist/cli/commands/start/start-command.js +0 -462
  228. package/dist/cli/commands/start/start-command.js.map +0 -1
  229. package/dist/cli/commands/start/system-monitor.d.ts +0 -25
  230. package/dist/cli/commands/start/system-monitor.d.ts.map +0 -1
  231. package/dist/cli/commands/start/system-monitor.js +0 -265
  232. package/dist/cli/commands/start/system-monitor.js.map +0 -1
  233. package/dist/cli/commands/start/types.d.ts +0 -64
  234. package/dist/cli/commands/start/types.d.ts.map +0 -1
  235. package/dist/cli/commands/start/types.js +0 -22
  236. package/dist/cli/commands/start/types.js.map +0 -1
  237. package/dist/cli/commands/start.d.ts +0 -6
  238. package/dist/cli/commands/start.d.ts.map +0 -1
  239. package/dist/cli/commands/start.js +0 -6
  240. package/dist/cli/commands/start.js.map +0 -1
  241. package/dist/cli/commands/status.d.ts +0 -6
  242. package/dist/cli/commands/status.d.ts.map +0 -1
  243. package/dist/cli/commands/status.js +0 -307
  244. package/dist/cli/commands/status.js.map +0 -1
  245. package/dist/cli/commands/swarm.d.ts +0 -6
  246. package/dist/cli/commands/swarm.d.ts.map +0 -1
  247. package/dist/cli/commands/swarm.js +0 -465
  248. package/dist/cli/commands/swarm.js.map +0 -1
  249. package/dist/cli/commands/task.d.ts +0 -6
  250. package/dist/cli/commands/task.d.ts.map +0 -1
  251. package/dist/cli/commands/task.js +0 -75
  252. package/dist/cli/commands/task.js.map +0 -1
  253. package/dist/cli/commands/workflow.d.ts +0 -6
  254. package/dist/cli/commands/workflow.d.ts.map +0 -1
  255. package/dist/cli/commands/workflow.js +0 -624
  256. package/dist/cli/commands/workflow.js.map +0 -1
  257. package/dist/cli/completion.d.ts +0 -19
  258. package/dist/cli/completion.d.ts.map +0 -1
  259. package/dist/cli/completion.js +0 -545
  260. package/dist/cli/completion.js.map +0 -1
  261. package/dist/cli/formatter.d.ts +0 -69
  262. package/dist/cli/formatter.d.ts.map +0 -1
  263. package/dist/cli/formatter.js +0 -277
  264. package/dist/cli/formatter.js.map +0 -1
  265. package/dist/cli/help-formatter.d.ts +0 -49
  266. package/dist/cli/help-formatter.d.ts.map +0 -1
  267. package/dist/cli/help-formatter.js +0 -108
  268. package/dist/cli/help-formatter.js.map +0 -1
  269. package/dist/cli/index-remote.d.ts +0 -7
  270. package/dist/cli/index-remote.d.ts.map +0 -1
  271. package/dist/cli/index-remote.js +0 -126
  272. package/dist/cli/index-remote.js.map +0 -1
  273. package/dist/cli/index.d.ts +0 -7
  274. package/dist/cli/index.d.ts.map +0 -1
  275. package/dist/cli/index.js +0 -191
  276. package/dist/cli/index.js.map +0 -1
  277. package/dist/cli/node-compat.d.ts +0 -81
  278. package/dist/cli/node-compat.d.ts.map +0 -1
  279. package/dist/cli/node-compat.js +0 -229
  280. package/dist/cli/node-compat.js.map +0 -1
  281. package/dist/cli/repl.d.ts +0 -5
  282. package/dist/cli/repl.d.ts.map +0 -1
  283. package/dist/cli/repl.js +0 -949
  284. package/dist/cli/repl.js.map +0 -1
  285. package/dist/cli/runtime-detector.d.ts +0 -128
  286. package/dist/cli/runtime-detector.d.ts.map +0 -1
  287. package/dist/cli/runtime-detector.js +0 -267
  288. package/dist/cli/runtime-detector.js.map +0 -1
  289. package/dist/cli/simple-cli.d.ts +0 -7
  290. package/dist/cli/simple-cli.d.ts.map +0 -1
  291. package/dist/cli/simple-cli.js +0 -3074
  292. package/dist/cli/simple-cli.js.map +0 -1
  293. package/dist/cli/simple-commands/agent.d.ts +0 -2
  294. package/dist/cli/simple-commands/agent.d.ts.map +0 -1
  295. package/dist/cli/simple-commands/agent.js +0 -175
  296. package/dist/cli/simple-commands/agent.js.map +0 -1
  297. package/dist/cli/simple-commands/analysis.d.ts +0 -2
  298. package/dist/cli/simple-commands/analysis.d.ts.map +0 -1
  299. package/dist/cli/simple-commands/analysis.js +0 -207
  300. package/dist/cli/simple-commands/analysis.js.map +0 -1
  301. package/dist/cli/simple-commands/automation.d.ts +0 -2
  302. package/dist/cli/simple-commands/automation.d.ts.map +0 -1
  303. package/dist/cli/simple-commands/automation.js +0 -246
  304. package/dist/cli/simple-commands/automation.js.map +0 -1
  305. package/dist/cli/simple-commands/batch-manager.d.ts +0 -2
  306. package/dist/cli/simple-commands/batch-manager.d.ts.map +0 -1
  307. package/dist/cli/simple-commands/batch-manager.js +0 -290
  308. package/dist/cli/simple-commands/batch-manager.js.map +0 -1
  309. package/dist/cli/simple-commands/config.d.ts +0 -2
  310. package/dist/cli/simple-commands/config.d.ts.map +0 -1
  311. package/dist/cli/simple-commands/config.js +0 -278
  312. package/dist/cli/simple-commands/config.js.map +0 -1
  313. package/dist/cli/simple-commands/coordination.d.ts +0 -2
  314. package/dist/cli/simple-commands/coordination.d.ts.map +0 -1
  315. package/dist/cli/simple-commands/coordination.js +0 -249
  316. package/dist/cli/simple-commands/coordination.js.map +0 -1
  317. package/dist/cli/simple-commands/fix-hook-variables.d.ts +0 -16
  318. package/dist/cli/simple-commands/fix-hook-variables.d.ts.map +0 -1
  319. package/dist/cli/simple-commands/fix-hook-variables.js +0 -320
  320. package/dist/cli/simple-commands/fix-hook-variables.js.map +0 -1
  321. package/dist/cli/simple-commands/github.d.ts +0 -3
  322. package/dist/cli/simple-commands/github.d.ts.map +0 -1
  323. package/dist/cli/simple-commands/github.js +0 -343
  324. package/dist/cli/simple-commands/github.js.map +0 -1
  325. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.d.ts +0 -68
  326. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.d.ts.map +0 -1
  327. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.js +0 -264
  328. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.js.map +0 -1
  329. package/dist/cli/simple-commands/hive-mind/communication.d.ts +0 -176
  330. package/dist/cli/simple-commands/hive-mind/communication.d.ts.map +0 -1
  331. package/dist/cli/simple-commands/hive-mind/communication.js +0 -611
  332. package/dist/cli/simple-commands/hive-mind/communication.js.map +0 -1
  333. package/dist/cli/simple-commands/hive-mind/core.d.ts +0 -306
  334. package/dist/cli/simple-commands/hive-mind/core.d.ts.map +0 -1
  335. package/dist/cli/simple-commands/hive-mind/core.js +0 -840
  336. package/dist/cli/simple-commands/hive-mind/core.js.map +0 -1
  337. package/dist/cli/simple-commands/hive-mind/db-optimizer.d.ts +0 -32
  338. package/dist/cli/simple-commands/hive-mind/db-optimizer.d.ts.map +0 -1
  339. package/dist/cli/simple-commands/hive-mind/db-optimizer.js +0 -702
  340. package/dist/cli/simple-commands/hive-mind/db-optimizer.js.map +0 -1
  341. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts +0 -270
  342. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts.map +0 -1
  343. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js +0 -1211
  344. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js.map +0 -1
  345. package/dist/cli/simple-commands/hive-mind/memory.d.ts +0 -334
  346. package/dist/cli/simple-commands/hive-mind/memory.d.ts.map +0 -1
  347. package/dist/cli/simple-commands/hive-mind/memory.js +0 -1068
  348. package/dist/cli/simple-commands/hive-mind/memory.js.map +0 -1
  349. package/dist/cli/simple-commands/hive-mind/performance-optimizer.d.ts +0 -256
  350. package/dist/cli/simple-commands/hive-mind/performance-optimizer.d.ts.map +0 -1
  351. package/dist/cli/simple-commands/hive-mind/performance-optimizer.js +0 -520
  352. package/dist/cli/simple-commands/hive-mind/performance-optimizer.js.map +0 -1
  353. package/dist/cli/simple-commands/hive-mind/queen.d.ts +0 -235
  354. package/dist/cli/simple-commands/hive-mind/queen.d.ts.map +0 -1
  355. package/dist/cli/simple-commands/hive-mind/queen.js +0 -697
  356. package/dist/cli/simple-commands/hive-mind/queen.js.map +0 -1
  357. package/dist/cli/simple-commands/hive-mind/session-manager.d.ts +0 -139
  358. package/dist/cli/simple-commands/hive-mind/session-manager.d.ts.map +0 -1
  359. package/dist/cli/simple-commands/hive-mind/session-manager.js +0 -835
  360. package/dist/cli/simple-commands/hive-mind/session-manager.js.map +0 -1
  361. package/dist/cli/simple-commands/hive-mind-optimize.d.ts +0 -6
  362. package/dist/cli/simple-commands/hive-mind-optimize.d.ts.map +0 -1
  363. package/dist/cli/simple-commands/hive-mind-optimize.js +0 -317
  364. package/dist/cli/simple-commands/hive-mind-optimize.js.map +0 -1
  365. package/dist/cli/simple-commands/hive-mind.d.ts +0 -18
  366. package/dist/cli/simple-commands/hive-mind.d.ts.map +0 -1
  367. package/dist/cli/simple-commands/hive-mind.js +0 -2430
  368. package/dist/cli/simple-commands/hive-mind.js.map +0 -1
  369. package/dist/cli/simple-commands/hook-safety.d.ts +0 -177
  370. package/dist/cli/simple-commands/hook-safety.d.ts.map +0 -1
  371. package/dist/cli/simple-commands/hook-safety.js +0 -590
  372. package/dist/cli/simple-commands/hook-safety.js.map +0 -1
  373. package/dist/cli/simple-commands/hooks.d.ts +0 -3
  374. package/dist/cli/simple-commands/hooks.d.ts.map +0 -1
  375. package/dist/cli/simple-commands/hooks.js +0 -1026
  376. package/dist/cli/simple-commands/hooks.js.map +0 -1
  377. package/dist/cli/simple-commands/init/agent-copier.d.ts +0 -43
  378. package/dist/cli/simple-commands/init/agent-copier.d.ts.map +0 -1
  379. package/dist/cli/simple-commands/init/agent-copier.js +0 -200
  380. package/dist/cli/simple-commands/init/agent-copier.js.map +0 -1
  381. package/dist/cli/simple-commands/init/batch-init.d.ts +0 -137
  382. package/dist/cli/simple-commands/init/batch-init.d.ts.map +0 -1
  383. package/dist/cli/simple-commands/init/batch-init.js +0 -558
  384. package/dist/cli/simple-commands/init/batch-init.js.map +0 -1
  385. package/dist/cli/simple-commands/init/claude-commands/claude-flow-commands.d.ts +0 -2
  386. package/dist/cli/simple-commands/init/claude-commands/claude-flow-commands.d.ts.map +0 -1
  387. package/dist/cli/simple-commands/init/claude-commands/claude-flow-commands.js +0 -433
  388. package/dist/cli/simple-commands/init/claude-commands/claude-flow-commands.js.map +0 -1
  389. package/dist/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.d.ts +0 -2
  390. package/dist/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.d.ts.map +0 -1
  391. package/dist/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +0 -871
  392. package/dist/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js.map +0 -1
  393. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.d.ts +0 -2
  394. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.d.ts.map +0 -1
  395. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +0 -332
  396. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.js.map +0 -1
  397. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.d.ts +0 -3
  398. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.d.ts.map +0 -1
  399. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +0 -488
  400. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js.map +0 -1
  401. package/dist/cli/simple-commands/init/claude-commands/slash-commands.d.ts +0 -2
  402. package/dist/cli/simple-commands/init/claude-commands/slash-commands.d.ts.map +0 -1
  403. package/dist/cli/simple-commands/init/claude-commands/slash-commands.js +0 -51
  404. package/dist/cli/simple-commands/init/claude-commands/slash-commands.js.map +0 -1
  405. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.d.ts +0 -3
  406. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.d.ts.map +0 -1
  407. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.js +0 -288
  408. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.js.map +0 -1
  409. package/dist/cli/simple-commands/init/copy-revised-templates.d.ts +0 -29
  410. package/dist/cli/simple-commands/init/copy-revised-templates.d.ts.map +0 -1
  411. package/dist/cli/simple-commands/init/copy-revised-templates.js +0 -159
  412. package/dist/cli/simple-commands/init/copy-revised-templates.js.map +0 -1
  413. package/dist/cli/simple-commands/init/executable-wrapper.d.ts +0 -2
  414. package/dist/cli/simple-commands/init/executable-wrapper.d.ts.map +0 -1
  415. package/dist/cli/simple-commands/init/executable-wrapper.js +0 -116
  416. package/dist/cli/simple-commands/init/executable-wrapper.js.map +0 -1
  417. package/dist/cli/simple-commands/init/gitignore-updater.d.ts +0 -23
  418. package/dist/cli/simple-commands/init/gitignore-updater.d.ts.map +0 -1
  419. package/dist/cli/simple-commands/init/gitignore-updater.js +0 -126
  420. package/dist/cli/simple-commands/init/gitignore-updater.js.map +0 -1
  421. package/dist/cli/simple-commands/init/help.d.ts +0 -2
  422. package/dist/cli/simple-commands/init/help.d.ts.map +0 -1
  423. package/dist/cli/simple-commands/init/help.js +0 -95
  424. package/dist/cli/simple-commands/init/help.js.map +0 -1
  425. package/dist/cli/simple-commands/init/index.d.ts +0 -2
  426. package/dist/cli/simple-commands/init/index.d.ts.map +0 -1
  427. package/dist/cli/simple-commands/init/index.js +0 -1178
  428. package/dist/cli/simple-commands/init/index.js.map +0 -1
  429. package/dist/cli/simple-commands/init/performance-monitor.d.ts +0 -73
  430. package/dist/cli/simple-commands/init/performance-monitor.d.ts.map +0 -1
  431. package/dist/cli/simple-commands/init/performance-monitor.js +0 -277
  432. package/dist/cli/simple-commands/init/performance-monitor.js.map +0 -1
  433. package/dist/cli/simple-commands/init/rollback/backup-manager.d.ts +0 -95
  434. package/dist/cli/simple-commands/init/rollback/backup-manager.d.ts.map +0 -1
  435. package/dist/cli/simple-commands/init/rollback/backup-manager.js +0 -486
  436. package/dist/cli/simple-commands/init/rollback/backup-manager.js.map +0 -1
  437. package/dist/cli/simple-commands/init/rollback/index.d.ts +0 -114
  438. package/dist/cli/simple-commands/init/rollback/index.d.ts.map +0 -1
  439. package/dist/cli/simple-commands/init/rollback/index.js +0 -353
  440. package/dist/cli/simple-commands/init/rollback/index.js.map +0 -1
  441. package/dist/cli/simple-commands/init/rollback/recovery-manager.d.ts +0 -161
  442. package/dist/cli/simple-commands/init/rollback/recovery-manager.d.ts.map +0 -1
  443. package/dist/cli/simple-commands/init/rollback/recovery-manager.js +0 -686
  444. package/dist/cli/simple-commands/init/rollback/recovery-manager.js.map +0 -1
  445. package/dist/cli/simple-commands/init/rollback/rollback-executor.d.ts +0 -112
  446. package/dist/cli/simple-commands/init/rollback/rollback-executor.d.ts.map +0 -1
  447. package/dist/cli/simple-commands/init/rollback/rollback-executor.js +0 -480
  448. package/dist/cli/simple-commands/init/rollback/rollback-executor.js.map +0 -1
  449. package/dist/cli/simple-commands/init/rollback/state-tracker.d.ts +0 -121
  450. package/dist/cli/simple-commands/init/rollback/state-tracker.d.ts.map +0 -1
  451. package/dist/cli/simple-commands/init/rollback/state-tracker.js +0 -432
  452. package/dist/cli/simple-commands/init/rollback/state-tracker.js.map +0 -1
  453. package/dist/cli/simple-commands/init/sparc/roo-readme.d.ts +0 -2
  454. package/dist/cli/simple-commands/init/sparc/roo-readme.d.ts.map +0 -1
  455. package/dist/cli/simple-commands/init/sparc/roo-readme.js +0 -61
  456. package/dist/cli/simple-commands/init/sparc/roo-readme.js.map +0 -1
  457. package/dist/cli/simple-commands/init/sparc/roomodes-config.d.ts +0 -2
  458. package/dist/cli/simple-commands/init/sparc/roomodes-config.d.ts.map +0 -1
  459. package/dist/cli/simple-commands/init/sparc/roomodes-config.js +0 -80
  460. package/dist/cli/simple-commands/init/sparc/roomodes-config.js.map +0 -1
  461. package/dist/cli/simple-commands/init/sparc/workflows.d.ts +0 -2
  462. package/dist/cli/simple-commands/init/sparc/workflows.d.ts.map +0 -1
  463. package/dist/cli/simple-commands/init/sparc/workflows.js +0 -36
  464. package/dist/cli/simple-commands/init/sparc/workflows.js.map +0 -1
  465. package/dist/cli/simple-commands/init/sparc-structure.d.ts +0 -2
  466. package/dist/cli/simple-commands/init/sparc-structure.d.ts.map +0 -1
  467. package/dist/cli/simple-commands/init/sparc-structure.js +0 -63
  468. package/dist/cli/simple-commands/init/sparc-structure.js.map +0 -1
  469. package/dist/cli/simple-commands/init/template-copier.d.ts +0 -27
  470. package/dist/cli/simple-commands/init/template-copier.d.ts.map +0 -1
  471. package/dist/cli/simple-commands/init/template-copier.js +0 -510
  472. package/dist/cli/simple-commands/init/template-copier.js.map +0 -1
  473. package/dist/cli/simple-commands/init/templates/claude-md.d.ts +0 -5
  474. package/dist/cli/simple-commands/init/templates/claude-md.d.ts.map +0 -1
  475. package/dist/cli/simple-commands/init/templates/claude-md.js +0 -646
  476. package/dist/cli/simple-commands/init/templates/claude-md.js.map +0 -1
  477. package/dist/cli/simple-commands/init/templates/coordination-md.d.ts +0 -4
  478. package/dist/cli/simple-commands/init/templates/coordination-md.d.ts.map +0 -1
  479. package/dist/cli/simple-commands/init/templates/coordination-md.js +0 -338
  480. package/dist/cli/simple-commands/init/templates/coordination-md.js.map +0 -1
  481. package/dist/cli/simple-commands/init/templates/enhanced-templates.d.ts +0 -18
  482. package/dist/cli/simple-commands/init/templates/enhanced-templates.d.ts.map +0 -1
  483. package/dist/cli/simple-commands/init/templates/enhanced-templates.js +0 -1407
  484. package/dist/cli/simple-commands/init/templates/enhanced-templates.js.map +0 -1
  485. package/dist/cli/simple-commands/init/templates/memory-bank-md.d.ts +0 -4
  486. package/dist/cli/simple-commands/init/templates/memory-bank-md.d.ts.map +0 -1
  487. package/dist/cli/simple-commands/init/templates/memory-bank-md.js +0 -257
  488. package/dist/cli/simple-commands/init/templates/memory-bank-md.js.map +0 -1
  489. package/dist/cli/simple-commands/init/templates/readme-files.d.ts +0 -3
  490. package/dist/cli/simple-commands/init/templates/readme-files.d.ts.map +0 -1
  491. package/dist/cli/simple-commands/init/templates/readme-files.js +0 -71
  492. package/dist/cli/simple-commands/init/templates/readme-files.js.map +0 -1
  493. package/dist/cli/simple-commands/init/templates/sparc-modes.d.ts +0 -30
  494. package/dist/cli/simple-commands/init/templates/sparc-modes.d.ts.map +0 -1
  495. package/dist/cli/simple-commands/init/templates/sparc-modes.js +0 -1375
  496. package/dist/cli/simple-commands/init/templates/sparc-modes.js.map +0 -1
  497. package/dist/cli/simple-commands/init/validation/config-validator.d.ts +0 -63
  498. package/dist/cli/simple-commands/init/validation/config-validator.d.ts.map +0 -1
  499. package/dist/cli/simple-commands/init/validation/config-validator.js +0 -308
  500. package/dist/cli/simple-commands/init/validation/config-validator.js.map +0 -1
  501. package/dist/cli/simple-commands/init/validation/health-checker.d.ts +0 -117
  502. package/dist/cli/simple-commands/init/validation/health-checker.d.ts.map +0 -1
  503. package/dist/cli/simple-commands/init/validation/health-checker.js +0 -539
  504. package/dist/cli/simple-commands/init/validation/health-checker.js.map +0 -1
  505. package/dist/cli/simple-commands/init/validation/index.d.ts +0 -55
  506. package/dist/cli/simple-commands/init/validation/index.d.ts.map +0 -1
  507. package/dist/cli/simple-commands/init/validation/index.js +0 -347
  508. package/dist/cli/simple-commands/init/validation/index.js.map +0 -1
  509. package/dist/cli/simple-commands/init/validation/mode-validator.d.ts +0 -76
  510. package/dist/cli/simple-commands/init/validation/mode-validator.d.ts.map +0 -1
  511. package/dist/cli/simple-commands/init/validation/mode-validator.js +0 -343
  512. package/dist/cli/simple-commands/init/validation/mode-validator.js.map +0 -1
  513. package/dist/cli/simple-commands/init/validation/post-init-validator.d.ts +0 -62
  514. package/dist/cli/simple-commands/init/validation/post-init-validator.d.ts.map +0 -1
  515. package/dist/cli/simple-commands/init/validation/post-init-validator.js +0 -349
  516. package/dist/cli/simple-commands/init/validation/post-init-validator.js.map +0 -1
  517. package/dist/cli/simple-commands/init/validation/pre-init-validator.d.ts +0 -86
  518. package/dist/cli/simple-commands/init/validation/pre-init-validator.d.ts.map +0 -1
  519. package/dist/cli/simple-commands/init/validation/pre-init-validator.js +0 -260
  520. package/dist/cli/simple-commands/init/validation/pre-init-validator.js.map +0 -1
  521. package/dist/cli/simple-commands/mcp.d.ts +0 -2
  522. package/dist/cli/simple-commands/mcp.d.ts.map +0 -1
  523. package/dist/cli/simple-commands/mcp.js +0 -366
  524. package/dist/cli/simple-commands/mcp.js.map +0 -1
  525. package/dist/cli/simple-commands/memory.d.ts +0 -2
  526. package/dist/cli/simple-commands/memory.d.ts.map +0 -1
  527. package/dist/cli/simple-commands/memory.js +0 -278
  528. package/dist/cli/simple-commands/memory.js.map +0 -1
  529. package/dist/cli/simple-commands/migrate-hooks.d.ts +0 -10
  530. package/dist/cli/simple-commands/migrate-hooks.d.ts.map +0 -1
  531. package/dist/cli/simple-commands/migrate-hooks.js +0 -57
  532. package/dist/cli/simple-commands/migrate-hooks.js.map +0 -1
  533. package/dist/cli/simple-commands/monitor.d.ts +0 -3
  534. package/dist/cli/simple-commands/monitor.d.ts.map +0 -1
  535. package/dist/cli/simple-commands/monitor.js +0 -366
  536. package/dist/cli/simple-commands/monitor.js.map +0 -1
  537. package/dist/cli/simple-commands/process-ui-enhanced.d.ts +0 -55
  538. package/dist/cli/simple-commands/process-ui-enhanced.d.ts.map +0 -1
  539. package/dist/cli/simple-commands/process-ui-enhanced.js +0 -680
  540. package/dist/cli/simple-commands/process-ui-enhanced.js.map +0 -1
  541. package/dist/cli/simple-commands/sparc-modes/architect.d.ts +0 -2
  542. package/dist/cli/simple-commands/sparc-modes/architect.d.ts.map +0 -1
  543. package/dist/cli/simple-commands/sparc-modes/architect.js +0 -126
  544. package/dist/cli/simple-commands/sparc-modes/architect.js.map +0 -1
  545. package/dist/cli/simple-commands/sparc-modes/ask.d.ts +0 -2
  546. package/dist/cli/simple-commands/sparc-modes/ask.d.ts.map +0 -1
  547. package/dist/cli/simple-commands/sparc-modes/ask.js +0 -127
  548. package/dist/cli/simple-commands/sparc-modes/ask.js.map +0 -1
  549. package/dist/cli/simple-commands/sparc-modes/code.d.ts +0 -2
  550. package/dist/cli/simple-commands/sparc-modes/code.d.ts.map +0 -1
  551. package/dist/cli/simple-commands/sparc-modes/code.js +0 -149
  552. package/dist/cli/simple-commands/sparc-modes/code.js.map +0 -1
  553. package/dist/cli/simple-commands/sparc-modes/debug.d.ts +0 -2
  554. package/dist/cli/simple-commands/sparc-modes/debug.d.ts.map +0 -1
  555. package/dist/cli/simple-commands/sparc-modes/debug.js +0 -113
  556. package/dist/cli/simple-commands/sparc-modes/debug.js.map +0 -1
  557. package/dist/cli/simple-commands/sparc-modes/devops.d.ts +0 -2
  558. package/dist/cli/simple-commands/sparc-modes/devops.d.ts.map +0 -1
  559. package/dist/cli/simple-commands/sparc-modes/devops.js +0 -138
  560. package/dist/cli/simple-commands/sparc-modes/devops.js.map +0 -1
  561. package/dist/cli/simple-commands/sparc-modes/docs-writer.d.ts +0 -2
  562. package/dist/cli/simple-commands/sparc-modes/docs-writer.d.ts.map +0 -1
  563. package/dist/cli/simple-commands/sparc-modes/docs-writer.js +0 -39
  564. package/dist/cli/simple-commands/sparc-modes/docs-writer.js.map +0 -1
  565. package/dist/cli/simple-commands/sparc-modes/generic.d.ts +0 -2
  566. package/dist/cli/simple-commands/sparc-modes/generic.d.ts.map +0 -1
  567. package/dist/cli/simple-commands/sparc-modes/generic.js +0 -35
  568. package/dist/cli/simple-commands/sparc-modes/generic.js.map +0 -1
  569. package/dist/cli/simple-commands/sparc-modes/index.d.ts +0 -17
  570. package/dist/cli/simple-commands/sparc-modes/index.d.ts.map +0 -1
  571. package/dist/cli/simple-commands/sparc-modes/index.js +0 -196
  572. package/dist/cli/simple-commands/sparc-modes/index.js.map +0 -1
  573. package/dist/cli/simple-commands/sparc-modes/integration.d.ts +0 -2
  574. package/dist/cli/simple-commands/sparc-modes/integration.d.ts.map +0 -1
  575. package/dist/cli/simple-commands/sparc-modes/integration.js +0 -56
  576. package/dist/cli/simple-commands/sparc-modes/integration.js.map +0 -1
  577. package/dist/cli/simple-commands/sparc-modes/mcp.d.ts +0 -2
  578. package/dist/cli/simple-commands/sparc-modes/mcp.d.ts.map +0 -1
  579. package/dist/cli/simple-commands/sparc-modes/mcp.js +0 -39
  580. package/dist/cli/simple-commands/sparc-modes/mcp.js.map +0 -1
  581. package/dist/cli/simple-commands/sparc-modes/monitoring.d.ts +0 -2
  582. package/dist/cli/simple-commands/sparc-modes/monitoring.d.ts.map +0 -1
  583. package/dist/cli/simple-commands/sparc-modes/monitoring.js +0 -39
  584. package/dist/cli/simple-commands/sparc-modes/monitoring.js.map +0 -1
  585. package/dist/cli/simple-commands/sparc-modes/optimization.d.ts +0 -2
  586. package/dist/cli/simple-commands/sparc-modes/optimization.d.ts.map +0 -1
  587. package/dist/cli/simple-commands/sparc-modes/optimization.js +0 -39
  588. package/dist/cli/simple-commands/sparc-modes/optimization.js.map +0 -1
  589. package/dist/cli/simple-commands/sparc-modes/security-review.d.ts +0 -2
  590. package/dist/cli/simple-commands/sparc-modes/security-review.d.ts.map +0 -1
  591. package/dist/cli/simple-commands/sparc-modes/security-review.js +0 -131
  592. package/dist/cli/simple-commands/sparc-modes/security-review.js.map +0 -1
  593. package/dist/cli/simple-commands/sparc-modes/sparc-orchestrator.d.ts +0 -2
  594. package/dist/cli/simple-commands/sparc-modes/sparc-orchestrator.d.ts.map +0 -1
  595. package/dist/cli/simple-commands/sparc-modes/sparc-orchestrator.js +0 -168
  596. package/dist/cli/simple-commands/sparc-modes/sparc-orchestrator.js.map +0 -1
  597. package/dist/cli/simple-commands/sparc-modes/spec-pseudocode.d.ts +0 -2
  598. package/dist/cli/simple-commands/sparc-modes/spec-pseudocode.d.ts.map +0 -1
  599. package/dist/cli/simple-commands/sparc-modes/spec-pseudocode.js +0 -39
  600. package/dist/cli/simple-commands/sparc-modes/spec-pseudocode.js.map +0 -1
  601. package/dist/cli/simple-commands/sparc-modes/supabase-admin.d.ts +0 -2
  602. package/dist/cli/simple-commands/sparc-modes/supabase-admin.d.ts.map +0 -1
  603. package/dist/cli/simple-commands/sparc-modes/supabase-admin.js +0 -150
  604. package/dist/cli/simple-commands/sparc-modes/supabase-admin.js.map +0 -1
  605. package/dist/cli/simple-commands/sparc-modes/swarm.d.ts +0 -81
  606. package/dist/cli/simple-commands/sparc-modes/swarm.d.ts.map +0 -1
  607. package/dist/cli/simple-commands/sparc-modes/swarm.js +0 -428
  608. package/dist/cli/simple-commands/sparc-modes/swarm.js.map +0 -1
  609. package/dist/cli/simple-commands/sparc-modes/tdd.d.ts +0 -2
  610. package/dist/cli/simple-commands/sparc-modes/tdd.d.ts.map +0 -1
  611. package/dist/cli/simple-commands/sparc-modes/tdd.js +0 -113
  612. package/dist/cli/simple-commands/sparc-modes/tdd.js.map +0 -1
  613. package/dist/cli/simple-commands/sparc-modes/tutorial.d.ts +0 -2
  614. package/dist/cli/simple-commands/sparc-modes/tutorial.d.ts.map +0 -1
  615. package/dist/cli/simple-commands/sparc-modes/tutorial.js +0 -278
  616. package/dist/cli/simple-commands/sparc-modes/tutorial.js.map +0 -1
  617. package/dist/cli/simple-commands/sparc.d.ts +0 -2
  618. package/dist/cli/simple-commands/sparc.d.ts.map +0 -1
  619. package/dist/cli/simple-commands/sparc.js +0 -480
  620. package/dist/cli/simple-commands/sparc.js.map +0 -1
  621. package/dist/cli/simple-commands/start-ui.d.ts +0 -2
  622. package/dist/cli/simple-commands/start-ui.d.ts.map +0 -1
  623. package/dist/cli/simple-commands/start-ui.js +0 -135
  624. package/dist/cli/simple-commands/start-ui.js.map +0 -1
  625. package/dist/cli/simple-commands/start-wrapper.d.ts +0 -2
  626. package/dist/cli/simple-commands/start-wrapper.d.ts.map +0 -1
  627. package/dist/cli/simple-commands/start-wrapper.js +0 -264
  628. package/dist/cli/simple-commands/start-wrapper.js.map +0 -1
  629. package/dist/cli/simple-commands/start.d.ts +0 -2
  630. package/dist/cli/simple-commands/start.d.ts.map +0 -1
  631. package/dist/cli/simple-commands/start.js +0 -3
  632. package/dist/cli/simple-commands/start.js.map +0 -1
  633. package/dist/cli/simple-commands/status.d.ts +0 -2
  634. package/dist/cli/simple-commands/status.d.ts.map +0 -1
  635. package/dist/cli/simple-commands/status.js +0 -274
  636. package/dist/cli/simple-commands/status.js.map +0 -1
  637. package/dist/cli/simple-commands/swarm-executor.d.ts +0 -68
  638. package/dist/cli/simple-commands/swarm-executor.d.ts.map +0 -1
  639. package/dist/cli/simple-commands/swarm-executor.js +0 -218
  640. package/dist/cli/simple-commands/swarm-executor.js.map +0 -1
  641. package/dist/cli/simple-commands/swarm-metrics-integration.d.ts +0 -69
  642. package/dist/cli/simple-commands/swarm-metrics-integration.d.ts.map +0 -1
  643. package/dist/cli/simple-commands/swarm-metrics-integration.js +0 -294
  644. package/dist/cli/simple-commands/swarm-metrics-integration.js.map +0 -1
  645. package/dist/cli/simple-commands/swarm-webui-integration.d.ts +0 -68
  646. package/dist/cli/simple-commands/swarm-webui-integration.d.ts.map +0 -1
  647. package/dist/cli/simple-commands/swarm-webui-integration.js +0 -265
  648. package/dist/cli/simple-commands/swarm-webui-integration.js.map +0 -1
  649. package/dist/cli/simple-commands/swarm.d.ts +0 -2
  650. package/dist/cli/simple-commands/swarm.d.ts.map +0 -1
  651. package/dist/cli/simple-commands/swarm.js +0 -1964
  652. package/dist/cli/simple-commands/swarm.js.map +0 -1
  653. package/dist/cli/simple-commands/task.d.ts +0 -2
  654. package/dist/cli/simple-commands/task.d.ts.map +0 -1
  655. package/dist/cli/simple-commands/task.js +0 -190
  656. package/dist/cli/simple-commands/task.js.map +0 -1
  657. package/dist/cli/simple-commands/training.d.ts +0 -2
  658. package/dist/cli/simple-commands/training.d.ts.map +0 -1
  659. package/dist/cli/simple-commands/training.js +0 -240
  660. package/dist/cli/simple-commands/training.js.map +0 -1
  661. package/dist/cli/simple-commands/web-server.d.ts +0 -152
  662. package/dist/cli/simple-commands/web-server.d.ts.map +0 -1
  663. package/dist/cli/simple-commands/web-server.js +0 -816
  664. package/dist/cli/simple-commands/web-server.js.map +0 -1
  665. package/dist/cli/utils/interactive-detector.d.ts +0 -25
  666. package/dist/cli/utils/interactive-detector.d.ts.map +0 -1
  667. package/dist/cli/utils/interactive-detector.js +0 -129
  668. package/dist/cli/utils/interactive-detector.js.map +0 -1
  669. package/dist/cli/utils/safe-interactive.d.ts +0 -30
  670. package/dist/cli/utils/safe-interactive.d.ts.map +0 -1
  671. package/dist/cli/utils/safe-interactive.js +0 -134
  672. package/dist/cli/utils/safe-interactive.js.map +0 -1
  673. package/dist/cli/utils.d.ts +0 -75
  674. package/dist/cli/utils.d.ts.map +0 -1
  675. package/dist/cli/utils.js +0 -567
  676. package/dist/cli/utils.js.map +0 -1
  677. package/dist/config/config-manager.d.ts +0 -212
  678. package/dist/config/config-manager.d.ts.map +0 -1
  679. package/dist/config/config-manager.js +0 -550
  680. package/dist/config/config-manager.js.map +0 -1
  681. package/dist/constants/agent-types.d.ts +0 -55
  682. package/dist/constants/agent-types.d.ts.map +0 -1
  683. package/dist/constants/agent-types.js +0 -66
  684. package/dist/constants/agent-types.js.map +0 -1
  685. package/dist/coordination/advanced-scheduler.d.ts +0 -121
  686. package/dist/coordination/advanced-scheduler.d.ts.map +0 -1
  687. package/dist/coordination/advanced-scheduler.js +0 -382
  688. package/dist/coordination/advanced-scheduler.js.map +0 -1
  689. package/dist/coordination/background-executor.d.ts +0 -69
  690. package/dist/coordination/background-executor.d.ts.map +0 -1
  691. package/dist/coordination/background-executor.js +0 -363
  692. package/dist/coordination/background-executor.js.map +0 -1
  693. package/dist/coordination/circuit-breaker.d.ts +0 -124
  694. package/dist/coordination/circuit-breaker.d.ts.map +0 -1
  695. package/dist/coordination/circuit-breaker.js +0 -301
  696. package/dist/coordination/circuit-breaker.js.map +0 -1
  697. package/dist/coordination/conflict-resolution.d.ts +0 -133
  698. package/dist/coordination/conflict-resolution.d.ts.map +0 -1
  699. package/dist/coordination/conflict-resolution.js +0 -360
  700. package/dist/coordination/conflict-resolution.js.map +0 -1
  701. package/dist/coordination/dependency-graph.d.ts +0 -78
  702. package/dist/coordination/dependency-graph.d.ts.map +0 -1
  703. package/dist/coordination/dependency-graph.js +0 -387
  704. package/dist/coordination/dependency-graph.js.map +0 -1
  705. package/dist/coordination/manager.d.ts +0 -66
  706. package/dist/coordination/manager.d.ts.map +0 -1
  707. package/dist/coordination/manager.js +0 -354
  708. package/dist/coordination/manager.js.map +0 -1
  709. package/dist/coordination/messaging.d.ts +0 -37
  710. package/dist/coordination/messaging.d.ts.map +0 -1
  711. package/dist/coordination/messaging.js +0 -219
  712. package/dist/coordination/messaging.js.map +0 -1
  713. package/dist/coordination/metrics.d.ts +0 -153
  714. package/dist/coordination/metrics.d.ts.map +0 -1
  715. package/dist/coordination/metrics.js +0 -436
  716. package/dist/coordination/metrics.js.map +0 -1
  717. package/dist/coordination/resources.d.ts +0 -36
  718. package/dist/coordination/resources.d.ts.map +0 -1
  719. package/dist/coordination/resources.js +0 -254
  720. package/dist/coordination/resources.js.map +0 -1
  721. package/dist/coordination/scheduler.d.ts +0 -48
  722. package/dist/coordination/scheduler.d.ts.map +0 -1
  723. package/dist/coordination/scheduler.js +0 -308
  724. package/dist/coordination/scheduler.js.map +0 -1
  725. package/dist/coordination/swarm-coordinator.d.ts +0 -116
  726. package/dist/coordination/swarm-coordinator.d.ts.map +0 -1
  727. package/dist/coordination/swarm-coordinator.js +0 -563
  728. package/dist/coordination/swarm-coordinator.js.map +0 -1
  729. package/dist/coordination/swarm-monitor.d.ts +0 -101
  730. package/dist/coordination/swarm-monitor.d.ts.map +0 -1
  731. package/dist/coordination/swarm-monitor.js +0 -340
  732. package/dist/coordination/swarm-monitor.js.map +0 -1
  733. package/dist/coordination/work-stealing.d.ts +0 -44
  734. package/dist/coordination/work-stealing.d.ts.map +0 -1
  735. package/dist/coordination/work-stealing.js +0 -158
  736. package/dist/coordination/work-stealing.js.map +0 -1
  737. package/dist/core/config.d.ts +0 -243
  738. package/dist/core/config.d.ts.map +0 -1
  739. package/dist/core/config.js +0 -1125
  740. package/dist/core/config.js.map +0 -1
  741. package/dist/core/event-bus.d.ts +0 -63
  742. package/dist/core/event-bus.d.ts.map +0 -1
  743. package/dist/core/event-bus.js +0 -153
  744. package/dist/core/event-bus.js.map +0 -1
  745. package/dist/core/json-persistence.d.ts +0 -55
  746. package/dist/core/json-persistence.d.ts.map +0 -1
  747. package/dist/core/json-persistence.js +0 -111
  748. package/dist/core/json-persistence.js.map +0 -1
  749. package/dist/core/logger.d.ts +0 -62
  750. package/dist/core/logger.d.ts.map +0 -1
  751. package/dist/core/logger.js +0 -252
  752. package/dist/core/logger.js.map +0 -1
  753. package/dist/core/orchestrator-fixed.d.ts +0 -81
  754. package/dist/core/orchestrator-fixed.d.ts.map +0 -1
  755. package/dist/core/orchestrator-fixed.js +0 -213
  756. package/dist/core/orchestrator-fixed.js.map +0 -1
  757. package/dist/core/orchestrator.d.ts +0 -123
  758. package/dist/core/orchestrator.d.ts.map +0 -1
  759. package/dist/core/orchestrator.js +0 -1058
  760. package/dist/core/orchestrator.js.map +0 -1
  761. package/dist/enterprise/analytics-manager.d.ts +0 -489
  762. package/dist/enterprise/analytics-manager.d.ts.map +0 -1
  763. package/dist/enterprise/analytics-manager.js +0 -956
  764. package/dist/enterprise/analytics-manager.js.map +0 -1
  765. package/dist/enterprise/audit-manager.d.ts +0 -459
  766. package/dist/enterprise/audit-manager.d.ts.map +0 -1
  767. package/dist/enterprise/audit-manager.js +0 -1014
  768. package/dist/enterprise/audit-manager.js.map +0 -1
  769. package/dist/enterprise/cloud-manager.d.ts +0 -435
  770. package/dist/enterprise/cloud-manager.d.ts.map +0 -1
  771. package/dist/enterprise/cloud-manager.js +0 -789
  772. package/dist/enterprise/cloud-manager.js.map +0 -1
  773. package/dist/enterprise/deployment-manager.d.ts +0 -328
  774. package/dist/enterprise/deployment-manager.d.ts.map +0 -1
  775. package/dist/enterprise/deployment-manager.js +0 -830
  776. package/dist/enterprise/deployment-manager.js.map +0 -1
  777. package/dist/enterprise/project-manager.d.ts +0 -228
  778. package/dist/enterprise/project-manager.d.ts.map +0 -1
  779. package/dist/enterprise/project-manager.js +0 -537
  780. package/dist/enterprise/project-manager.js.map +0 -1
  781. package/dist/enterprise/security-manager.d.ts +0 -422
  782. package/dist/enterprise/security-manager.d.ts.map +0 -1
  783. package/dist/enterprise/security-manager.js +0 -910
  784. package/dist/enterprise/security-manager.js.map +0 -1
  785. package/dist/hive-mind/core/Agent.d.ts +0 -137
  786. package/dist/hive-mind/core/Agent.d.ts.map +0 -1
  787. package/dist/hive-mind/core/Agent.js +0 -567
  788. package/dist/hive-mind/core/Agent.js.map +0 -1
  789. package/dist/hive-mind/core/Communication.d.ts +0 -116
  790. package/dist/hive-mind/core/Communication.d.ts.map +0 -1
  791. package/dist/hive-mind/core/Communication.js +0 -407
  792. package/dist/hive-mind/core/Communication.js.map +0 -1
  793. package/dist/hive-mind/core/DatabaseManager.d.ts +0 -99
  794. package/dist/hive-mind/core/DatabaseManager.d.ts.map +0 -1
  795. package/dist/hive-mind/core/DatabaseManager.js +0 -648
  796. package/dist/hive-mind/core/DatabaseManager.js.map +0 -1
  797. package/dist/hive-mind/core/HiveMind.d.ts +0 -90
  798. package/dist/hive-mind/core/HiveMind.d.ts.map +0 -1
  799. package/dist/hive-mind/core/HiveMind.js +0 -455
  800. package/dist/hive-mind/core/HiveMind.js.map +0 -1
  801. package/dist/hive-mind/core/Memory.d.ts +0 -235
  802. package/dist/hive-mind/core/Memory.d.ts.map +0 -1
  803. package/dist/hive-mind/core/Memory.js +0 -1192
  804. package/dist/hive-mind/core/Memory.js.map +0 -1
  805. package/dist/hive-mind/core/Queen.d.ts +0 -115
  806. package/dist/hive-mind/core/Queen.d.ts.map +0 -1
  807. package/dist/hive-mind/core/Queen.js +0 -649
  808. package/dist/hive-mind/core/Queen.js.map +0 -1
  809. package/dist/hive-mind/integration/ConsensusEngine.d.ts +0 -117
  810. package/dist/hive-mind/integration/ConsensusEngine.d.ts.map +0 -1
  811. package/dist/hive-mind/integration/ConsensusEngine.js +0 -478
  812. package/dist/hive-mind/integration/ConsensusEngine.js.map +0 -1
  813. package/dist/hive-mind/integration/MCPToolWrapper.d.ts +0 -172
  814. package/dist/hive-mind/integration/MCPToolWrapper.d.ts.map +0 -1
  815. package/dist/hive-mind/integration/MCPToolWrapper.js +0 -217
  816. package/dist/hive-mind/integration/MCPToolWrapper.js.map +0 -1
  817. package/dist/hive-mind/integration/SwarmOrchestrator.d.ts +0 -172
  818. package/dist/hive-mind/integration/SwarmOrchestrator.d.ts.map +0 -1
  819. package/dist/hive-mind/integration/SwarmOrchestrator.js +0 -748
  820. package/dist/hive-mind/integration/SwarmOrchestrator.js.map +0 -1
  821. package/dist/hive-mind/types.d.ts +0 -314
  822. package/dist/hive-mind/types.d.ts.map +0 -1
  823. package/dist/hive-mind/types.js +0 -7
  824. package/dist/hive-mind/types.js.map +0 -1
  825. package/dist/mcp/auth.d.ts +0 -80
  826. package/dist/mcp/auth.d.ts.map +0 -1
  827. package/dist/mcp/auth.js +0 -350
  828. package/dist/mcp/auth.js.map +0 -1
  829. package/dist/mcp/claude-flow-tools.d.ts +0 -13
  830. package/dist/mcp/claude-flow-tools.d.ts.map +0 -1
  831. package/dist/mcp/claude-flow-tools.js +0 -1176
  832. package/dist/mcp/claude-flow-tools.js.map +0 -1
  833. package/dist/mcp/load-balancer.d.ts +0 -88
  834. package/dist/mcp/load-balancer.d.ts.map +0 -1
  835. package/dist/mcp/load-balancer.js +0 -393
  836. package/dist/mcp/load-balancer.js.map +0 -1
  837. package/dist/mcp/router.d.ts +0 -54
  838. package/dist/mcp/router.d.ts.map +0 -1
  839. package/dist/mcp/router.js +0 -204
  840. package/dist/mcp/router.js.map +0 -1
  841. package/dist/mcp/ruv-swarm-tools.d.ts +0 -58
  842. package/dist/mcp/ruv-swarm-tools.d.ts.map +0 -1
  843. package/dist/mcp/ruv-swarm-tools.js +0 -548
  844. package/dist/mcp/ruv-swarm-tools.js.map +0 -1
  845. package/dist/mcp/server.d.ts +0 -75
  846. package/dist/mcp/server.d.ts.map +0 -1
  847. package/dist/mcp/server.js +0 -538
  848. package/dist/mcp/server.js.map +0 -1
  849. package/dist/mcp/session-manager.d.ts +0 -60
  850. package/dist/mcp/session-manager.d.ts.map +0 -1
  851. package/dist/mcp/session-manager.js +0 -323
  852. package/dist/mcp/session-manager.js.map +0 -1
  853. package/dist/mcp/swarm-tools.d.ts +0 -87
  854. package/dist/mcp/swarm-tools.d.ts.map +0 -1
  855. package/dist/mcp/swarm-tools.js +0 -731
  856. package/dist/mcp/swarm-tools.js.map +0 -1
  857. package/dist/mcp/tools.d.ts +0 -145
  858. package/dist/mcp/tools.d.ts.map +0 -1
  859. package/dist/mcp/tools.js +0 -434
  860. package/dist/mcp/tools.js.map +0 -1
  861. package/dist/mcp/transports/base.d.ts +0 -22
  862. package/dist/mcp/transports/base.d.ts.map +0 -1
  863. package/dist/mcp/transports/base.js +0 -5
  864. package/dist/mcp/transports/base.js.map +0 -1
  865. package/dist/mcp/transports/http.d.ts +0 -48
  866. package/dist/mcp/transports/http.d.ts.map +0 -1
  867. package/dist/mcp/transports/http.js +0 -400
  868. package/dist/mcp/transports/http.js.map +0 -1
  869. package/dist/mcp/transports/stdio.d.ts +0 -37
  870. package/dist/mcp/transports/stdio.d.ts.map +0 -1
  871. package/dist/mcp/transports/stdio.js +0 -206
  872. package/dist/mcp/transports/stdio.js.map +0 -1
  873. package/dist/memory/advanced-serializer.d.ts +0 -159
  874. package/dist/memory/advanced-serializer.d.ts.map +0 -1
  875. package/dist/memory/advanced-serializer.js +0 -564
  876. package/dist/memory/advanced-serializer.js.map +0 -1
  877. package/dist/memory/backends/base.d.ts +0 -21
  878. package/dist/memory/backends/base.d.ts.map +0 -1
  879. package/dist/memory/backends/base.js +0 -5
  880. package/dist/memory/backends/base.js.map +0 -1
  881. package/dist/memory/backends/markdown.d.ts +0 -35
  882. package/dist/memory/backends/markdown.d.ts.map +0 -1
  883. package/dist/memory/backends/markdown.js +0 -223
  884. package/dist/memory/backends/markdown.js.map +0 -1
  885. package/dist/memory/backends/sqlite.d.ts +0 -33
  886. package/dist/memory/backends/sqlite.d.ts.map +0 -1
  887. package/dist/memory/backends/sqlite.js +0 -291
  888. package/dist/memory/backends/sqlite.js.map +0 -1
  889. package/dist/memory/cache.d.ts +0 -65
  890. package/dist/memory/cache.d.ts.map +0 -1
  891. package/dist/memory/cache.js +0 -188
  892. package/dist/memory/cache.js.map +0 -1
  893. package/dist/memory/distributed-memory.d.ts +0 -188
  894. package/dist/memory/distributed-memory.d.ts.map +0 -1
  895. package/dist/memory/distributed-memory.js +0 -710
  896. package/dist/memory/distributed-memory.js.map +0 -1
  897. package/dist/memory/enhanced-session-serializer.d.ts +0 -115
  898. package/dist/memory/enhanced-session-serializer.d.ts.map +0 -1
  899. package/dist/memory/enhanced-session-serializer.js +0 -478
  900. package/dist/memory/enhanced-session-serializer.js.map +0 -1
  901. package/dist/memory/fallback-store.d.ts +0 -28
  902. package/dist/memory/fallback-store.d.ts.map +0 -1
  903. package/dist/memory/fallback-store.js +0 -101
  904. package/dist/memory/fallback-store.js.map +0 -1
  905. package/dist/memory/in-memory-store.d.ts +0 -37
  906. package/dist/memory/in-memory-store.d.ts.map +0 -1
  907. package/dist/memory/in-memory-store.js +0 -174
  908. package/dist/memory/in-memory-store.js.map +0 -1
  909. package/dist/memory/indexer.d.ts +0 -52
  910. package/dist/memory/indexer.d.ts.map +0 -1
  911. package/dist/memory/indexer.js +0 -191
  912. package/dist/memory/indexer.js.map +0 -1
  913. package/dist/memory/manager.d.ts +0 -58
  914. package/dist/memory/manager.d.ts.map +0 -1
  915. package/dist/memory/manager.js +0 -423
  916. package/dist/memory/manager.js.map +0 -1
  917. package/dist/memory/sqlite-store.d.ts +0 -34
  918. package/dist/memory/sqlite-store.d.ts.map +0 -1
  919. package/dist/memory/sqlite-store.js +0 -267
  920. package/dist/memory/sqlite-store.js.map +0 -1
  921. package/dist/memory/sqlite-wrapper.d.ts +0 -38
  922. package/dist/memory/sqlite-wrapper.d.ts.map +0 -1
  923. package/dist/memory/sqlite-wrapper.js +0 -152
  924. package/dist/memory/sqlite-wrapper.js.map +0 -1
  925. package/dist/memory/swarm-memory.d.ts +0 -91
  926. package/dist/memory/swarm-memory.d.ts.map +0 -1
  927. package/dist/memory/swarm-memory.js +0 -454
  928. package/dist/memory/swarm-memory.js.map +0 -1
  929. package/dist/migration/logger.d.ts +0 -26
  930. package/dist/migration/logger.d.ts.map +0 -1
  931. package/dist/migration/logger.js +0 -145
  932. package/dist/migration/logger.js.map +0 -1
  933. package/dist/migration/migration-analyzer.d.ts +0 -18
  934. package/dist/migration/migration-analyzer.d.ts.map +0 -1
  935. package/dist/migration/migration-analyzer.js +0 -284
  936. package/dist/migration/migration-analyzer.js.map +0 -1
  937. package/dist/migration/migration-runner.d.ts +0 -26
  938. package/dist/migration/migration-runner.d.ts.map +0 -1
  939. package/dist/migration/migration-runner.js +0 -505
  940. package/dist/migration/migration-runner.js.map +0 -1
  941. package/dist/migration/migration-validator.d.ts +0 -17
  942. package/dist/migration/migration-validator.d.ts.map +0 -1
  943. package/dist/migration/migration-validator.js +0 -309
  944. package/dist/migration/migration-validator.js.map +0 -1
  945. package/dist/migration/progress-reporter.d.ts +0 -28
  946. package/dist/migration/progress-reporter.d.ts.map +0 -1
  947. package/dist/migration/progress-reporter.js +0 -163
  948. package/dist/migration/progress-reporter.js.map +0 -1
  949. package/dist/migration/rollback-manager.d.ts +0 -24
  950. package/dist/migration/rollback-manager.d.ts.map +0 -1
  951. package/dist/migration/rollback-manager.js +0 -351
  952. package/dist/migration/rollback-manager.js.map +0 -1
  953. package/dist/migration/types.d.ts +0 -103
  954. package/dist/migration/types.d.ts.map +0 -1
  955. package/dist/migration/types.js +0 -6
  956. package/dist/migration/types.js.map +0 -1
  957. package/dist/swarm/types.d.ts +0 -578
  958. package/dist/swarm/types.d.ts.map +0 -1
  959. package/dist/swarm/types.js +0 -54
  960. package/dist/swarm/types.js.map +0 -1
  961. package/dist/terminal/adapters/base.d.ts +0 -40
  962. package/dist/terminal/adapters/base.d.ts.map +0 -1
  963. package/dist/terminal/adapters/base.js +0 -5
  964. package/dist/terminal/adapters/base.js.map +0 -1
  965. package/dist/terminal/adapters/native.d.ts +0 -19
  966. package/dist/terminal/adapters/native.d.ts.map +0 -1
  967. package/dist/terminal/adapters/native.js +0 -414
  968. package/dist/terminal/adapters/native.js.map +0 -1
  969. package/dist/terminal/adapters/vscode.d.ts +0 -23
  970. package/dist/terminal/adapters/vscode.d.ts.map +0 -1
  971. package/dist/terminal/adapters/vscode.js +0 -267
  972. package/dist/terminal/adapters/vscode.js.map +0 -1
  973. package/dist/terminal/manager.d.ts +0 -59
  974. package/dist/terminal/manager.d.ts.map +0 -1
  975. package/dist/terminal/manager.js +0 -235
  976. package/dist/terminal/manager.js.map +0 -1
  977. package/dist/terminal/pool.d.ts +0 -32
  978. package/dist/terminal/pool.d.ts.map +0 -1
  979. package/dist/terminal/pool.js +0 -208
  980. package/dist/terminal/pool.js.map +0 -1
  981. package/dist/terminal/session.d.ts +0 -41
  982. package/dist/terminal/session.d.ts.map +0 -1
  983. package/dist/terminal/session.js +0 -210
  984. package/dist/terminal/session.js.map +0 -1
  985. package/dist/utils/error-handler.d.ts +0 -14
  986. package/dist/utils/error-handler.d.ts.map +0 -1
  987. package/dist/utils/error-handler.js +0 -29
  988. package/dist/utils/error-handler.js.map +0 -1
  989. package/dist/utils/errors.d.ts +0 -121
  990. package/dist/utils/errors.d.ts.map +0 -1
  991. package/dist/utils/errors.js +0 -194
  992. package/dist/utils/errors.js.map +0 -1
  993. package/dist/utils/formatters.d.ts +0 -15
  994. package/dist/utils/formatters.d.ts.map +0 -1
  995. package/dist/utils/formatters.js +0 -75
  996. package/dist/utils/formatters.js.map +0 -1
  997. package/dist/utils/helpers.d.ts +0 -134
  998. package/dist/utils/helpers.d.ts.map +0 -1
  999. package/dist/utils/helpers.js +0 -444
  1000. package/dist/utils/helpers.js.map +0 -1
  1001. package/dist/utils/npx-isolated-cache.d.ts +0 -17
  1002. package/dist/utils/npx-isolated-cache.d.ts.map +0 -1
  1003. package/dist/utils/npx-isolated-cache.js +0 -140
  1004. package/dist/utils/npx-isolated-cache.js.map +0 -1
  1005. package/dist/utils/type-guards.d.ts +0 -117
  1006. package/dist/utils/type-guards.d.ts.map +0 -1
  1007. package/dist/utils/type-guards.js +0 -166
  1008. package/dist/utils/type-guards.js.map +0 -1
  1009. package/dist/utils/types.d.ts +0 -568
  1010. package/dist/utils/types.d.ts.map +0 -1
  1011. package/dist/utils/types.js +0 -37
  1012. package/dist/utils/types.js.map +0 -1
@@ -1,2430 +0,0 @@
1
- /**
2
- * Hive Mind command for Claude-Flow v2.0.0
3
- * Advanced swarm intelligence with collective decision-making
4
- */
5
- import { spawn } from 'child_process';
6
- import { existsSync, mkdirSync } from 'fs';
7
- import { writeFile, readFile } from 'fs/promises';
8
- import path from 'path';
9
- import readline from 'readline';
10
- import inquirer from 'inquirer';
11
- import chalk from 'chalk';
12
- import ora from 'ora';
13
- import { args, cwd, exit, writeTextFile, readTextFile, mkdirAsync } from '../node-compat.js';
14
- import { isInteractive, isRawModeSupported, warnNonInteractive, checkNonInteractiveAuth, } from '../utils/interactive-detector.js';
15
- import { safeInteractive, nonInteractiveProgress, nonInteractiveSelect, } from '../utils/safe-interactive.js';
16
- // Import SQLite for persistence
17
- import Database from 'better-sqlite3';
18
- // Import help formatter
19
- import { HelpFormatter } from '../help-formatter.js';
20
- // Import MCP tool wrappers
21
- import { MCPToolWrapper } from './hive-mind/mcp-wrapper.js';
22
- import { HiveMindCore } from './hive-mind/core.js';
23
- import { QueenCoordinator } from './hive-mind/queen.js';
24
- import { CollectiveMemory } from './hive-mind/memory.js';
25
- import { SwarmCommunication } from './hive-mind/communication.js';
26
- import { HiveMindSessionManager } from './hive-mind/session-manager.js';
27
- import { createAutoSaveMiddleware } from './hive-mind/auto-save-middleware.js';
28
- function showHiveMindHelp() {
29
- console.log(`
30
- ${chalk.yellow('🧠 Claude Flow Hive Mind System')}
31
-
32
- ${chalk.bold('USAGE:')}
33
- claude-flow hive-mind [subcommand] [options]
34
-
35
- ${chalk.bold('SUBCOMMANDS:')}
36
- ${chalk.green('init')} Initialize hive mind system
37
- ${chalk.green('spawn')} Spawn hive mind swarm for a task
38
- ${chalk.green('status')} Show hive mind status
39
- ${chalk.green('resume')} Resume a paused hive mind session
40
- ${chalk.green('stop')} Stop a running hive mind session
41
- ${chalk.green('sessions')} List all hive mind sessions
42
- ${chalk.green('consensus')} View consensus decisions
43
- ${chalk.green('memory')} Manage collective memory
44
- ${chalk.green('metrics')} View performance metrics
45
- ${chalk.green('wizard')} Interactive hive mind wizard
46
-
47
- ${chalk.bold('EXAMPLES:')}
48
- ${chalk.gray('# Initialize hive mind')}
49
- claude-flow hive-mind init
50
-
51
- ${chalk.gray('# Spawn swarm with interactive wizard')}
52
- claude-flow hive-mind spawn
53
-
54
- ${chalk.gray('# Quick spawn with objective')}
55
- claude-flow hive-mind spawn "Build microservices architecture"
56
-
57
- ${chalk.gray('# View current status')}
58
- claude-flow hive-mind status
59
-
60
- ${chalk.gray('# Interactive wizard')}
61
- claude-flow hive-mind wizard
62
-
63
- ${chalk.gray('# Spawn with Claude Code coordination')}
64
- claude-flow hive-mind spawn "Build REST API" --claude
65
-
66
- ${chalk.gray('# Auto-spawn coordinated Claude Code instances')}
67
- claude-flow hive-mind spawn "Research AI trends" --auto-spawn --verbose
68
-
69
- ${chalk.gray('# List all sessions')}
70
- claude-flow hive-mind sessions
71
-
72
- ${chalk.gray('# Resume a paused session')}
73
- claude-flow hive-mind resume session-1234567890-abc123
74
-
75
- ${chalk.bold('KEY FEATURES:')}
76
- ${chalk.cyan('🐝')} Queen-led coordination with worker specialization
77
- ${chalk.cyan('🧠')} Collective memory and knowledge sharing
78
- ${chalk.cyan('🀝')} Consensus building for critical decisions
79
- ${chalk.cyan('⚑')} Parallel task execution with auto-scaling
80
- ${chalk.cyan('πŸ”„')} Work stealing and load balancing
81
- ${chalk.cyan('πŸ“Š')} Real-time metrics and performance tracking
82
- ${chalk.cyan('πŸ›‘οΈ')} Fault tolerance and self-healing
83
- ${chalk.cyan('πŸ”’')} Secure communication between agents
84
-
85
- ${chalk.bold('OPTIONS:')}
86
- --queen-type <type> Queen coordinator type (strategic, tactical, adaptive)
87
- --max-workers <n> Maximum worker agents (default: 8)
88
- --consensus <type> Consensus algorithm (majority, weighted, byzantine)
89
- --memory-size <mb> Collective memory size in MB (default: 100)
90
- --auto-scale Enable auto-scaling based on workload
91
- --encryption Enable encrypted communication
92
- --monitor Real-time monitoring dashboard
93
- --verbose Detailed logging
94
- --claude Generate Claude Code spawn commands with coordination
95
- --spawn Alias for --claude
96
- --auto-spawn Automatically spawn Claude Code instances
97
- --execute Execute Claude Code spawn commands immediately
98
-
99
- ${chalk.bold('For more information:')}
100
- ${chalk.blue('https://github.com/ruvnet/claude-flow/tree/main/docs/hive-mind')}
101
- `);
102
- }
103
- /**
104
- * Initialize hive mind system
105
- */
106
- async function initHiveMind(flags) {
107
- const spinner = ora('Initializing Hive Mind system...').start();
108
- try {
109
- // Create hive mind directory structure
110
- const hiveMindDir = path.join(cwd(), '.hive-mind');
111
- if (!existsSync(hiveMindDir)) {
112
- mkdirSync(hiveMindDir, { recursive: true });
113
- }
114
- // Initialize SQLite database
115
- const dbPath = path.join(hiveMindDir, 'hive.db');
116
- const db = new Database(dbPath);
117
- // Create tables
118
- db.exec(`
119
- CREATE TABLE IF NOT EXISTS swarms (
120
- id TEXT PRIMARY KEY,
121
- name TEXT NOT NULL,
122
- objective TEXT,
123
- status TEXT DEFAULT 'active',
124
- queen_type TEXT DEFAULT 'strategic',
125
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
126
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
127
- );
128
-
129
- CREATE TABLE IF NOT EXISTS agents (
130
- id TEXT PRIMARY KEY,
131
- swarm_id TEXT,
132
- name TEXT NOT NULL,
133
- type TEXT NOT NULL,
134
- role TEXT,
135
- status TEXT DEFAULT 'idle',
136
- capabilities TEXT,
137
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
138
- FOREIGN KEY (swarm_id) REFERENCES swarms(id)
139
- );
140
-
141
- CREATE TABLE IF NOT EXISTS tasks (
142
- id TEXT PRIMARY KEY,
143
- swarm_id TEXT,
144
- agent_id TEXT,
145
- description TEXT,
146
- status TEXT DEFAULT 'pending',
147
- priority INTEGER DEFAULT 5,
148
- result TEXT,
149
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
150
- completed_at DATETIME,
151
- FOREIGN KEY (swarm_id) REFERENCES swarms(id),
152
- FOREIGN KEY (agent_id) REFERENCES agents(id)
153
- );
154
-
155
- CREATE TABLE IF NOT EXISTS collective_memory (
156
- id TEXT PRIMARY KEY,
157
- swarm_id TEXT,
158
- key TEXT NOT NULL,
159
- value TEXT,
160
- type TEXT DEFAULT 'knowledge',
161
- confidence REAL DEFAULT 1.0,
162
- created_by TEXT,
163
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
164
- accessed_at DATETIME,
165
- access_count INTEGER DEFAULT 0,
166
- compressed INTEGER DEFAULT 0,
167
- size INTEGER DEFAULT 0,
168
- FOREIGN KEY (swarm_id) REFERENCES swarms(id)
169
- );
170
-
171
- CREATE TABLE IF NOT EXISTS consensus_decisions (
172
- id TEXT PRIMARY KEY,
173
- swarm_id TEXT,
174
- topic TEXT NOT NULL,
175
- decision TEXT,
176
- votes TEXT,
177
- algorithm TEXT DEFAULT 'majority',
178
- confidence REAL,
179
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
180
- FOREIGN KEY (swarm_id) REFERENCES swarms(id)
181
- );
182
- `);
183
- db.close();
184
- // Create configuration file
185
- const config = {
186
- version: '2.0.0',
187
- initialized: new Date().toISOString(),
188
- defaults: {
189
- queenType: 'strategic',
190
- maxWorkers: 8,
191
- consensusAlgorithm: 'majority',
192
- memorySize: 100,
193
- autoScale: true,
194
- encryption: false,
195
- },
196
- mcpTools: {
197
- enabled: true,
198
- parallel: true,
199
- timeout: 60000,
200
- },
201
- };
202
- await writeFile(path.join(hiveMindDir, 'config.json'), JSON.stringify(config, null, 2));
203
- spinner.succeed('Hive Mind system initialized successfully!');
204
- console.log('\n' + chalk.green('βœ“') + ' Created .hive-mind directory');
205
- console.log(chalk.green('βœ“') + ' Initialized SQLite database');
206
- console.log(chalk.green('βœ“') + ' Created configuration file');
207
- console.log('\n' + chalk.yellow('Next steps:'));
208
- console.log(' 1. Run ' + chalk.cyan('claude-flow hive-mind spawn') + ' to create your first swarm');
209
- console.log(' 2. Use ' + chalk.cyan('claude-flow hive-mind wizard') + ' for interactive setup');
210
- }
211
- catch (error) {
212
- spinner.fail('Failed to initialize Hive Mind system');
213
- console.error(chalk.red('Error:'), error.message);
214
- exit(1);
215
- }
216
- }
217
- /**
218
- * Interactive wizard for hive mind operations
219
- */
220
- // Wrapped wizard function that handles non-interactive environments
221
- const hiveMindWizard = safeInteractive(
222
- // Interactive version
223
- async function (flags = {}) {
224
- console.log(chalk.yellow('\nπŸ§™ Hive Mind Interactive Wizard\n'));
225
- const { action } = await inquirer.prompt([
226
- {
227
- type: 'list',
228
- name: 'action',
229
- message: 'What would you like to do?',
230
- choices: [
231
- { name: '🐝 Create new swarm', value: 'spawn' },
232
- { name: 'πŸ“Š View swarm status', value: 'status' },
233
- { name: '🧠 Manage collective memory', value: 'memory' },
234
- { name: '🀝 View consensus decisions', value: 'consensus' },
235
- { name: 'πŸ“ˆ Performance metrics', value: 'metrics' },
236
- { name: 'πŸ”§ Configure hive mind', value: 'config' },
237
- { name: '❌ Exit', value: 'exit' },
238
- ],
239
- },
240
- ]);
241
- switch (action) {
242
- case 'spawn':
243
- await spawnSwarmWizard();
244
- break;
245
- case 'status':
246
- await showStatus({});
247
- break;
248
- case 'memory':
249
- await manageMemoryWizard();
250
- break;
251
- case 'consensus':
252
- await showConsensus({});
253
- break;
254
- case 'metrics':
255
- await showMetrics({});
256
- break;
257
- case 'config':
258
- await configureWizard();
259
- break;
260
- case 'exit':
261
- console.log(chalk.gray('Exiting wizard...'));
262
- break;
263
- }
264
- },
265
- // Non-interactive fallback
266
- async function (flags = {}) {
267
- console.log(chalk.yellow('\nπŸ§™ Hive Mind - Non-Interactive Mode\n'));
268
- // Default to creating a swarm with sensible defaults
269
- console.log(chalk.cyan('Creating new swarm with default settings...'));
270
- console.log(chalk.gray('Use command-line flags to customize:'));
271
- console.log(chalk.gray(' --objective "Your task" Set swarm objective'));
272
- console.log(chalk.gray(' --queen-type strategic Set queen type'));
273
- console.log(chalk.gray(' --max-workers 8 Set worker count'));
274
- console.log();
275
- const objective = flags.objective || 'General task coordination';
276
- const config = {
277
- name: flags.name || `swarm-${Date.now()}`,
278
- queenType: flags.queenType || flags['queen-type'] || 'strategic',
279
- maxWorkers: parseInt(flags.maxWorkers || flags['max-workers'] || '8'),
280
- consensusAlgorithm: flags.consensus || flags.consensusAlgorithm || 'majority',
281
- autoScale: flags.autoScale || flags['auto-scale'] || false,
282
- namespace: flags.namespace || 'default',
283
- verbose: flags.verbose || false,
284
- encryption: flags.encryption || false,
285
- };
286
- await spawnSwarm([objective], {
287
- ...flags,
288
- name: config.name,
289
- queenType: config.queenType,
290
- maxWorkers: config.maxWorkers,
291
- consensusAlgorithm: config.consensusAlgorithm,
292
- autoScale: config.autoScale,
293
- encryption: config.encryption,
294
- nonInteractive: true,
295
- });
296
- });
297
- /**
298
- * Spawn swarm wizard
299
- */
300
- async function spawnSwarmWizard() {
301
- const answers = await inquirer.prompt([
302
- {
303
- type: 'input',
304
- name: 'objective',
305
- message: 'What is the swarm objective?',
306
- validate: (input) => input.trim().length > 0 || 'Please enter an objective',
307
- },
308
- {
309
- type: 'input',
310
- name: 'name',
311
- message: 'Swarm name (optional):',
312
- default: (answers) => `swarm-${Date.now()}`,
313
- },
314
- {
315
- type: 'list',
316
- name: 'queenType',
317
- message: 'Select queen coordinator type:',
318
- choices: [
319
- { name: 'Strategic - High-level planning and coordination', value: 'strategic' },
320
- { name: 'Tactical - Detailed task management', value: 'tactical' },
321
- { name: 'Adaptive - Learns and adapts strategies', value: 'adaptive' },
322
- ],
323
- default: 'strategic',
324
- },
325
- {
326
- type: 'number',
327
- name: 'maxWorkers',
328
- message: 'Maximum number of worker agents:',
329
- default: 8,
330
- validate: (input) => (input > 0 && input <= 20) || 'Please enter a number between 1 and 20',
331
- },
332
- {
333
- type: 'checkbox',
334
- name: 'workerTypes',
335
- message: 'Select worker agent types:',
336
- choices: [
337
- { name: 'Researcher', value: 'researcher', checked: true },
338
- { name: 'Coder', value: 'coder', checked: true },
339
- { name: 'Analyst', value: 'analyst', checked: true },
340
- { name: 'Tester', value: 'tester', checked: true },
341
- { name: 'Architect', value: 'architect' },
342
- { name: 'Reviewer', value: 'reviewer' },
343
- { name: 'Optimizer', value: 'optimizer' },
344
- { name: 'Documenter', value: 'documenter' },
345
- ],
346
- },
347
- {
348
- type: 'list',
349
- name: 'consensusAlgorithm',
350
- message: 'Consensus algorithm for decisions:',
351
- choices: [
352
- { name: 'Majority - Simple majority voting', value: 'majority' },
353
- { name: 'Weighted - Expertise-weighted voting', value: 'weighted' },
354
- { name: 'Byzantine - Fault-tolerant consensus', value: 'byzantine' },
355
- ],
356
- default: 'majority',
357
- },
358
- {
359
- type: 'confirm',
360
- name: 'autoScale',
361
- message: 'Enable auto-scaling?',
362
- default: true,
363
- },
364
- {
365
- type: 'confirm',
366
- name: 'monitor',
367
- message: 'Launch monitoring dashboard?',
368
- default: true,
369
- },
370
- ]);
371
- // Spawn the swarm with collected parameters
372
- await spawnSwarm([answers.objective], {
373
- name: answers.name,
374
- queenType: answers.queenType,
375
- 'queen-type': answers.queenType,
376
- maxWorkers: answers.maxWorkers,
377
- 'max-workers': answers.maxWorkers,
378
- workerTypes: answers.workerTypes.join(','),
379
- consensus: answers.consensusAlgorithm,
380
- autoScale: answers.autoScale,
381
- 'auto-scale': answers.autoScale,
382
- monitor: answers.monitor,
383
- namespace: answers.namespace || 'default',
384
- verbose: answers.verbose || false,
385
- });
386
- }
387
- /**
388
- * Spawn a hive mind swarm
389
- */
390
- async function spawnSwarm(args, flags) {
391
- const objective = args.join(' ').trim();
392
- if (!objective && !flags.wizard) {
393
- console.error(chalk.red('Error: Please provide an objective or use --wizard flag'));
394
- console.log('Example: claude-flow hive-mind spawn "Build REST API"');
395
- return;
396
- }
397
- // Validate parameters
398
- if (flags.verbose) {
399
- console.log(chalk.gray('πŸ” Debug: Parsed flags:'));
400
- console.log(chalk.gray(JSON.stringify(flags, null, 2)));
401
- }
402
- // Validate queen type
403
- const validQueenTypes = ['strategic', 'tactical', 'adaptive'];
404
- const queenType = flags.queenType || flags['queen-type'] || 'strategic';
405
- if (!validQueenTypes.includes(queenType)) {
406
- console.error(chalk.red(`Error: Invalid queen type '${queenType}'. Must be one of: ${validQueenTypes.join(', ')}`));
407
- return;
408
- }
409
- // Validate max workers
410
- const maxWorkers = parseInt(flags.maxWorkers || flags['max-workers'] || '8');
411
- if (isNaN(maxWorkers) || maxWorkers < 1 || maxWorkers > 20) {
412
- console.error(chalk.red('Error: max-workers must be a number between 1 and 20'));
413
- return;
414
- }
415
- // Validate consensus algorithm
416
- const validConsensusTypes = ['majority', 'weighted', 'byzantine'];
417
- const consensusAlgorithm = flags.consensus || flags.consensusAlgorithm || 'majority';
418
- if (!validConsensusTypes.includes(consensusAlgorithm)) {
419
- console.error(chalk.red(`Error: Invalid consensus algorithm '${consensusAlgorithm}'. Must be one of: ${validConsensusTypes.join(', ')}`));
420
- return;
421
- }
422
- const spinner = ora('Spawning Hive Mind swarm...').start();
423
- try {
424
- // Initialize hive mind core with error handling
425
- let hiveMind;
426
- try {
427
- spinner.text = 'Initializing Hive Mind Core...';
428
- hiveMind = new HiveMindCore({
429
- objective,
430
- name: flags.name || `hive-${Date.now()}`,
431
- queenType: flags.queenType || flags['queen-type'] || 'strategic',
432
- maxWorkers: parseInt(flags.maxWorkers || flags['max-workers'] || '8'),
433
- consensusAlgorithm: flags.consensus || flags.consensusAlgorithm || 'majority',
434
- autoScale: flags.autoScale !== undefined ? flags.autoScale : (flags['auto-scale'] !== undefined ? flags['auto-scale'] : true),
435
- namespace: flags.namespace || 'default',
436
- encryption: flags.encryption || false,
437
- });
438
- }
439
- catch (error) {
440
- console.error('HiveMindCore initialization failed:', error);
441
- throw new Error(`Failed to initialize HiveMindCore: ${error.message}`);
442
- }
443
- spinner.text = 'Setting up database connection...';
444
- // Initialize database connection
445
- const dbDir = path.join(cwd(), '.hive-mind');
446
- const dbPath = path.join(dbDir, 'hive.db');
447
- // Ensure .hive-mind directory exists
448
- if (!existsSync(dbDir)) {
449
- mkdirSync(dbDir, { recursive: true });
450
- }
451
- // Check if database file exists and try to create a clean one if needed
452
- let db;
453
- try {
454
- spinner.text = 'Creating database connection...';
455
- db = new Database(dbPath);
456
- // Test the database with a simple query
457
- db.prepare('SELECT 1').get();
458
- spinner.text = 'Database connection established';
459
- }
460
- catch (error) {
461
- console.warn('Database issue detected, recreating...', error.message);
462
- spinner.text = 'Recreating database...';
463
- // Remove corrupted database
464
- if (existsSync(dbPath)) {
465
- try {
466
- const fs = await import('fs');
467
- fs.unlinkSync(dbPath);
468
- }
469
- catch (e) {
470
- console.warn('Could not remove corrupted database:', e.message);
471
- }
472
- }
473
- // Create new database
474
- db = new Database(dbPath);
475
- }
476
- // Initialize database schema if not exists
477
- spinner.text = 'Creating database schema...';
478
- try {
479
- db.exec(`
480
- CREATE TABLE IF NOT EXISTS swarms (
481
- id TEXT PRIMARY KEY,
482
- name TEXT NOT NULL,
483
- objective TEXT,
484
- queen_type TEXT,
485
- status TEXT DEFAULT 'active',
486
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
487
- updated_at DATETIME
488
- );
489
-
490
- CREATE TABLE IF NOT EXISTS agents (
491
- id TEXT PRIMARY KEY,
492
- swarm_id TEXT NOT NULL,
493
- name TEXT NOT NULL,
494
- type TEXT NOT NULL,
495
- role TEXT NOT NULL,
496
- status TEXT DEFAULT 'idle',
497
- capabilities TEXT,
498
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
499
- FOREIGN KEY (swarm_id) REFERENCES swarms(id)
500
- );
501
-
502
- CREATE TABLE IF NOT EXISTS tasks (
503
- id TEXT PRIMARY KEY,
504
- swarm_id TEXT NOT NULL,
505
- agent_id TEXT,
506
- description TEXT,
507
- status TEXT DEFAULT 'pending',
508
- priority INTEGER DEFAULT 5,
509
- result TEXT,
510
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
511
- completed_at DATETIME,
512
- FOREIGN KEY (swarm_id) REFERENCES swarms(id),
513
- FOREIGN KEY (agent_id) REFERENCES agents(id)
514
- );
515
-
516
- CREATE TABLE IF NOT EXISTS collective_memory (
517
- id TEXT PRIMARY KEY,
518
- swarm_id TEXT,
519
- key TEXT NOT NULL,
520
- value TEXT,
521
- type TEXT DEFAULT 'knowledge',
522
- confidence REAL DEFAULT 1.0,
523
- created_by TEXT,
524
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
525
- accessed_at DATETIME,
526
- access_count INTEGER DEFAULT 0,
527
- compressed INTEGER DEFAULT 0,
528
- size INTEGER DEFAULT 0,
529
- FOREIGN KEY (swarm_id) REFERENCES swarms(id)
530
- );
531
-
532
- CREATE TABLE IF NOT EXISTS consensus_decisions (
533
- id TEXT PRIMARY KEY,
534
- swarm_id TEXT,
535
- topic TEXT NOT NULL,
536
- decision TEXT,
537
- votes TEXT,
538
- algorithm TEXT DEFAULT 'majority',
539
- confidence REAL,
540
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
541
- FOREIGN KEY (swarm_id) REFERENCES swarms(id)
542
- );
543
- `);
544
- spinner.text = 'Database schema created successfully';
545
- }
546
- catch (error) {
547
- console.error('Database schema creation failed:', error);
548
- throw new Error(`Failed to create database schema: ${error.message}`);
549
- }
550
- // Create swarm record with safe ID generation
551
- spinner.text = 'Creating swarm record...';
552
- const timestamp = Date.now();
553
- const randomPart = Math.random().toString(36).substring(2, 11); // Use substring instead of substr
554
- const swarmId = `swarm-${timestamp}-${randomPart}`;
555
- try {
556
- db.prepare(`
557
- INSERT INTO swarms (id, name, objective, queen_type)
558
- VALUES (?, ?, ?, ?)
559
- `).run(swarmId, hiveMind.config.name, objective, hiveMind.config.queenType);
560
- }
561
- catch (error) {
562
- console.error('Failed to create swarm record:', error);
563
- throw new Error(`Failed to create swarm record: ${error.message}`);
564
- }
565
- // Create session for this swarm
566
- spinner.text = 'Creating session tracking...';
567
- const sessionManager = new HiveMindSessionManager();
568
- const sessionId = await sessionManager.createSession(swarmId, hiveMind.config.name, objective, {
569
- queenType: hiveMind.config.queenType,
570
- maxWorkers: hiveMind.config.maxWorkers,
571
- consensusAlgorithm: hiveMind.config.consensusAlgorithm,
572
- autoScale: hiveMind.config.autoScale,
573
- encryption: hiveMind.config.encryption,
574
- workerTypes: flags.workerTypes,
575
- });
576
- spinner.text = 'Session tracking established...';
577
- // Initialize auto-save middleware (use the same session manager)
578
- const autoSave = createAutoSaveMiddleware(sessionId, sessionManager, {
579
- saveInterval: 30000, // Save every 30 seconds
580
- autoStart: true,
581
- });
582
- // Close session manager after auto-save is set up
583
- // sessionManager.close(); // Don't close yet as auto-save needs it
584
- // Track initial swarm creation
585
- autoSave.trackChange('swarm_created', {
586
- swarmId,
587
- swarmName: hiveMind.config.name,
588
- objective,
589
- workerCount: hiveMind.config.maxWorkers,
590
- });
591
- spinner.text = 'Initializing Queen coordinator...';
592
- // Initialize Queen
593
- const queen = new QueenCoordinator({
594
- swarmId,
595
- type: hiveMind.config.queenType,
596
- objective,
597
- });
598
- // Spawn Queen agent
599
- const queenAgent = {
600
- id: `queen-${swarmId}`,
601
- swarmId,
602
- name: 'Queen Coordinator',
603
- type: 'coordinator',
604
- role: 'queen',
605
- status: 'active',
606
- capabilities: JSON.stringify(['coordination', 'planning', 'decision-making']),
607
- };
608
- db.prepare(`
609
- INSERT INTO agents (id, swarm_id, name, type, role, status, capabilities)
610
- VALUES (?, ?, ?, ?, ?, ?, ?)
611
- `).run(...Object.values(queenAgent));
612
- spinner.text = 'Spawning worker agents...';
613
- // Determine worker types
614
- const workerTypes = flags.workerTypes
615
- ? flags.workerTypes.split(',')
616
- : ['researcher', 'coder', 'analyst', 'tester'];
617
- // Spawn worker agents
618
- const workers = [];
619
- for (let i = 0; i < Math.min(workerTypes.length, hiveMind.config.maxWorkers); i++) {
620
- const workerType = workerTypes[i % workerTypes.length];
621
- const workerId = `worker-${swarmId}-${i}`;
622
- const worker = {
623
- id: workerId,
624
- swarmId,
625
- name: `${workerType.charAt(0).toUpperCase() + workerType.slice(1)} Worker ${i + 1}`,
626
- type: workerType,
627
- role: 'worker',
628
- status: 'idle',
629
- capabilities: JSON.stringify(getAgentCapabilities(workerType)),
630
- };
631
- workers.push(worker);
632
- db.prepare(`
633
- INSERT INTO agents (id, swarm_id, name, type, role, status, capabilities)
634
- VALUES (?, ?, ?, ?, ?, ?, ?)
635
- `).run(...Object.values(worker));
636
- // Track agent spawning for auto-save
637
- autoSave.trackAgentActivity(workerId, 'spawned', {
638
- type: workerType,
639
- name: worker.name,
640
- });
641
- }
642
- spinner.text = 'Initializing collective memory...';
643
- // Initialize collective memory
644
- const memory = new CollectiveMemory({
645
- swarmId,
646
- maxSize: flags.memorySize || 100,
647
- });
648
- // Store initial context
649
- memory.store('objective', objective, 'context');
650
- memory.store('queen_type', hiveMind.config.queenType, 'config');
651
- memory.store('worker_count', workers.length, 'metrics');
652
- memory.store('session_id', sessionId, 'system');
653
- spinner.text = 'Establishing communication channels...';
654
- // Initialize communication system
655
- const communication = new SwarmCommunication({
656
- swarmId,
657
- encryption: hiveMind.config.encryption,
658
- });
659
- db.close();
660
- spinner.succeed('Hive Mind swarm spawned successfully!');
661
- // Display swarm summary
662
- console.log('\n' + chalk.bold('🐝 Swarm Summary:'));
663
- console.log(chalk.gray('─'.repeat(50)));
664
- console.log(chalk.cyan('Swarm ID:'), swarmId);
665
- console.log(chalk.cyan('Session ID:'), sessionId);
666
- console.log(chalk.cyan('Name:'), hiveMind.config.name);
667
- console.log(chalk.cyan('Objective:'), objective);
668
- console.log(chalk.cyan('Queen Type:'), hiveMind.config.queenType);
669
- console.log(chalk.cyan('Workers:'), workers.length);
670
- console.log(chalk.cyan('Worker Types:'), workerTypes.join(', '));
671
- console.log(chalk.cyan('Consensus:'), hiveMind.config.consensusAlgorithm);
672
- console.log(chalk.cyan('Auto-scaling:'), hiveMind.config.autoScale ? 'Enabled' : 'Disabled');
673
- console.log(chalk.gray('─'.repeat(50)));
674
- // Launch monitoring if requested
675
- if (flags.monitor) {
676
- console.log('\n' + chalk.yellow('Launching monitoring dashboard...'));
677
- // TODO: Implement monitoring dashboard
678
- }
679
- // Enhanced coordination instructions with MCP tools
680
- console.log('\n' + chalk.green('βœ“') + ' Swarm is ready for coordination');
681
- console.log(chalk.gray('Use "claude-flow hive-mind status" to view swarm activity'));
682
- console.log(chalk.gray('Session auto-save enabled - progress saved every 30 seconds'));
683
- console.log(chalk.blue('πŸ’‘ To pause:') + ' Press Ctrl+C to safely pause and resume later');
684
- console.log(chalk.blue('πŸ’‘ To resume:') + ' claude-flow hive-mind resume ' + sessionId);
685
- // Set up SIGINT handler for automatic session pausing
686
- let isExiting = false;
687
- const sigintHandler = async () => {
688
- if (isExiting)
689
- return;
690
- isExiting = true;
691
- console.log('\n\n' + chalk.yellow('⏸️ Pausing session...'));
692
- try {
693
- // Save current checkpoint using the existing session manager
694
- // const sessionManager = new HiveMindSessionManager(); // Use existing one
695
- // Create checkpoint data
696
- const checkpointData = {
697
- timestamp: new Date().toISOString(),
698
- swarmId,
699
- objective,
700
- workerCount: workers.length,
701
- workerTypes,
702
- status: 'paused_by_user',
703
- reason: 'User pressed Ctrl+C',
704
- };
705
- // Save checkpoint
706
- await sessionManager.saveCheckpoint(sessionId, 'auto-pause', checkpointData);
707
- // Pause the session
708
- await sessionManager.pauseSession(sessionId);
709
- // Close session manager
710
- sessionManager.close();
711
- console.log(chalk.green('βœ“') + ' Session paused successfully');
712
- console.log(chalk.cyan('\nTo resume this session, run:'));
713
- console.log(chalk.bold(` claude-flow hive-mind resume ${sessionId}`));
714
- console.log();
715
- // Clean up auto-save if active
716
- if (global.autoSaveInterval) {
717
- clearInterval(global.autoSaveInterval);
718
- }
719
- process.exit(0);
720
- }
721
- catch (error) {
722
- console.error(chalk.red('Error pausing session:'), error.message);
723
- process.exit(1);
724
- }
725
- };
726
- // Register SIGINT handler
727
- process.on('SIGINT', sigintHandler);
728
- process.on('SIGTERM', sigintHandler);
729
- // Offer to spawn Claude Code instances with coordination instructions
730
- if (flags.claude || flags.spawn) {
731
- await spawnClaudeCodeInstances(swarmId, hiveMind.config.name, objective, workers, flags);
732
- }
733
- else {
734
- console.log('\n' +
735
- chalk.blue('πŸ’‘ Pro Tip:') +
736
- ' Add --claude to spawn coordinated Claude Code instances');
737
- console.log(chalk.gray(' claude-flow hive-mind spawn "objective" --claude'));
738
- }
739
- }
740
- catch (error) {
741
- spinner.fail('Failed to spawn Hive Mind swarm');
742
- console.error(chalk.red('Error:'), error.message);
743
- // If error contains "sha3", provide specific guidance
744
- if (error.message.includes('sha3') || error.message.includes('SHA3')) {
745
- console.error('\nπŸ” SHA3 Function Error Detected');
746
- console.error('This appears to be a SQLite extension or better-sqlite3 configuration issue.');
747
- console.error('\nPossible solutions:');
748
- console.error('1. Try removing the corrupted database: rm -rf .hive-mind/');
749
- console.error('2. Reinstall better-sqlite3: npm reinstall better-sqlite3');
750
- console.error('3. Check if any SQLite extensions are conflicting');
751
- console.error('\n🚨 Detailed error:');
752
- console.error(error.stack || error.message);
753
- }
754
- exit(1);
755
- }
756
- }
757
- /**
758
- * Get agent capabilities based on type
759
- */
760
- function getAgentCapabilities(type) {
761
- const capabilities = {
762
- researcher: ['web-search', 'data-gathering', 'analysis', 'synthesis'],
763
- coder: ['code-generation', 'implementation', 'refactoring', 'debugging'],
764
- analyst: ['data-analysis', 'pattern-recognition', 'reporting', 'visualization'],
765
- tester: ['test-generation', 'quality-assurance', 'bug-detection', 'validation'],
766
- architect: ['system-design', 'architecture', 'planning', 'documentation'],
767
- reviewer: ['code-review', 'quality-check', 'feedback', 'improvement'],
768
- optimizer: ['performance-tuning', 'optimization', 'profiling', 'enhancement'],
769
- documenter: ['documentation', 'explanation', 'tutorial-creation', 'knowledge-base'],
770
- };
771
- return capabilities[type] || ['general'];
772
- }
773
- /**
774
- * Show hive mind status
775
- */
776
- async function showStatus(flags) {
777
- try {
778
- const dbPath = path.join(cwd(), '.hive-mind', 'hive.db');
779
- if (!existsSync(dbPath)) {
780
- console.error(chalk.red('Error: Hive Mind not initialized'));
781
- console.log('Run "claude-flow hive-mind init" first');
782
- return;
783
- }
784
- const db = new Database(dbPath);
785
- // Get active swarms
786
- const swarms = db
787
- .prepare(`
788
- SELECT * FROM swarms
789
- WHERE status = 'active'
790
- ORDER BY created_at DESC
791
- `)
792
- .all();
793
- if (swarms.length === 0) {
794
- console.log(chalk.gray('No active swarms found'));
795
- db.close();
796
- return;
797
- }
798
- console.log(chalk.bold('\n🐝 Active Hive Mind Swarms\n'));
799
- for (const swarm of swarms) {
800
- console.log(chalk.yellow('═'.repeat(60)));
801
- console.log(chalk.cyan('Swarm:'), swarm.name);
802
- console.log(chalk.cyan('ID:'), swarm.id);
803
- console.log(chalk.cyan('Objective:'), swarm.objective);
804
- console.log(chalk.cyan('Queen Type:'), swarm.queen_type);
805
- console.log(chalk.cyan('Status:'), chalk.green(swarm.status));
806
- console.log(chalk.cyan('Created:'), new Date(swarm.created_at).toLocaleString());
807
- // Get agents
808
- const agents = db
809
- .prepare(`
810
- SELECT * FROM agents
811
- WHERE swarm_id = ?
812
- `)
813
- .all(swarm.id);
814
- console.log('\n' + chalk.bold('Agents:'));
815
- // Group by role
816
- const queen = agents.find((a) => a.role === 'queen');
817
- const workers = agents.filter((a) => a.role === 'worker');
818
- if (queen) {
819
- console.log(' ' + chalk.magenta('πŸ‘‘ Queen:'), queen.name, chalk.gray(`(${queen.status})`));
820
- }
821
- console.log(' ' + chalk.blue('🐝 Workers:'));
822
- workers.forEach((worker) => {
823
- const statusColor = worker.status === 'active' ? 'green' : worker.status === 'busy' ? 'yellow' : 'gray';
824
- console.log(` - ${worker.name} (${worker.type}) ${chalk[statusColor](worker.status)}`);
825
- });
826
- // Get task statistics
827
- const taskStats = db
828
- .prepare(`
829
- SELECT
830
- COUNT(*) as total,
831
- SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed,
832
- SUM(CASE WHEN status = 'in_progress' THEN 1 ELSE 0 END) as in_progress,
833
- SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending
834
- FROM tasks
835
- WHERE swarm_id = ?
836
- `)
837
- .get(swarm.id);
838
- console.log('\n' + chalk.bold('Tasks:'));
839
- console.log(` Total: ${taskStats.total}`);
840
- console.log(` Completed: ${chalk.green(taskStats.completed)}`);
841
- console.log(` In Progress: ${chalk.yellow(taskStats.in_progress)}`);
842
- console.log(` Pending: ${chalk.gray(taskStats.pending)}`);
843
- // Get memory stats
844
- const memoryCount = db
845
- .prepare(`
846
- SELECT COUNT(*) as count FROM collective_memory
847
- WHERE swarm_id = ?
848
- `)
849
- .get(swarm.id);
850
- console.log('\n' + chalk.bold('Collective Memory:'));
851
- console.log(` Entries: ${memoryCount.count}`);
852
- // Get consensus stats
853
- const consensusCount = db
854
- .prepare(`
855
- SELECT COUNT(*) as count FROM consensus_decisions
856
- WHERE swarm_id = ?
857
- `)
858
- .get(swarm.id);
859
- console.log('\n' + chalk.bold('Consensus Decisions:'));
860
- console.log(` Total: ${consensusCount.count}`);
861
- }
862
- console.log(chalk.yellow('═'.repeat(60)) + '\n');
863
- db.close();
864
- }
865
- catch (error) {
866
- console.error(chalk.red('Error:'), error.message);
867
- exit(1);
868
- }
869
- }
870
- /**
871
- * Show consensus decisions
872
- */
873
- async function showConsensus(flags) {
874
- try {
875
- const dbPath = path.join(cwd(), '.hive-mind', 'hive.db');
876
- const db = new Database(dbPath);
877
- const decisions = db
878
- .prepare(`
879
- SELECT cd.*, s.name as swarm_name
880
- FROM consensus_decisions cd
881
- JOIN swarms s ON cd.swarm_id = s.id
882
- ORDER BY cd.created_at DESC
883
- LIMIT 20
884
- `)
885
- .all();
886
- if (decisions.length === 0) {
887
- console.log(chalk.gray('No consensus decisions found'));
888
- db.close();
889
- return;
890
- }
891
- console.log(chalk.bold('\n🀝 Recent Consensus Decisions\n'));
892
- decisions.forEach((decision) => {
893
- console.log(chalk.yellow('─'.repeat(50)));
894
- console.log(chalk.cyan('Swarm:'), decision.swarm_name);
895
- console.log(chalk.cyan('Topic:'), decision.topic);
896
- console.log(chalk.cyan('Decision:'), decision.decision);
897
- console.log(chalk.cyan('Algorithm:'), decision.algorithm);
898
- console.log(chalk.cyan('Confidence:'), `${(decision.confidence * 100).toFixed(1)}%`);
899
- console.log(chalk.cyan('Time:'), new Date(decision.created_at).toLocaleString());
900
- if (decision.votes) {
901
- const votes = JSON.parse(decision.votes);
902
- console.log(chalk.cyan('Votes:'));
903
- // Handle vote summary format (for/against/abstain/details)
904
- if (votes.for !== undefined || votes.against !== undefined || votes.abstain !== undefined) {
905
- console.log(` - for: ${votes.for || 0}`);
906
- console.log(` - against: ${votes.against || 0}`);
907
- console.log(` - abstain: ${votes.abstain || 0}`);
908
- // Display vote details properly if they exist
909
- if (votes.details && Array.isArray(votes.details)) {
910
- console.log(' - details:');
911
- votes.details.forEach((detail, index) => {
912
- if (typeof detail === 'object') {
913
- // Extract available fields
914
- const agent = detail.agentId ||
915
- detail.agent ||
916
- detail.id ||
917
- detail.name ||
918
- `agent-${index + 1}`;
919
- const vote = detail.vote || detail.choice || detail.decision || 'unknown';
920
- const reason = detail.reason || detail.justification || detail.rationale;
921
- // Build display string
922
- let displayString = ` ${index + 1}. Agent: ${agent}, Vote: ${vote}`;
923
- // Add reason if available
924
- if (reason && reason !== 'N/A' && reason !== '') {
925
- displayString += `, Reason: ${reason}`;
926
- }
927
- console.log(displayString);
928
- }
929
- else {
930
- console.log(` ${index + 1}. ${detail}`);
931
- }
932
- });
933
- }
934
- }
935
- else {
936
- // Handle individual agent votes format
937
- Object.entries(votes).forEach(([agent, vote]) => {
938
- console.log(` - ${agent}: ${vote}`);
939
- });
940
- }
941
- }
942
- });
943
- console.log(chalk.yellow('─'.repeat(50)) + '\n');
944
- db.close();
945
- }
946
- catch (error) {
947
- console.error(chalk.red('Error:'), error.message);
948
- exit(1);
949
- }
950
- }
951
- /**
952
- * Show performance metrics
953
- */
954
- async function showMetrics(flags) {
955
- try {
956
- const dbPath = path.join(cwd(), '.hive-mind', 'hive.db');
957
- const db = new Database(dbPath);
958
- // Get overall metrics
959
- const overallStats = db
960
- .prepare(`
961
- SELECT
962
- (SELECT COUNT(*) FROM swarms) as total_swarms,
963
- (SELECT COUNT(*) FROM agents) as total_agents,
964
- (SELECT COUNT(*) FROM tasks) as total_tasks,
965
- (SELECT COUNT(*) FROM tasks WHERE status = 'completed') as completed_tasks
966
- `)
967
- .get();
968
- console.log(chalk.bold('\nπŸ“Š Hive Mind Performance Metrics\n'));
969
- // Get task status breakdown
970
- const taskBreakdown = db
971
- .prepare(`
972
- SELECT
973
- status,
974
- COUNT(*) as count
975
- FROM tasks
976
- GROUP BY status
977
- ORDER BY count DESC
978
- `)
979
- .all();
980
- console.log(chalk.cyan('Overall Statistics:'));
981
- console.log(` Total Swarms: ${overallStats.total_swarms}`);
982
- console.log(` Total Agents: ${overallStats.total_agents}`);
983
- console.log(` Total Tasks: ${overallStats.total_tasks}`);
984
- console.log(` Completed Tasks: ${overallStats.completed_tasks}`);
985
- console.log(` Success Rate: ${overallStats.total_tasks > 0
986
- ? ((overallStats.completed_tasks / overallStats.total_tasks) * 100).toFixed(1) + '%'
987
- : 'N/A'}`);
988
- if (taskBreakdown.length > 0) {
989
- console.log('\n' + chalk.cyan('Task Status Breakdown:'));
990
- taskBreakdown.forEach((status) => {
991
- const percentage = overallStats.total_tasks > 0
992
- ? ((status.count / overallStats.total_tasks) * 100).toFixed(1)
993
- : '0';
994
- const statusColor = status.status === 'completed'
995
- ? 'green'
996
- : status.status === 'in_progress'
997
- ? 'yellow'
998
- : status.status === 'failed'
999
- ? 'red'
1000
- : 'gray';
1001
- console.log(` ${chalk[statusColor](status.status.charAt(0).toUpperCase() + status.status.slice(1))}: ${status.count} (${percentage}%)`);
1002
- });
1003
- }
1004
- // Get agent performance (check for completed_at column)
1005
- let agentPerf = [];
1006
- try {
1007
- // Check if completed_at exists
1008
- const hasCompletedAt = db
1009
- .prepare(`
1010
- SELECT COUNT(*) as count FROM pragma_table_info('tasks')
1011
- WHERE name = 'completed_at'
1012
- `)
1013
- .get();
1014
- if (hasCompletedAt && hasCompletedAt.count > 0) {
1015
- agentPerf = db
1016
- .prepare(`
1017
- SELECT
1018
- a.name,
1019
- a.type,
1020
- COUNT(t.id) as tasks_assigned,
1021
- SUM(CASE WHEN t.status = 'completed' THEN 1 ELSE 0 END) as tasks_completed,
1022
- AVG(CASE WHEN t.completed_at IS NOT NULL
1023
- THEN (julianday(t.completed_at) - julianday(t.created_at)) * 24 * 60
1024
- ELSE NULL END) as avg_completion_minutes
1025
- FROM agents a
1026
- LEFT JOIN tasks t ON a.id = t.agent_id
1027
- GROUP BY a.id
1028
- HAVING tasks_assigned > 0
1029
- ORDER BY tasks_completed DESC
1030
- LIMIT 10
1031
- `)
1032
- .all();
1033
- }
1034
- else {
1035
- // Simpler query without completed_at
1036
- agentPerf = db
1037
- .prepare(`
1038
- SELECT
1039
- a.name,
1040
- a.type,
1041
- COUNT(t.id) as tasks_assigned,
1042
- SUM(CASE WHEN t.status = 'completed' THEN 1 ELSE 0 END) as tasks_completed,
1043
- NULL as avg_completion_minutes
1044
- FROM agents a
1045
- LEFT JOIN tasks t ON a.id = t.agent_id
1046
- GROUP BY a.id
1047
- HAVING tasks_assigned > 0
1048
- ORDER BY tasks_completed DESC
1049
- LIMIT 10
1050
- `)
1051
- .all();
1052
- }
1053
- }
1054
- catch (error) {
1055
- console.warn('Could not get agent performance:', error.message);
1056
- }
1057
- if (agentPerf.length > 0) {
1058
- console.log('\n' + chalk.cyan('Top Performing Agents:'));
1059
- agentPerf.forEach((agent, index) => {
1060
- const successRate = agent.tasks_assigned > 0
1061
- ? ((agent.tasks_completed / agent.tasks_assigned) * 100).toFixed(1)
1062
- : '0';
1063
- console.log(` ${index + 1}. ${agent.name} (${agent.type})`);
1064
- console.log(` Tasks: ${agent.tasks_completed}/${agent.tasks_assigned} (${successRate}%)`);
1065
- if (agent.avg_completion_minutes) {
1066
- console.log(` Avg Time: ${agent.avg_completion_minutes.toFixed(1)} minutes`);
1067
- }
1068
- });
1069
- }
1070
- // Get swarm performance
1071
- const swarmPerf = db
1072
- .prepare(`
1073
- SELECT
1074
- s.name,
1075
- s.objective,
1076
- (SELECT COUNT(*) FROM agents a WHERE a.swarm_id = s.id) as agent_count,
1077
- (SELECT COUNT(*) FROM tasks t WHERE t.swarm_id = s.id) as task_count,
1078
- (SELECT COUNT(*) FROM tasks t WHERE t.swarm_id = s.id AND t.status = 'completed') as completed_count,
1079
- (SELECT COUNT(*) FROM collective_memory cm WHERE cm.swarm_id = s.id) as memory_entries,
1080
- (SELECT COUNT(*) FROM consensus_decisions cd WHERE cd.swarm_id = s.id) as consensus_count
1081
- FROM swarms s
1082
- WHERE s.status = 'active'
1083
- ORDER BY s.created_at DESC
1084
- LIMIT 5
1085
- `)
1086
- .all();
1087
- if (swarmPerf.length > 0) {
1088
- console.log('\n' + chalk.cyan('Active Swarm Performance:'));
1089
- swarmPerf.forEach((swarm) => {
1090
- const successRate = swarm.task_count > 0
1091
- ? ((swarm.completed_count / swarm.task_count) * 100).toFixed(1)
1092
- : '0';
1093
- console.log(`\n ${chalk.yellow(swarm.name)}`);
1094
- console.log(` Objective: ${swarm.objective.substring(0, 50)}...`);
1095
- console.log(` Agents: ${swarm.agent_count}, Tasks: ${swarm.completed_count}/${swarm.task_count} (${successRate}%)`);
1096
- console.log(` Memory: ${swarm.memory_entries} entries, Consensus: ${swarm.consensus_count} decisions`);
1097
- });
1098
- }
1099
- // Get performance insights
1100
- let avgTaskTime = { avg_minutes: null };
1101
- try {
1102
- // Check if completed_at exists
1103
- const hasCompletedAt = db
1104
- .prepare(`
1105
- SELECT COUNT(*) as count FROM pragma_table_info('tasks')
1106
- WHERE name = 'completed_at'
1107
- `)
1108
- .get();
1109
- if (hasCompletedAt && hasCompletedAt.count > 0) {
1110
- avgTaskTime = db
1111
- .prepare(`
1112
- SELECT
1113
- AVG(CASE WHEN completed_at IS NOT NULL
1114
- THEN (julianday(completed_at) - julianday(created_at)) * 24 * 60
1115
- ELSE NULL END) as avg_minutes
1116
- FROM tasks
1117
- WHERE status = 'completed'
1118
- `)
1119
- .get();
1120
- }
1121
- }
1122
- catch (error) {
1123
- console.warn('Could not calculate average task time:', error.message);
1124
- }
1125
- // Get agent type performance
1126
- let agentTypePerf = [];
1127
- try {
1128
- // Check if completed_at exists
1129
- const hasCompletedAt = db
1130
- .prepare(`
1131
- SELECT COUNT(*) as count FROM pragma_table_info('tasks')
1132
- WHERE name = 'completed_at'
1133
- `)
1134
- .get();
1135
- if (hasCompletedAt && hasCompletedAt.count > 0) {
1136
- agentTypePerf = db
1137
- .prepare(`
1138
- SELECT
1139
- a.type,
1140
- COUNT(t.id) as total_tasks,
1141
- SUM(CASE WHEN t.status = 'completed' THEN 1 ELSE 0 END) as completed_tasks,
1142
- AVG(CASE WHEN t.completed_at IS NOT NULL
1143
- THEN (julianday(t.completed_at) - julianday(t.created_at)) * 24 * 60
1144
- ELSE NULL END) as avg_completion_minutes
1145
- FROM agents a
1146
- LEFT JOIN tasks t ON a.id = t.agent_id
1147
- GROUP BY a.type
1148
- HAVING total_tasks > 0
1149
- ORDER BY completed_tasks DESC
1150
- `)
1151
- .all();
1152
- }
1153
- else {
1154
- // Simpler query without completed_at
1155
- agentTypePerf = db
1156
- .prepare(`
1157
- SELECT
1158
- a.type,
1159
- COUNT(t.id) as total_tasks,
1160
- SUM(CASE WHEN t.status = 'completed' THEN 1 ELSE 0 END) as completed_tasks,
1161
- NULL as avg_completion_minutes
1162
- FROM agents a
1163
- LEFT JOIN tasks t ON a.id = t.agent_id
1164
- GROUP BY a.type
1165
- HAVING total_tasks > 0
1166
- ORDER BY completed_tasks DESC
1167
- `)
1168
- .all();
1169
- }
1170
- }
1171
- catch (error) {
1172
- console.warn('Could not get agent type performance:', error.message);
1173
- }
1174
- if (avgTaskTime.avg_minutes) {
1175
- console.log('\n' + chalk.cyan('Performance Insights:'));
1176
- console.log(` Average Task Completion Time: ${avgTaskTime.avg_minutes.toFixed(1)} minutes`);
1177
- if (agentTypePerf.length > 0) {
1178
- console.log('\n' + chalk.cyan('Agent Type Performance:'));
1179
- agentTypePerf.forEach((type) => {
1180
- const successRate = type.total_tasks > 0
1181
- ? ((type.completed_tasks / type.total_tasks) * 100).toFixed(1)
1182
- : '0';
1183
- console.log(` ${type.type.charAt(0).toUpperCase() + type.type.slice(1)}: ${type.completed_tasks}/${type.total_tasks} (${successRate}%)`);
1184
- if (type.avg_completion_minutes) {
1185
- console.log(` Average time: ${type.avg_completion_minutes.toFixed(1)} minutes`);
1186
- }
1187
- });
1188
- }
1189
- }
1190
- console.log('\n');
1191
- db.close();
1192
- }
1193
- catch (error) {
1194
- console.error(chalk.red('Error:'), error.message);
1195
- exit(1);
1196
- }
1197
- }
1198
- /**
1199
- * Manage collective memory wizard
1200
- */
1201
- async function manageMemoryWizard() {
1202
- console.log(chalk.blue('\n🧠 Collective Memory Management\n'));
1203
- const { action } = await inquirer.prompt([
1204
- {
1205
- type: 'list',
1206
- name: 'action',
1207
- message: 'What would you like to do with collective memory?',
1208
- choices: [
1209
- { name: 'πŸ“‹ View all memories', value: 'list' },
1210
- { name: 'πŸ” Search memories', value: 'search' },
1211
- { name: 'πŸ’Ύ Store new memory', value: 'store' },
1212
- { name: 'πŸ“Š Memory statistics', value: 'stats' },
1213
- { name: 'πŸ—‘οΈ Clean old memories', value: 'clean' },
1214
- { name: 'πŸ“€ Export memory backup', value: 'export' },
1215
- { name: '⬅️ Back to main menu', value: 'back' },
1216
- ],
1217
- },
1218
- ]);
1219
- switch (action) {
1220
- case 'list':
1221
- await listMemories();
1222
- break;
1223
- case 'search':
1224
- await searchMemories();
1225
- break;
1226
- case 'store':
1227
- await storeMemoryWizard();
1228
- break;
1229
- case 'stats':
1230
- await showMemoryStats();
1231
- break;
1232
- case 'clean':
1233
- await cleanMemories();
1234
- break;
1235
- case 'export':
1236
- await exportMemoryBackup();
1237
- break;
1238
- case 'back':
1239
- await hiveMindWizard();
1240
- return;
1241
- }
1242
- // Ask if user wants to continue
1243
- const { continue: continueAction } = await inquirer.prompt([
1244
- {
1245
- type: 'confirm',
1246
- name: 'continue',
1247
- message: 'Would you like to perform another memory operation?',
1248
- default: true,
1249
- },
1250
- ]);
1251
- if (continueAction) {
1252
- await manageMemoryWizard();
1253
- }
1254
- }
1255
- /**
1256
- * Configure hive mind wizard
1257
- */
1258
- async function configureWizard() {
1259
- // TODO: Implement configuration wizard
1260
- console.log(chalk.yellow('Configuration wizard coming soon...'));
1261
- }
1262
- /**
1263
- * Main hive mind command handler
1264
- */
1265
- export async function hiveMindCommand(args, flags) {
1266
- const subcommand = args[0];
1267
- const subArgs = args.slice(1);
1268
- // Handle help flags
1269
- if (!subcommand ||
1270
- subcommand === '--help' ||
1271
- subcommand === '-h' ||
1272
- subcommand === 'help' ||
1273
- flags.help) {
1274
- showHiveMindHelp();
1275
- return;
1276
- }
1277
- // Warn about non-interactive environments for certain commands
1278
- if ((subcommand === 'spawn' && (flags.claude || flags.spawn)) || subcommand === 'wizard') {
1279
- warnNonInteractive('hive-mind ' + subcommand);
1280
- }
1281
- switch (subcommand) {
1282
- case 'init':
1283
- await initHiveMind(flags);
1284
- break;
1285
- case 'spawn':
1286
- if (flags.wizard || subArgs.length === 0) {
1287
- await spawnSwarmWizard();
1288
- }
1289
- else {
1290
- await spawnSwarm(subArgs, flags);
1291
- }
1292
- break;
1293
- case 'status':
1294
- await showStatus(flags);
1295
- break;
1296
- case 'sessions':
1297
- await showSessions(flags);
1298
- break;
1299
- case 'resume':
1300
- await resumeSession(subArgs, flags);
1301
- break;
1302
- case 'stop':
1303
- await stopSession(subArgs, flags);
1304
- break;
1305
- case 'consensus':
1306
- await showConsensus(flags);
1307
- break;
1308
- case 'memory':
1309
- await manageMemoryWizard();
1310
- break;
1311
- case 'metrics':
1312
- await showMetrics(flags);
1313
- break;
1314
- case 'wizard':
1315
- await hiveMindWizard(flags);
1316
- break;
1317
- case 'help':
1318
- case '--help':
1319
- case '-h':
1320
- showHiveMindHelp();
1321
- break;
1322
- default:
1323
- console.error(chalk.red(`Unknown subcommand: ${subcommand}`));
1324
- console.log('Run "claude-flow hive-mind help" for usage information');
1325
- exit(1);
1326
- }
1327
- }
1328
- /**
1329
- * List all memories in the collective memory store
1330
- */
1331
- async function listMemories() {
1332
- try {
1333
- console.log(chalk.blue('\nπŸ“‹ Collective Memory Store\n'));
1334
- // Use MCP wrapper to search for all memories (empty pattern matches all)
1335
- const mcpWrapper = await getMcpWrapper();
1336
- const searchResult = await mcpWrapper.searchMemory('hive-mind', '');
1337
- // Handle different possible response structures
1338
- let memories = [];
1339
- if (searchResult && Array.isArray(searchResult.results)) {
1340
- memories = searchResult.results;
1341
- }
1342
- else if (searchResult && Array.isArray(searchResult)) {
1343
- memories = searchResult;
1344
- }
1345
- else if (searchResult && searchResult.data && Array.isArray(searchResult.data)) {
1346
- memories = searchResult.data;
1347
- }
1348
- if (!memories || memories.length === 0) {
1349
- console.log(chalk.yellow('No memories found in the collective store.'));
1350
- console.log(chalk.gray('Try storing some memories first using the "πŸ’Ύ Store new memory" option.'));
1351
- return;
1352
- }
1353
- memories.forEach((memory, index) => {
1354
- console.log(chalk.cyan(`${index + 1}. ${memory.key || `memory-${index}`}`));
1355
- console.log(` Category: ${memory.type || 'general'}`);
1356
- console.log(` Created: ${new Date(memory.timestamp || Date.now()).toLocaleString()}`);
1357
- if (memory.value && typeof memory.value === 'object') {
1358
- console.log(` Preview: ${JSON.stringify(memory.value).substring(0, 100)}...`);
1359
- }
1360
- else {
1361
- console.log(` Value: ${String(memory.value || memory).substring(0, 100)}...`);
1362
- }
1363
- console.log('');
1364
- });
1365
- }
1366
- catch (error) {
1367
- console.error(chalk.red('Error listing memories:'), error.message);
1368
- console.log(chalk.gray('This might be because no memories have been stored yet.'));
1369
- }
1370
- }
1371
- /**
1372
- * Search memories by keyword
1373
- */
1374
- async function searchMemories() {
1375
- try {
1376
- const { searchTerm } = await inquirer.prompt([
1377
- {
1378
- type: 'input',
1379
- name: 'searchTerm',
1380
- message: 'Enter search term:',
1381
- validate: (input) => input.length > 0,
1382
- },
1383
- ]);
1384
- console.log(chalk.blue(`\nπŸ” Searching for: "${searchTerm}"\n`));
1385
- const mcpWrapper = await getMcpWrapper();
1386
- const searchResult = await mcpWrapper.searchMemory('hive-mind', searchTerm);
1387
- // Handle different possible response structures
1388
- let memories = [];
1389
- if (searchResult && Array.isArray(searchResult.results)) {
1390
- memories = searchResult.results;
1391
- }
1392
- else if (searchResult && Array.isArray(searchResult)) {
1393
- memories = searchResult;
1394
- }
1395
- else if (searchResult && searchResult.data && Array.isArray(searchResult.data)) {
1396
- memories = searchResult.data;
1397
- }
1398
- if (!memories || memories.length === 0) {
1399
- console.log(chalk.yellow('No memories found matching your search.'));
1400
- return;
1401
- }
1402
- memories.forEach((memory, index) => {
1403
- console.log(chalk.green(`${index + 1}. ${memory.key || `result-${index}`}`));
1404
- console.log(` Category: ${memory.type || 'general'}`);
1405
- console.log(` Created: ${new Date(memory.timestamp || Date.now()).toLocaleString()}`);
1406
- console.log(` Value: ${JSON.stringify(memory.value || memory, null, 2)}`);
1407
- console.log('');
1408
- });
1409
- }
1410
- catch (error) {
1411
- console.error(chalk.red('Error searching memories:'), error.message);
1412
- }
1413
- }
1414
- /**
1415
- * Store new memory wizard
1416
- */
1417
- async function storeMemoryWizard() {
1418
- try {
1419
- const answers = await inquirer.prompt([
1420
- {
1421
- type: 'input',
1422
- name: 'key',
1423
- message: 'Memory key (identifier):',
1424
- validate: (input) => input.length > 0,
1425
- },
1426
- {
1427
- type: 'list',
1428
- name: 'category',
1429
- message: 'Memory category:',
1430
- choices: [
1431
- 'consensus',
1432
- 'decision',
1433
- 'pattern',
1434
- 'learning',
1435
- 'coordination',
1436
- 'performance',
1437
- 'configuration',
1438
- 'general',
1439
- ],
1440
- },
1441
- {
1442
- type: 'editor',
1443
- name: 'value',
1444
- message: 'Memory content (JSON or text):',
1445
- },
1446
- ]);
1447
- const mcpWrapper = await getMcpWrapper();
1448
- let memoryValue;
1449
- // Try to parse as JSON, fall back to string
1450
- try {
1451
- memoryValue = JSON.parse(answers.value);
1452
- }
1453
- catch {
1454
- memoryValue = answers.value;
1455
- }
1456
- await mcpWrapper.storeMemory('hive-mind', answers.key, memoryValue, answers.category);
1457
- console.log(chalk.green(`\nβœ… Memory stored successfully!`));
1458
- console.log(`Key: ${answers.key}`);
1459
- console.log(`Category: ${answers.category}`);
1460
- }
1461
- catch (error) {
1462
- console.error(chalk.red('Error storing memory:'), error.message);
1463
- }
1464
- }
1465
- /**
1466
- * Show memory statistics
1467
- */
1468
- async function showMemoryStats() {
1469
- try {
1470
- console.log(chalk.blue('\nπŸ“Š Memory Statistics\n'));
1471
- const mcpWrapper = await getMcpWrapper();
1472
- // Search for all memories with an empty pattern to get everything
1473
- const searchResult = await mcpWrapper.searchMemory('hive-mind', '');
1474
- // Handle different possible response structures
1475
- let memories = [];
1476
- if (searchResult && Array.isArray(searchResult.results)) {
1477
- memories = searchResult.results;
1478
- }
1479
- else if (searchResult && Array.isArray(searchResult)) {
1480
- memories = searchResult;
1481
- }
1482
- else if (searchResult && searchResult.data && Array.isArray(searchResult.data)) {
1483
- memories = searchResult.data;
1484
- }
1485
- if (!memories || memories.length === 0) {
1486
- console.log(chalk.yellow('No memories found.'));
1487
- console.log(chalk.gray('Use "Store new memory" to create your first memory.'));
1488
- return;
1489
- }
1490
- // Calculate statistics
1491
- const stats = {
1492
- total: memories.length,
1493
- categories: {},
1494
- oldestDate: null,
1495
- newestDate: null,
1496
- totalSize: 0,
1497
- };
1498
- memories.forEach((memory) => {
1499
- // Count by category
1500
- const category = memory.category || memory.type || 'general';
1501
- stats.categories[category] = (stats.categories[category] || 0) + 1;
1502
- // Track dates
1503
- const date = new Date(memory.timestamp || Date.now());
1504
- if (!stats.oldestDate || date < stats.oldestDate) {
1505
- stats.oldestDate = date;
1506
- }
1507
- if (!stats.newestDate || date > stats.newestDate) {
1508
- stats.newestDate = date;
1509
- }
1510
- // Estimate size
1511
- stats.totalSize += JSON.stringify(memory).length;
1512
- });
1513
- console.log(chalk.cyan('Total memories:'), stats.total);
1514
- console.log(chalk.cyan('Estimated size:'), `${(stats.totalSize / 1024).toFixed(2)} KB`);
1515
- console.log(chalk.cyan('Date range:'), `${stats.oldestDate?.toLocaleDateString()} - ${stats.newestDate?.toLocaleDateString()}`);
1516
- console.log(chalk.cyan('\nBy category:'));
1517
- Object.entries(stats.categories).forEach(([category, count]) => {
1518
- console.log(` ${category}: ${count}`);
1519
- });
1520
- }
1521
- catch (error) {
1522
- console.error(chalk.red('Error getting memory stats:'), error.message);
1523
- }
1524
- }
1525
- /**
1526
- * Clean old memories
1527
- */
1528
- async function cleanMemories() {
1529
- try {
1530
- const { days } = await inquirer.prompt([
1531
- {
1532
- type: 'number',
1533
- name: 'days',
1534
- message: 'Remove memories older than how many days?',
1535
- default: 30,
1536
- validate: (input) => input > 0,
1537
- },
1538
- ]);
1539
- const { confirm } = await inquirer.prompt([
1540
- {
1541
- type: 'confirm',
1542
- name: 'confirm',
1543
- message: `Are you sure you want to delete memories older than ${days} days?`,
1544
- default: false,
1545
- },
1546
- ]);
1547
- if (!confirm) {
1548
- console.log(chalk.yellow('Operation cancelled.'));
1549
- return;
1550
- }
1551
- const mcpWrapper = await getMcpWrapper();
1552
- // Get all memories first
1553
- const searchResult = await mcpWrapper.searchMemory('hive-mind', '');
1554
- // Handle different possible response structures
1555
- let memories = [];
1556
- if (searchResult && Array.isArray(searchResult.results)) {
1557
- memories = searchResult.results;
1558
- }
1559
- else if (searchResult && Array.isArray(searchResult)) {
1560
- memories = searchResult;
1561
- }
1562
- else if (searchResult && searchResult.data && Array.isArray(searchResult.data)) {
1563
- memories = searchResult.data;
1564
- }
1565
- const cutoffDate = new Date();
1566
- cutoffDate.setDate(cutoffDate.getDate() - days);
1567
- // Filter memories older than cutoff date
1568
- const oldMemories = memories.filter((memory) => {
1569
- const memoryDate = new Date(memory.timestamp || 0);
1570
- return memoryDate < cutoffDate;
1571
- });
1572
- if (oldMemories.length === 0) {
1573
- console.log(chalk.yellow('\nπŸŽ‰ No old memories found to clean.'));
1574
- return;
1575
- }
1576
- console.log(chalk.green(`\nβœ… Found ${oldMemories.length} old memories to clean.`));
1577
- console.log(chalk.gray('Note: Individual memory deletion not yet implemented in MCPWrapper.'));
1578
- console.log(chalk.gray('Consider implementing batch deletion or memory lifecycle management.'));
1579
- }
1580
- catch (error) {
1581
- console.error(chalk.red('Error cleaning memories:'), error.message);
1582
- }
1583
- }
1584
- /**
1585
- * Export memory backup
1586
- */
1587
- async function exportMemoryBackup() {
1588
- try {
1589
- const { filename } = await inquirer.prompt([
1590
- {
1591
- type: 'input',
1592
- name: 'filename',
1593
- message: 'Export filename:',
1594
- default: `hive-mind-memory-backup-${new Date().toISOString().split('T')[0]}.json`,
1595
- },
1596
- ]);
1597
- const mcpWrapper = await getMcpWrapper();
1598
- // Get all memories using search
1599
- const searchResult = await mcpWrapper.searchMemory('hive-mind', '');
1600
- // Handle different possible response structures
1601
- let memories = [];
1602
- if (searchResult && Array.isArray(searchResult.results)) {
1603
- memories = searchResult.results;
1604
- }
1605
- else if (searchResult && Array.isArray(searchResult)) {
1606
- memories = searchResult;
1607
- }
1608
- else if (searchResult && searchResult.data && Array.isArray(searchResult.data)) {
1609
- memories = searchResult.data;
1610
- }
1611
- const backup = {
1612
- exportDate: new Date().toISOString(),
1613
- version: '1.0',
1614
- totalMemories: memories.length,
1615
- namespace: 'hive-mind',
1616
- memories: memories,
1617
- };
1618
- const fs = await import('fs');
1619
- fs.writeFileSync(filename, JSON.stringify(backup, null, 2));
1620
- console.log(chalk.green(`\nβœ… Memory backup exported to: ${filename}`));
1621
- console.log(chalk.cyan(`Exported ${memories.length} memories`));
1622
- }
1623
- catch (error) {
1624
- console.error(chalk.red('Error exporting memory backup:'), error.message);
1625
- }
1626
- }
1627
- /**
1628
- * Get active session ID for a swarm
1629
- */
1630
- async function getActiveSessionId(swarmId) {
1631
- const sessionManager = new HiveMindSessionManager();
1632
- try {
1633
- const sessions = await sessionManager.getActiveSessions();
1634
- const activeSession = sessions.find(s => s.swarm_id === swarmId && s.status === 'active');
1635
- return activeSession ? activeSession.id : null;
1636
- }
1637
- finally {
1638
- sessionManager.close();
1639
- }
1640
- }
1641
- /**
1642
- * Spawn Claude Code with Hive Mind coordination instructions
1643
- */
1644
- async function spawnClaudeCodeInstances(swarmId, swarmName, objective, workers, flags) {
1645
- console.log('\n' + chalk.bold('πŸš€ Launching Claude Code with Hive Mind Coordination'));
1646
- console.log(chalk.gray('─'.repeat(60)));
1647
- const spinner = ora('Preparing Hive Mind coordination prompt...').start();
1648
- try {
1649
- // Generate comprehensive Hive Mind prompt
1650
- const workerGroups = groupWorkersByType(workers);
1651
- const hiveMindPrompt = generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGroups, flags);
1652
- spinner.succeed('Hive Mind coordination prompt ready!');
1653
- // Display coordination summary
1654
- console.log('\n' + chalk.bold('🧠 Hive Mind Configuration'));
1655
- console.log(chalk.gray('─'.repeat(60)));
1656
- console.log(chalk.cyan('Swarm ID:'), swarmId);
1657
- console.log(chalk.cyan('Objective:'), objective);
1658
- console.log(chalk.cyan('Queen Type:'), flags.queenType || 'strategic');
1659
- console.log(chalk.cyan('Worker Count:'), workers.length);
1660
- console.log(chalk.cyan('Worker Types:'), Object.keys(workerGroups).join(', '));
1661
- console.log(chalk.cyan('Consensus Algorithm:'), flags.consensus || 'majority');
1662
- console.log(chalk.cyan('MCP Tools:'), 'Full Claude-Flow integration enabled');
1663
- try {
1664
- // ALWAYS save the prompt file first (fix for issue #330)
1665
- // Ensure sessions directory exists
1666
- const sessionsDir = path.join('.hive-mind', 'sessions');
1667
- await mkdirAsync(sessionsDir, { recursive: true });
1668
- const promptFile = path.join(sessionsDir, `hive-mind-prompt-${swarmId}.txt`);
1669
- await writeFile(promptFile, hiveMindPrompt, 'utf8');
1670
- console.log(chalk.green(`\nβœ“ Hive Mind prompt saved to: ${promptFile}`));
1671
- // Check if claude command exists
1672
- const { spawn: childSpawn, execSync } = await import('child_process');
1673
- let claudeAvailable = false;
1674
- try {
1675
- execSync('which claude', { stdio: 'ignore' });
1676
- claudeAvailable = true;
1677
- }
1678
- catch {
1679
- console.log(chalk.yellow('\n⚠️ Claude Code CLI not found in PATH'));
1680
- console.log(chalk.gray('Install it with: npm install -g @anthropic-ai/claude-code'));
1681
- console.log(chalk.gray('\nFalling back to displaying instructions...'));
1682
- }
1683
- if (claudeAvailable && !flags.dryRun) {
1684
- // Pass the prompt directly as an argument to claude
1685
- // Remove --print to allow interactive session
1686
- const claudeArgs = [hiveMindPrompt];
1687
- // Add auto-permission flag by default for hive-mind mode (unless explicitly disabled)
1688
- if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) {
1689
- claudeArgs.push('--dangerously-skip-permissions');
1690
- console.log(chalk.yellow('πŸ”“ Using --dangerously-skip-permissions by default for seamless hive-mind execution'));
1691
- }
1692
- // Spawn claude with the prompt as the first argument
1693
- // Use 'inherit' to allow interactive session
1694
- const claudeProcess = childSpawn('claude', claudeArgs, {
1695
- stdio: 'inherit',
1696
- shell: false,
1697
- });
1698
- // Track child process PID in session
1699
- const sessionManager = new HiveMindSessionManager();
1700
- const sessionId = await getActiveSessionId(swarmId);
1701
- if (sessionId && claudeProcess.pid) {
1702
- sessionManager.addChildPid(sessionId, claudeProcess.pid);
1703
- }
1704
- // Set up SIGINT handler for automatic session pausing
1705
- let isExiting = false;
1706
- const sigintHandler = async () => {
1707
- if (isExiting)
1708
- return;
1709
- isExiting = true;
1710
- console.log('\n\n' + chalk.yellow('⏸️ Pausing session and terminating Claude Code...'));
1711
- try {
1712
- // Terminate Claude Code process
1713
- if (claudeProcess && !claudeProcess.killed) {
1714
- claudeProcess.kill('SIGTERM');
1715
- }
1716
- // Save checkpoint and pause session
1717
- if (sessionId) {
1718
- const checkpointData = {
1719
- timestamp: new Date().toISOString(),
1720
- swarmId,
1721
- objective,
1722
- status: 'paused_by_user',
1723
- reason: 'User pressed Ctrl+C during Claude Code execution',
1724
- claudePid: claudeProcess.pid,
1725
- };
1726
- await sessionManager.saveCheckpoint(sessionId, 'auto-pause-claude', checkpointData);
1727
- await sessionManager.pauseSession(sessionId);
1728
- console.log(chalk.green('βœ“') + ' Session paused successfully');
1729
- console.log(chalk.cyan('\nTo resume this session, run:'));
1730
- console.log(chalk.bold(` claude-flow hive-mind resume ${sessionId}`));
1731
- }
1732
- sessionManager.close();
1733
- process.exit(0);
1734
- }
1735
- catch (error) {
1736
- console.error(chalk.red('Error pausing session:'), error.message);
1737
- sessionManager.close();
1738
- process.exit(1);
1739
- }
1740
- };
1741
- // Register SIGINT handler
1742
- process.on('SIGINT', sigintHandler);
1743
- process.on('SIGTERM', sigintHandler);
1744
- // Handle stdout
1745
- if (claudeProcess.stdout) {
1746
- claudeProcess.stdout.on('data', (data) => {
1747
- console.log(data.toString());
1748
- });
1749
- }
1750
- // Handle stderr
1751
- if (claudeProcess.stderr) {
1752
- claudeProcess.stderr.on('data', (data) => {
1753
- console.error(chalk.red(data.toString()));
1754
- });
1755
- }
1756
- // Handle process exit
1757
- claudeProcess.on('exit', (code) => {
1758
- // Remove child PID from session
1759
- if (sessionId && claudeProcess.pid) {
1760
- sessionManager.removeChildPid(sessionId, claudeProcess.pid);
1761
- sessionManager.close();
1762
- }
1763
- if (code === 0) {
1764
- console.log(chalk.green('\nβœ“ Claude Code completed successfully'));
1765
- }
1766
- else if (code !== null) {
1767
- console.log(chalk.red(`\nβœ— Claude Code exited with code ${code}`));
1768
- }
1769
- });
1770
- console.log(chalk.green('\nβœ“ Claude Code launched with Hive Mind coordination'));
1771
- console.log(chalk.blue(' The Queen coordinator will orchestrate all worker agents'));
1772
- console.log(chalk.blue(' Use MCP tools for collective intelligence and task distribution'));
1773
- console.log(chalk.gray(` Prompt file saved at: ${promptFile}`));
1774
- }
1775
- else if (flags.dryRun) {
1776
- console.log(chalk.blue('\nDry run - would execute Claude Code with prompt:'));
1777
- console.log(chalk.gray('Prompt length:'), hiveMindPrompt.length, 'characters');
1778
- console.log(chalk.gray('\nFirst 500 characters of prompt:'));
1779
- console.log(chalk.yellow(hiveMindPrompt.substring(0, 500) + '...'));
1780
- console.log(chalk.gray(`\nFull prompt saved to: ${promptFile}`));
1781
- }
1782
- else {
1783
- // Claude not available - show instructions with already saved prompt
1784
- console.log(chalk.yellow('\nπŸ“‹ Manual Execution Instructions:'));
1785
- console.log(chalk.gray('─'.repeat(50)));
1786
- console.log(chalk.gray('1. Install Claude Code:'));
1787
- console.log(chalk.green(' npm install -g @anthropic-ai/claude-code'));
1788
- console.log(chalk.gray('\n2. Run with the saved prompt:'));
1789
- console.log(chalk.green(` claude < ${promptFile}`));
1790
- console.log(chalk.gray('\n3. Or copy the prompt manually:'));
1791
- console.log(chalk.green(` cat ${promptFile} | claude`));
1792
- console.log(chalk.gray('\n4. With auto-permissions:'));
1793
- console.log(chalk.green(` claude --dangerously-skip-permissions < ${promptFile}`));
1794
- }
1795
- }
1796
- catch (error) {
1797
- console.error(chalk.red('\nFailed to launch Claude Code:'), error.message);
1798
- // Save prompt as fallback
1799
- const promptFile = `hive-mind-prompt-${swarmId}-fallback.txt`;
1800
- await writeFile(promptFile, hiveMindPrompt, 'utf8');
1801
- console.log(chalk.green(`\nβœ“ Prompt saved to: ${promptFile}`));
1802
- console.log(chalk.yellow('\nYou can run Claude Code manually with the saved prompt'));
1803
- }
1804
- console.log('\n' + chalk.bold('πŸ’‘ Pro Tips:'));
1805
- console.log(chalk.gray('─'.repeat(30)));
1806
- console.log('β€’ Use --auto-spawn to launch instances automatically');
1807
- console.log('β€’ Add --verbose for detailed coordination context');
1808
- console.log('β€’ Monitor with: claude-flow hive-mind status');
1809
- console.log('β€’ Share memories: mcp__ruv-swarm__memory_usage');
1810
- }
1811
- catch (error) {
1812
- spinner.fail('Failed to prepare Claude Code coordination');
1813
- console.error(chalk.red('Error:'), error.message);
1814
- }
1815
- }
1816
- /**
1817
- * Generate comprehensive Hive Mind prompt for Claude Code
1818
- */
1819
- function generateHiveMindPrompt(swarmId, swarmName, objective, workers, workerGroups, flags) {
1820
- const currentTime = new Date().toISOString();
1821
- const workerTypes = Object.keys(workerGroups);
1822
- const queenType = flags.queenType || 'strategic';
1823
- const consensusAlgorithm = flags.consensus || 'majority';
1824
- return `🧠 HIVE MIND COLLECTIVE INTELLIGENCE SYSTEM
1825
- ═══════════════════════════════════════════════
1826
-
1827
- You are the Queen coordinator of a Hive Mind swarm with collective intelligence capabilities.
1828
-
1829
- HIVE MIND CONFIGURATION:
1830
- πŸ“Œ Swarm ID: ${swarmId}
1831
- πŸ“Œ Swarm Name: ${swarmName}
1832
- 🎯 Objective: ${objective}
1833
- πŸ‘‘ Queen Type: ${queenType}
1834
- 🐝 Worker Count: ${workers.length}
1835
- 🀝 Consensus Algorithm: ${consensusAlgorithm}
1836
- ⏰ Initialized: ${currentTime}
1837
-
1838
- WORKER DISTRIBUTION:
1839
- ${workerTypes.map((type) => `β€’ ${type}: ${workerGroups[type].length} agents`).join('\n')}
1840
-
1841
- πŸ”§ AVAILABLE MCP TOOLS FOR HIVE MIND COORDINATION:
1842
-
1843
- 1️⃣ **COLLECTIVE INTELLIGENCE**
1844
- mcp__claude-flow__consensus_vote - Democratic decision making
1845
- mcp__claude-flow__memory_share - Share knowledge across the hive
1846
- mcp__claude-flow__neural_sync - Synchronize neural patterns
1847
- mcp__claude-flow__swarm_think - Collective problem solving
1848
-
1849
- 2️⃣ **QUEEN COORDINATION**
1850
- mcp__claude-flow__queen_command - Issue directives to workers
1851
- mcp__claude-flow__queen_monitor - Monitor swarm health
1852
- mcp__claude-flow__queen_delegate - Delegate complex tasks
1853
- mcp__claude-flow__queen_aggregate - Aggregate worker results
1854
-
1855
- 3️⃣ **WORKER MANAGEMENT**
1856
- mcp__claude-flow__agent_spawn - Create specialized workers
1857
- mcp__claude-flow__agent_assign - Assign tasks to workers
1858
- mcp__claude-flow__agent_communicate - Inter-agent communication
1859
- mcp__claude-flow__agent_metrics - Track worker performance
1860
-
1861
- 4️⃣ **TASK ORCHESTRATION**
1862
- mcp__claude-flow__task_create - Create hierarchical tasks
1863
- mcp__claude-flow__task_distribute - Distribute work efficiently
1864
- mcp__claude-flow__task_monitor - Track task progress
1865
- mcp__claude-flow__task_aggregate - Combine task results
1866
-
1867
- 5️⃣ **MEMORY & LEARNING**
1868
- mcp__claude-flow__memory_store - Store collective knowledge
1869
- mcp__claude-flow__memory_retrieve - Access shared memory
1870
- mcp__claude-flow__neural_train - Learn from experiences
1871
- mcp__claude-flow__pattern_recognize - Identify patterns
1872
-
1873
- πŸ“‹ HIVE MIND EXECUTION PROTOCOL:
1874
-
1875
- As the Queen coordinator, you must:
1876
-
1877
- 1. **INITIALIZE THE HIVE** (Single BatchTool Message):
1878
- [BatchTool]:
1879
- ${workerTypes.map((type) => ` mcp__claude-flow__agent_spawn { "type": "${type}", "count": ${workerGroups[type].length} }`).join('\n')}
1880
- mcp__claude-flow__memory_store { "key": "hive/objective", "value": "${objective}" }
1881
- mcp__claude-flow__memory_store { "key": "hive/queen", "value": "${queenType}" }
1882
- mcp__claude-flow__swarm_think { "topic": "initial_strategy" }
1883
- TodoWrite { "todos": [/* Create 5-10 high-level tasks */] }
1884
-
1885
- 2. **ESTABLISH COLLECTIVE INTELLIGENCE**:
1886
- - Use consensus_vote for major decisions
1887
- - Share all discoveries via memory_share
1888
- - Synchronize learning with neural_sync
1889
- - Coordinate strategy with swarm_think
1890
-
1891
- 3. **QUEEN LEADERSHIP PATTERNS**:
1892
- ${queenType === 'strategic'
1893
- ? `
1894
- - Focus on high-level planning and coordination
1895
- - Delegate implementation details to workers
1896
- - Monitor overall progress and adjust strategy
1897
- - Make executive decisions when consensus fails`
1898
- : ''}
1899
- ${queenType === 'tactical'
1900
- ? `
1901
- - Manage detailed task breakdowns and assignments
1902
- - Closely monitor worker progress and efficiency
1903
- - Optimize resource allocation and load balancing
1904
- - Intervene directly when workers need guidance`
1905
- : ''}
1906
- ${queenType === 'adaptive'
1907
- ? `
1908
- - Learn from swarm performance and adapt strategies
1909
- - Experiment with different coordination patterns
1910
- - Use neural training to improve over time
1911
- - Balance between strategic and tactical approaches`
1912
- : ''}
1913
-
1914
- 4. **WORKER COORDINATION**:
1915
- - Spawn workers based on task requirements
1916
- - Assign tasks according to worker specializations
1917
- - Enable peer-to-peer communication for collaboration
1918
- - Monitor and rebalance workloads as needed
1919
-
1920
- 5. **CONSENSUS MECHANISMS**:
1921
- ${consensusAlgorithm === 'majority' ? '- Decisions require >50% worker agreement' : ''}
1922
- ${consensusAlgorithm === 'unanimous' ? '- All workers must agree for major decisions' : ''}
1923
- ${consensusAlgorithm === 'weighted' ? '- Worker votes weighted by expertise and performance' : ''}
1924
- ${consensusAlgorithm === 'quorum' ? '- Decisions require 2/3 worker participation' : ''}
1925
-
1926
- 6. **COLLECTIVE MEMORY**:
1927
- - Store all important decisions in shared memory
1928
- - Tag memories with worker IDs and timestamps
1929
- - Use memory namespaces: hive/, queen/, workers/, tasks/
1930
- - Implement memory consensus for critical data
1931
-
1932
- 7. **PERFORMANCE OPTIMIZATION**:
1933
- - Monitor swarm metrics continuously
1934
- - Identify and resolve bottlenecks
1935
- - Train neural networks on successful patterns
1936
- - Scale worker count based on workload
1937
-
1938
- πŸ’‘ HIVE MIND BEST PRACTICES:
1939
-
1940
- βœ… ALWAYS use BatchTool for parallel operations
1941
- βœ… Store decisions in collective memory immediately
1942
- βœ… Use consensus for critical path decisions
1943
- βœ… Monitor worker health and reassign if needed
1944
- βœ… Learn from failures and adapt strategies
1945
- βœ… Maintain constant inter-agent communication
1946
- βœ… Aggregate results before final delivery
1947
-
1948
- ❌ NEVER make unilateral decisions without consensus
1949
- ❌ NEVER let workers operate in isolation
1950
- ❌ NEVER ignore performance metrics
1951
- ❌ NEVER skip memory synchronization
1952
- ❌ NEVER abandon failing workers
1953
-
1954
- 🎯 OBJECTIVE EXECUTION STRATEGY:
1955
-
1956
- For the objective: "${objective}"
1957
-
1958
- 1. Break down into major phases using swarm_think
1959
- 2. Create specialized worker teams for each phase
1960
- 3. Establish success criteria and checkpoints
1961
- 4. Implement feedback loops and adaptation
1962
- 5. Aggregate and synthesize all worker outputs
1963
- 6. Deliver comprehensive solution with consensus
1964
-
1965
- ⚑ PARALLEL EXECUTION REMINDER:
1966
- The Hive Mind operates with massive parallelism. Always batch operations:
1967
- - Spawn ALL workers in one message
1968
- - Create ALL initial tasks together
1969
- - Store multiple memories simultaneously
1970
- - Check all statuses in parallel
1971
-
1972
- πŸš€ BEGIN HIVE MIND EXECUTION:
1973
-
1974
- Initialize the swarm now with the configuration above. Use your collective intelligence to solve the objective efficiently. The Queen must coordinate, workers must collaborate, and the hive must think as one.
1975
-
1976
- Remember: You are not just coordinating agents - you are orchestrating a collective intelligence that is greater than the sum of its parts.`;
1977
- }
1978
- /**
1979
- * Generate comprehensive coordination instructions for Claude Code instances
1980
- */
1981
- function generateCoordinationInstructions(swarmId, swarmName, objective, workers) {
1982
- return {
1983
- swarmId,
1984
- swarmName,
1985
- objective,
1986
- hiveMindEndpoint: 'ws://localhost:3000/hive-mind',
1987
- mcpTools: [
1988
- 'mcp__ruv-swarm__memory_usage',
1989
- 'mcp__ruv-swarm__swarm_monitor',
1990
- 'mcp__ruv-swarm__task_orchestrate',
1991
- 'mcp__ruv-swarm__neural_train',
1992
- 'mcp__ruv-swarm__consensus_vote',
1993
- 'mcp__ruv-swarm__agent_spawn',
1994
- 'mcp__ruv-swarm__swarm_status',
1995
- ],
1996
- coordinationProtocol: {
1997
- memoryNamespace: `hive-mind-${swarmId}`,
1998
- consensusThreshold: 0.7,
1999
- taskUpdateInterval: 30000,
2000
- healthCheckInterval: 60000,
2001
- },
2002
- workerCapabilities: workers.map((w) => ({
2003
- id: w.id,
2004
- type: w.type,
2005
- capabilities: JSON.parse(w.capabilities),
2006
- })),
2007
- };
2008
- }
2009
- /**
2010
- * Group workers by type for specialized spawning
2011
- */
2012
- function groupWorkersByType(workers) {
2013
- return workers.reduce((groups, worker) => {
2014
- if (!groups[worker.type]) {
2015
- groups[worker.type] = [];
2016
- }
2017
- groups[worker.type].push(worker);
2018
- return groups;
2019
- }, {});
2020
- }
2021
- /**
2022
- * Create Claude Code spawn command with coordination context
2023
- */
2024
- function createClaudeCodeSpawnCommand(swarmId, swarmName, objective, workerType, typeWorkers, instructions) {
2025
- const context = `You are a ${workerType} agent in the "${swarmName}" Hive Mind swarm.
2026
-
2027
- 🎯 MISSION: ${objective}
2028
-
2029
- 🐝 SWARM COORDINATION:
2030
- - Swarm ID: ${swarmId}
2031
- - Your Role: ${workerType.toUpperCase()} specialist
2032
- - Team Size: ${typeWorkers.length} ${workerType}(s)
2033
- - Coordination: Hive Mind collective intelligence
2034
-
2035
- 🧠 MANDATORY COORDINATION PROTOCOL:
2036
- 1. BEFORE starting work:
2037
- mcp__ruv-swarm__memory_usage {"action": "retrieve", "key": "hive-mind-${swarmId}/status"}
2038
- mcp__ruv-swarm__swarm_status {"swarmId": "${swarmId}"}
2039
-
2040
- 2. DURING work (after each major step):
2041
- mcp__ruv-swarm__memory_usage {"action": "store", "key": "hive-mind-${swarmId}/${workerType}/progress", "value": {"step": "X", "status": "Y", "findings": "Z"}}
2042
- mcp__ruv-swarm__task_orchestrate {"swarmId": "${swarmId}", "update": {"agentId": "your-id", "progress": "details"}}
2043
-
2044
- 3. FOR decisions requiring consensus:
2045
- mcp__ruv-swarm__consensus_vote {"swarmId": "${swarmId}", "topic": "decision topic", "vote": "your choice", "rationale": "reasoning"}
2046
-
2047
- 4. WHEN sharing insights:
2048
- mcp__ruv-swarm__memory_usage {"action": "store", "key": "hive-mind-${swarmId}/insights/${workerType}", "value": {"insight": "your discovery", "impact": "significance"}}
2049
-
2050
- 5. BEFORE completing work:
2051
- mcp__ruv-swarm__neural_train {"swarmId": "${swarmId}", "experience": {"what": "learned", "outcome": "result"}}
2052
-
2053
- πŸ”§ SPECIALIZED CAPABILITIES:
2054
- ${getWorkerTypeInstructions(workerType)}
2055
-
2056
- 🀝 COORDINATION RULES:
2057
- - Share ALL discoveries via memory_usage
2058
- - Vote on critical decisions using consensus_vote
2059
- - Update progress every 15 minutes via task_orchestrate
2060
- - Monitor other agents via swarm_status
2061
- - Learn from patterns via neural_train
2062
-
2063
- Remember: You are part of a COLLECTIVE INTELLIGENCE. Your individual success depends on swarm coordination!`;
2064
- const command = `claude code --context "${context.replace(/"/g, '\\"')}"`;
2065
- return {
2066
- title: `${workerType.toUpperCase()} Agent (${typeWorkers.length} instance${typeWorkers.length > 1 ? 's' : ''})`,
2067
- command,
2068
- context,
2069
- workerType,
2070
- count: typeWorkers.length,
2071
- };
2072
- }
2073
- /**
2074
- * Get specialized instructions for each worker type
2075
- */
2076
- function getWorkerTypeInstructions(workerType) {
2077
- const instructions = {
2078
- researcher: `- Conduct thorough research using WebSearch and WebFetch
2079
- - Document findings in structured formats
2080
- - Validate source credibility and relevance
2081
- - Synthesize insights from multiple sources
2082
- - Share research methodology and results`,
2083
- coder: `- Write clean, maintainable, well-documented code
2084
- - Follow project conventions and best practices
2085
- - Test implementations thoroughly
2086
- - Document code changes and decisions
2087
- - Review and optimize existing code`,
2088
- analyst: `- Analyze data patterns and trends
2089
- - Create comprehensive reports and visualizations
2090
- - Identify key insights and recommendations
2091
- - Validate analytical methodologies
2092
- - Correlate findings across data sources`,
2093
- tester: `- Design comprehensive test strategies
2094
- - Execute functional, integration, and performance tests
2095
- - Document test results and issues
2096
- - Verify bug fixes and improvements
2097
- - Ensure quality standards and coverage`,
2098
- coordinator: `- Monitor overall progress and coordination
2099
- - Facilitate communication between agents
2100
- - Resolve conflicts and blockers
2101
- - Optimize resource allocation
2102
- - Ensure alignment with objectives`,
2103
- architect: `- Design system architecture and components
2104
- - Define technical standards and patterns
2105
- - Create implementation guidelines
2106
- - Review and approve design decisions
2107
- - Ensure scalability and maintainability`,
2108
- };
2109
- return (instructions[workerType] ||
2110
- `- Execute tasks according to ${workerType} best practices
2111
- - Collaborate effectively with team members
2112
- - Document work and share insights
2113
- - Maintain quality standards
2114
- - Contribute to collective objectives`);
2115
- }
2116
- /**
2117
- * Show all hive mind sessions
2118
- */
2119
- async function showSessions(flags) {
2120
- try {
2121
- const sessionManager = new HiveMindSessionManager();
2122
- const sessions = await sessionManager.getActiveSessions();
2123
- if (sessions.length === 0) {
2124
- console.log(chalk.gray('No active or paused sessions found'));
2125
- sessionManager.close();
2126
- return;
2127
- }
2128
- console.log(chalk.bold('\nπŸ—‚οΈ Hive Mind Sessions\n'));
2129
- sessions.forEach((session, index) => {
2130
- const statusColor = session.status === 'active' ? 'green' : session.status === 'paused' ? 'yellow' : 'gray';
2131
- const statusIcon = session.status === 'active' ? '🟒' : session.status === 'paused' ? '🟑' : '⚫';
2132
- console.log(chalk.yellow('═'.repeat(60)));
2133
- console.log(`${statusIcon} ${chalk.bold(session.swarm_name)}`);
2134
- console.log(chalk.cyan('Session ID:'), session.id);
2135
- console.log(chalk.cyan('Status:'), chalk[statusColor](session.status));
2136
- console.log(chalk.cyan('Objective:'), session.objective);
2137
- console.log(chalk.cyan('Progress:'), `${session.completion_percentage}%`);
2138
- console.log(chalk.cyan('Created:'), new Date(session.created_at).toLocaleString());
2139
- console.log(chalk.cyan('Last Updated:'), new Date(session.updated_at).toLocaleString());
2140
- if (session.paused_at) {
2141
- console.log(chalk.cyan('Paused At:'), new Date(session.paused_at).toLocaleString());
2142
- }
2143
- console.log('\n' + chalk.bold('Progress:'));
2144
- console.log(` Agents: ${session.agent_count || 0}`);
2145
- console.log(` Tasks: ${session.completed_tasks || 0}/${session.task_count || 0}`);
2146
- if (session.checkpoint_data) {
2147
- console.log('\n' + chalk.bold('Last Checkpoint:'));
2148
- console.log(chalk.gray(JSON.stringify(session.checkpoint_data, null, 2).substring(0, 200) + '...'));
2149
- }
2150
- });
2151
- console.log(chalk.yellow('═'.repeat(60)) + '\n');
2152
- console.log(chalk.blue('πŸ’‘ Tips:'));
2153
- console.log(' β€’ Resume a session: claude-flow hive-mind resume <session-id>');
2154
- console.log(' β€’ View session details: claude-flow hive-mind status');
2155
- sessionManager.close();
2156
- }
2157
- catch (error) {
2158
- console.error(chalk.red('Error:'), error.message);
2159
- exit(1);
2160
- }
2161
- }
2162
- /**
2163
- * Resume a paused hive mind session
2164
- */
2165
- async function resumeSession(args, flags) {
2166
- const sessionId = args[0];
2167
- if (!sessionId) {
2168
- console.error(chalk.red('Error: Please provide a session ID'));
2169
- console.log('Usage: claude-flow hive-mind resume <session-id>');
2170
- console.log('Run "claude-flow hive-mind sessions" to see available sessions');
2171
- return;
2172
- }
2173
- const spinner = ora('Resuming Hive Mind session...').start();
2174
- try {
2175
- const sessionManager = new HiveMindSessionManager();
2176
- // Get session details
2177
- const session = sessionManager.getSession(sessionId);
2178
- if (!session) {
2179
- spinner.fail(`Session ${sessionId} not found`);
2180
- console.log('\nRun "claude-flow hive-mind sessions" to see available sessions');
2181
- sessionManager.close();
2182
- return;
2183
- }
2184
- // Allow resuming any session regardless of status
2185
- spinner.text = `Resuming session from status: ${session.status}...`;
2186
- if (session.status === 'stopped') {
2187
- spinner.text = 'Restarting stopped session with original configuration...';
2188
- }
2189
- // Resume the session
2190
- const resumedSession = await sessionManager.resumeSession(sessionId);
2191
- spinner.succeed('Session resumed successfully!');
2192
- // Display session summary
2193
- console.log('\n' + chalk.bold('πŸ“‹ Resumed Session Summary:'));
2194
- console.log(chalk.gray('─'.repeat(50)));
2195
- console.log(chalk.cyan('Session ID:'), sessionId);
2196
- console.log(chalk.cyan('Swarm Name:'), resumedSession.swarm_name);
2197
- console.log(chalk.cyan('Objective:'), resumedSession.objective);
2198
- console.log(chalk.cyan('Progress:'), `${resumedSession.statistics.completionPercentage}%`);
2199
- console.log(chalk.cyan('Active Agents:'), `${resumedSession.statistics.activeAgents}/${resumedSession.statistics.totalAgents}`);
2200
- console.log(chalk.cyan('Tasks:'), `${resumedSession.statistics.completedTasks}/${resumedSession.statistics.totalTasks} completed`);
2201
- console.log(chalk.gray('─'.repeat(50)));
2202
- // Show task breakdown
2203
- console.log('\n' + chalk.bold('πŸ“Š Task Status:'));
2204
- console.log(` βœ… Completed: ${resumedSession.statistics.completedTasks}`);
2205
- console.log(` πŸ”„ In Progress: ${resumedSession.statistics.inProgressTasks}`);
2206
- console.log(` ⏳ Pending: ${resumedSession.statistics.pendingTasks}`);
2207
- // Show recent activity
2208
- if (resumedSession.recentLogs && resumedSession.recentLogs.length > 0) {
2209
- console.log('\n' + chalk.bold('πŸ“œ Recent Activity:'));
2210
- resumedSession.recentLogs.slice(0, 5).forEach((log) => {
2211
- const timestamp = new Date(log.timestamp).toLocaleTimeString();
2212
- console.log(` [${timestamp}] ${log.message}`);
2213
- });
2214
- }
2215
- // Restore checkpoint if available
2216
- if (resumedSession.checkpoint_data) {
2217
- console.log('\n' + chalk.bold('♻️ Restoring from checkpoint...'));
2218
- console.log(chalk.gray('Checkpoint data available for restoration'));
2219
- }
2220
- sessionManager.close();
2221
- // Offer to spawn Claude Code with restored context
2222
- if (flags.claude || flags.spawn) {
2223
- console.log('\n' + chalk.yellow('πŸš€ Launching Claude Code with restored context...'));
2224
- // Generate prompt with session context
2225
- const restoredPrompt = generateRestoredSessionPrompt(resumedSession);
2226
- // Launch Claude Code with restored context
2227
- await launchClaudeWithContext(restoredPrompt, flags);
2228
- }
2229
- else {
2230
- console.log('\n' +
2231
- chalk.blue('πŸ’‘ Pro Tip:') +
2232
- ' Add --claude to spawn Claude Code with restored context');
2233
- console.log(chalk.gray(' claude-flow hive-mind resume ' + sessionId + ' --claude'));
2234
- }
2235
- }
2236
- catch (error) {
2237
- spinner.fail('Failed to resume session');
2238
- console.error(chalk.red('Error:'), error.message);
2239
- exit(1);
2240
- }
2241
- }
2242
- /**
2243
- * Stop a hive mind session
2244
- */
2245
- async function stopSession(args, flags) {
2246
- const sessionId = args[0];
2247
- if (!sessionId) {
2248
- console.error(chalk.red('Error: Please provide a session ID'));
2249
- console.log('Usage: claude-flow hive-mind stop <session-id>');
2250
- console.log('Run "claude-flow hive-mind sessions" to see available sessions');
2251
- return;
2252
- }
2253
- const spinner = ora('Stopping Hive Mind session...').start();
2254
- try {
2255
- const sessionManager = new HiveMindSessionManager();
2256
- // Get session details
2257
- const session = sessionManager.getSession(sessionId);
2258
- if (!session) {
2259
- spinner.fail(`Session ${sessionId} not found`);
2260
- console.log('\nRun "claude-flow hive-mind sessions" to see available sessions');
2261
- sessionManager.close();
2262
- return;
2263
- }
2264
- // Stop the session
2265
- await sessionManager.stopSession(sessionId);
2266
- spinner.succeed('Session stopped successfully!');
2267
- // Display session summary
2268
- console.log('\n' + chalk.bold('πŸ›‘ Stopped Session Summary:'));
2269
- console.log(chalk.gray('─'.repeat(50)));
2270
- console.log(chalk.cyan('Session ID:'), sessionId);
2271
- console.log(chalk.cyan('Swarm Name:'), session.swarm_name || 'Unknown');
2272
- console.log(chalk.cyan('Final Status:'), 'Stopped');
2273
- console.log(chalk.cyan('Active Agents:'), session.statistics ? session.statistics.activeAgents : 0);
2274
- console.log(chalk.gray('─'.repeat(50)));
2275
- console.log('\n' + chalk.yellow('πŸ’‘ Session has been stopped and all processes cleaned up.'));
2276
- console.log(chalk.gray('To resume this session later, use: claude-flow hive-mind resume ' + sessionId));
2277
- sessionManager.close();
2278
- }
2279
- catch (error) {
2280
- spinner.fail('Failed to stop session');
2281
- console.error(chalk.red('Error:'), error.message);
2282
- exit(1);
2283
- }
2284
- }
2285
- /**
2286
- * Generate prompt for restored session
2287
- */
2288
- function generateRestoredSessionPrompt(session) {
2289
- const activeAgents = session.agents.filter((a) => a.status === 'active' || a.status === 'busy');
2290
- const pendingTasks = session.tasks.filter((t) => t.status === 'pending' || t.status === 'in_progress');
2291
- return `πŸ”„ RESUMING HIVE MIND SESSION
2292
- ═══════════════════════════════════
2293
-
2294
- You are resuming a paused Hive Mind session with the following context:
2295
-
2296
- SESSION DETAILS:
2297
- πŸ“Œ Session ID: ${session.id}
2298
- πŸ“Œ Swarm Name: ${session.swarm_name}
2299
- 🎯 Objective: ${session.objective}
2300
- πŸ“Š Progress: ${session.statistics.completionPercentage}% complete
2301
- ⏸️ Paused: ${new Date(session.paused_at).toLocaleString()}
2302
- ▢️ Resumed: ${new Date().toLocaleString()}
2303
-
2304
- CURRENT STATUS:
2305
- β€’ Total Agents: ${session.statistics.totalAgents}
2306
- β€’ Active Agents: ${session.statistics.activeAgents}
2307
- β€’ Completed Tasks: ${session.statistics.completedTasks}/${session.statistics.totalTasks}
2308
- β€’ Pending Tasks: ${pendingTasks.length}
2309
-
2310
- ACTIVE AGENTS:
2311
- ${activeAgents.map((agent) => `β€’ ${agent.name} (${agent.type}) - ${agent.status}`).join('\n')}
2312
-
2313
- PENDING TASKS:
2314
- ${pendingTasks
2315
- .slice(0, 10)
2316
- .map((task) => `β€’ [${task.priority}] ${task.description}`)
2317
- .join('\n')}
2318
- ${pendingTasks.length > 10 ? `... and ${pendingTasks.length - 10} more tasks` : ''}
2319
-
2320
- CHECKPOINT DATA:
2321
- ${session.checkpoint_data ? JSON.stringify(session.checkpoint_data, null, 2) : 'No checkpoint data available'}
2322
-
2323
- RECENT ACTIVITY:
2324
- ${session.recentLogs
2325
- .slice(0, 10)
2326
- .map((log) => `[${new Date(log.timestamp).toLocaleTimeString()}] ${log.message}`)
2327
- .join('\n')}
2328
-
2329
- 🎯 RESUMPTION PROTOCOL:
2330
-
2331
- 1. **RESTORE CONTEXT**:
2332
- - Review the checkpoint data and recent activity
2333
- - Check collective memory for important decisions
2334
- - Verify agent status and reassign if needed
2335
-
2336
- 2. **CONTINUE EXECUTION**:
2337
- - Resume pending tasks based on priority
2338
- - Maintain coordination with existing agents
2339
- - Update progress tracking regularly
2340
-
2341
- 3. **COORDINATION**:
2342
- - Use mcp__claude-flow__memory_retrieve to access shared knowledge
2343
- - Continue using consensus mechanisms for decisions
2344
- - Maintain swarm communication protocols
2345
-
2346
- Resume the hive mind operation and continue working towards the objective.`;
2347
- }
2348
- /**
2349
- * Launch Claude Code with context
2350
- */
2351
- async function launchClaudeWithContext(prompt, flags) {
2352
- try {
2353
- // ALWAYS save the prompt file first (fix for issue #330)
2354
- const promptFile = `hive-mind-resume-${Date.now()}.txt`;
2355
- await writeFile(promptFile, prompt);
2356
- console.log(chalk.green(`\nβœ“ Session context saved to: ${promptFile}`));
2357
- const { spawn: childSpawn, execSync } = await import('child_process');
2358
- let claudeAvailable = false;
2359
- try {
2360
- execSync('which claude', { stdio: 'ignore' });
2361
- claudeAvailable = true;
2362
- }
2363
- catch {
2364
- console.log(chalk.yellow('\n⚠️ Claude Code CLI not found'));
2365
- console.log(chalk.gray('Install Claude Code: npm install -g @anthropic-ai/claude-code'));
2366
- console.log(chalk.gray(`Run with: claude < ${promptFile}`));
2367
- return;
2368
- }
2369
- if (claudeAvailable && !flags.dryRun) {
2370
- const claudeArgs = [prompt, '--print'];
2371
- if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) {
2372
- claudeArgs.push('--dangerously-skip-permissions');
2373
- }
2374
- // Use 'pipe' instead of 'inherit' to prevent terminal conflicts
2375
- const claudeProcess = childSpawn('claude', claudeArgs, {
2376
- stdio: 'pipe',
2377
- shell: false,
2378
- });
2379
- // Set up SIGINT handler for clean termination (no session pausing here since we're resuming)
2380
- const sigintHandler = () => {
2381
- console.log('\n\n' + chalk.yellow('⏹️ Terminating Claude Code...'));
2382
- if (claudeProcess && !claudeProcess.killed) {
2383
- claudeProcess.kill('SIGTERM');
2384
- }
2385
- process.exit(0);
2386
- };
2387
- process.on('SIGINT', sigintHandler);
2388
- process.on('SIGTERM', sigintHandler);
2389
- // Handle stdout
2390
- if (claudeProcess.stdout) {
2391
- claudeProcess.stdout.on('data', (data) => {
2392
- console.log(data.toString());
2393
- });
2394
- }
2395
- // Handle stderr
2396
- if (claudeProcess.stderr) {
2397
- claudeProcess.stderr.on('data', (data) => {
2398
- console.error(chalk.red(data.toString()));
2399
- });
2400
- }
2401
- // Handle process exit
2402
- claudeProcess.on('exit', (code) => {
2403
- if (code === 0) {
2404
- console.log(chalk.green('\nβœ“ Claude Code completed successfully'));
2405
- }
2406
- else if (code !== null) {
2407
- console.log(chalk.red(`\nβœ— Claude Code exited with code ${code}`));
2408
- }
2409
- // Clean up signal handlers
2410
- process.removeListener('SIGINT', sigintHandler);
2411
- process.removeListener('SIGTERM', sigintHandler);
2412
- });
2413
- console.log(chalk.green('\nβœ“ Claude Code launched with restored session context'));
2414
- console.log(chalk.gray(` Prompt file saved at: ${promptFile}`));
2415
- }
2416
- }
2417
- catch (error) {
2418
- console.error(chalk.red('Failed to launch Claude Code:'), error.message);
2419
- }
2420
- }
2421
- /**
2422
- * Get MCP wrapper instance
2423
- */
2424
- async function getMcpWrapper() {
2425
- const { MCPToolWrapper } = await import('./hive-mind/mcp-wrapper.js');
2426
- return new MCPToolWrapper();
2427
- }
2428
- // Export for testing
2429
- export { showHiveMindHelp, initHiveMind, spawnSwarm, showStatus };
2430
- //# sourceMappingURL=hive-mind.js.map