claude-flow 2.7.0 → 2.7.2

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