claude-flow 2.0.0-alpha.60 → 2.0.0-alpha.62

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 (1428) hide show
  1. package/.claude/commands/sparc/analyzer.md +24 -77
  2. package/.claude/commands/sparc/architect.md +25 -76
  3. package/.claude/commands/sparc/batch-executor.md +28 -78
  4. package/.claude/commands/sparc/coder.md +28 -79
  5. package/.claude/commands/sparc/debugger.md +26 -76
  6. package/.claude/commands/sparc/designer.md +25 -75
  7. package/.claude/commands/sparc/documenter.md +26 -75
  8. package/.claude/commands/sparc/innovator.md +26 -76
  9. package/.claude/commands/sparc/memory-manager.md +28 -77
  10. package/.claude/commands/sparc/optimizer.md +26 -76
  11. package/.claude/commands/sparc/orchestrator.md +23 -74
  12. package/.claude/commands/sparc/researcher.md +26 -77
  13. package/.claude/commands/sparc/reviewer.md +26 -76
  14. package/.claude/commands/sparc/sparc-modes.md +38 -358
  15. package/.claude/commands/sparc/swarm-coordinator.md +28 -77
  16. package/.claude/commands/sparc/tdd.md +28 -78
  17. package/.claude/commands/sparc/tester.md +26 -76
  18. package/.claude/commands/sparc/workflow-manager.md +28 -77
  19. package/.claude/commands/swarm/analysis.md +14 -17
  20. package/.claude/commands/swarm/development.md +14 -16
  21. package/.claude/commands/swarm/examples.md +20 -53
  22. package/.claude/commands/swarm/maintenance.md +14 -17
  23. package/.claude/commands/swarm/optimization.md +15 -17
  24. package/.claude/commands/swarm/research.md +14 -17
  25. package/.claude/commands/swarm/testing.md +15 -17
  26. package/.claude/config.json +32 -11
  27. package/CHANGELOG.md +113 -0
  28. package/bin/claude-flow +1 -1
  29. package/dist/adapters/cliffy-node.d.ts.map +1 -1
  30. package/dist/adapters/cliffy-node.js +13 -7
  31. package/dist/adapters/cliffy-node.js.map +1 -1
  32. package/dist/agents/agent-manager.d.ts.map +1 -1
  33. package/dist/agents/agent-manager.js +77 -65
  34. package/dist/agents/agent-manager.js.map +1 -1
  35. package/dist/agents/agent-registry.d.ts.map +1 -1
  36. package/dist/agents/agent-registry.js +38 -30
  37. package/dist/agents/agent-registry.js.map +1 -1
  38. package/dist/api/claude-client.d.ts.map +1 -1
  39. package/dist/api/claude-client.js +22 -16
  40. package/dist/api/claude-client.js.map +1 -1
  41. package/dist/cli/agents/analyst.d.ts.map +1 -1
  42. package/dist/cli/agents/analyst.js +94 -114
  43. package/dist/cli/agents/analyst.js.map +1 -1
  44. package/dist/cli/agents/architect.d.ts.map +1 -1
  45. package/dist/cli/agents/architect.js +100 -114
  46. package/dist/cli/agents/architect.js.map +1 -1
  47. package/dist/cli/agents/base-agent.d.ts.map +1 -1
  48. package/dist/cli/agents/base-agent.js +27 -27
  49. package/dist/cli/agents/base-agent.js.map +1 -1
  50. package/dist/cli/agents/capabilities.d.ts.map +1 -1
  51. package/dist/cli/agents/capabilities.js +49 -51
  52. package/dist/cli/agents/capabilities.js.map +1 -1
  53. package/dist/cli/agents/coder.d.ts.map +1 -1
  54. package/dist/cli/agents/coder.js +92 -98
  55. package/dist/cli/agents/coder.js.map +1 -1
  56. package/dist/cli/agents/coordinator.d.ts.map +1 -1
  57. package/dist/cli/agents/coordinator.js +59 -64
  58. package/dist/cli/agents/coordinator.js.map +1 -1
  59. package/dist/cli/agents/hive-agents.d.ts.map +1 -1
  60. package/dist/cli/agents/hive-agents.js +22 -24
  61. package/dist/cli/agents/hive-agents.js.map +1 -1
  62. package/dist/cli/agents/index.d.ts.map +1 -1
  63. package/dist/cli/agents/index.js +17 -17
  64. package/dist/cli/agents/index.js.map +1 -1
  65. package/dist/cli/agents/researcher.d.ts.map +1 -1
  66. package/dist/cli/agents/researcher.js +41 -61
  67. package/dist/cli/agents/researcher.js.map +1 -1
  68. package/dist/cli/agents/tester.d.ts.map +1 -1
  69. package/dist/cli/agents/tester.js +78 -90
  70. package/dist/cli/agents/tester.js.map +1 -1
  71. package/dist/cli/cli-core.d.ts +4 -1
  72. package/dist/cli/cli-core.d.ts.map +1 -1
  73. package/dist/cli/cli-core.js +40 -39
  74. package/dist/cli/cli-core.js.map +1 -1
  75. package/dist/cli/command-registry.d.ts.map +1 -1
  76. package/dist/cli/command-registry.js +99 -74
  77. package/dist/cli/command-registry.js.map +1 -1
  78. package/dist/cli/commands/advanced-memory-commands.d.ts.map +1 -1
  79. package/dist/cli/commands/advanced-memory-commands.js +49 -40
  80. package/dist/cli/commands/advanced-memory-commands.js.map +1 -1
  81. package/dist/cli/commands/agent-simple.d.ts +3 -0
  82. package/dist/cli/commands/agent-simple.d.ts.map +1 -1
  83. package/dist/cli/commands/agent-simple.js +30 -27
  84. package/dist/cli/commands/agent-simple.js.map +1 -1
  85. package/dist/cli/commands/agent.d.ts.map +1 -1
  86. package/dist/cli/commands/agent.js +53 -40
  87. package/dist/cli/commands/agent.js.map +1 -1
  88. package/dist/cli/commands/claude-api.js +4 -4
  89. package/dist/cli/commands/claude-api.js.map +1 -1
  90. package/dist/cli/commands/claude.d.ts.map +1 -1
  91. package/dist/cli/commands/claude.js +2 -2
  92. package/dist/cli/commands/claude.js.map +1 -1
  93. package/dist/cli/commands/config-integration.d.ts +7 -1
  94. package/dist/cli/commands/config-integration.d.ts.map +1 -1
  95. package/dist/cli/commands/config-integration.js +18 -9
  96. package/dist/cli/commands/config-integration.js.map +1 -1
  97. package/dist/cli/commands/config.d.ts.map +1 -1
  98. package/dist/cli/commands/config.js +2 -3
  99. package/dist/cli/commands/config.js.map +1 -1
  100. package/dist/cli/commands/enterprise.d.ts.map +1 -1
  101. package/dist/cli/commands/enterprise.js +115 -95
  102. package/dist/cli/commands/enterprise.js.map +1 -1
  103. package/dist/cli/commands/help-new.d.ts +7 -0
  104. package/dist/cli/commands/help-new.d.ts.map +1 -0
  105. package/dist/cli/commands/help-new.js +236 -0
  106. package/dist/cli/commands/help-new.js.map +1 -0
  107. package/dist/cli/commands/help.d.ts +2 -1
  108. package/dist/cli/commands/help.d.ts.map +1 -1
  109. package/dist/cli/commands/help.js +283 -133
  110. package/dist/cli/commands/help.js.map +1 -1
  111. package/dist/cli/commands/hive-mind/index.d.ts +1 -1
  112. package/dist/cli/commands/hive-mind/index.d.ts.map +1 -1
  113. package/dist/cli/commands/hive-mind/index.js +1 -1
  114. package/dist/cli/commands/hive-mind/index.js.map +1 -1
  115. package/dist/cli/commands/hive-mind/init.d.ts.map +1 -1
  116. package/dist/cli/commands/hive-mind/init.js.map +1 -1
  117. package/dist/cli/commands/hive-mind/optimize-memory.d.ts.map +1 -1
  118. package/dist/cli/commands/hive-mind/optimize-memory.js +35 -26
  119. package/dist/cli/commands/hive-mind/optimize-memory.js.map +1 -1
  120. package/dist/cli/commands/hive-mind/pause.d.ts.map +1 -1
  121. package/dist/cli/commands/hive-mind/pause.js +8 -6
  122. package/dist/cli/commands/hive-mind/pause.js.map +1 -1
  123. package/dist/cli/commands/hive-mind/ps.d.ts.map +1 -1
  124. package/dist/cli/commands/hive-mind/ps.js +17 -12
  125. package/dist/cli/commands/hive-mind/ps.js.map +1 -1
  126. package/dist/cli/commands/hive-mind/resume.js +12 -10
  127. package/dist/cli/commands/hive-mind/resume.js.map +1 -1
  128. package/dist/cli/commands/hive-mind/spawn.d.ts.map +1 -1
  129. package/dist/cli/commands/hive-mind/spawn.js +20 -11
  130. package/dist/cli/commands/hive-mind/spawn.js.map +1 -1
  131. package/dist/cli/commands/hive-mind/status.js +17 -22
  132. package/dist/cli/commands/hive-mind/status.js.map +1 -1
  133. package/dist/cli/commands/hive-mind/stop.d.ts.map +1 -1
  134. package/dist/cli/commands/hive-mind/stop.js +23 -15
  135. package/dist/cli/commands/hive-mind/stop.js.map +1 -1
  136. package/dist/cli/commands/hive-mind/task.d.ts.map +1 -1
  137. package/dist/cli/commands/hive-mind/task.js +25 -19
  138. package/dist/cli/commands/hive-mind/task.js.map +1 -1
  139. package/dist/cli/commands/hive-mind/wizard.d.ts.map +1 -1
  140. package/dist/cli/commands/hive-mind/wizard.js +86 -68
  141. package/dist/cli/commands/hive-mind/wizard.js.map +1 -1
  142. package/dist/cli/commands/hive.js +73 -38
  143. package/dist/cli/commands/hive.js.map +1 -1
  144. package/dist/cli/commands/hook-validator.d.ts.map +1 -1
  145. package/dist/cli/commands/hook-validator.js +4 -2
  146. package/dist/cli/commands/hook-validator.js.map +1 -1
  147. package/dist/cli/commands/hook.d.ts.map +1 -1
  148. package/dist/cli/commands/hook.js +8 -8
  149. package/dist/cli/commands/hook.js.map +1 -1
  150. package/dist/cli/commands/index.d.ts +1 -1
  151. package/dist/cli/commands/index.d.ts.map +1 -1
  152. package/dist/cli/commands/index.js +850 -784
  153. package/dist/cli/commands/index.js.map +1 -1
  154. package/dist/cli/commands/mcp.d.ts.map +1 -1
  155. package/dist/cli/commands/mcp.js +8 -16
  156. package/dist/cli/commands/mcp.js.map +1 -1
  157. package/dist/cli/commands/memory.d.ts.map +1 -1
  158. package/dist/cli/commands/memory.js +8 -8
  159. package/dist/cli/commands/memory.js.map +1 -1
  160. package/dist/cli/commands/migrate.d.ts.map +1 -1
  161. package/dist/cli/commands/migrate.js +3 -3
  162. package/dist/cli/commands/migrate.js.map +1 -1
  163. package/dist/cli/commands/monitor.d.ts.map +1 -1
  164. package/dist/cli/commands/monitor.js +50 -34
  165. package/dist/cli/commands/monitor.js.map +1 -1
  166. package/dist/cli/commands/ruv-swarm.d.ts +7 -1
  167. package/dist/cli/commands/ruv-swarm.d.ts.map +1 -1
  168. package/dist/cli/commands/ruv-swarm.js +6 -6
  169. package/dist/cli/commands/ruv-swarm.js.map +1 -1
  170. package/dist/cli/commands/session.d.ts.map +1 -1
  171. package/dist/cli/commands/session.js +22 -17
  172. package/dist/cli/commands/session.js.map +1 -1
  173. package/dist/cli/commands/sparc.d.ts +1 -1
  174. package/dist/cli/commands/sparc.d.ts.map +1 -1
  175. package/dist/cli/commands/sparc.js +146 -126
  176. package/dist/cli/commands/sparc.js.map +1 -1
  177. package/dist/cli/commands/start/event-emitter.js +1 -1
  178. package/dist/cli/commands/start/event-emitter.js.map +1 -1
  179. package/dist/cli/commands/start/process-manager.d.ts.map +1 -1
  180. package/dist/cli/commands/start/process-manager.js +20 -18
  181. package/dist/cli/commands/start/process-manager.js.map +1 -1
  182. package/dist/cli/commands/start/process-ui-simple.d.ts +4 -0
  183. package/dist/cli/commands/start/process-ui-simple.d.ts.map +1 -1
  184. package/dist/cli/commands/start/process-ui-simple.js +2 -2
  185. package/dist/cli/commands/start/process-ui-simple.js.map +1 -1
  186. package/dist/cli/commands/start/start-command.d.ts.map +1 -1
  187. package/dist/cli/commands/start/start-command.js +27 -15
  188. package/dist/cli/commands/start/start-command.js.map +1 -1
  189. package/dist/cli/commands/start/system-monitor.d.ts +3 -0
  190. package/dist/cli/commands/start/system-monitor.d.ts.map +1 -1
  191. package/dist/cli/commands/start/system-monitor.js +16 -18
  192. package/dist/cli/commands/start/system-monitor.js.map +1 -1
  193. package/dist/cli/commands/status.d.ts.map +1 -1
  194. package/dist/cli/commands/status.js +28 -33
  195. package/dist/cli/commands/status.js.map +1 -1
  196. package/dist/cli/commands/swarm-spawn.d.ts.map +1 -1
  197. package/dist/cli/commands/swarm-spawn.js +1 -1
  198. package/dist/cli/commands/swarm-spawn.js.map +1 -1
  199. package/dist/cli/commands/swarm.d.ts +4 -1
  200. package/dist/cli/commands/swarm.d.ts.map +1 -1
  201. package/dist/cli/commands/swarm.js +23 -18
  202. package/dist/cli/commands/swarm.js.map +1 -1
  203. package/dist/cli/commands/task.d.ts.map +1 -1
  204. package/dist/cli/commands/task.js.map +1 -1
  205. package/dist/cli/commands/workflow.d.ts.map +1 -1
  206. package/dist/cli/commands/workflow.js +49 -45
  207. package/dist/cli/commands/workflow.js.map +1 -1
  208. package/dist/cli/completion.d.ts +3 -0
  209. package/dist/cli/completion.d.ts.map +1 -1
  210. package/dist/cli/completion.js +15 -5
  211. package/dist/cli/completion.js.map +1 -1
  212. package/dist/cli/formatter.d.ts +3 -0
  213. package/dist/cli/formatter.d.ts.map +1 -1
  214. package/dist/cli/formatter.js +3 -3
  215. package/dist/cli/formatter.js.map +1 -1
  216. package/dist/cli/help-formatter.d.ts +49 -0
  217. package/dist/cli/help-formatter.d.ts.map +1 -0
  218. package/dist/cli/help-formatter.js +108 -0
  219. package/dist/cli/help-formatter.js.map +1 -0
  220. package/dist/cli/index-remote.d.ts +4 -0
  221. package/dist/cli/index-remote.d.ts.map +1 -1
  222. package/dist/cli/index-remote.js +1 -1
  223. package/dist/cli/index-remote.js.map +1 -1
  224. package/dist/cli/index.d.ts +1 -1
  225. package/dist/cli/index.d.ts.map +1 -1
  226. package/dist/cli/index.js +32 -34
  227. package/dist/cli/index.js.map +1 -1
  228. package/dist/cli/init/batch-tools.d.ts.map +1 -1
  229. package/dist/cli/init/batch-tools.js.map +1 -1
  230. package/dist/cli/init/claude-config.d.ts.map +1 -1
  231. package/dist/cli/init/claude-config.js +111 -106
  232. package/dist/cli/init/claude-config.js.map +1 -1
  233. package/dist/cli/init/directory-structure.d.ts.map +1 -1
  234. package/dist/cli/init/directory-structure.js +3 -3
  235. package/dist/cli/init/directory-structure.js.map +1 -1
  236. package/dist/cli/init/index.d.ts.map +1 -1
  237. package/dist/cli/init/index.js +1 -1
  238. package/dist/cli/init/index.js.map +1 -1
  239. package/dist/cli/init/sparc-environment.d.ts.map +1 -1
  240. package/dist/cli/init/sparc-environment.js +69 -69
  241. package/dist/cli/init/sparc-environment.js.map +1 -1
  242. package/dist/cli/init/swarm-commands.d.ts.map +1 -1
  243. package/dist/cli/init/swarm-commands.js +1 -1
  244. package/dist/cli/init/swarm-commands.js.map +1 -1
  245. package/dist/cli/main.d.ts +3 -0
  246. package/dist/cli/main.d.ts.map +1 -1
  247. package/dist/cli/main.js +6 -6
  248. package/dist/cli/main.js.map +1 -1
  249. package/dist/cli/node-compat.d.ts.map +1 -1
  250. package/dist/cli/node-compat.js +24 -18
  251. package/dist/cli/node-compat.js.map +1 -1
  252. package/dist/cli/node-repl.d.ts +4 -0
  253. package/dist/cli/node-repl.d.ts.map +1 -1
  254. package/dist/cli/node-repl.js +24 -30
  255. package/dist/cli/node-repl.js.map +1 -1
  256. package/dist/cli/repl.d.ts.map +1 -1
  257. package/dist/cli/repl.js +81 -70
  258. package/dist/cli/repl.js.map +1 -1
  259. package/dist/cli/runtime-detector.d.ts.map +1 -1
  260. package/dist/cli/runtime-detector.js +11 -7
  261. package/dist/cli/runtime-detector.js.map +1 -1
  262. package/dist/cli/simple-cli.d.ts +4 -0
  263. package/dist/cli/simple-cli.d.ts.map +1 -1
  264. package/dist/cli/simple-cli.js +109 -95
  265. package/dist/cli/simple-cli.js.map +1 -1
  266. package/dist/cli/simple-commands/analysis.d.ts.map +1 -1
  267. package/dist/cli/simple-commands/analysis.js +18 -11
  268. package/dist/cli/simple-commands/analysis.js.map +1 -1
  269. package/dist/cli/simple-commands/automation.js +32 -17
  270. package/dist/cli/simple-commands/automation.js.map +1 -1
  271. package/dist/cli/simple-commands/batch-manager.js +44 -39
  272. package/dist/cli/simple-commands/batch-manager.js.map +1 -1
  273. package/dist/cli/simple-commands/config.d.ts.map +1 -1
  274. package/dist/cli/simple-commands/config.js +22 -21
  275. package/dist/cli/simple-commands/config.js.map +1 -1
  276. package/dist/cli/simple-commands/coordination.d.ts.map +1 -1
  277. package/dist/cli/simple-commands/coordination.js +12 -12
  278. package/dist/cli/simple-commands/coordination.js.map +1 -1
  279. package/dist/cli/simple-commands/fix-hook-variables.d.ts.map +1 -1
  280. package/dist/cli/simple-commands/fix-hook-variables.js +36 -30
  281. package/dist/cli/simple-commands/fix-hook-variables.js.map +1 -1
  282. package/dist/cli/simple-commands/github.d.ts.map +1 -1
  283. package/dist/cli/simple-commands/github.js +15 -15
  284. package/dist/cli/simple-commands/github.js.map +1 -1
  285. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.d.ts.map +1 -1
  286. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.js +12 -10
  287. package/dist/cli/simple-commands/hive-mind/auto-save-middleware.js.map +1 -1
  288. package/dist/cli/simple-commands/hive-mind/communication.d.ts.map +1 -1
  289. package/dist/cli/simple-commands/hive-mind/communication.js +42 -45
  290. package/dist/cli/simple-commands/hive-mind/communication.js.map +1 -1
  291. package/dist/cli/simple-commands/hive-mind/core.d.ts.map +1 -1
  292. package/dist/cli/simple-commands/hive-mind/core.js +97 -89
  293. package/dist/cli/simple-commands/hive-mind/core.js.map +1 -1
  294. package/dist/cli/simple-commands/hive-mind/db-optimizer.d.ts.map +1 -1
  295. package/dist/cli/simple-commands/hive-mind/db-optimizer.js +114 -59
  296. package/dist/cli/simple-commands/hive-mind/db-optimizer.js.map +1 -1
  297. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts.map +1 -1
  298. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js +182 -103
  299. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js.map +1 -1
  300. package/dist/cli/simple-commands/hive-mind/memory.d.ts.map +1 -1
  301. package/dist/cli/simple-commands/hive-mind/memory.js +105 -75
  302. package/dist/cli/simple-commands/hive-mind/memory.js.map +1 -1
  303. package/dist/cli/simple-commands/hive-mind/performance-optimizer.d.ts.map +1 -1
  304. package/dist/cli/simple-commands/hive-mind/performance-optimizer.js +45 -43
  305. package/dist/cli/simple-commands/hive-mind/performance-optimizer.js.map +1 -1
  306. package/dist/cli/simple-commands/hive-mind/queen.d.ts.map +1 -1
  307. package/dist/cli/simple-commands/hive-mind/queen.js +101 -88
  308. package/dist/cli/simple-commands/hive-mind/queen.js.map +1 -1
  309. package/dist/cli/simple-commands/hive-mind/session-manager.js +75 -53
  310. package/dist/cli/simple-commands/hive-mind/session-manager.js.map +1 -1
  311. package/dist/cli/simple-commands/hive-mind-optimize.js +18 -18
  312. package/dist/cli/simple-commands/hive-mind-optimize.js.map +1 -1
  313. package/dist/cli/simple-commands/hive-mind.d.ts.map +1 -1
  314. package/dist/cli/simple-commands/hive-mind.js +207 -144
  315. package/dist/cli/simple-commands/hive-mind.js.map +1 -1
  316. package/dist/cli/simple-commands/hook-safety.d.ts.map +1 -1
  317. package/dist/cli/simple-commands/hook-safety.js +19 -19
  318. package/dist/cli/simple-commands/hook-safety.js.map +1 -1
  319. package/dist/cli/simple-commands/hooks.d.ts.map +1 -1
  320. package/dist/cli/simple-commands/hooks.js +85 -71
  321. package/dist/cli/simple-commands/hooks.js.map +1 -1
  322. package/dist/cli/simple-commands/init/batch-init.d.ts.map +1 -1
  323. package/dist/cli/simple-commands/init/batch-init.js +62 -55
  324. package/dist/cli/simple-commands/init/batch-init.js.map +1 -1
  325. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.d.ts.map +1 -1
  326. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +2 -2
  327. package/dist/cli/simple-commands/init/claude-commands/optimized-slash-commands.js.map +1 -1
  328. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.d.ts.map +1 -1
  329. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +58 -50
  330. package/dist/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js.map +1 -1
  331. package/dist/cli/simple-commands/init/claude-commands/slash-commands.d.ts.map +1 -1
  332. package/dist/cli/simple-commands/init/claude-commands/slash-commands.js.map +1 -1
  333. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.d.ts.map +1 -1
  334. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.js +34 -28
  335. package/dist/cli/simple-commands/init/claude-commands/sparc-commands.js.map +1 -1
  336. package/dist/cli/simple-commands/init/executable-wrapper.d.ts.map +1 -1
  337. package/dist/cli/simple-commands/init/executable-wrapper.js +7 -4
  338. package/dist/cli/simple-commands/init/executable-wrapper.js.map +1 -1
  339. package/dist/cli/simple-commands/init/gitignore-updater.d.ts.map +1 -1
  340. package/dist/cli/simple-commands/init/gitignore-updater.js +10 -9
  341. package/dist/cli/simple-commands/init/gitignore-updater.js.map +1 -1
  342. package/dist/cli/simple-commands/init/help.d.ts.map +1 -1
  343. package/dist/cli/simple-commands/init/help.js.map +1 -1
  344. package/dist/cli/simple-commands/init/index.d.ts.map +1 -1
  345. package/dist/cli/simple-commands/init/index.js +159 -103
  346. package/dist/cli/simple-commands/init/index.js.map +1 -1
  347. package/dist/cli/simple-commands/init/performance-monitor.d.ts.map +1 -1
  348. package/dist/cli/simple-commands/init/performance-monitor.js +17 -18
  349. package/dist/cli/simple-commands/init/performance-monitor.js.map +1 -1
  350. package/dist/cli/simple-commands/init/rollback/backup-manager.d.ts.map +1 -1
  351. package/dist/cli/simple-commands/init/rollback/backup-manager.js +19 -25
  352. package/dist/cli/simple-commands/init/rollback/backup-manager.js.map +1 -1
  353. package/dist/cli/simple-commands/init/rollback/index.d.ts.map +1 -1
  354. package/dist/cli/simple-commands/init/rollback/index.js +18 -15
  355. package/dist/cli/simple-commands/init/rollback/index.js.map +1 -1
  356. package/dist/cli/simple-commands/init/rollback/recovery-manager.d.ts.map +1 -1
  357. package/dist/cli/simple-commands/init/rollback/recovery-manager.js +49 -68
  358. package/dist/cli/simple-commands/init/rollback/recovery-manager.js.map +1 -1
  359. package/dist/cli/simple-commands/init/rollback/rollback-executor.d.ts.map +1 -1
  360. package/dist/cli/simple-commands/init/rollback/rollback-executor.js +16 -24
  361. package/dist/cli/simple-commands/init/rollback/rollback-executor.js.map +1 -1
  362. package/dist/cli/simple-commands/init/rollback/state-tracker.d.ts.map +1 -1
  363. package/dist/cli/simple-commands/init/rollback/state-tracker.js +25 -25
  364. package/dist/cli/simple-commands/init/rollback/state-tracker.js.map +1 -1
  365. package/dist/cli/simple-commands/init/sparc/roomodes-config.d.ts.map +1 -1
  366. package/dist/cli/simple-commands/init/sparc/roomodes-config.js +57 -57
  367. package/dist/cli/simple-commands/init/sparc/roomodes-config.js.map +1 -1
  368. package/dist/cli/simple-commands/init/sparc/workflows.d.ts.map +1 -1
  369. package/dist/cli/simple-commands/init/sparc/workflows.js +21 -21
  370. package/dist/cli/simple-commands/init/sparc/workflows.js.map +1 -1
  371. package/dist/cli/simple-commands/init/sparc-structure.d.ts.map +1 -1
  372. package/dist/cli/simple-commands/init/sparc-structure.js +1 -1
  373. package/dist/cli/simple-commands/init/sparc-structure.js.map +1 -1
  374. package/dist/cli/simple-commands/init/templates/enhanced-templates.d.ts.map +1 -1
  375. package/dist/cli/simple-commands/init/templates/enhanced-templates.js +69 -78
  376. package/dist/cli/simple-commands/init/templates/enhanced-templates.js.map +1 -1
  377. package/dist/cli/simple-commands/init/templates/sparc-modes.js +2 -2
  378. package/dist/cli/simple-commands/init/validation/config-validator.d.ts.map +1 -1
  379. package/dist/cli/simple-commands/init/validation/config-validator.js +12 -16
  380. package/dist/cli/simple-commands/init/validation/config-validator.js.map +1 -1
  381. package/dist/cli/simple-commands/init/validation/health-checker.d.ts.map +1 -1
  382. package/dist/cli/simple-commands/init/validation/health-checker.js +39 -41
  383. package/dist/cli/simple-commands/init/validation/health-checker.js.map +1 -1
  384. package/dist/cli/simple-commands/init/validation/index.d.ts.map +1 -1
  385. package/dist/cli/simple-commands/init/validation/index.js +8 -8
  386. package/dist/cli/simple-commands/init/validation/index.js.map +1 -1
  387. package/dist/cli/simple-commands/init/validation/mode-validator.d.ts.map +1 -1
  388. package/dist/cli/simple-commands/init/validation/mode-validator.js +12 -12
  389. package/dist/cli/simple-commands/init/validation/mode-validator.js.map +1 -1
  390. package/dist/cli/simple-commands/init/validation/post-init-validator.d.ts.map +1 -1
  391. package/dist/cli/simple-commands/init/validation/post-init-validator.js +13 -13
  392. package/dist/cli/simple-commands/init/validation/post-init-validator.js.map +1 -1
  393. package/dist/cli/simple-commands/init/validation/pre-init-validator.d.ts.map +1 -1
  394. package/dist/cli/simple-commands/init/validation/pre-init-validator.js +19 -24
  395. package/dist/cli/simple-commands/init/validation/pre-init-validator.js.map +1 -1
  396. package/dist/cli/simple-commands/mcp.js +2 -2
  397. package/dist/cli/simple-commands/mcp.js.map +1 -1
  398. package/dist/cli/simple-commands/memory.js +4 -4
  399. package/dist/cli/simple-commands/memory.js.map +1 -1
  400. package/dist/cli/simple-commands/migrate-hooks.d.ts.map +1 -1
  401. package/dist/cli/simple-commands/migrate-hooks.js +3 -3
  402. package/dist/cli/simple-commands/migrate-hooks.js.map +1 -1
  403. package/dist/cli/simple-commands/monitor.d.ts.map +1 -1
  404. package/dist/cli/simple-commands/monitor.js +34 -26
  405. package/dist/cli/simple-commands/monitor.js.map +1 -1
  406. package/dist/cli/simple-commands/process-ui-enhanced.d.ts.map +1 -1
  407. package/dist/cli/simple-commands/process-ui-enhanced.js +53 -39
  408. package/dist/cli/simple-commands/process-ui-enhanced.js.map +1 -1
  409. package/dist/cli/simple-commands/sparc-modes/index.js +11 -11
  410. package/dist/cli/simple-commands/sparc-modes/index.js.map +1 -1
  411. package/dist/cli/simple-commands/sparc-modes/swarm.js +50 -50
  412. package/dist/cli/simple-commands/sparc.d.ts.map +1 -1
  413. package/dist/cli/simple-commands/sparc.js +21 -11
  414. package/dist/cli/simple-commands/sparc.js.map +1 -1
  415. package/dist/cli/simple-commands/start-ui.d.ts.map +1 -1
  416. package/dist/cli/simple-commands/start-ui.js +5 -3
  417. package/dist/cli/simple-commands/start-ui.js.map +1 -1
  418. package/dist/cli/simple-commands/start-wrapper.d.ts.map +1 -1
  419. package/dist/cli/simple-commands/start-wrapper.js +1 -1
  420. package/dist/cli/simple-commands/start-wrapper.js.map +1 -1
  421. package/dist/cli/simple-commands/status.js +14 -14
  422. package/dist/cli/simple-commands/status.js.map +1 -1
  423. package/dist/cli/simple-commands/swarm-executor.d.ts.map +1 -1
  424. package/dist/cli/simple-commands/swarm-executor.js +19 -19
  425. package/dist/cli/simple-commands/swarm-executor.js.map +1 -1
  426. package/dist/cli/simple-commands/swarm-metrics-integration.d.ts.map +1 -1
  427. package/dist/cli/simple-commands/swarm-metrics-integration.js +30 -21
  428. package/dist/cli/simple-commands/swarm-metrics-integration.js.map +1 -1
  429. package/dist/cli/simple-commands/swarm-webui-integration.d.ts.map +1 -1
  430. package/dist/cli/simple-commands/swarm-webui-integration.js +30 -18
  431. package/dist/cli/simple-commands/swarm-webui-integration.js.map +1 -1
  432. package/dist/cli/simple-commands/swarm.d.ts +1 -1
  433. package/dist/cli/simple-commands/swarm.d.ts.map +1 -1
  434. package/dist/cli/simple-commands/swarm.js +81 -76
  435. package/dist/cli/simple-commands/swarm.js.map +1 -1
  436. package/dist/cli/simple-commands/training.d.ts.map +1 -1
  437. package/dist/cli/simple-commands/training.js +7 -7
  438. package/dist/cli/simple-commands/training.js.map +1 -1
  439. package/dist/cli/simple-commands/web-server.d.ts.map +1 -1
  440. package/dist/cli/simple-commands/web-server.js +68 -66
  441. package/dist/cli/simple-commands/web-server.js.map +1 -1
  442. package/dist/cli/simple-mcp.d.ts.map +1 -1
  443. package/dist/cli/simple-mcp.js +2 -4
  444. package/dist/cli/simple-mcp.js.map +1 -1
  445. package/dist/cli/simple-orchestrator.d.ts +3 -0
  446. package/dist/cli/simple-orchestrator.d.ts.map +1 -1
  447. package/dist/cli/simple-orchestrator.js +36 -35
  448. package/dist/cli/simple-orchestrator.js.map +1 -1
  449. package/dist/cli/ui/compatible-ui.d.ts +4 -0
  450. package/dist/cli/ui/compatible-ui.d.ts.map +1 -1
  451. package/dist/cli/ui/compatible-ui.js +9 -8
  452. package/dist/cli/ui/compatible-ui.js.map +1 -1
  453. package/dist/cli/ui/fallback-handler.d.ts.map +1 -1
  454. package/dist/cli/ui/fallback-handler.js +4 -4
  455. package/dist/cli/ui/fallback-handler.js.map +1 -1
  456. package/dist/cli/ui/index.d.ts +2 -2
  457. package/dist/cli/ui/index.d.ts.map +1 -1
  458. package/dist/cli/ui/index.js +3 -3
  459. package/dist/cli/ui/index.js.map +1 -1
  460. package/dist/cli/utils/environment-detector.d.ts.map +1 -1
  461. package/dist/cli/utils/environment-detector.js +13 -11
  462. package/dist/cli/utils/environment-detector.js.map +1 -1
  463. package/dist/cli/utils/interactive-detector.d.ts.map +1 -1
  464. package/dist/cli/utils/interactive-detector.js +1 -1
  465. package/dist/cli/utils/interactive-detector.js.map +1 -1
  466. package/dist/cli/utils/prompt-defaults.d.ts.map +1 -1
  467. package/dist/cli/utils/prompt-defaults.js +6 -7
  468. package/dist/cli/utils/prompt-defaults.js.map +1 -1
  469. package/dist/cli/utils/safe-interactive.d.ts.map +1 -1
  470. package/dist/cli/utils/safe-interactive.js +7 -6
  471. package/dist/cli/utils/safe-interactive.js.map +1 -1
  472. package/dist/cli/utils.d.ts.map +1 -1
  473. package/dist/cli/utils.js +58 -50
  474. package/dist/cli/utils.js.map +1 -1
  475. package/dist/cli/validation-helper.d.ts +27 -0
  476. package/dist/cli/validation-helper.d.ts.map +1 -0
  477. package/dist/cli/validation-helper.js +72 -0
  478. package/dist/cli/validation-helper.js.map +1 -0
  479. package/dist/communication/message-bus.d.ts.map +1 -1
  480. package/dist/communication/message-bus.js +80 -74
  481. package/dist/communication/message-bus.js.map +1 -1
  482. package/dist/config/config-manager.d.ts +3 -0
  483. package/dist/config/config-manager.d.ts.map +1 -1
  484. package/dist/config/config-manager.js +23 -6
  485. package/dist/config/config-manager.js.map +1 -1
  486. package/dist/config/ruv-swarm-config.d.ts +6 -0
  487. package/dist/config/ruv-swarm-config.d.ts.map +1 -1
  488. package/dist/config/ruv-swarm-config.js +37 -22
  489. package/dist/config/ruv-swarm-config.js.map +1 -1
  490. package/dist/config/ruv-swarm-integration.d.ts.map +1 -1
  491. package/dist/config/ruv-swarm-integration.js +21 -21
  492. package/dist/config/ruv-swarm-integration.js.map +1 -1
  493. package/dist/constants/agent-types.d.ts +4 -4
  494. package/dist/constants/agent-types.d.ts.map +1 -1
  495. package/dist/constants/agent-types.js +4 -4
  496. package/dist/constants/agent-types.js.map +1 -1
  497. package/dist/coordination/advanced-scheduler.d.ts.map +1 -1
  498. package/dist/coordination/advanced-scheduler.js +6 -10
  499. package/dist/coordination/advanced-scheduler.js.map +1 -1
  500. package/dist/coordination/advanced-task-executor.d.ts.map +1 -1
  501. package/dist/coordination/advanced-task-executor.js +33 -33
  502. package/dist/coordination/advanced-task-executor.js.map +1 -1
  503. package/dist/coordination/background-executor.d.ts.map +1 -1
  504. package/dist/coordination/background-executor.js +17 -16
  505. package/dist/coordination/background-executor.js.map +1 -1
  506. package/dist/coordination/circuit-breaker.d.ts.map +1 -1
  507. package/dist/coordination/circuit-breaker.js +3 -0
  508. package/dist/coordination/circuit-breaker.js.map +1 -1
  509. package/dist/coordination/conflict-resolution.d.ts.map +1 -1
  510. package/dist/coordination/conflict-resolution.js +10 -8
  511. package/dist/coordination/conflict-resolution.js.map +1 -1
  512. package/dist/coordination/dependency-graph.d.ts.map +1 -1
  513. package/dist/coordination/dependency-graph.js +4 -3
  514. package/dist/coordination/dependency-graph.js.map +1 -1
  515. package/dist/coordination/hive-orchestrator.d.ts.map +1 -1
  516. package/dist/coordination/hive-orchestrator.js +29 -25
  517. package/dist/coordination/hive-orchestrator.js.map +1 -1
  518. package/dist/coordination/hive-protocol.d.ts.map +1 -1
  519. package/dist/coordination/hive-protocol.js +22 -23
  520. package/dist/coordination/hive-protocol.js.map +1 -1
  521. package/dist/coordination/index.d.ts +1 -1
  522. package/dist/coordination/index.d.ts.map +1 -1
  523. package/dist/coordination/index.js +1 -1
  524. package/dist/coordination/index.js.map +1 -1
  525. package/dist/coordination/load-balancer.d.ts.map +1 -1
  526. package/dist/coordination/load-balancer.js +55 -56
  527. package/dist/coordination/load-balancer.js.map +1 -1
  528. package/dist/coordination/manager.d.ts.map +1 -1
  529. package/dist/coordination/manager.js +2 -8
  530. package/dist/coordination/manager.js.map +1 -1
  531. package/dist/coordination/messaging.d.ts.map +1 -1
  532. package/dist/coordination/messaging.js +4 -4
  533. package/dist/coordination/messaging.js.map +1 -1
  534. package/dist/coordination/metrics.d.ts.map +1 -1
  535. package/dist/coordination/metrics.js +11 -9
  536. package/dist/coordination/metrics.js.map +1 -1
  537. package/dist/coordination/resources.d.ts.map +1 -1
  538. package/dist/coordination/resources.js +10 -6
  539. package/dist/coordination/resources.js.map +1 -1
  540. package/dist/coordination/scheduler.d.ts.map +1 -1
  541. package/dist/coordination/scheduler.js +4 -4
  542. package/dist/coordination/scheduler.js.map +1 -1
  543. package/dist/coordination/swarm-coordinator.d.ts.map +1 -1
  544. package/dist/coordination/swarm-coordinator.js +32 -34
  545. package/dist/coordination/swarm-coordinator.js.map +1 -1
  546. package/dist/coordination/swarm-monitor.d.ts.map +1 -1
  547. package/dist/coordination/swarm-monitor.js +17 -17
  548. package/dist/coordination/swarm-monitor.js.map +1 -1
  549. package/dist/coordination/work-stealing.d.ts.map +1 -1
  550. package/dist/coordination/work-stealing.js +3 -0
  551. package/dist/coordination/work-stealing.js.map +1 -1
  552. package/dist/core/config.d.ts +4 -0
  553. package/dist/core/config.d.ts.map +1 -1
  554. package/dist/core/config.js +28 -31
  555. package/dist/core/config.js.map +1 -1
  556. package/dist/core/event-bus.d.ts +3 -0
  557. package/dist/core/event-bus.d.ts.map +1 -1
  558. package/dist/core/event-bus.js.map +1 -1
  559. package/dist/core/json-persistence.d.ts +3 -0
  560. package/dist/core/json-persistence.d.ts.map +1 -1
  561. package/dist/core/json-persistence.js +19 -23
  562. package/dist/core/json-persistence.js.map +1 -1
  563. package/dist/core/logger.d.ts +3 -0
  564. package/dist/core/logger.d.ts.map +1 -1
  565. package/dist/core/logger.js +2 -6
  566. package/dist/core/logger.js.map +1 -1
  567. package/dist/core/orchestrator-fixed.d.ts.map +1 -1
  568. package/dist/core/orchestrator-fixed.js +4 -1
  569. package/dist/core/orchestrator-fixed.js.map +1 -1
  570. package/dist/core/orchestrator.d.ts.map +1 -1
  571. package/dist/core/orchestrator.js +66 -33
  572. package/dist/core/orchestrator.js.map +1 -1
  573. package/dist/core/persistence.d.ts +3 -0
  574. package/dist/core/persistence.d.ts.map +1 -1
  575. package/dist/core/persistence.js +25 -19
  576. package/dist/core/persistence.js.map +1 -1
  577. package/dist/enterprise/analytics-manager.d.ts.map +1 -1
  578. package/dist/enterprise/analytics-manager.js +141 -134
  579. package/dist/enterprise/analytics-manager.js.map +1 -1
  580. package/dist/enterprise/audit-manager.d.ts.map +1 -1
  581. package/dist/enterprise/audit-manager.js +144 -122
  582. package/dist/enterprise/audit-manager.js.map +1 -1
  583. package/dist/enterprise/cloud-manager.d.ts.map +1 -1
  584. package/dist/enterprise/cloud-manager.js +104 -99
  585. package/dist/enterprise/cloud-manager.js.map +1 -1
  586. package/dist/enterprise/deployment-manager.d.ts.map +1 -1
  587. package/dist/enterprise/deployment-manager.js +104 -97
  588. package/dist/enterprise/deployment-manager.js.map +1 -1
  589. package/dist/enterprise/index.d.ts +6 -6
  590. package/dist/enterprise/index.d.ts.map +1 -1
  591. package/dist/enterprise/project-manager.d.ts.map +1 -1
  592. package/dist/enterprise/project-manager.js +74 -66
  593. package/dist/enterprise/project-manager.js.map +1 -1
  594. package/dist/enterprise/security-manager.d.ts.map +1 -1
  595. package/dist/enterprise/security-manager.js +137 -129
  596. package/dist/enterprise/security-manager.js.map +1 -1
  597. package/dist/hive-mind/core/Agent.d.ts.map +1 -1
  598. package/dist/hive-mind/core/Agent.js +36 -36
  599. package/dist/hive-mind/core/Agent.js.map +1 -1
  600. package/dist/hive-mind/core/Communication.d.ts.map +1 -1
  601. package/dist/hive-mind/core/Communication.js +17 -17
  602. package/dist/hive-mind/core/Communication.js.map +1 -1
  603. package/dist/hive-mind/core/DatabaseManager.d.ts.map +1 -1
  604. package/dist/hive-mind/core/DatabaseManager.js +104 -58
  605. package/dist/hive-mind/core/DatabaseManager.js.map +1 -1
  606. package/dist/hive-mind/core/HiveMind.d.ts.map +1 -1
  607. package/dist/hive-mind/core/HiveMind.js +35 -35
  608. package/dist/hive-mind/core/HiveMind.js.map +1 -1
  609. package/dist/hive-mind/core/Memory.d.ts.map +1 -1
  610. package/dist/hive-mind/core/Memory.js +78 -71
  611. package/dist/hive-mind/core/Memory.js.map +1 -1
  612. package/dist/hive-mind/core/MemoryMonitor.d.ts.map +1 -1
  613. package/dist/hive-mind/core/MemoryMonitor.js +38 -38
  614. package/dist/hive-mind/core/MemoryMonitor.js.map +1 -1
  615. package/dist/hive-mind/core/Queen.d.ts.map +1 -1
  616. package/dist/hive-mind/core/Queen.js +110 -47
  617. package/dist/hive-mind/core/Queen.js.map +1 -1
  618. package/dist/hive-mind/integration/ConsensusEngine.d.ts.map +1 -1
  619. package/dist/hive-mind/integration/ConsensusEngine.js +25 -23
  620. package/dist/hive-mind/integration/ConsensusEngine.js.map +1 -1
  621. package/dist/hive-mind/integration/MCPToolWrapper.d.ts.map +1 -1
  622. package/dist/hive-mind/integration/MCPToolWrapper.js.map +1 -1
  623. package/dist/hive-mind/integration/SwarmOrchestrator.d.ts.map +1 -1
  624. package/dist/hive-mind/integration/SwarmOrchestrator.js +60 -58
  625. package/dist/hive-mind/integration/SwarmOrchestrator.js.map +1 -1
  626. package/dist/hive-mind/types.d.ts.map +1 -1
  627. package/dist/integration/mock-components.d.ts.map +1 -1
  628. package/dist/integration/mock-components.js +21 -21
  629. package/dist/integration/mock-components.js.map +1 -1
  630. package/dist/integration/system-integration.d.ts.map +1 -1
  631. package/dist/integration/system-integration.js +29 -12
  632. package/dist/integration/system-integration.js.map +1 -1
  633. package/dist/mcp/auth.d.ts +1 -1
  634. package/dist/mcp/auth.d.ts.map +1 -1
  635. package/dist/mcp/auth.js +8 -1
  636. package/dist/mcp/auth.js.map +1 -1
  637. package/dist/mcp/claude-code-wrapper.d.ts.map +1 -1
  638. package/dist/mcp/claude-code-wrapper.js +169 -68
  639. package/dist/mcp/claude-code-wrapper.js.map +1 -1
  640. package/dist/mcp/claude-flow-tools.d.ts.map +1 -1
  641. package/dist/mcp/claude-flow-tools.js +42 -3
  642. package/dist/mcp/claude-flow-tools.js.map +1 -1
  643. package/dist/mcp/client.d.ts.map +1 -1
  644. package/dist/mcp/client.js.map +1 -1
  645. package/dist/mcp/index.d.ts +6 -6
  646. package/dist/mcp/index.d.ts.map +1 -1
  647. package/dist/mcp/index.js +9 -9
  648. package/dist/mcp/index.js.map +1 -1
  649. package/dist/mcp/integrate-wrapper.d.ts.map +1 -1
  650. package/dist/mcp/integrate-wrapper.js +5 -7
  651. package/dist/mcp/integrate-wrapper.js.map +1 -1
  652. package/dist/mcp/lifecycle-manager.d.ts.map +1 -1
  653. package/dist/mcp/lifecycle-manager.js +8 -7
  654. package/dist/mcp/lifecycle-manager.js.map +1 -1
  655. package/dist/mcp/load-balancer.d.ts.map +1 -1
  656. package/dist/mcp/load-balancer.js +5 -1
  657. package/dist/mcp/load-balancer.js.map +1 -1
  658. package/dist/mcp/orchestration-integration.d.ts.map +1 -1
  659. package/dist/mcp/orchestration-integration.js +22 -9
  660. package/dist/mcp/orchestration-integration.js.map +1 -1
  661. package/dist/mcp/performance-monitor.d.ts.map +1 -1
  662. package/dist/mcp/performance-monitor.js +22 -19
  663. package/dist/mcp/performance-monitor.js.map +1 -1
  664. package/dist/mcp/protocol-manager.d.ts.map +1 -1
  665. package/dist/mcp/protocol-manager.js +8 -19
  666. package/dist/mcp/protocol-manager.js.map +1 -1
  667. package/dist/mcp/recovery/connection-health-monitor.d.ts.map +1 -1
  668. package/dist/mcp/recovery/connection-health-monitor.js +5 -5
  669. package/dist/mcp/recovery/connection-health-monitor.js.map +1 -1
  670. package/dist/mcp/recovery/connection-state-manager.d.ts +4 -0
  671. package/dist/mcp/recovery/connection-state-manager.d.ts.map +1 -1
  672. package/dist/mcp/recovery/connection-state-manager.js +13 -13
  673. package/dist/mcp/recovery/connection-state-manager.js.map +1 -1
  674. package/dist/mcp/recovery/fallback-coordinator.d.ts.map +1 -1
  675. package/dist/mcp/recovery/fallback-coordinator.js +5 -5
  676. package/dist/mcp/recovery/fallback-coordinator.js.map +1 -1
  677. package/dist/mcp/recovery/index.d.ts +4 -4
  678. package/dist/mcp/recovery/index.d.ts.map +1 -1
  679. package/dist/mcp/recovery/index.js +4 -4
  680. package/dist/mcp/recovery/index.js.map +1 -1
  681. package/dist/mcp/recovery/reconnection-manager.d.ts.map +1 -1
  682. package/dist/mcp/recovery/reconnection-manager.js +1 -1
  683. package/dist/mcp/recovery/reconnection-manager.js.map +1 -1
  684. package/dist/mcp/recovery/recovery-manager.d.ts.map +1 -1
  685. package/dist/mcp/recovery/recovery-manager.js +2 -4
  686. package/dist/mcp/recovery/recovery-manager.js.map +1 -1
  687. package/dist/mcp/router.d.ts.map +1 -1
  688. package/dist/mcp/router.js +3 -0
  689. package/dist/mcp/router.js.map +1 -1
  690. package/dist/mcp/ruv-swarm-tools.d.ts.map +1 -1
  691. package/dist/mcp/ruv-swarm-tools.js +132 -102
  692. package/dist/mcp/ruv-swarm-tools.js.map +1 -1
  693. package/dist/mcp/server-with-wrapper.d.ts +3 -0
  694. package/dist/mcp/server-with-wrapper.d.ts.map +1 -1
  695. package/dist/mcp/server-with-wrapper.js +2 -3
  696. package/dist/mcp/server-with-wrapper.js.map +1 -1
  697. package/dist/mcp/server-wrapper-mode.d.ts +5 -0
  698. package/dist/mcp/server-wrapper-mode.d.ts.map +1 -1
  699. package/dist/mcp/server-wrapper-mode.js +2 -3
  700. package/dist/mcp/server-wrapper-mode.js.map +1 -1
  701. package/dist/mcp/server.d.ts.map +1 -1
  702. package/dist/mcp/server.js +12 -7
  703. package/dist/mcp/server.js.map +1 -1
  704. package/dist/mcp/session-manager.d.ts.map +1 -1
  705. package/dist/mcp/session-manager.js +4 -3
  706. package/dist/mcp/session-manager.js.map +1 -1
  707. package/dist/mcp/sparc-modes.d.ts.map +1 -1
  708. package/dist/mcp/sparc-modes.js +15 -15
  709. package/dist/mcp/sparc-modes.js.map +1 -1
  710. package/dist/mcp/swarm-tools.d.ts.map +1 -1
  711. package/dist/mcp/swarm-tools.js +100 -80
  712. package/dist/mcp/swarm-tools.js.map +1 -1
  713. package/dist/mcp/tools.d.ts.map +1 -1
  714. package/dist/mcp/tools.js +28 -12
  715. package/dist/mcp/tools.js.map +1 -1
  716. package/dist/mcp/transports/base.d.ts.map +1 -1
  717. package/dist/mcp/transports/base.js +3 -0
  718. package/dist/mcp/transports/base.js.map +1 -1
  719. package/dist/mcp/transports/http.d.ts +3 -0
  720. package/dist/mcp/transports/http.d.ts.map +1 -1
  721. package/dist/mcp/transports/http.js +3 -3
  722. package/dist/mcp/transports/http.js.map +1 -1
  723. package/dist/mcp/transports/stdio.d.ts +3 -0
  724. package/dist/mcp/transports/stdio.d.ts.map +1 -1
  725. package/dist/mcp/transports/stdio.js +3 -0
  726. package/dist/mcp/transports/stdio.js.map +1 -1
  727. package/dist/memory/advanced-memory-manager.d.ts.map +1 -1
  728. package/dist/memory/advanced-memory-manager.js +109 -100
  729. package/dist/memory/advanced-memory-manager.js.map +1 -1
  730. package/dist/memory/backends/base.d.ts.map +1 -1
  731. package/dist/memory/backends/base.js +3 -0
  732. package/dist/memory/backends/base.js.map +1 -1
  733. package/dist/memory/backends/markdown.d.ts +3 -0
  734. package/dist/memory/backends/markdown.d.ts.map +1 -1
  735. package/dist/memory/backends/markdown.js +8 -8
  736. package/dist/memory/backends/markdown.js.map +1 -1
  737. package/dist/memory/backends/sqlite.d.ts +3 -0
  738. package/dist/memory/backends/sqlite.d.ts.map +1 -1
  739. package/dist/memory/backends/sqlite.js +6 -2
  740. package/dist/memory/backends/sqlite.js.map +1 -1
  741. package/dist/memory/cache.d.ts.map +1 -1
  742. package/dist/memory/cache.js +5 -3
  743. package/dist/memory/cache.js.map +1 -1
  744. package/dist/memory/distributed-memory.d.ts.map +1 -1
  745. package/dist/memory/distributed-memory.js +27 -28
  746. package/dist/memory/distributed-memory.js.map +1 -1
  747. package/dist/memory/fallback-store.d.ts.map +1 -1
  748. package/dist/memory/fallback-store.js.map +1 -1
  749. package/dist/memory/in-memory-store.d.ts.map +1 -1
  750. package/dist/memory/in-memory-store.js +8 -8
  751. package/dist/memory/in-memory-store.js.map +1 -1
  752. package/dist/memory/indexer.d.ts.map +1 -1
  753. package/dist/memory/indexer.js +4 -1
  754. package/dist/memory/indexer.js.map +1 -1
  755. package/dist/memory/manager.d.ts.map +1 -1
  756. package/dist/memory/manager.js +17 -20
  757. package/dist/memory/manager.js.map +1 -1
  758. package/dist/memory/sqlite-store.js +12 -8
  759. package/dist/memory/sqlite-store.js.map +1 -1
  760. package/dist/memory/swarm-memory.d.ts.map +1 -1
  761. package/dist/memory/swarm-memory.js +37 -44
  762. package/dist/memory/swarm-memory.js.map +1 -1
  763. package/dist/migration/index.d.ts +4 -0
  764. package/dist/migration/index.d.ts.map +1 -1
  765. package/dist/migration/index.js +8 -8
  766. package/dist/migration/index.js.map +1 -1
  767. package/dist/migration/logger.d.ts.map +1 -1
  768. package/dist/migration/logger.js +5 -5
  769. package/dist/migration/logger.js.map +1 -1
  770. package/dist/migration/migration-analyzer.d.ts +3 -0
  771. package/dist/migration/migration-analyzer.d.ts.map +1 -1
  772. package/dist/migration/migration-analyzer.js +25 -20
  773. package/dist/migration/migration-analyzer.js.map +1 -1
  774. package/dist/migration/migration-runner.d.ts.map +1 -1
  775. package/dist/migration/migration-runner.js +35 -29
  776. package/dist/migration/migration-runner.js.map +1 -1
  777. package/dist/migration/migration-validator.d.ts +3 -0
  778. package/dist/migration/migration-validator.d.ts.map +1 -1
  779. package/dist/migration/migration-validator.js +22 -26
  780. package/dist/migration/migration-validator.js.map +1 -1
  781. package/dist/migration/progress-reporter.d.ts +3 -0
  782. package/dist/migration/progress-reporter.d.ts.map +1 -1
  783. package/dist/migration/progress-reporter.js +8 -8
  784. package/dist/migration/progress-reporter.js.map +1 -1
  785. package/dist/migration/rollback-manager.d.ts +3 -0
  786. package/dist/migration/rollback-manager.d.ts.map +1 -1
  787. package/dist/migration/rollback-manager.js +29 -26
  788. package/dist/migration/rollback-manager.js.map +1 -1
  789. package/dist/monitoring/diagnostics.d.ts.map +1 -1
  790. package/dist/monitoring/diagnostics.js +49 -37
  791. package/dist/monitoring/diagnostics.js.map +1 -1
  792. package/dist/monitoring/health-check.d.ts.map +1 -1
  793. package/dist/monitoring/health-check.js +24 -25
  794. package/dist/monitoring/health-check.js.map +1 -1
  795. package/dist/monitoring/real-time-monitor.d.ts.map +1 -1
  796. package/dist/monitoring/real-time-monitor.js +71 -58
  797. package/dist/monitoring/real-time-monitor.js.map +1 -1
  798. package/dist/resources/resource-manager.d.ts.map +1 -1
  799. package/dist/resources/resource-manager.js +96 -83
  800. package/dist/resources/resource-manager.js.map +1 -1
  801. package/dist/swarm/claude-flow-executor.d.ts.map +1 -1
  802. package/dist/swarm/claude-flow-executor.js +37 -31
  803. package/dist/swarm/claude-flow-executor.js.map +1 -1
  804. package/dist/swarm/coordinator.d.ts.map +1 -1
  805. package/dist/swarm/coordinator.js +330 -280
  806. package/dist/swarm/coordinator.js.map +1 -1
  807. package/dist/swarm/direct-executor.d.ts.map +1 -1
  808. package/dist/swarm/direct-executor.js +44 -37
  809. package/dist/swarm/direct-executor.js.map +1 -1
  810. package/dist/swarm/executor-v2.d.ts.map +1 -1
  811. package/dist/swarm/executor-v2.js +28 -27
  812. package/dist/swarm/executor-v2.js.map +1 -1
  813. package/dist/swarm/executor.d.ts +3 -0
  814. package/dist/swarm/executor.d.ts.map +1 -1
  815. package/dist/swarm/executor.js +58 -52
  816. package/dist/swarm/executor.js.map +1 -1
  817. package/dist/swarm/index.d.ts.map +1 -1
  818. package/dist/swarm/index.js +2 -2
  819. package/dist/swarm/index.js.map +1 -1
  820. package/dist/swarm/json-output-aggregator.d.ts.map +1 -1
  821. package/dist/swarm/json-output-aggregator.js +20 -19
  822. package/dist/swarm/json-output-aggregator.js.map +1 -1
  823. package/dist/swarm/memory.d.ts.map +1 -1
  824. package/dist/swarm/memory.js +67 -67
  825. package/dist/swarm/memory.js.map +1 -1
  826. package/dist/swarm/optimizations/async-file-manager.d.ts +4 -0
  827. package/dist/swarm/optimizations/async-file-manager.d.ts.map +1 -1
  828. package/dist/swarm/optimizations/async-file-manager.js +19 -23
  829. package/dist/swarm/optimizations/async-file-manager.js.map +1 -1
  830. package/dist/swarm/optimizations/circular-buffer.d.ts.map +1 -1
  831. package/dist/swarm/optimizations/circular-buffer.js +2 -4
  832. package/dist/swarm/optimizations/circular-buffer.js.map +1 -1
  833. package/dist/swarm/optimizations/connection-pool.d.ts.map +1 -1
  834. package/dist/swarm/optimizations/connection-pool.js +12 -13
  835. package/dist/swarm/optimizations/connection-pool.js.map +1 -1
  836. package/dist/swarm/optimizations/index.js +2 -2
  837. package/dist/swarm/optimizations/optimized-executor.d.ts.map +1 -1
  838. package/dist/swarm/optimizations/optimized-executor.js +23 -29
  839. package/dist/swarm/optimizations/optimized-executor.js.map +1 -1
  840. package/dist/swarm/optimizations/ttl-map.d.ts.map +1 -1
  841. package/dist/swarm/optimizations/ttl-map.js +4 -4
  842. package/dist/swarm/optimizations/ttl-map.js.map +1 -1
  843. package/dist/swarm/prompt-cli.d.ts.map +1 -1
  844. package/dist/swarm/prompt-cli.js +18 -13
  845. package/dist/swarm/prompt-cli.js.map +1 -1
  846. package/dist/swarm/prompt-copier-enhanced.d.ts.map +1 -1
  847. package/dist/swarm/prompt-copier-enhanced.js +12 -12
  848. package/dist/swarm/prompt-copier-enhanced.js.map +1 -1
  849. package/dist/swarm/prompt-copier.d.ts.map +1 -1
  850. package/dist/swarm/prompt-copier.js +15 -18
  851. package/dist/swarm/prompt-copier.js.map +1 -1
  852. package/dist/swarm/prompt-manager.d.ts.map +1 -1
  853. package/dist/swarm/prompt-manager.js +27 -21
  854. package/dist/swarm/prompt-manager.js.map +1 -1
  855. package/dist/swarm/prompt-utils.d.ts.map +1 -1
  856. package/dist/swarm/prompt-utils.js +34 -32
  857. package/dist/swarm/prompt-utils.js.map +1 -1
  858. package/dist/swarm/sparc-executor.d.ts.map +1 -1
  859. package/dist/swarm/sparc-executor.js +189 -123
  860. package/dist/swarm/sparc-executor.js.map +1 -1
  861. package/dist/swarm/strategies/auto.d.ts.map +1 -1
  862. package/dist/swarm/strategies/auto.js +105 -86
  863. package/dist/swarm/strategies/auto.js.map +1 -1
  864. package/dist/swarm/strategies/base.d.ts.map +1 -1
  865. package/dist/swarm/strategies/base.js +14 -11
  866. package/dist/swarm/strategies/base.js.map +1 -1
  867. package/dist/swarm/strategies/research.d.ts.map +1 -1
  868. package/dist/swarm/strategies/research.js +76 -71
  869. package/dist/swarm/strategies/research.js.map +1 -1
  870. package/dist/swarm/types.d.ts.map +1 -1
  871. package/dist/swarm/types.js +3 -0
  872. package/dist/swarm/types.js.map +1 -1
  873. package/dist/swarm/workers/copy-worker.js +4 -4
  874. package/dist/swarm/workers/copy-worker.js.map +1 -1
  875. package/dist/task/commands.d.ts.map +1 -1
  876. package/dist/task/commands.js +11 -7
  877. package/dist/task/commands.js.map +1 -1
  878. package/dist/task/coordination.d.ts.map +1 -1
  879. package/dist/task/coordination.js +75 -70
  880. package/dist/task/coordination.js.map +1 -1
  881. package/dist/task/engine.d.ts.map +1 -1
  882. package/dist/task/engine.js +34 -32
  883. package/dist/task/engine.js.map +1 -1
  884. package/dist/task/index.d.ts +3 -3
  885. package/dist/task/index.d.ts.map +1 -1
  886. package/dist/task/index.js +11 -11
  887. package/dist/task/index.js.map +1 -1
  888. package/dist/terminal/adapters/native.d.ts.map +1 -1
  889. package/dist/terminal/adapters/native.js +6 -6
  890. package/dist/terminal/adapters/native.js.map +1 -1
  891. package/dist/terminal/adapters/vscode.d.ts +3 -0
  892. package/dist/terminal/adapters/vscode.d.ts.map +1 -1
  893. package/dist/terminal/adapters/vscode.js +6 -4
  894. package/dist/terminal/adapters/vscode.js.map +1 -1
  895. package/dist/terminal/manager.d.ts.map +1 -1
  896. package/dist/terminal/manager.js +6 -8
  897. package/dist/terminal/manager.js.map +1 -1
  898. package/dist/terminal/pool.d.ts.map +1 -1
  899. package/dist/terminal/pool.js +3 -0
  900. package/dist/terminal/pool.js.map +1 -1
  901. package/dist/terminal/session.d.ts.map +1 -1
  902. package/dist/terminal/session.js +6 -2
  903. package/dist/terminal/session.js.map +1 -1
  904. package/dist/ui/hive-dashboard.d.ts.map +1 -1
  905. package/dist/ui/hive-dashboard.js +52 -33
  906. package/dist/ui/hive-dashboard.js.map +1 -1
  907. package/dist/utils/error-handler.d.ts.map +1 -1
  908. package/dist/utils/error-handler.js +1 -1
  909. package/dist/utils/error-handler.js.map +1 -1
  910. package/dist/utils/errors.d.ts.map +1 -1
  911. package/dist/utils/errors.js.map +1 -1
  912. package/dist/utils/helpers.d.ts +3 -0
  913. package/dist/utils/helpers.d.ts.map +1 -1
  914. package/dist/utils/helpers.js +5 -8
  915. package/dist/utils/helpers.js.map +1 -1
  916. package/dist/utils/npx-isolated-cache.js +3 -3
  917. package/dist/utils/npx-isolated-cache.js.map +1 -1
  918. package/dist/utils/paths.d.ts.map +1 -1
  919. package/dist/utils/paths.js +8 -4
  920. package/dist/utils/paths.js.map +1 -1
  921. package/dist/utils/type-guards.d.ts +1 -1
  922. package/dist/utils/type-guards.d.ts.map +1 -1
  923. package/dist/utils/type-guards.js +11 -10
  924. package/dist/utils/type-guards.js.map +1 -1
  925. package/package.json +7 -6
  926. package/src/adapters/cliffy-node.ts +27 -22
  927. package/src/agents/agent-manager.ts +145 -121
  928. package/src/agents/agent-registry.ts +77 -70
  929. package/src/api/claude-client.ts +59 -38
  930. package/src/api/routes/analysis.js +750 -735
  931. package/src/cli/__tests__/command-registry.test.js +42 -32
  932. package/src/cli/__tests__/simple-cli.test.js +42 -37
  933. package/src/cli/__tests__/utils.test.js +9 -9
  934. package/src/cli/agents/README.md +30 -4
  935. package/src/cli/agents/analyst.ts +161 -163
  936. package/src/cli/agents/architect.ts +126 -131
  937. package/src/cli/agents/base-agent.ts +48 -47
  938. package/src/cli/agents/capabilities.ts +87 -85
  939. package/src/cli/agents/coder.ts +127 -120
  940. package/src/cli/agents/coordinator.ts +72 -72
  941. package/src/cli/agents/hive-agents.ts +96 -70
  942. package/src/cli/agents/index.ts +70 -55
  943. package/src/cli/agents/researcher.ts +63 -74
  944. package/src/cli/agents/tester.ts +91 -98
  945. package/src/cli/cli-core.ts +56 -47
  946. package/src/cli/command-registry.js +125 -83
  947. package/src/cli/commands/advanced-memory-commands.ts +210 -142
  948. package/src/cli/commands/agent-simple.ts +146 -114
  949. package/src/cli/commands/agent.ts +119 -95
  950. package/src/cli/commands/claude-api.ts +19 -15
  951. package/src/cli/commands/claude.ts +96 -88
  952. package/src/cli/commands/config-integration.ts +120 -101
  953. package/src/cli/commands/config.ts +10 -8
  954. package/src/cli/commands/enterprise.ts +323 -187
  955. package/src/cli/commands/help-new.ts +246 -0
  956. package/src/cli/commands/help.ts +326 -183
  957. package/src/cli/commands/hive-mind/index.ts +3 -3
  958. package/src/cli/commands/hive-mind/init.ts +19 -12
  959. package/src/cli/commands/hive-mind/optimize-memory.ts +83 -53
  960. package/src/cli/commands/hive-mind/pause.ts +27 -25
  961. package/src/cli/commands/hive-mind/ps.ts +43 -37
  962. package/src/cli/commands/hive-mind/resume.ts +26 -26
  963. package/src/cli/commands/hive-mind/spawn.ts +37 -29
  964. package/src/cli/commands/hive-mind/status.ts +51 -51
  965. package/src/cli/commands/hive-mind/stop.ts +56 -51
  966. package/src/cli/commands/hive-mind/task.ts +65 -54
  967. package/src/cli/commands/hive-mind/wizard.ts +181 -167
  968. package/src/cli/commands/hive.ts +136 -96
  969. package/src/cli/commands/hook-types.ts +2 -2
  970. package/src/cli/commands/hook-validator.ts +8 -4
  971. package/src/cli/commands/hook.ts +44 -42
  972. package/src/cli/commands/index.ts +1162 -1031
  973. package/src/cli/commands/mcp.ts +105 -94
  974. package/src/cli/commands/memory.ts +24 -21
  975. package/src/cli/commands/migrate.ts +24 -24
  976. package/src/cli/commands/monitor.ts +123 -93
  977. package/src/cli/commands/ruv-swarm.ts +131 -122
  978. package/src/cli/commands/session.ts +60 -45
  979. package/src/cli/commands/sparc.ts +170 -139
  980. package/src/cli/commands/start/event-emitter.ts +2 -2
  981. package/src/cli/commands/start/index.ts +1 -1
  982. package/src/cli/commands/start/process-manager.ts +30 -47
  983. package/src/cli/commands/start/process-ui-simple.ts +60 -49
  984. package/src/cli/commands/start/process-ui.ts +1 -1
  985. package/src/cli/commands/start/start-command.ts +104 -75
  986. package/src/cli/commands/start/system-monitor.ts +35 -41
  987. package/src/cli/commands/start/types.ts +3 -3
  988. package/src/cli/commands/start.ts +1 -1
  989. package/src/cli/commands/status.ts +67 -67
  990. package/src/cli/commands/swarm-spawn.ts +21 -12
  991. package/src/cli/commands/swarm.ts +221 -150
  992. package/src/cli/commands/task.ts +55 -55
  993. package/src/cli/commands/workflow.ts +174 -157
  994. package/src/cli/completion.ts +34 -19
  995. package/src/cli/create-enhanced-task.js +49 -17
  996. package/src/cli/formatter.ts +38 -37
  997. package/src/cli/help-formatter.js +145 -0
  998. package/src/cli/help-formatter.ts +173 -0
  999. package/src/cli/help-text.js +273 -6
  1000. package/src/cli/index-remote.ts +12 -9
  1001. package/src/cli/index.ts +77 -67
  1002. package/src/cli/init/batch-tools.ts +4 -5
  1003. package/src/cli/init/claude-config.ts +125 -118
  1004. package/src/cli/init/directory-structure.ts +10 -11
  1005. package/src/cli/init/index.ts +13 -13
  1006. package/src/cli/init/sparc-environment.ts +90 -74
  1007. package/src/cli/init/swarm-commands.ts +5 -6
  1008. package/src/cli/init/utils.ts +1 -1
  1009. package/src/cli/main.ts +9 -10
  1010. package/src/cli/node-compat.js +26 -19
  1011. package/src/cli/node-repl.ts +104 -87
  1012. package/src/cli/repl.ts +190 -158
  1013. package/src/cli/runtime-detector.js +24 -19
  1014. package/src/cli/simple-cli.js +479 -394
  1015. package/src/cli/simple-cli.ts +426 -366
  1016. package/src/cli/simple-commands/__tests__/agent.test.js +49 -55
  1017. package/src/cli/simple-commands/__tests__/memory.test.js +4 -401
  1018. package/src/cli/simple-commands/__tests__/swarm.test.js +49 -55
  1019. package/src/cli/simple-commands/__tests__/task.test.js +4 -478
  1020. package/src/cli/simple-commands/agent.js +27 -27
  1021. package/src/cli/simple-commands/analysis.js +179 -161
  1022. package/src/cli/simple-commands/automation.js +226 -205
  1023. package/src/cli/simple-commands/batch-manager.js +98 -88
  1024. package/src/cli/simple-commands/config.js +65 -60
  1025. package/src/cli/simple-commands/coordination.js +197 -185
  1026. package/src/cli/simple-commands/enhanced-ui-views.js +142 -115
  1027. package/src/cli/simple-commands/enhanced-webui-complete.js +267 -167
  1028. package/src/cli/simple-commands/fix-hook-variables.js +73 -67
  1029. package/src/cli/simple-commands/github/gh-coordinator.js +63 -53
  1030. package/src/cli/simple-commands/github/github-api.js +45 -47
  1031. package/src/cli/simple-commands/github.js +33 -34
  1032. package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +44 -40
  1033. package/src/cli/simple-commands/hive-mind/communication.js +198 -185
  1034. package/src/cli/simple-commands/hive-mind/core.js +289 -304
  1035. package/src/cli/simple-commands/hive-mind/db-optimizer.js +278 -168
  1036. package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +352 -258
  1037. package/src/cli/simple-commands/hive-mind/memory.js +356 -287
  1038. package/src/cli/simple-commands/hive-mind/performance-optimizer.js +88 -79
  1039. package/src/cli/simple-commands/hive-mind/performance-test.js +61 -49
  1040. package/src/cli/simple-commands/hive-mind/queen.js +223 -213
  1041. package/src/cli/simple-commands/hive-mind/session-manager.js +217 -157
  1042. package/src/cli/simple-commands/hive-mind-optimize.js +69 -65
  1043. package/src/cli/simple-commands/hive-mind-wizard.js +213 -211
  1044. package/src/cli/simple-commands/hive-mind.js +602 -435
  1045. package/src/cli/simple-commands/hive.js +12 -12
  1046. package/src/cli/simple-commands/hook-safety.js +114 -111
  1047. package/src/cli/simple-commands/hooks.js +1077 -1017
  1048. package/src/cli/simple-commands/init/README.md +8 -1
  1049. package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +27 -1
  1050. package/src/cli/simple-commands/init/batch-init.js +105 -100
  1051. package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +6 -6
  1052. package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +6 -6
  1053. package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +20 -18
  1054. package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +85 -71
  1055. package/src/cli/simple-commands/init/claude-commands/slash-commands.js +6 -7
  1056. package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +42 -33
  1057. package/src/cli/simple-commands/init/executable-wrapper.js +13 -10
  1058. package/src/cli/simple-commands/init/gitignore-updater.js +22 -22
  1059. package/src/cli/simple-commands/init/help.js +4 -2
  1060. package/src/cli/simple-commands/init/index.js +405 -303
  1061. package/src/cli/simple-commands/init/performance-monitor.js +71 -64
  1062. package/src/cli/simple-commands/init/rollback/backup-manager.js +44 -64
  1063. package/src/cli/simple-commands/init/rollback/index.js +31 -39
  1064. package/src/cli/simple-commands/init/rollback/recovery-manager.js +71 -101
  1065. package/src/cli/simple-commands/init/rollback/rollback-executor.js +34 -53
  1066. package/src/cli/simple-commands/init/rollback/state-tracker.js +38 -49
  1067. package/src/cli/simple-commands/init/sparc/roo-readme.js +1 -1
  1068. package/src/cli/simple-commands/init/sparc/roomodes-config.js +99 -77
  1069. package/src/cli/simple-commands/init/sparc/workflows.js +37 -33
  1070. package/src/cli/simple-commands/init/sparc-structure.js +9 -10
  1071. package/src/cli/simple-commands/init/templates/CLAUDE.md +94 -26
  1072. package/src/cli/simple-commands/init/templates/claude-flow-universal +9 -7
  1073. package/src/cli/simple-commands/init/templates/claude-md.js +1 -1
  1074. package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +15 -3
  1075. package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +12 -2
  1076. package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +10 -1
  1077. package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +18 -5
  1078. package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +12 -1
  1079. package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +12 -1
  1080. package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +12 -1
  1081. package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +12 -1
  1082. package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +12 -1
  1083. package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +12 -1
  1084. package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +13 -6
  1085. package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +12 -1
  1086. package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +12 -1
  1087. package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +13 -5
  1088. package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +12 -1
  1089. package/src/cli/simple-commands/init/templates/coordination-md.js +1 -1
  1090. package/src/cli/simple-commands/init/templates/enhanced-templates.js +116 -113
  1091. package/src/cli/simple-commands/init/templates/memory-bank-md.js +1 -1
  1092. package/src/cli/simple-commands/init/templates/readme-files.js +1 -1
  1093. package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +176 -127
  1094. package/src/cli/simple-commands/init/templates/settings.json +2 -5
  1095. package/src/cli/simple-commands/init/templates/sparc-modes.js +3 -3
  1096. package/src/cli/simple-commands/init/validation/config-validator.js +17 -28
  1097. package/src/cli/simple-commands/init/validation/health-checker.js +54 -62
  1098. package/src/cli/simple-commands/init/validation/index.js +18 -23
  1099. package/src/cli/simple-commands/init/validation/mode-validator.js +22 -32
  1100. package/src/cli/simple-commands/init/validation/post-init-validator.js +25 -26
  1101. package/src/cli/simple-commands/init/validation/pre-init-validator.js +32 -36
  1102. package/src/cli/simple-commands/init/validation/test-runner.js +55 -63
  1103. package/src/cli/simple-commands/init.js +1 -1
  1104. package/src/cli/simple-commands/mcp-integration-layer.js +179 -110
  1105. package/src/cli/simple-commands/mcp.js +55 -48
  1106. package/src/cli/simple-commands/memory.js +62 -56
  1107. package/src/cli/simple-commands/migrate-hooks.js +9 -10
  1108. package/src/cli/simple-commands/monitor.js +87 -67
  1109. package/src/cli/simple-commands/process-ui-enhanced.js +207 -155
  1110. package/src/cli/simple-commands/process-ui.js +65 -56
  1111. package/src/cli/simple-commands/realtime-update-system.js +136 -129
  1112. package/src/cli/simple-commands/sparc/architecture.js +352 -251
  1113. package/src/cli/simple-commands/sparc/commands.js +122 -94
  1114. package/src/cli/simple-commands/sparc/completion.js +274 -199
  1115. package/src/cli/simple-commands/sparc/coordinator.js +217 -169
  1116. package/src/cli/simple-commands/sparc/index.js +40 -36
  1117. package/src/cli/simple-commands/sparc/phase-base.js +72 -58
  1118. package/src/cli/simple-commands/sparc/pseudocode.js +275 -159
  1119. package/src/cli/simple-commands/sparc/refinement.js +306 -212
  1120. package/src/cli/simple-commands/sparc/specification.js +164 -94
  1121. package/src/cli/simple-commands/sparc-modes/architect.js +1 -1
  1122. package/src/cli/simple-commands/sparc-modes/ask.js +1 -1
  1123. package/src/cli/simple-commands/sparc-modes/code.js +1 -1
  1124. package/src/cli/simple-commands/sparc-modes/debug.js +1 -1
  1125. package/src/cli/simple-commands/sparc-modes/devops.js +1 -1
  1126. package/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
  1127. package/src/cli/simple-commands/sparc-modes/generic.js +1 -1
  1128. package/src/cli/simple-commands/sparc-modes/index.js +15 -15
  1129. package/src/cli/simple-commands/sparc-modes/integration.js +1 -1
  1130. package/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
  1131. package/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
  1132. package/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
  1133. package/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
  1134. package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
  1135. package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
  1136. package/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
  1137. package/src/cli/simple-commands/sparc-modes/swarm.js +52 -52
  1138. package/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
  1139. package/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
  1140. package/src/cli/simple-commands/sparc.js +87 -69
  1141. package/src/cli/simple-commands/start-ui.js +21 -20
  1142. package/src/cli/simple-commands/start-wrapper.js +29 -31
  1143. package/src/cli/simple-commands/start.js +1 -1
  1144. package/src/cli/simple-commands/status.js +53 -47
  1145. package/src/cli/simple-commands/swarm-executor.js +47 -57
  1146. package/src/cli/simple-commands/swarm-metrics-integration.js +119 -79
  1147. package/src/cli/simple-commands/swarm-ui.js +120 -118
  1148. package/src/cli/simple-commands/swarm-webui-integration.js +48 -27
  1149. package/src/cli/simple-commands/swarm.js +216 -181
  1150. package/src/cli/simple-commands/task.js +29 -29
  1151. package/src/cli/simple-commands/timestamp-fix.js +28 -25
  1152. package/src/cli/simple-commands/tool-execution-framework.js +115 -118
  1153. package/src/cli/simple-commands/training.js +219 -194
  1154. package/src/cli/simple-commands/web-server.js +118 -117
  1155. package/src/cli/simple-commands/webui-validator.js +4 -3
  1156. package/src/cli/simple-mcp.ts +14 -17
  1157. package/src/cli/simple-orchestrator.ts +113 -101
  1158. package/src/cli/swarm-standalone.js +20 -21
  1159. package/src/cli/ui/compatible-ui.ts +55 -44
  1160. package/src/cli/ui/fallback-handler.ts +19 -16
  1161. package/src/cli/ui/index.ts +14 -15
  1162. package/src/cli/utils/environment-detector.ts +75 -67
  1163. package/src/cli/utils/interactive-detector.js +17 -11
  1164. package/src/cli/utils/prompt-defaults.ts +32 -28
  1165. package/src/cli/utils/safe-interactive.js +21 -20
  1166. package/src/cli/utils.js +127 -110
  1167. package/src/cli/validation-helper.js +113 -0
  1168. package/src/cli/validation-helper.ts +128 -0
  1169. package/src/communication/message-bus.ts +137 -124
  1170. package/src/config/config-manager.ts +62 -30
  1171. package/src/config/ruv-swarm-config.ts +105 -86
  1172. package/src/config/ruv-swarm-integration.ts +38 -38
  1173. package/src/constants/agent-types.ts +9 -8
  1174. package/src/coordination/README.md +54 -31
  1175. package/src/coordination/advanced-scheduler.ts +23 -26
  1176. package/src/coordination/advanced-task-executor.ts +74 -68
  1177. package/src/coordination/background-executor.ts +33 -30
  1178. package/src/coordination/circuit-breaker.ts +26 -27
  1179. package/src/coordination/conflict-resolution.ts +18 -27
  1180. package/src/coordination/dependency-graph.ts +15 -18
  1181. package/src/coordination/hive-orchestrator.ts +111 -81
  1182. package/src/coordination/hive-protocol.ts +68 -77
  1183. package/src/coordination/index.ts +3 -7
  1184. package/src/coordination/load-balancer.ts +115 -105
  1185. package/src/coordination/manager.ts +38 -51
  1186. package/src/coordination/messaging.ts +19 -29
  1187. package/src/coordination/metrics.ts +57 -60
  1188. package/src/coordination/resources.ts +32 -37
  1189. package/src/coordination/scheduler.ts +29 -30
  1190. package/src/coordination/swarm-coordinator.ts +81 -70
  1191. package/src/coordination/swarm-monitor.ts +90 -69
  1192. package/src/coordination/work-stealing.ts +6 -13
  1193. package/src/core/config.ts +148 -143
  1194. package/src/core/event-bus.ts +5 -6
  1195. package/src/core/json-persistence.ts +27 -34
  1196. package/src/core/logger.ts +13 -16
  1197. package/src/core/orchestrator-fixed.ts +33 -32
  1198. package/src/core/orchestrator.ts +166 -159
  1199. package/src/core/persistence.ts +47 -36
  1200. package/src/enterprise/analytics-manager.ts +242 -233
  1201. package/src/enterprise/audit-manager.ts +238 -184
  1202. package/src/enterprise/cloud-manager.ts +167 -151
  1203. package/src/enterprise/deployment-manager.ts +223 -180
  1204. package/src/enterprise/index.ts +7 -7
  1205. package/src/enterprise/project-manager.ts +151 -133
  1206. package/src/enterprise/security-manager.ts +278 -223
  1207. package/src/hive-mind/core/Agent.ts +112 -109
  1208. package/src/hive-mind/core/Communication.ts +67 -69
  1209. package/src/hive-mind/core/DatabaseManager.ts +299 -166
  1210. package/src/hive-mind/core/HiveMind.ts +100 -96
  1211. package/src/hive-mind/core/Memory.ts +304 -295
  1212. package/src/hive-mind/core/MemoryMonitor.ts +46 -47
  1213. package/src/hive-mind/core/Queen.ts +187 -114
  1214. package/src/hive-mind/index.ts +2 -2
  1215. package/src/hive-mind/integration/ConsensusEngine.ts +88 -92
  1216. package/src/hive-mind/integration/MCPToolWrapper.ts +20 -72
  1217. package/src/hive-mind/integration/SwarmOrchestrator.ts +173 -165
  1218. package/src/hive-mind/types.ts +24 -12
  1219. package/src/integration/mock-components.ts +42 -30
  1220. package/src/integration/system-integration.ts +93 -69
  1221. package/src/integration/types.ts +7 -7
  1222. package/src/mcp/README.md +23 -4
  1223. package/src/mcp/auth.ts +25 -18
  1224. package/src/mcp/claude-code-wrapper.ts +257 -150
  1225. package/src/mcp/claude-flow-tools.ts +52 -13
  1226. package/src/mcp/client.ts +15 -13
  1227. package/src/mcp/index.ts +22 -27
  1228. package/src/mcp/integrate-wrapper.ts +18 -18
  1229. package/src/mcp/lifecycle-manager.ts +30 -27
  1230. package/src/mcp/load-balancer.ts +10 -11
  1231. package/src/mcp/mcp-server.js +755 -370
  1232. package/src/mcp/orchestration-integration.ts +32 -17
  1233. package/src/mcp/performance-monitor.ts +65 -51
  1234. package/src/mcp/protocol-manager.ts +36 -52
  1235. package/src/mcp/recovery/connection-health-monitor.ts +40 -35
  1236. package/src/mcp/recovery/connection-state-manager.ts +52 -50
  1237. package/src/mcp/recovery/fallback-coordinator.ts +24 -24
  1238. package/src/mcp/recovery/index.ts +23 -4
  1239. package/src/mcp/recovery/reconnection-manager.ts +14 -15
  1240. package/src/mcp/recovery/recovery-manager.ts +52 -68
  1241. package/src/mcp/router.ts +1 -2
  1242. package/src/mcp/ruv-swarm-tools.ts +167 -138
  1243. package/src/mcp/ruv-swarm-wrapper.js +31 -23
  1244. package/src/mcp/server-with-wrapper.ts +4 -5
  1245. package/src/mcp/server-wrapper-mode.ts +5 -6
  1246. package/src/mcp/server.ts +45 -40
  1247. package/src/mcp/session-manager.ts +8 -11
  1248. package/src/mcp/sparc-modes.ts +29 -28
  1249. package/src/mcp/swarm-tools.ts +131 -114
  1250. package/src/mcp/tests/mcp-integration.test.ts +49 -55
  1251. package/src/mcp/tools.ts +53 -38
  1252. package/src/mcp/transports/base.ts +4 -5
  1253. package/src/mcp/transports/http.ts +45 -42
  1254. package/src/mcp/transports/stdio.ts +9 -12
  1255. package/src/memory/README.md +37 -27
  1256. package/src/memory/advanced-memory-manager.ts +336 -279
  1257. package/src/memory/backends/base.ts +4 -5
  1258. package/src/memory/backends/markdown.ts +16 -22
  1259. package/src/memory/backends/sqlite.ts +19 -15
  1260. package/src/memory/cache.ts +18 -18
  1261. package/src/memory/distributed-memory.ts +84 -92
  1262. package/src/memory/enhanced-examples.js +68 -59
  1263. package/src/memory/enhanced-memory.js +99 -80
  1264. package/src/memory/fallback-store.js +16 -7
  1265. package/src/memory/in-memory-store.js +31 -27
  1266. package/src/memory/index.js +4 -4
  1267. package/src/memory/indexer.ts +6 -10
  1268. package/src/memory/manager.ts +45 -59
  1269. package/src/memory/migration.js +107 -90
  1270. package/src/memory/shared-memory.js +155 -157
  1271. package/src/memory/sqlite-store.js +76 -59
  1272. package/src/memory/swarm-memory.js +138 -131
  1273. package/src/memory/swarm-memory.ts +74 -75
  1274. package/src/memory/test-example.js +28 -30
  1275. package/src/migration/README.md +25 -9
  1276. package/src/migration/index.ts +13 -14
  1277. package/src/migration/logger.ts +9 -7
  1278. package/src/migration/migration-analyzer.ts +66 -52
  1279. package/src/migration/migration-manifest.json +2 -6
  1280. package/src/migration/migration-runner.ts +86 -63
  1281. package/src/migration/migration-validator.ts +93 -68
  1282. package/src/migration/package.json +1 -1
  1283. package/src/migration/progress-reporter.ts +25 -21
  1284. package/src/migration/rollback-manager.ts +79 -63
  1285. package/src/migration/tests/migration-system.test.ts +4 -491
  1286. package/src/migration/tsconfig.json +3 -10
  1287. package/src/migration/types.ts +1 -1
  1288. package/src/monitoring/diagnostics.ts +123 -97
  1289. package/src/monitoring/health-check.ts +45 -51
  1290. package/src/monitoring/real-time-monitor.ts +105 -92
  1291. package/src/resources/resource-manager.ts +205 -159
  1292. package/src/swarm/__tests__/integration.test.ts +59 -65
  1293. package/src/swarm/__tests__/prompt-copier.test.ts +27 -27
  1294. package/src/swarm/claude-flow-executor.ts +50 -49
  1295. package/src/swarm/coordinator.ts +727 -635
  1296. package/src/swarm/direct-executor.ts +80 -86
  1297. package/src/swarm/executor-v2.ts +81 -66
  1298. package/src/swarm/executor.ts +124 -124
  1299. package/src/swarm/index.ts +7 -8
  1300. package/src/swarm/json-output-aggregator.ts +56 -40
  1301. package/src/swarm/memory.ts +152 -147
  1302. package/src/swarm/optimizations/README.md +20 -12
  1303. package/src/swarm/optimizations/__tests__/optimization.test.ts +84 -87
  1304. package/src/swarm/optimizations/async-file-manager.ts +70 -80
  1305. package/src/swarm/optimizations/circular-buffer.ts +37 -37
  1306. package/src/swarm/optimizations/connection-pool.ts +64 -64
  1307. package/src/swarm/optimizations/index.ts +4 -4
  1308. package/src/swarm/optimizations/migration-guide.md +27 -16
  1309. package/src/swarm/optimizations/optimized-executor.ts +104 -114
  1310. package/src/swarm/optimizations/ttl-map.ts +66 -63
  1311. package/src/swarm/prompt-cli.ts +48 -42
  1312. package/src/swarm/prompt-copier-enhanced.ts +54 -55
  1313. package/src/swarm/prompt-copier.ts +59 -65
  1314. package/src/swarm/prompt-copying-README.md +49 -33
  1315. package/src/swarm/prompt-manager.ts +69 -63
  1316. package/src/swarm/prompt-utils.ts +71 -66
  1317. package/src/swarm/sparc-executor.ts +298 -225
  1318. package/src/swarm/strategies/auto.ts +367 -252
  1319. package/src/swarm/strategies/base.ts +24 -20
  1320. package/src/swarm/strategies/research.ts +144 -124
  1321. package/src/swarm/types.ts +340 -309
  1322. package/src/swarm/workers/copy-worker.ts +12 -13
  1323. package/src/task/README.md +99 -70
  1324. package/src/task/commands.ts +16 -8
  1325. package/src/task/coordination.ts +209 -162
  1326. package/src/task/engine.ts +81 -65
  1327. package/src/task/index.ts +28 -31
  1328. package/src/templates/claude-optimized/.claude/BATCHTOOLS_BEST_PRACTICES.md +479 -481
  1329. package/src/templates/claude-optimized/.claude/BATCHTOOLS_GUIDE.md +210 -188
  1330. package/src/templates/claude-optimized/.claude/MIGRATION_GUIDE.md +151 -105
  1331. package/src/templates/claude-optimized/.claude/PERFORMANCE_BENCHMARKS.md +102 -87
  1332. package/src/templates/claude-optimized/.claude/commands/claude-flow-help.md +18 -1
  1333. package/src/templates/claude-optimized/.claude/commands/claude-flow-memory.md +17 -1
  1334. package/src/templates/claude-optimized/.claude/commands/claude-flow-swarm.md +21 -1
  1335. package/src/templates/claude-optimized/.claude/commands/sparc/architect.md +11 -4
  1336. package/src/templates/claude-optimized/.claude/commands/sparc/ask.md +16 -10
  1337. package/src/templates/claude-optimized/.claude/commands/sparc/code.md +26 -7
  1338. package/src/templates/claude-optimized/.claude/commands/sparc/debug.md +14 -4
  1339. package/src/templates/claude-optimized/.claude/commands/sparc/devops.md +23 -10
  1340. package/src/templates/claude-optimized/.claude/commands/sparc/docs-writer.md +8 -4
  1341. package/src/templates/claude-optimized/.claude/commands/sparc/integration.md +43 -27
  1342. package/src/templates/claude-optimized/.claude/commands/sparc/mcp.md +15 -1
  1343. package/src/templates/claude-optimized/.claude/commands/sparc/post-deployment-monitoring-mode.md +45 -30
  1344. package/src/templates/claude-optimized/.claude/commands/sparc/refinement-optimization-mode.md +23 -13
  1345. package/src/templates/claude-optimized/.claude/commands/sparc/security-review.md +31 -17
  1346. package/src/templates/claude-optimized/.claude/commands/sparc/sparc.md +54 -47
  1347. package/src/templates/claude-optimized/.claude/commands/sparc/spec-pseudocode.md +27 -17
  1348. package/src/templates/claude-optimized/.claude/commands/sparc/supabase-admin.md +18 -4
  1349. package/src/templates/claude-optimized/.claude/commands/sparc/tdd.md +23 -9
  1350. package/src/templates/claude-optimized/.claude/commands/sparc/tutorial.md +22 -16
  1351. package/src/templates/claude-optimized/.claude/commands/sparc.md +20 -1
  1352. package/src/templates/claude-optimized/README.md +10 -1
  1353. package/src/templates/claude-optimized/SUMMARY.md +23 -1
  1354. package/src/templates/claude-optimized/deploy-to-project.js +22 -10
  1355. package/src/templates/claude-optimized/install-template.js +14 -10
  1356. package/src/templates/claude-optimized/manifest.json +1 -1
  1357. package/src/templates/claude-optimized/package.json +1 -1
  1358. package/src/templates/claude-optimized/template-manager.js +8 -8
  1359. package/src/templates/claude-optimized/validate-template.js +33 -23
  1360. package/src/terminal/adapters/base.ts +1 -1
  1361. package/src/terminal/adapters/native.ts +47 -47
  1362. package/src/terminal/adapters/vscode.ts +21 -28
  1363. package/src/terminal/manager.ts +27 -22
  1364. package/src/terminal/pool.ts +24 -27
  1365. package/src/terminal/session.ts +18 -18
  1366. package/src/terminal/vscode-bridge.ts +21 -21
  1367. package/src/tests/validation-consistency.test.ts +4 -4
  1368. package/src/types/cliffy.d.ts +11 -14
  1369. package/src/types/global.d.ts +1 -2
  1370. package/src/types/index.ts +2 -2
  1371. package/src/types/mcp.d.ts +11 -17
  1372. package/src/types/vscode.d.ts +18 -5
  1373. package/src/ui/console/README-analysis-tools.md +52 -2
  1374. package/src/ui/console/README.md +33 -1
  1375. package/src/ui/console/WORKFLOW_DESIGNER_README.md +81 -22
  1376. package/src/ui/console/analysis-tools.html +282 -261
  1377. package/src/ui/console/analytics.html +329 -326
  1378. package/src/ui/console/index.html +221 -209
  1379. package/src/ui/console/js/analysis-tools.js +815 -754
  1380. package/src/ui/console/js/command-handler.js +226 -196
  1381. package/src/ui/console/js/console.js +117 -119
  1382. package/src/ui/console/js/daa-tools.js +797 -787
  1383. package/src/ui/console/js/memory-interface.js +676 -638
  1384. package/src/ui/console/js/memory-test.js +49 -46
  1385. package/src/ui/console/js/memory-tools.js +181 -159
  1386. package/src/ui/console/js/settings.js +124 -103
  1387. package/src/ui/console/js/terminal-emulator.js +147 -130
  1388. package/src/ui/console/js/websocket-client.js +71 -71
  1389. package/src/ui/console/js/workflow-designer.js +1126 -1110
  1390. package/src/ui/console/neural-networks-demo.md +45 -16
  1391. package/src/ui/console/styles/analysis-tools.css +571 -561
  1392. package/src/ui/console/styles/console.css +16 -12
  1393. package/src/ui/console/styles/daa-tools.css +322 -319
  1394. package/src/ui/console/styles/responsive.css +71 -70
  1395. package/src/ui/console/styles/settings.css +12 -12
  1396. package/src/ui/console/styles/workflow-designer.css +628 -584
  1397. package/src/ui/console/test-neural-networks.js +59 -54
  1398. package/src/ui/console/test-neural.html +194 -196
  1399. package/src/ui/console/workflow-designer-demo.html +433 -424
  1400. package/src/ui/hive-dashboard.ts +74 -52
  1401. package/src/ui/web-ui/EnhancedProcessUI.js +570 -424
  1402. package/src/ui/web-ui/EnhancedWebUI.js +65 -65
  1403. package/src/ui/web-ui/README.md +16 -16
  1404. package/src/ui/web-ui/components/ComponentLibrary.js +173 -124
  1405. package/src/ui/web-ui/core/EventBus.js +27 -25
  1406. package/src/ui/web-ui/core/MCPIntegrationLayer.js +294 -108
  1407. package/src/ui/web-ui/core/StateManager.js +43 -46
  1408. package/src/ui/web-ui/core/UIManager.js +120 -70
  1409. package/src/ui/web-ui/core/ViewManager.js +16 -19
  1410. package/src/ui/web-ui/index.js +101 -48
  1411. package/src/ui/web-ui/neural-panel-test.js +109 -108
  1412. package/src/ui/web-ui/test-github-view.js +11 -12
  1413. package/src/ui/web-ui/test-neural-panel.html +219 -205
  1414. package/src/ui/web-ui/views/DAAView.js +88 -85
  1415. package/src/ui/web-ui/views/GitHubIntegrationTest.js +42 -42
  1416. package/src/ui/web-ui/views/GitHubIntegrationView.js +59 -53
  1417. package/src/ui/web-ui/views/NeuralNetworkView.js +20 -21
  1418. package/src/ui/web-ui/views/WorkflowAutomationView.js +31 -32
  1419. package/src/utils/error-handler.js +1 -1
  1420. package/src/utils/error-handler.ts +9 -5
  1421. package/src/utils/errors.ts +20 -18
  1422. package/src/utils/formatters.ts +6 -6
  1423. package/src/utils/helpers.ts +53 -55
  1424. package/src/utils/npx-isolated-cache.js +16 -16
  1425. package/src/utils/paths.ts +9 -6
  1426. package/src/utils/timezone-utils.js +16 -16
  1427. package/src/utils/type-guards.ts +37 -26
  1428. package/src/utils/types.ts +2 -2
@@ -1,14 +1,30 @@
1
- import { getErrorMessage } from '../utils/error-handler.js';
2
1
  import { EventEmitter } from 'events';
3
2
  import { promises as fs } from 'node:fs';
4
3
  import { Logger } from '../core/logger.js';
5
4
  import { generateId } from '../utils/helpers.js';
6
5
  import {
7
- SwarmId, AgentId, TaskId, AgentState, TaskDefinition, SwarmObjective,
8
- SwarmConfig, SwarmStatus, SwarmProgress, SwarmResults, SwarmMetrics,
9
- SwarmMode, SwarmStrategy, AgentType, TaskType, TaskStatus, TaskPriority,
10
- SwarmEvent, EventType, SwarmEventEmitter, ValidationResult,
11
- SWARM_CONSTANTS
6
+ SwarmId,
7
+ AgentId,
8
+ TaskId,
9
+ AgentState,
10
+ TaskDefinition,
11
+ SwarmObjective,
12
+ SwarmConfig,
13
+ SwarmStatus,
14
+ SwarmProgress,
15
+ SwarmResults,
16
+ SwarmMetrics,
17
+ SwarmMode,
18
+ SwarmStrategy,
19
+ AgentType,
20
+ TaskType,
21
+ TaskStatus,
22
+ TaskPriority,
23
+ SwarmEvent,
24
+ EventType,
25
+ SwarmEventEmitter,
26
+ ValidationResult,
27
+ SWARM_CONSTANTS,
12
28
  } from './types.js';
13
29
  import { AutoStrategy } from './strategies/auto.js';
14
30
  import { getClaudeFlowRoot, getClaudeFlowBin } from '../utils/paths.js';
@@ -18,65 +34,65 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
18
34
  private logger: Logger;
19
35
  private config: SwarmConfig;
20
36
  private swarmId: SwarmId;
21
-
37
+
22
38
  // Core state management
23
39
  private agents: Map<string, AgentState> = new Map();
24
40
  private tasks: Map<string, TaskDefinition> = new Map();
25
41
  private objectives: Map<string, SwarmObjective> = new Map();
26
-
42
+
27
43
  // Execution state
28
44
  private _isRunning: boolean = false;
29
45
  private status: SwarmStatus = 'planning';
30
46
  private startTime?: Date;
31
47
  private endTime?: Date;
32
-
48
+
33
49
  // Performance tracking
34
50
  private metrics: SwarmMetrics;
35
51
  private events: SwarmEvent[] = [];
36
52
  private lastHeartbeat: Date = new Date();
37
-
53
+
38
54
  // JSON output aggregation (optional)
39
55
  private jsonOutputAggregator?: SwarmJsonOutputAggregator;
40
-
56
+
41
57
  // Background processes
42
58
  private heartbeatTimer?: NodeJS.Timeout;
43
59
  private monitoringTimer?: NodeJS.Timeout;
44
60
  private cleanupTimer?: NodeJS.Timeout;
45
61
  private executionIntervals?: Map<string, NodeJS.Timeout>;
46
-
62
+
47
63
  // Strategy instances
48
64
  private autoStrategy: AutoStrategy;
49
-
65
+
50
66
  constructor(config: Partial<SwarmConfig> = {}) {
51
67
  super();
52
-
68
+
53
69
  // Configure logger based on config or default to quiet mode
54
70
  const logLevel = (config as any).logging?.level || 'error';
55
71
  const logFormat = (config as any).logging?.format || 'text';
56
72
  const logDestination = (config as any).logging?.destination || 'console';
57
-
73
+
58
74
  this.logger = new Logger(
59
75
  { level: logLevel, format: logFormat, destination: logDestination },
60
- { component: 'SwarmCoordinator' }
76
+ { component: 'SwarmCoordinator' },
61
77
  );
62
78
  this.swarmId = this.generateSwarmId();
63
-
79
+
64
80
  // Initialize configuration with defaults
65
81
  this.config = this.mergeWithDefaults(config);
66
-
82
+
67
83
  // Initialize metrics
68
84
  this.metrics = this.initializeMetrics();
69
-
85
+
70
86
  // Initialize strategy instances
71
87
  this.autoStrategy = new AutoStrategy(config);
72
-
88
+
73
89
  // Setup event handlers
74
90
  this.setupEventHandlers();
75
-
76
- this.logger.info('SwarmCoordinator initialized', {
91
+
92
+ this.logger.info('SwarmCoordinator initialized', {
77
93
  swarmId: this.swarmId.id,
78
94
  mode: this.config.mode,
79
- strategy: this.config.strategy
95
+ strategy: this.config.strategy,
80
96
  });
81
97
  }
82
98
 
@@ -89,24 +105,26 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
89
105
 
90
106
  this.logger.info('Initializing swarm coordinator...');
91
107
  this.status = 'initializing';
92
-
108
+
93
109
  try {
94
110
  // Validate configuration
95
111
  const validation = await this.validateConfiguration();
96
112
  if (!validation.valid) {
97
- throw new Error(`Configuration validation failed: ${validation.errors.map(e => e.message).join(', ')}`);
113
+ throw new Error(
114
+ `Configuration validation failed: ${validation.errors.map((e) => e.message).join(', ')}`,
115
+ );
98
116
  }
99
117
 
100
118
  // Initialize subsystems
101
119
  await this.initializeSubsystems();
102
-
120
+
103
121
  // Start background processes
104
122
  this.startBackgroundProcesses();
105
-
123
+
106
124
  this._isRunning = true;
107
125
  this.startTime = new Date();
108
126
  this.status = 'executing';
109
-
127
+
110
128
  this.emitSwarmEvent({
111
129
  id: generateId('event'),
112
130
  timestamp: new Date(),
@@ -114,11 +132,10 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
114
132
  source: this.swarmId.id,
115
133
  data: { swarmId: this.swarmId },
116
134
  broadcast: true,
117
- processed: false
135
+ processed: false,
118
136
  });
119
-
137
+
120
138
  this.logger.info('Swarm coordinator initialized successfully');
121
-
122
139
  } catch (error) {
123
140
  this.status = 'failed';
124
141
  this.logger.error('Failed to initialize swarm coordinator', { error });
@@ -133,40 +150,39 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
133
150
 
134
151
  this.logger.info('Shutting down swarm coordinator...');
135
152
  this.status = 'paused';
136
-
153
+
137
154
  try {
138
155
  // Stop background processes
139
156
  this.stopBackgroundProcesses();
140
-
157
+
141
158
  // Gracefully stop all agents
142
159
  await this.stopAllAgents();
143
-
160
+
144
161
  // Complete any running tasks
145
162
  await this.completeRunningTasks();
146
-
163
+
147
164
  // Save final state
148
165
  await this.saveState();
149
-
166
+
150
167
  this._isRunning = false;
151
168
  this.endTime = new Date();
152
169
  this.status = 'completed';
153
-
170
+
154
171
  this.emitSwarmEvent({
155
172
  id: generateId('event'),
156
173
  timestamp: new Date(),
157
174
  type: 'swarm.completed',
158
175
  source: this.swarmId.id,
159
- data: {
176
+ data: {
160
177
  swarmId: this.swarmId,
161
178
  metrics: this.metrics,
162
- duration: this.endTime.getTime() - (this.startTime?.getTime() || 0)
179
+ duration: this.endTime.getTime() - (this.startTime?.getTime() || 0),
163
180
  },
164
181
  broadcast: true,
165
- processed: false
182
+ processed: false,
166
183
  });
167
-
184
+
168
185
  this.logger.info('Swarm coordinator shut down successfully');
169
-
170
186
  } catch (error) {
171
187
  this.logger.error('Error during swarm coordinator shutdown', { error });
172
188
  throw error;
@@ -180,14 +196,14 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
180
196
 
181
197
  this.logger.info('Pausing swarm coordinator...');
182
198
  this.status = 'paused';
183
-
199
+
184
200
  // Pause all agents
185
201
  for (const agent of this.agents.values()) {
186
202
  if (agent.status === 'busy') {
187
203
  await this.pauseAgent(agent.id);
188
204
  }
189
205
  }
190
-
206
+
191
207
  this.emitSwarmEvent({
192
208
  id: generateId('event'),
193
209
  timestamp: new Date(),
@@ -195,7 +211,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
195
211
  source: this.swarmId.id,
196
212
  data: { swarmId: this.swarmId },
197
213
  broadcast: true,
198
- processed: false
214
+ processed: false,
199
215
  });
200
216
  }
201
217
 
@@ -206,14 +222,14 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
206
222
 
207
223
  this.logger.info('Resuming swarm coordinator...');
208
224
  this.status = 'executing';
209
-
225
+
210
226
  // Resume all paused agents
211
227
  for (const agent of this.agents.values()) {
212
228
  if (agent.status === 'paused') {
213
229
  await this.resumeAgent(agent.id);
214
230
  }
215
231
  }
216
-
232
+
217
233
  this.emitSwarmEvent({
218
234
  id: generateId('event'),
219
235
  timestamp: new Date(),
@@ -221,7 +237,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
221
237
  source: this.swarmId.id,
222
238
  data: { swarmId: this.swarmId },
223
239
  broadcast: true,
224
- processed: false
240
+ processed: false,
225
241
  });
226
242
  }
227
243
 
@@ -231,10 +247,10 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
231
247
  name: string,
232
248
  description: string,
233
249
  strategy: SwarmStrategy = 'auto',
234
- requirements: Partial<SwarmObjective['requirements']> = {}
250
+ requirements: Partial<SwarmObjective['requirements']> = {},
235
251
  ): Promise<string> {
236
252
  const objectiveId = generateId('objective');
237
-
253
+
238
254
  const objective: SwarmObjective = {
239
255
  id: objectiveId,
240
256
  name,
@@ -246,45 +262,47 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
246
262
  maxAgents: this.config.maxAgents,
247
263
  agentTypes: this.determineRequiredAgentTypes(strategy),
248
264
  estimatedDuration: 60 * 60 * 1000, // 1 hour default
249
- maxDuration: 4 * 60 * 60 * 1000, // 4 hours default
265
+ maxDuration: 4 * 60 * 60 * 1000, // 4 hours default
250
266
  qualityThreshold: this.config.qualityThreshold,
251
267
  reviewCoverage: 0.8,
252
268
  testCoverage: 0.7,
253
269
  reliabilityTarget: 0.95,
254
- ...requirements
270
+ ...requirements,
255
271
  },
256
272
  constraints: {
257
273
  minQuality: this.config.qualityThreshold,
258
274
  requiredApprovals: [],
259
275
  allowedFailures: Math.floor(this.config.maxAgents * 0.1),
260
276
  recoveryTime: 5 * 60 * 1000, // 5 minutes
261
- milestones: []
277
+ milestones: [],
262
278
  },
263
279
  tasks: [],
264
280
  dependencies: [],
265
281
  status: 'planning',
266
282
  progress: this.initializeProgress(),
267
283
  createdAt: new Date(),
268
- metrics: this.initializeMetrics()
284
+ metrics: this.initializeMetrics(),
269
285
  };
270
286
 
271
287
  // Decompose objective into tasks using optimized AUTO strategy
272
288
  if (objective.strategy === 'auto') {
273
289
  const decompositionResult = await this.autoStrategy.decomposeObjective(objective);
274
290
  objective.tasks = decompositionResult.tasks;
275
- objective.dependencies = this.convertDependenciesToTaskDependencies(decompositionResult.dependencies);
291
+ objective.dependencies = this.convertDependenciesToTaskDependencies(
292
+ decompositionResult.dependencies,
293
+ );
276
294
  } else {
277
295
  objective.tasks = await this.decomposeObjective(objective);
278
296
  objective.dependencies = this.analyzeDependencies(objective.tasks);
279
297
  }
280
-
298
+
281
299
  this.objectives.set(objectiveId, objective);
282
-
283
- this.logger.info('Created objective', {
284
- objectiveId,
285
- name,
286
- strategy,
287
- taskCount: objective.tasks.length
300
+
301
+ this.logger.info('Created objective', {
302
+ objectiveId,
303
+ name,
304
+ strategy,
305
+ taskCount: objective.tasks.length,
288
306
  });
289
307
 
290
308
  return objectiveId;
@@ -307,13 +325,12 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
307
325
  try {
308
326
  // Ensure we have required agents
309
327
  await this.ensureRequiredAgents(objective);
310
-
328
+
311
329
  // Schedule initial tasks
312
330
  await this.scheduleInitialTasks(objective);
313
-
331
+
314
332
  // Start task execution loop
315
333
  this.startTaskExecutionLoop(objective);
316
-
317
334
  } catch (error) {
318
335
  objective.status = 'failed';
319
336
  this.logger.error('Failed to execute objective', { objectiveId, error });
@@ -326,13 +343,13 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
326
343
  async registerAgent(
327
344
  name: string,
328
345
  type: AgentType,
329
- capabilities: Partial<AgentState['capabilities']> = {}
346
+ capabilities: Partial<AgentState['capabilities']> = {},
330
347
  ): Promise<string> {
331
348
  const agentId: AgentId = {
332
349
  id: generateId('agent'),
333
350
  swarmId: this.swarmId.id,
334
351
  type,
335
- instance: this.getNextInstanceNumber(type)
352
+ instance: this.getNextInstanceNumber(type),
336
353
  };
337
354
 
338
355
  const agentState: AgentState = {
@@ -362,7 +379,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
362
379
  reliability: 0.8,
363
380
  speed: 1.0,
364
381
  quality: 0.8,
365
- ...capabilities
382
+ ...capabilities,
366
383
  },
367
384
  metrics: {
368
385
  tasksCompleted: 0,
@@ -379,7 +396,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
379
396
  userSatisfaction: 0,
380
397
  totalUptime: 0,
381
398
  lastActivity: new Date(),
382
- responseTime: 0
399
+ responseTime: 0,
383
400
  },
384
401
  workload: 0,
385
402
  health: 1.0,
@@ -395,7 +412,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
395
412
  permissions: this.getDefaultPermissions(type),
396
413
  trustedAgents: [],
397
414
  expertise: {},
398
- preferences: {}
415
+ preferences: {},
399
416
  },
400
417
  environment: {
401
418
  runtime: 'deno',
@@ -406,32 +423,32 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
406
423
  apiEndpoints: {},
407
424
  credentials: {},
408
425
  availableTools: [],
409
- toolConfigs: {}
426
+ toolConfigs: {},
410
427
  },
411
428
  endpoints: [],
412
429
  lastHeartbeat: new Date(),
413
430
  taskHistory: [],
414
431
  errorHistory: [],
415
432
  childAgents: [],
416
- collaborators: []
433
+ collaborators: [],
417
434
  };
418
435
 
419
436
  this.agents.set(agentId.id, agentState);
420
-
437
+
421
438
  // Track agent in JSON output if enabled
422
439
  this.trackAgentInJsonOutput(agentState);
423
-
440
+
424
441
  // Initialize agent capabilities based on type
425
442
  await this.initializeAgentCapabilities(agentState);
426
-
443
+
427
444
  // Start agent
428
445
  await this.startAgent(agentId.id);
429
-
430
- this.logger.info('Registered agent', {
431
- agentId: agentId.id,
432
- name,
446
+
447
+ this.logger.info('Registered agent', {
448
+ agentId: agentId.id,
449
+ name,
433
450
  type,
434
- capabilities: Object.keys(capabilities)
451
+ capabilities: Object.keys(capabilities),
435
452
  });
436
453
 
437
454
  this.emitSwarmEvent({
@@ -441,7 +458,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
441
458
  source: agentId.id,
442
459
  data: { agent: agentState },
443
460
  broadcast: false,
444
- processed: false
461
+ processed: false,
445
462
  });
446
463
 
447
464
  return agentId.id;
@@ -454,18 +471,18 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
454
471
  }
455
472
 
456
473
  this.logger.info('Unregistering agent', { agentId, name: agent.name });
457
-
474
+
458
475
  // Stop agent gracefully
459
476
  await this.stopAgent(agentId);
460
-
477
+
461
478
  // Reassign any active tasks
462
479
  if (agent.currentTask) {
463
480
  await this.reassignTask(agent.currentTask.id);
464
481
  }
465
-
482
+
466
483
  // Remove from agents map
467
484
  this.agents.delete(agentId);
468
-
485
+
469
486
  this.emitSwarmEvent({
470
487
  id: generateId('event'),
471
488
  timestamp: new Date(),
@@ -473,7 +490,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
473
490
  source: agentId,
474
491
  data: { agentId },
475
492
  broadcast: false,
476
- processed: false
493
+ processed: false,
477
494
  });
478
495
  }
479
496
 
@@ -488,17 +505,17 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
488
505
  }
489
506
 
490
507
  this.logger.info('Starting agent', { agentId, name: agent.name });
491
-
508
+
492
509
  try {
493
510
  // Initialize agent environment
494
511
  await this.initializeAgentEnvironment(agent);
495
-
512
+
496
513
  // Start agent heartbeat
497
514
  this.startAgentHeartbeat(agent);
498
-
515
+
499
516
  agent.status = 'idle';
500
517
  agent.lastHeartbeat = new Date();
501
-
518
+
502
519
  this.emitSwarmEvent({
503
520
  id: generateId('event'),
504
521
  timestamp: new Date(),
@@ -506,21 +523,20 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
506
523
  source: agentId,
507
524
  data: { agent },
508
525
  broadcast: false,
509
- processed: false
526
+ processed: false,
510
527
  });
511
-
512
528
  } catch (error) {
513
529
  agent.status = 'error';
514
530
  agent.errorHistory.push({
515
531
  timestamp: new Date(),
516
532
  type: 'startup_error',
517
- message: (error instanceof Error ? error.message : String(error)),
533
+ message: error instanceof Error ? error.message : String(error),
518
534
  stack: error.stack,
519
535
  context: { agentId },
520
536
  severity: 'high',
521
- resolved: false
537
+ resolved: false,
522
538
  });
523
-
539
+
524
540
  this.logger.error('Failed to start agent', { agentId, error });
525
541
  throw error;
526
542
  }
@@ -537,23 +553,22 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
537
553
  }
538
554
 
539
555
  this.logger.info('Stopping agent', { agentId, name: agent.name });
540
-
556
+
541
557
  agent.status = 'terminating';
542
-
558
+
543
559
  try {
544
560
  // Cancel current task if any
545
561
  if (agent.currentTask) {
546
562
  await this.cancelTask(agent.currentTask.id, 'Agent stopping');
547
563
  }
548
-
564
+
549
565
  // Stop heartbeat
550
566
  this.stopAgentHeartbeat(agent);
551
-
567
+
552
568
  // Cleanup agent environment
553
569
  await this.cleanupAgentEnvironment(agent);
554
-
570
+
555
571
  agent.status = 'terminated';
556
-
557
572
  } catch (error) {
558
573
  agent.status = 'error';
559
574
  this.logger.error('Error stopping agent', { agentId, error });
@@ -587,13 +602,13 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
587
602
  name: string,
588
603
  description: string,
589
604
  instructions: string,
590
- options: Partial<TaskDefinition> = {}
605
+ options: Partial<TaskDefinition> = {},
591
606
  ): Promise<string> {
592
607
  const taskId: TaskId = {
593
608
  id: generateId('task'),
594
609
  swarmId: this.swarmId.id,
595
610
  sequence: this.tasks.size + 1,
596
- priority: 1
611
+ priority: 1,
597
612
  };
598
613
 
599
614
  const task: TaskDefinition = {
@@ -606,7 +621,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
606
621
  capabilities: this.getRequiredCapabilities(type),
607
622
  tools: this.getRequiredTools(type),
608
623
  permissions: this.getRequiredPermissions(type),
609
- ...options.requirements
624
+ ...options.requirements,
610
625
  },
611
626
  constraints: {
612
627
  dependencies: [],
@@ -614,7 +629,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
614
629
  conflicts: [],
615
630
  maxRetries: SWARM_CONSTANTS.MAX_RETRIES,
616
631
  timeoutAfter: SWARM_CONSTANTS.DEFAULT_TASK_TIMEOUT,
617
- ...options.constraints
632
+ ...options.constraints,
618
633
  },
619
634
  priority: 'normal',
620
635
  input: options.input || {},
@@ -624,26 +639,28 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
624
639
  createdAt: new Date(),
625
640
  updatedAt: new Date(),
626
641
  attempts: [],
627
- statusHistory: [{
628
- timestamp: new Date(),
629
- from: 'created' as TaskStatus,
630
- to: 'created' as TaskStatus,
631
- reason: 'Task created',
632
- triggeredBy: 'system'
633
- }],
634
- ...options
642
+ statusHistory: [
643
+ {
644
+ timestamp: new Date(),
645
+ from: 'created' as TaskStatus,
646
+ to: 'created' as TaskStatus,
647
+ reason: 'Task created',
648
+ triggeredBy: 'system',
649
+ },
650
+ ],
651
+ ...options,
635
652
  };
636
653
 
637
654
  this.tasks.set(taskId.id, task);
638
-
655
+
639
656
  // Track task in JSON output if enabled
640
657
  this.trackTaskInJsonOutput(task);
641
-
642
- this.logger.info('Created task', {
643
- taskId: taskId.id,
644
- type,
658
+
659
+ this.logger.info('Created task', {
660
+ taskId: taskId.id,
661
+ type,
645
662
  name,
646
- priority: task.priority
663
+ priority: task.priority,
647
664
  });
648
665
 
649
666
  this.emitSwarmEvent({
@@ -653,7 +670,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
653
670
  source: this.swarmId.id,
654
671
  data: { task },
655
672
  broadcast: false,
656
- processed: false
673
+ processed: false,
657
674
  });
658
675
 
659
676
  return taskId.id;
@@ -690,23 +707,23 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
690
707
  task.assignedTo = agent.id;
691
708
  task.assignedAt = new Date();
692
709
  task.status = 'assigned';
693
-
710
+
694
711
  agent.currentTask = task.id;
695
712
  agent.status = 'busy';
696
-
713
+
697
714
  // Update status history
698
715
  task.statusHistory.push({
699
716
  timestamp: new Date(),
700
717
  from: task.statusHistory[task.statusHistory.length - 1].to,
701
718
  to: 'assigned',
702
719
  reason: `Assigned to agent ${agent.name}`,
703
- triggeredBy: 'system'
720
+ triggeredBy: 'system',
704
721
  });
705
722
 
706
- this.logger.info('Assigned task', {
707
- taskId,
708
- agentId,
709
- agentName: agent.name
723
+ this.logger.info('Assigned task', {
724
+ taskId,
725
+ agentId,
726
+ agentName: agent.name,
710
727
  });
711
728
 
712
729
  this.emitSwarmEvent({
@@ -716,7 +733,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
716
733
  source: agentId,
717
734
  data: { task, agent },
718
735
  broadcast: false,
719
- processed: false
736
+ processed: false,
720
737
  });
721
738
 
722
739
  // Start task execution
@@ -733,31 +750,31 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
733
750
  throw new Error(`Agent not found: ${task.assignedTo.id}`);
734
751
  }
735
752
 
736
- this.logger.info('Starting task execution', {
737
- taskId: task.id.id,
738
- agentId: agent.id.id
753
+ this.logger.info('Starting task execution', {
754
+ taskId: task.id.id,
755
+ agentId: agent.id.id,
739
756
  });
740
757
 
741
758
  task.status = 'running';
742
759
  task.startedAt = new Date();
743
-
760
+
744
761
  // Create attempt record
745
762
  const attempt = {
746
763
  attemptNumber: task.attempts.length + 1,
747
764
  agent: agent.id,
748
765
  startedAt: new Date(),
749
766
  status: 'running' as TaskStatus,
750
- resourcesUsed: {}
767
+ resourcesUsed: {},
751
768
  };
752
769
  task.attempts.push(attempt);
753
-
770
+
754
771
  // Update status history
755
772
  task.statusHistory.push({
756
773
  timestamp: new Date(),
757
774
  from: 'assigned',
758
775
  to: 'running',
759
776
  reason: 'Task execution started',
760
- triggeredBy: agent.id
777
+ triggeredBy: agent.id,
761
778
  });
762
779
 
763
780
  this.emitSwarmEvent({
@@ -767,14 +784,13 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
767
784
  source: agent.id.id,
768
785
  data: { task, agent, attempt },
769
786
  broadcast: false,
770
- processed: false
787
+ processed: false,
771
788
  });
772
789
 
773
790
  try {
774
791
  // Execute task (this would spawn actual Claude process)
775
792
  const result = await this.executeTaskWithAgent(task, agent);
776
793
  await this.completeTask(task.id.id, result);
777
-
778
794
  } catch (error) {
779
795
  await this.failTask(task.id.id, error);
780
796
  }
@@ -804,7 +820,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
804
820
  accuracy: 1.0,
805
821
  executionTime: task.completedAt.getTime() - (task.startedAt?.getTime() || 0),
806
822
  resourcesUsed: {},
807
- validated: false
823
+ validated: false,
808
824
  };
809
825
 
810
826
  // Update attempt
@@ -821,7 +837,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
821
837
  agent.metrics.tasksCompleted++;
822
838
  agent.metrics.lastActivity = new Date();
823
839
  agent.taskHistory.push(task.id);
824
-
840
+
825
841
  // Update agent metrics
826
842
  this.updateAgentMetrics(agent, task);
827
843
 
@@ -831,7 +847,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
831
847
  from: 'running',
832
848
  to: 'completed',
833
849
  reason: 'Task completed successfully',
834
- triggeredBy: agent.id
850
+ triggeredBy: agent.id,
835
851
  });
836
852
 
837
853
  this.emitSwarmEvent({
@@ -841,7 +857,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
841
857
  source: agent.id.id,
842
858
  data: { task, agent, result: task.result },
843
859
  broadcast: false,
844
- processed: false
860
+ processed: false,
845
861
  });
846
862
 
847
863
  // Check for dependent tasks
@@ -859,16 +875,20 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
859
875
  throw new Error('Task not assigned to any agent');
860
876
  }
861
877
 
862
- this.logger.warn('Task failed', { taskId, agentId: agent.id.id, error: (error instanceof Error ? error.message : String(error)) });
878
+ this.logger.warn('Task failed', {
879
+ taskId,
880
+ agentId: agent.id.id,
881
+ error: error instanceof Error ? error.message : String(error),
882
+ });
863
883
 
864
884
  task.error = {
865
885
  type: error.constructor.name,
866
- message: (error instanceof Error ? error.message : String(error)),
886
+ message: error instanceof Error ? error.message : String(error),
867
887
  code: error.code,
868
888
  stack: error.stack,
869
889
  context: { taskId, agentId: agent.id.id },
870
890
  recoverable: this.isRecoverableError(error),
871
- retryable: this.isRetryableError(error)
891
+ retryable: this.isRetryableError(error),
872
892
  };
873
893
 
874
894
  // Update attempt
@@ -884,33 +904,34 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
884
904
  agent.currentTask = undefined;
885
905
  agent.metrics.tasksFailed++;
886
906
  agent.metrics.lastActivity = new Date();
887
-
907
+
888
908
  // Add to error history
889
909
  agent.errorHistory.push({
890
910
  timestamp: new Date(),
891
911
  type: 'task_failure',
892
- message: (error instanceof Error ? error.message : String(error)),
912
+ message: error instanceof Error ? error.message : String(error),
893
913
  stack: error.stack,
894
914
  context: { taskId },
895
915
  severity: 'medium',
896
- resolved: false
916
+ resolved: false,
897
917
  });
898
918
 
899
919
  // Determine if we should retry
900
- const shouldRetry = task.error.retryable &&
901
- task.attempts.length < (task.constraints.maxRetries || SWARM_CONSTANTS.MAX_RETRIES);
920
+ const shouldRetry =
921
+ task.error.retryable &&
922
+ task.attempts.length < (task.constraints.maxRetries || SWARM_CONSTANTS.MAX_RETRIES);
902
923
 
903
924
  if (shouldRetry) {
904
925
  task.status = 'retrying';
905
926
  task.assignedTo = undefined;
906
-
927
+
907
928
  // Update status history
908
929
  task.statusHistory.push({
909
930
  timestamp: new Date(),
910
931
  from: 'running',
911
932
  to: 'retrying',
912
- reason: `Task failed, will retry: ${(error instanceof Error ? error.message : String(error))}`,
913
- triggeredBy: agent.id
933
+ reason: `Task failed, will retry: ${error instanceof Error ? error.message : String(error)}`,
934
+ triggeredBy: agent.id,
914
935
  });
915
936
 
916
937
  this.emitSwarmEvent({
@@ -920,28 +941,27 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
920
941
  source: agent.id.id,
921
942
  data: { task, error: task.error, attempt: task.attempts.length },
922
943
  broadcast: false,
923
- processed: false
944
+ processed: false,
924
945
  });
925
946
 
926
947
  // Schedule retry with exponential backoff
927
948
  const retryDelay = Math.pow(2, task.attempts.length) * 1000;
928
949
  setTimeout(() => {
929
- this.assignTask(taskId).catch(retryError => {
950
+ this.assignTask(taskId).catch((retryError) => {
930
951
  this.logger.error('Failed to retry task', { taskId, retryError });
931
952
  });
932
953
  }, retryDelay);
933
-
934
954
  } else {
935
955
  task.status = 'failed';
936
956
  task.completedAt = new Date();
937
-
957
+
938
958
  // Update status history
939
959
  task.statusHistory.push({
940
960
  timestamp: new Date(),
941
961
  from: 'running',
942
962
  to: 'failed',
943
- reason: `Task failed permanently: ${(error instanceof Error ? error.message : String(error))}`,
944
- triggeredBy: agent.id
963
+ reason: `Task failed permanently: ${error instanceof Error ? error.message : String(error)}`,
964
+ triggeredBy: agent.id,
945
965
  });
946
966
 
947
967
  this.emitSwarmEvent({
@@ -951,7 +971,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
951
971
  source: agent.id.id,
952
972
  data: { task, error: task.error },
953
973
  broadcast: false,
954
- processed: false
974
+ processed: false,
955
975
  });
956
976
 
957
977
  // Handle failure cascade
@@ -983,7 +1003,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
983
1003
  from: task.statusHistory[task.statusHistory.length - 1].to,
984
1004
  to: 'cancelled',
985
1005
  reason: `Task cancelled: ${reason}`,
986
- triggeredBy: 'system'
1006
+ triggeredBy: 'system',
987
1007
  });
988
1008
 
989
1009
  this.emitSwarmEvent({
@@ -993,27 +1013,25 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
993
1013
  source: this.swarmId.id,
994
1014
  data: { task, reason },
995
1015
  broadcast: false,
996
- processed: false
1016
+ processed: false,
997
1017
  });
998
1018
  }
999
1019
 
1000
1020
  // ===== ADVANCED FEATURES =====
1001
1021
 
1002
1022
  async selectAgentForTask(task: TaskDefinition): Promise<string | null> {
1003
- const availableAgents = Array.from(this.agents.values())
1004
- .filter(agent =>
1005
- agent.status === 'idle' &&
1006
- this.agentCanHandleTask(agent, task)
1007
- );
1023
+ const availableAgents = Array.from(this.agents.values()).filter(
1024
+ (agent) => agent.status === 'idle' && this.agentCanHandleTask(agent, task),
1025
+ );
1008
1026
 
1009
1027
  if (availableAgents.length === 0) {
1010
1028
  return null;
1011
1029
  }
1012
1030
 
1013
1031
  // Score agents based on multiple criteria
1014
- const scoredAgents = availableAgents.map(agent => ({
1032
+ const scoredAgents = availableAgents.map((agent) => ({
1015
1033
  agent,
1016
- score: this.calculateAgentScore(agent, task)
1034
+ score: this.calculateAgentScore(agent, task),
1017
1035
  }));
1018
1036
 
1019
1037
  // Sort by score (highest first)
@@ -1059,24 +1077,37 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1059
1077
 
1060
1078
  private agentHasCapability(agent: AgentState, capability: string): boolean {
1061
1079
  const caps = agent.capabilities;
1062
-
1080
+
1063
1081
  switch (capability) {
1064
- case 'code-generation': return caps.codeGeneration;
1065
- case 'code-review': return caps.codeReview;
1066
- case 'testing': return caps.testing;
1067
- case 'documentation': return caps.documentation;
1068
- case 'research': return caps.research;
1069
- case 'analysis': return caps.analysis;
1070
- case 'web-search': return caps.webSearch;
1071
- case 'api-integration': return caps.apiIntegration;
1072
- case 'file-system': return caps.fileSystem;
1073
- case 'terminal-access': return caps.terminalAccess;
1074
- case 'validation': return caps.testing; // Validation is part of testing capability
1075
- default:
1076
- return caps.domains.includes(capability) ||
1077
- caps.languages.includes(capability) ||
1078
- caps.frameworks.includes(capability) ||
1079
- caps.tools.includes(capability);
1082
+ case 'code-generation':
1083
+ return caps.codeGeneration;
1084
+ case 'code-review':
1085
+ return caps.codeReview;
1086
+ case 'testing':
1087
+ return caps.testing;
1088
+ case 'documentation':
1089
+ return caps.documentation;
1090
+ case 'research':
1091
+ return caps.research;
1092
+ case 'analysis':
1093
+ return caps.analysis;
1094
+ case 'web-search':
1095
+ return caps.webSearch;
1096
+ case 'api-integration':
1097
+ return caps.apiIntegration;
1098
+ case 'file-system':
1099
+ return caps.fileSystem;
1100
+ case 'terminal-access':
1101
+ return caps.terminalAccess;
1102
+ case 'validation':
1103
+ return caps.testing; // Validation is part of testing capability
1104
+ default:
1105
+ return (
1106
+ caps.domains.includes(capability) ||
1107
+ caps.languages.includes(capability) ||
1108
+ caps.frameworks.includes(capability) ||
1109
+ caps.tools.includes(capability)
1110
+ );
1080
1111
  }
1081
1112
  }
1082
1113
 
@@ -1094,8 +1125,10 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1094
1125
  }
1095
1126
 
1096
1127
  // Check reliability requirement
1097
- if (task.requirements.minReliability &&
1098
- agent.capabilities.reliability < task.requirements.minReliability) {
1128
+ if (
1129
+ task.requirements.minReliability &&
1130
+ agent.capabilities.reliability < task.requirements.minReliability
1131
+ ) {
1099
1132
  return false;
1100
1133
  }
1101
1134
 
@@ -1113,7 +1146,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1113
1146
  return {
1114
1147
  id: generateId('swarm'),
1115
1148
  timestamp: Date.now(),
1116
- namespace: 'default'
1149
+ namespace: 'default',
1117
1150
  };
1118
1151
  }
1119
1152
 
@@ -1131,7 +1164,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1131
1164
  taskScheduling: 'priority',
1132
1165
  loadBalancing: 'work-stealing',
1133
1166
  faultTolerance: 'retry',
1134
- communication: 'event-driven'
1167
+ communication: 'event-driven',
1135
1168
  },
1136
1169
  maxAgents: 10,
1137
1170
  maxTasks: 100,
@@ -1139,7 +1172,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1139
1172
  resourceLimits: {
1140
1173
  memory: SWARM_CONSTANTS.DEFAULT_MEMORY_LIMIT,
1141
1174
  cpu: SWARM_CONSTANTS.DEFAULT_CPU_LIMIT,
1142
- disk: SWARM_CONSTANTS.DEFAULT_DISK_LIMIT
1175
+ disk: SWARM_CONSTANTS.DEFAULT_DISK_LIMIT,
1143
1176
  },
1144
1177
  qualityThreshold: SWARM_CONSTANTS.DEFAULT_QUALITY_THRESHOLD,
1145
1178
  reviewRequired: true,
@@ -1159,11 +1192,11 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1159
1192
  errorRate: 0.1,
1160
1193
  responseTime: 5000,
1161
1194
  memoryUsage: 0.8,
1162
- cpuUsage: 0.8
1195
+ cpuUsage: 0.8,
1163
1196
  },
1164
1197
  exportEnabled: false,
1165
1198
  exportFormat: 'json',
1166
- exportDestination: '/tmp/swarm-metrics'
1199
+ exportDestination: '/tmp/swarm-metrics',
1167
1200
  },
1168
1201
  memory: {
1169
1202
  namespace: 'default',
@@ -1172,14 +1205,14 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1172
1205
  read: 'swarm',
1173
1206
  write: 'team',
1174
1207
  delete: 'private',
1175
- share: 'team'
1208
+ share: 'team',
1176
1209
  },
1177
1210
  persistent: true,
1178
1211
  backupEnabled: true,
1179
1212
  distributed: false,
1180
1213
  consistency: 'eventual',
1181
1214
  cacheEnabled: true,
1182
- compressionEnabled: false
1215
+ compressionEnabled: false,
1183
1216
  },
1184
1217
  security: {
1185
1218
  authenticationRequired: false,
@@ -1190,7 +1223,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1190
1223
  auditEnabled: true,
1191
1224
  auditLevel: 'info',
1192
1225
  inputValidation: true,
1193
- outputSanitization: true
1226
+ outputSanitization: true,
1194
1227
  },
1195
1228
  performance: {
1196
1229
  maxConcurrency: 10,
@@ -1203,9 +1236,9 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1203
1236
  predictiveLoading: false,
1204
1237
  resourcePooling: true,
1205
1238
  connectionPooling: true,
1206
- memoryPooling: false
1239
+ memoryPooling: false,
1207
1240
  },
1208
- ...config
1241
+ ...config,
1209
1242
  };
1210
1243
  }
1211
1244
 
@@ -1224,7 +1257,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1224
1257
  agentSatisfaction: 0,
1225
1258
  collaborationEffectiveness: 0,
1226
1259
  scheduleVariance: 0,
1227
- deadlineAdherence: 0
1260
+ deadlineAdherence: 0,
1228
1261
  };
1229
1262
  }
1230
1263
 
@@ -1244,7 +1277,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1244
1277
  costSpent: 0,
1245
1278
  activeAgents: 0,
1246
1279
  idleAgents: 0,
1247
- busyAgents: 0
1280
+ busyAgents: 0,
1248
1281
  };
1249
1282
  }
1250
1283
 
@@ -1283,12 +1316,12 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1283
1316
 
1284
1317
  emitSwarmEvent(event: SwarmEvent): boolean {
1285
1318
  this.events.push(event);
1286
-
1319
+
1287
1320
  // Limit event history
1288
1321
  if (this.events.length > 1000) {
1289
1322
  this.events = this.events.slice(-500);
1290
1323
  }
1291
-
1324
+
1292
1325
  return this.emit(event.type, event);
1293
1326
  }
1294
1327
 
@@ -1315,7 +1348,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1315
1348
  }
1316
1349
 
1317
1350
  correlateEvents(correlationId: string): SwarmEvent[] {
1318
- return this.events.filter(event => event.correlationId === correlationId);
1351
+ return this.events.filter((event) => event.correlationId === correlationId);
1319
1352
  }
1320
1353
 
1321
1354
  // ===== PUBLIC API METHODS =====
@@ -1370,22 +1403,27 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1370
1403
  return endTime.getTime() - this.startTime.getTime();
1371
1404
  }
1372
1405
 
1373
- getSwarmStatus(): { status: SwarmStatus; objectives: number; tasks: { completed: number; failed: number; total: number }; agents: { total: number } } {
1406
+ getSwarmStatus(): {
1407
+ status: SwarmStatus;
1408
+ objectives: number;
1409
+ tasks: { completed: number; failed: number; total: number };
1410
+ agents: { total: number };
1411
+ } {
1374
1412
  const tasks = Array.from(this.tasks.values());
1375
- const completedTasks = tasks.filter(t => t.status === 'completed').length;
1376
- const failedTasks = tasks.filter(t => t.status === 'failed').length;
1377
-
1413
+ const completedTasks = tasks.filter((t) => t.status === 'completed').length;
1414
+ const failedTasks = tasks.filter((t) => t.status === 'failed').length;
1415
+
1378
1416
  return {
1379
1417
  status: this.status,
1380
1418
  objectives: this.objectives.size,
1381
1419
  tasks: {
1382
1420
  completed: completedTasks,
1383
1421
  failed: failedTasks,
1384
- total: tasks.length
1422
+ total: tasks.length,
1385
1423
  },
1386
1424
  agents: {
1387
- total: this.agents.size
1388
- }
1425
+ total: this.agents.size,
1426
+ },
1389
1427
  };
1390
1428
  }
1391
1429
 
@@ -1393,7 +1431,14 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1393
1431
 
1394
1432
  private async validateConfiguration(): Promise<ValidationResult> {
1395
1433
  // Implementation needed
1396
- return { valid: true, errors: [], warnings: [], validatedAt: new Date(), validator: 'SwarmCoordinator', context: {} };
1434
+ return {
1435
+ valid: true,
1436
+ errors: [],
1437
+ warnings: [],
1438
+ validatedAt: new Date(),
1439
+ validator: 'SwarmCoordinator',
1440
+ context: {},
1441
+ };
1397
1442
  }
1398
1443
 
1399
1444
  private async initializeSubsystems(): Promise<void> {
@@ -1440,24 +1485,23 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1440
1485
  }
1441
1486
 
1442
1487
  private async stopAllAgents(): Promise<void> {
1443
- const stopPromises = Array.from(this.agents.keys()).map(agentId =>
1444
- this.stopAgent(agentId)
1445
- );
1488
+ const stopPromises = Array.from(this.agents.keys()).map((agentId) => this.stopAgent(agentId));
1446
1489
  await Promise.allSettled(stopPromises);
1447
1490
  }
1448
1491
 
1449
1492
  private async completeRunningTasks(): Promise<void> {
1450
- const runningTasks = Array.from(this.tasks.values())
1451
- .filter(task => task.status === 'running');
1452
-
1493
+ const runningTasks = Array.from(this.tasks.values()).filter(
1494
+ (task) => task.status === 'running',
1495
+ );
1496
+
1453
1497
  // Wait for tasks to complete or timeout
1454
1498
  const timeout = 30000; // 30 seconds
1455
1499
  const deadline = Date.now() + timeout;
1456
-
1457
- while (runningTasks.some(task => task.status === 'running') && Date.now() < deadline) {
1458
- await new Promise(resolve => setTimeout(resolve, 1000));
1500
+
1501
+ while (runningTasks.some((task) => task.status === 'running') && Date.now() < deadline) {
1502
+ await new Promise((resolve) => setTimeout(resolve, 1000));
1459
1503
  }
1460
-
1504
+
1461
1505
  // Cancel any remaining running tasks
1462
1506
  for (const task of runningTasks) {
1463
1507
  if (task.status === 'running') {
@@ -1472,13 +1516,20 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1472
1516
 
1473
1517
  private determineRequiredAgentTypes(strategy: SwarmStrategy): AgentType[] {
1474
1518
  switch (strategy) {
1475
- case 'research': return ['researcher', 'analyst'];
1476
- case 'development': return ['coder', 'tester', 'reviewer'];
1477
- case 'analysis': return ['analyst', 'researcher'];
1478
- case 'testing': return ['tester', 'coder'];
1479
- case 'optimization': return ['analyst', 'coder'];
1480
- case 'maintenance': return ['coder', 'monitor'];
1481
- default: return ['coordinator', 'coder', 'analyst'];
1519
+ case 'research':
1520
+ return ['researcher', 'analyst'];
1521
+ case 'development':
1522
+ return ['coder', 'tester', 'reviewer'];
1523
+ case 'analysis':
1524
+ return ['analyst', 'researcher'];
1525
+ case 'testing':
1526
+ return ['tester', 'coder'];
1527
+ case 'optimization':
1528
+ return ['analyst', 'coder'];
1529
+ case 'maintenance':
1530
+ return ['coder', 'monitor'];
1531
+ default:
1532
+ return ['coordinator', 'coder', 'analyst'];
1482
1533
  }
1483
1534
  }
1484
1535
 
@@ -1526,31 +1577,37 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1526
1577
 
1527
1578
  private async decomposeObjective(objective: SwarmObjective): Promise<TaskDefinition[]> {
1528
1579
  // Decompose objective into tasks with clear instructions for Claude
1529
- this.logger.info('Decomposing objective', {
1530
- objectiveId: objective.id,
1531
- description: objective.description
1580
+ this.logger.info('Decomposing objective', {
1581
+ objectiveId: objective.id,
1582
+ description: objective.description,
1532
1583
  });
1533
-
1584
+
1534
1585
  const tasks: TaskDefinition[] = [];
1535
-
1586
+
1536
1587
  // Extract target directory from objective
1537
- const targetDirMatch = objective.description.match(/(?:in|to|at)\s+([^\s]+\/[^\s]+)|([^\s]+\/[^\s]+)$/);
1588
+ const targetDirMatch = objective.description.match(
1589
+ /(?:in|to|at)\s+([^\s]+\/[^\s]+)|([^\s]+\/[^\s]+)$/,
1590
+ );
1538
1591
  const targetDir = targetDirMatch ? targetDirMatch[1] || targetDirMatch[2] : null;
1539
- const targetPath = targetDir ? (targetDir.startsWith('/') ? targetDir : `${getClaudeFlowRoot()}/${targetDir}`) : null;
1540
-
1592
+ const targetPath = targetDir
1593
+ ? targetDir.startsWith('/')
1594
+ ? targetDir
1595
+ : `${getClaudeFlowRoot()}/${targetDir}`
1596
+ : null;
1597
+
1541
1598
  // Check if objective requests "each agent" or "each agent type" for parallel execution
1542
1599
  const eachAgentPattern = /\beach\s+agent(?:\s+type)?\b/i;
1543
1600
  const requestsParallelAgents = eachAgentPattern.test(objective.description);
1544
-
1601
+
1545
1602
  // Create tasks with specific prompts for Claude
1546
1603
  if (requestsParallelAgents && this.config.mode === 'parallel') {
1547
1604
  // Create parallel tasks for each agent type
1548
1605
  const agentTypes = this.determineRequiredAgentTypes(objective.strategy);
1549
- this.logger.info('Creating parallel tasks for each agent type', {
1606
+ this.logger.info('Creating parallel tasks for each agent type', {
1550
1607
  agentTypes,
1551
- mode: this.config.mode
1608
+ mode: this.config.mode,
1552
1609
  });
1553
-
1610
+
1554
1611
  for (const agentType of agentTypes) {
1555
1612
  const taskId = this.createTaskForObjective(`${agentType}-task`, agentType as TaskType, {
1556
1613
  title: `${agentType.charAt(0).toUpperCase() + agentType.slice(1)} Agent Task`,
@@ -1567,7 +1624,7 @@ ${this.getAgentTypeInstructions(agentType)}
1567
1624
  Work independently but be aware that other agents are working on this same objective from their perspectives.`,
1568
1625
  priority: 'high' as TaskPriority,
1569
1626
  estimatedDuration: 10 * 60 * 1000,
1570
- requiredCapabilities: this.getAgentCapabilities(agentType)
1627
+ requiredCapabilities: this.getAgentCapabilities(agentType),
1571
1628
  });
1572
1629
  tasks.push(taskId);
1573
1630
  }
@@ -1592,10 +1649,10 @@ Your analysis should include:
1592
1649
  Please provide a clear, structured plan that the next tasks can follow.`,
1593
1650
  priority: 'high' as TaskPriority,
1594
1651
  estimatedDuration: 5 * 60 * 1000,
1595
- requiredCapabilities: ['analysis', 'documentation']
1652
+ requiredCapabilities: ['analysis', 'documentation'],
1596
1653
  });
1597
1654
  tasks.push(task1);
1598
-
1655
+
1599
1656
  // Task 2: Implementation
1600
1657
  const task2 = this.createTaskForObjective('create-implementation', 'coding', {
1601
1658
  title: 'Implement the Solution',
@@ -1617,10 +1674,10 @@ Focus on creating a working implementation that matches the user's request exact
1617
1674
  priority: 'high' as TaskPriority,
1618
1675
  estimatedDuration: 10 * 60 * 1000,
1619
1676
  requiredCapabilities: ['code-generation', 'file-system'],
1620
- dependencies: [task1.id.id]
1677
+ dependencies: [task1.id.id],
1621
1678
  });
1622
1679
  tasks.push(task2);
1623
-
1680
+
1624
1681
  // Task 3: Testing
1625
1682
  const task3 = this.createTaskForObjective('write-tests', 'testing', {
1626
1683
  title: 'Create Tests',
@@ -1638,10 +1695,10 @@ Create appropriate test files that:
1638
1695
  priority: 'medium' as TaskPriority,
1639
1696
  estimatedDuration: 5 * 60 * 1000,
1640
1697
  requiredCapabilities: ['testing', 'code-generation'],
1641
- dependencies: [task2.id.id]
1698
+ dependencies: [task2.id.id],
1642
1699
  });
1643
1700
  tasks.push(task3);
1644
-
1701
+
1645
1702
  // Task 4: Documentation
1646
1703
  const task4 = this.createTaskForObjective('create-documentation', 'documentation', {
1647
1704
  title: 'Create Documentation',
@@ -1662,15 +1719,16 @@ Make sure the documentation is clear, complete, and helps users understand and u
1662
1719
  priority: 'medium' as TaskPriority,
1663
1720
  estimatedDuration: 5 * 60 * 1000,
1664
1721
  requiredCapabilities: ['documentation'],
1665
- dependencies: [task2.id.id]
1722
+ dependencies: [task2.id.id],
1666
1723
  });
1667
1724
  tasks.push(task4);
1668
1725
  } else {
1669
1726
  // For other strategies, create a comprehensive single task
1670
- tasks.push(this.createTaskForObjective('execute-objective', 'generic', {
1671
- title: 'Execute Objective',
1672
- description: objective.description,
1673
- instructions: `Please complete the following request:
1727
+ tasks.push(
1728
+ this.createTaskForObjective('execute-objective', 'generic', {
1729
+ title: 'Execute Objective',
1730
+ description: objective.description,
1731
+ instructions: `Please complete the following request:
1674
1732
 
1675
1733
  ${objective.description}
1676
1734
 
@@ -1684,28 +1742,29 @@ Please analyze what is being requested and implement it appropriately. This may
1684
1742
  - Any other tasks necessary to fulfill the request
1685
1743
 
1686
1744
  Ensure your implementation is complete, well-structured, and follows best practices.`,
1687
- priority: 'high' as TaskPriority,
1688
- estimatedDuration: 15 * 60 * 1000,
1689
- requiredCapabilities: ['code-generation', 'file-system', 'documentation']
1690
- }));
1691
- }
1692
-
1693
- this.logger.info('Objective decomposed', {
1694
- objectiveId: objective.id,
1695
- taskCount: tasks.length
1745
+ priority: 'high' as TaskPriority,
1746
+ estimatedDuration: 15 * 60 * 1000,
1747
+ requiredCapabilities: ['code-generation', 'file-system', 'documentation'],
1748
+ }),
1749
+ );
1750
+ }
1751
+
1752
+ this.logger.info('Objective decomposed', {
1753
+ objectiveId: objective.id,
1754
+ taskCount: tasks.length,
1696
1755
  });
1697
-
1756
+
1698
1757
  return tasks;
1699
1758
  }
1700
-
1759
+
1701
1760
  private createTaskForObjective(id: string, type: TaskType, params: any): TaskDefinition {
1702
1761
  const taskId: TaskId = {
1703
1762
  id: generateId('task'),
1704
1763
  swarmId: this.swarmId.id,
1705
1764
  sequence: this.tasks.size + 1,
1706
- priority: 1
1765
+ priority: 1,
1707
1766
  };
1708
-
1767
+
1709
1768
  return {
1710
1769
  id: taskId,
1711
1770
  type,
@@ -1715,36 +1774,38 @@ Ensure your implementation is complete, well-structured, and follows best practi
1715
1774
  requirements: {
1716
1775
  capabilities: params.requiredCapabilities || [],
1717
1776
  tools: this.getRequiredTools(type),
1718
- permissions: this.getRequiredPermissions(type)
1777
+ permissions: this.getRequiredPermissions(type),
1719
1778
  },
1720
1779
  constraints: {
1721
1780
  dependencies: params.dependencies || [],
1722
1781
  dependents: [],
1723
1782
  conflicts: [],
1724
1783
  maxRetries: SWARM_CONSTANTS.MAX_RETRIES,
1725
- timeoutAfter: params.estimatedDuration || SWARM_CONSTANTS.DEFAULT_TASK_TIMEOUT
1784
+ timeoutAfter: params.estimatedDuration || SWARM_CONSTANTS.DEFAULT_TASK_TIMEOUT,
1726
1785
  },
1727
1786
  priority: params.priority || 'medium',
1728
1787
  input: {
1729
1788
  description: params.description,
1730
- objective: params.description
1789
+ objective: params.description,
1731
1790
  },
1732
1791
  context: {
1733
1792
  objectiveId: id,
1734
- targetDir: params.targetDir
1793
+ targetDir: params.targetDir,
1735
1794
  },
1736
1795
  examples: [],
1737
1796
  status: 'created',
1738
1797
  createdAt: new Date(),
1739
1798
  updatedAt: new Date(),
1740
1799
  attempts: [],
1741
- statusHistory: [{
1742
- timestamp: new Date(),
1743
- from: 'created' as TaskStatus,
1744
- to: 'created' as TaskStatus,
1745
- reason: 'Task created',
1746
- triggeredBy: 'system'
1747
- }]
1800
+ statusHistory: [
1801
+ {
1802
+ timestamp: new Date(),
1803
+ from: 'created' as TaskStatus,
1804
+ to: 'created' as TaskStatus,
1805
+ reason: 'Task created',
1806
+ triggeredBy: 'system',
1807
+ },
1808
+ ],
1748
1809
  };
1749
1810
  }
1750
1811
 
@@ -1752,16 +1813,16 @@ Ensure your implementation is complete, well-structured, and follows best practi
1752
1813
  // Implementation needed - analyze task dependencies
1753
1814
  return [];
1754
1815
  }
1755
-
1816
+
1756
1817
  private convertDependenciesToTaskDependencies(dependencies: Map<string, string[]>): any[] {
1757
1818
  // Convert decomposition dependencies to task dependencies format
1758
1819
  const result: any[] = [];
1759
1820
  dependencies.forEach((deps, taskId) => {
1760
- deps.forEach(dependsOn => {
1821
+ deps.forEach((dependsOn) => {
1761
1822
  result.push({
1762
1823
  taskId,
1763
1824
  dependsOn,
1764
- type: 'sequential'
1825
+ type: 'sequential',
1765
1826
  });
1766
1827
  });
1767
1828
  });
@@ -1773,19 +1834,19 @@ Ensure your implementation is complete, well-structured, and follows best practi
1773
1834
  }
1774
1835
 
1775
1836
  private async scheduleInitialTasks(objective: SwarmObjective): Promise<void> {
1776
- this.logger.info('Scheduling initial tasks for objective', {
1777
- objectiveId: objective.id,
1778
- taskCount: objective.tasks.length
1837
+ this.logger.info('Scheduling initial tasks for objective', {
1838
+ objectiveId: objective.id,
1839
+ taskCount: objective.tasks.length,
1779
1840
  });
1780
-
1841
+
1781
1842
  // Extract target directory from objective description
1782
1843
  const targetDirPatterns = [
1783
1844
  /in\s+([^\s]+\/?)$/i,
1784
1845
  /(?:in|to|at)\s+([^\s]+\/[^\s]+)/i,
1785
1846
  /([^\s]+\/[^\s]+)$/,
1786
- /examples\/[^\s]+/i
1847
+ /examples\/[^\s]+/i,
1787
1848
  ];
1788
-
1849
+
1789
1850
  let objectiveTargetDir = null;
1790
1851
  for (const pattern of targetDirPatterns) {
1791
1852
  const match = objective.description.match(pattern);
@@ -1794,7 +1855,7 @@ Ensure your implementation is complete, well-structured, and follows best practi
1794
1855
  break;
1795
1856
  }
1796
1857
  }
1797
-
1858
+
1798
1859
  // Add all tasks to the tasks map
1799
1860
  for (const task of objective.tasks) {
1800
1861
  task.context.objectiveId = objective.id;
@@ -1803,35 +1864,35 @@ Ensure your implementation is complete, well-structured, and follows best practi
1803
1864
  task.context.targetDir = objectiveTargetDir;
1804
1865
  }
1805
1866
  this.tasks.set(task.id.id, task);
1806
-
1867
+
1807
1868
  // Track task in JSON output if enabled
1808
1869
  this.trackTaskInJsonOutput(task);
1809
1870
  }
1810
-
1871
+
1811
1872
  // Find tasks with no dependencies and queue them
1812
- const initialTasks = objective.tasks.filter(task =>
1813
- !task.constraints.dependencies || task.constraints.dependencies.length === 0
1873
+ const initialTasks = objective.tasks.filter(
1874
+ (task) => !task.constraints.dependencies || task.constraints.dependencies.length === 0,
1814
1875
  );
1815
-
1816
- this.logger.info('Found initial tasks without dependencies', {
1876
+
1877
+ this.logger.info('Found initial tasks without dependencies', {
1817
1878
  count: initialTasks.length,
1818
- tasks: initialTasks.map(t => ({ id: t.id.id, name: t.name }))
1879
+ tasks: initialTasks.map((t) => ({ id: t.id.id, name: t.name })),
1819
1880
  });
1820
-
1881
+
1821
1882
  // Queue initial tasks for execution
1822
1883
  for (const task of initialTasks) {
1823
1884
  task.status = 'queued';
1824
1885
  task.updatedAt = new Date();
1825
-
1886
+
1826
1887
  // Update status history
1827
1888
  task.statusHistory.push({
1828
1889
  timestamp: new Date(),
1829
1890
  from: 'created' as TaskStatus,
1830
1891
  to: 'queued' as TaskStatus,
1831
1892
  reason: 'Task queued for execution',
1832
- triggeredBy: 'system'
1893
+ triggeredBy: 'system',
1833
1894
  });
1834
-
1895
+
1835
1896
  // Emit task queued event
1836
1897
  this.emitSwarmEvent({
1837
1898
  id: generateId('event'),
@@ -1840,10 +1901,10 @@ Ensure your implementation is complete, well-structured, and follows best practi
1840
1901
  source: this.swarmId.id,
1841
1902
  data: { task },
1842
1903
  broadcast: false,
1843
- processed: false
1904
+ processed: false,
1844
1905
  });
1845
1906
  }
1846
-
1907
+
1847
1908
  // Update objective progress
1848
1909
  objective.progress.totalTasks = objective.tasks.length;
1849
1910
  objective.progress.runningTasks = 0;
@@ -1852,10 +1913,10 @@ Ensure your implementation is complete, well-structured, and follows best practi
1852
1913
  }
1853
1914
 
1854
1915
  private startTaskExecutionLoop(objective: SwarmObjective): void {
1855
- this.logger.info('Starting task execution loop for objective', {
1856
- objectiveId: objective.id
1916
+ this.logger.info('Starting task execution loop for objective', {
1917
+ objectiveId: objective.id,
1857
1918
  });
1858
-
1919
+
1859
1920
  // Create an interval to process queued tasks
1860
1921
  const executionInterval = setInterval(async () => {
1861
1922
  try {
@@ -1864,74 +1925,69 @@ Ensure your implementation is complete, well-structured, and follows best practi
1864
1925
  clearInterval(executionInterval);
1865
1926
  return;
1866
1927
  }
1867
-
1928
+
1868
1929
  // Find queued tasks
1869
- const queuedTasks = Array.from(this.tasks.values())
1870
- .filter(task =>
1871
- task.context?.objectiveId === objective.id &&
1872
- task.status === 'queued'
1873
- );
1874
-
1930
+ const queuedTasks = Array.from(this.tasks.values()).filter(
1931
+ (task) => task.context?.objectiveId === objective.id && task.status === 'queued',
1932
+ );
1933
+
1875
1934
  // Find idle agents
1876
- const idleAgents = Array.from(this.agents.values())
1877
- .filter(agent => agent.status === 'idle');
1878
-
1935
+ const idleAgents = Array.from(this.agents.values()).filter(
1936
+ (agent) => agent.status === 'idle',
1937
+ );
1938
+
1879
1939
  if (queuedTasks.length > 0 && idleAgents.length > 0) {
1880
- this.logger.debug('Processing queued tasks', {
1881
- queuedTasks: queuedTasks.length,
1882
- idleAgents: idleAgents.length
1940
+ this.logger.debug('Processing queued tasks', {
1941
+ queuedTasks: queuedTasks.length,
1942
+ idleAgents: idleAgents.length,
1883
1943
  });
1884
1944
  }
1885
-
1945
+
1886
1946
  // Assign tasks to idle agents
1887
1947
  for (const task of queuedTasks) {
1888
1948
  if (idleAgents.length === 0) break;
1889
-
1949
+
1890
1950
  // Find suitable agent
1891
- const suitableAgents = idleAgents.filter(agent =>
1892
- this.agentCanHandleTask(agent, task)
1893
- );
1894
-
1951
+ const suitableAgents = idleAgents.filter((agent) => this.agentCanHandleTask(agent, task));
1952
+
1895
1953
  if (suitableAgents.length > 0) {
1896
1954
  // Assign to first suitable agent
1897
1955
  await this.assignTask(task.id.id, suitableAgents[0].id.id);
1898
-
1956
+
1899
1957
  // Remove agent from idle list
1900
- const agentIndex = idleAgents.findIndex(a => a.id.id === suitableAgents[0].id.id);
1958
+ const agentIndex = idleAgents.findIndex((a) => a.id.id === suitableAgents[0].id.id);
1901
1959
  if (agentIndex >= 0) {
1902
1960
  idleAgents.splice(agentIndex, 1);
1903
1961
  }
1904
1962
  }
1905
1963
  }
1906
-
1964
+
1907
1965
  // Check for completed tasks and process dependencies
1908
- const completedTasks = Array.from(this.tasks.values())
1909
- .filter(task =>
1910
- task.context?.objectiveId === objective.id &&
1911
- task.status === 'completed'
1912
- );
1913
-
1966
+ const completedTasks = Array.from(this.tasks.values()).filter(
1967
+ (task) => task.context?.objectiveId === objective.id && task.status === 'completed',
1968
+ );
1969
+
1914
1970
  // Find tasks that can now be queued (dependencies met)
1915
- const pendingTasks = Array.from(this.tasks.values())
1916
- .filter(task =>
1917
- task.context?.objectiveId === objective.id &&
1971
+ const pendingTasks = Array.from(this.tasks.values()).filter(
1972
+ (task) =>
1973
+ task.context?.objectiveId === objective.id &&
1918
1974
  task.status === 'created' &&
1919
- this.taskDependenciesMet(task, completedTasks)
1920
- );
1921
-
1975
+ this.taskDependenciesMet(task, completedTasks),
1976
+ );
1977
+
1922
1978
  // Queue tasks with met dependencies
1923
1979
  for (const task of pendingTasks) {
1924
1980
  task.status = 'queued';
1925
1981
  task.updatedAt = new Date();
1926
-
1982
+
1927
1983
  task.statusHistory.push({
1928
1984
  timestamp: new Date(),
1929
1985
  from: 'created' as TaskStatus,
1930
1986
  to: 'queued' as TaskStatus,
1931
1987
  reason: 'Dependencies met, task queued',
1932
- triggeredBy: 'system'
1988
+ triggeredBy: 'system',
1933
1989
  });
1934
-
1990
+
1935
1991
  this.emitSwarmEvent({
1936
1992
  id: generateId('event'),
1937
1993
  timestamp: new Date(),
@@ -1939,30 +1995,28 @@ Ensure your implementation is complete, well-structured, and follows best practi
1939
1995
  source: this.swarmId.id,
1940
1996
  data: { task },
1941
1997
  broadcast: false,
1942
- processed: false
1998
+ processed: false,
1943
1999
  });
1944
2000
  }
1945
-
2001
+
1946
2002
  // Check for stuck/timed out tasks
1947
- const runningTasks = Array.from(this.tasks.values())
1948
- .filter(task =>
1949
- task.context?.objectiveId === objective.id &&
1950
- task.status === 'running'
1951
- );
1952
-
2003
+ const runningTasks = Array.from(this.tasks.values()).filter(
2004
+ (task) => task.context?.objectiveId === objective.id && task.status === 'running',
2005
+ );
2006
+
1953
2007
  const now = Date.now();
1954
2008
  for (const task of runningTasks) {
1955
2009
  if (task.startedAt) {
1956
2010
  const runtime = now - task.startedAt.getTime();
1957
2011
  const timeout = task.constraints?.timeoutAfter || SWARM_CONSTANTS.DEFAULT_TASK_TIMEOUT;
1958
-
2012
+
1959
2013
  if (runtime > timeout) {
1960
- this.logger.warn('Task timed out', {
1961
- taskId: task.id.id,
2014
+ this.logger.warn('Task timed out', {
2015
+ taskId: task.id.id,
1962
2016
  runtime: Math.round(runtime / 1000),
1963
- timeout: Math.round(timeout / 1000)
2017
+ timeout: Math.round(timeout / 1000),
1964
2018
  });
1965
-
2019
+
1966
2020
  // Mark task as failed due to timeout
1967
2021
  task.status = 'failed';
1968
2022
  task.completedAt = new Date();
@@ -1972,9 +2026,9 @@ Ensure your implementation is complete, well-structured, and follows best practi
1972
2026
  code: 'TASK_TIMEOUT',
1973
2027
  context: { taskId: task.id.id, runtime },
1974
2028
  recoverable: true,
1975
- retryable: true
2029
+ retryable: true,
1976
2030
  };
1977
-
2031
+
1978
2032
  // Update agent state if assigned
1979
2033
  if (task.assignedTo) {
1980
2034
  const agent = this.agents.get(task.assignedTo.id);
@@ -1984,7 +2038,7 @@ Ensure your implementation is complete, well-structured, and follows best practi
1984
2038
  agent.metrics.tasksFailed++;
1985
2039
  }
1986
2040
  }
1987
-
2041
+
1988
2042
  // Emit timeout event
1989
2043
  this.emitSwarmEvent({
1990
2044
  id: generateId('event'),
@@ -1993,37 +2047,42 @@ Ensure your implementation is complete, well-structured, and follows best practi
1993
2047
  source: this.swarmId.id,
1994
2048
  data: { task, reason: 'timeout' },
1995
2049
  broadcast: false,
1996
- processed: false
2050
+ processed: false,
1997
2051
  });
1998
2052
  }
1999
2053
  }
2000
2054
  }
2001
-
2055
+
2002
2056
  // Update objective progress
2003
- const allTasks = Array.from(this.tasks.values())
2004
- .filter(task => task.context?.objectiveId === objective.id);
2005
-
2057
+ const allTasks = Array.from(this.tasks.values()).filter(
2058
+ (task) => task.context?.objectiveId === objective.id,
2059
+ );
2060
+
2006
2061
  objective.progress.totalTasks = allTasks.length;
2007
- objective.progress.completedTasks = allTasks.filter(t => t.status === 'completed').length;
2008
- objective.progress.failedTasks = allTasks.filter(t => t.status === 'failed').length;
2009
- objective.progress.runningTasks = allTasks.filter(t => t.status === 'running').length;
2010
- objective.progress.percentComplete = objective.progress.totalTasks > 0
2011
- ? (objective.progress.completedTasks / objective.progress.totalTasks) * 100
2012
- : 0;
2013
-
2062
+ objective.progress.completedTasks = allTasks.filter((t) => t.status === 'completed').length;
2063
+ objective.progress.failedTasks = allTasks.filter((t) => t.status === 'failed').length;
2064
+ objective.progress.runningTasks = allTasks.filter((t) => t.status === 'running').length;
2065
+ objective.progress.percentComplete =
2066
+ objective.progress.totalTasks > 0
2067
+ ? (objective.progress.completedTasks / objective.progress.totalTasks) * 100
2068
+ : 0;
2069
+
2014
2070
  // Check if objective is complete
2015
- if (objective.progress.completedTasks + objective.progress.failedTasks === objective.progress.totalTasks) {
2071
+ if (
2072
+ objective.progress.completedTasks + objective.progress.failedTasks ===
2073
+ objective.progress.totalTasks
2074
+ ) {
2016
2075
  objective.status = objective.progress.failedTasks === 0 ? 'completed' : 'failed';
2017
2076
  objective.completedAt = new Date();
2018
2077
  clearInterval(executionInterval);
2019
-
2020
- this.logger.info('Objective completed', {
2078
+
2079
+ this.logger.info('Objective completed', {
2021
2080
  objectiveId: objective.id,
2022
2081
  status: objective.status,
2023
2082
  completedTasks: objective.progress.completedTasks,
2024
- failedTasks: objective.progress.failedTasks
2083
+ failedTasks: objective.progress.failedTasks,
2025
2084
  });
2026
-
2085
+
2027
2086
  this.emitSwarmEvent({
2028
2087
  id: generateId('event'),
2029
2088
  timestamp: new Date(),
@@ -2031,29 +2090,28 @@ Ensure your implementation is complete, well-structured, and follows best practi
2031
2090
  source: this.swarmId.id,
2032
2091
  data: { objective },
2033
2092
  broadcast: true,
2034
- processed: false
2093
+ processed: false,
2035
2094
  });
2036
2095
  }
2037
-
2038
2096
  } catch (error) {
2039
2097
  this.logger.error('Error in task execution loop', { error });
2040
2098
  }
2041
2099
  }, 2000); // Check every 2 seconds
2042
-
2100
+
2043
2101
  // Store interval reference for cleanup
2044
2102
  if (!this.executionIntervals) {
2045
2103
  this.executionIntervals = new Map();
2046
2104
  }
2047
2105
  this.executionIntervals.set(objective.id, executionInterval);
2048
2106
  }
2049
-
2107
+
2050
2108
  private taskDependenciesMet(task: TaskDefinition, completedTasks: TaskDefinition[]): boolean {
2051
2109
  if (!task.constraints.dependencies || task.constraints.dependencies.length === 0) {
2052
2110
  return true;
2053
2111
  }
2054
-
2055
- const completedTaskIds = completedTasks.map(t => t.id.id);
2056
- return task.constraints.dependencies.every(dep => {
2112
+
2113
+ const completedTaskIds = completedTasks.map((t) => t.id.id);
2114
+ return task.constraints.dependencies.every((dep) => {
2057
2115
  // Handle both string and TaskId object dependencies
2058
2116
  const depId = typeof dep === 'string' ? dep : dep.id;
2059
2117
  return completedTaskIds.includes(depId);
@@ -2061,18 +2119,22 @@ Ensure your implementation is complete, well-structured, and follows best practi
2061
2119
  }
2062
2120
 
2063
2121
  private getNextInstanceNumber(type: AgentType): number {
2064
- const agentsOfType = Array.from(this.agents.values())
2065
- .filter(agent => agent.type === type);
2122
+ const agentsOfType = Array.from(this.agents.values()).filter((agent) => agent.type === type);
2066
2123
  return agentsOfType.length + 1;
2067
2124
  }
2068
2125
 
2069
2126
  private getDefaultPermissions(type: AgentType): string[] {
2070
2127
  switch (type) {
2071
- case 'coordinator': return ['read', 'write', 'execute', 'admin'];
2072
- case 'coder': return ['read', 'write', 'execute'];
2073
- case 'tester': return ['read', 'execute'];
2074
- case 'reviewer': return ['read', 'write'];
2075
- default: return ['read'];
2128
+ case 'coordinator':
2129
+ return ['read', 'write', 'execute', 'admin'];
2130
+ case 'coder':
2131
+ return ['read', 'write', 'execute'];
2132
+ case 'tester':
2133
+ return ['read', 'execute'];
2134
+ case 'reviewer':
2135
+ return ['read', 'write'];
2136
+ default:
2137
+ return ['read'];
2076
2138
  }
2077
2139
  }
2078
2140
 
@@ -2134,120 +2196,135 @@ Ensure your implementation is complete, well-structured, and follows best practi
2134
2196
 
2135
2197
  private getRequiredCapabilities(type: TaskType): string[] {
2136
2198
  switch (type) {
2137
- case 'coding': return ['code-generation', 'file-system'];
2138
- case 'testing': return ['testing', 'code-review'];
2139
- case 'research': return ['research', 'web-search'];
2140
- case 'analysis': return ['analysis', 'documentation'];
2141
- case 'review': return ['code-review', 'documentation'];
2142
- case 'documentation': return ['documentation'];
2143
- default: return [];
2199
+ case 'coding':
2200
+ return ['code-generation', 'file-system'];
2201
+ case 'testing':
2202
+ return ['testing', 'code-review'];
2203
+ case 'research':
2204
+ return ['research', 'web-search'];
2205
+ case 'analysis':
2206
+ return ['analysis', 'documentation'];
2207
+ case 'review':
2208
+ return ['code-review', 'documentation'];
2209
+ case 'documentation':
2210
+ return ['documentation'];
2211
+ default:
2212
+ return [];
2144
2213
  }
2145
2214
  }
2146
2215
 
2147
2216
  private getRequiredTools(type: TaskType): string[] {
2148
2217
  switch (type) {
2149
- case 'coding': return ['editor', 'compiler', 'debugger'];
2150
- case 'testing': return ['test-runner', 'coverage-tool'];
2151
- case 'research': return ['web-browser', 'search-engine'];
2152
- case 'analysis': return ['data-tools', 'visualization'];
2153
- default: return [];
2218
+ case 'coding':
2219
+ return ['editor', 'compiler', 'debugger'];
2220
+ case 'testing':
2221
+ return ['test-runner', 'coverage-tool'];
2222
+ case 'research':
2223
+ return ['web-browser', 'search-engine'];
2224
+ case 'analysis':
2225
+ return ['data-tools', 'visualization'];
2226
+ default:
2227
+ return [];
2154
2228
  }
2155
2229
  }
2156
2230
 
2157
2231
  private getRequiredPermissions(type: TaskType): string[] {
2158
2232
  switch (type) {
2159
- case 'coding': return ['read', 'write', 'execute'];
2160
- case 'testing': return ['read', 'execute'];
2161
- case 'research': return ['read', 'network'];
2162
- default: return ['read'];
2233
+ case 'coding':
2234
+ return ['read', 'write', 'execute'];
2235
+ case 'testing':
2236
+ return ['read', 'execute'];
2237
+ case 'research':
2238
+ return ['read', 'network'];
2239
+ default:
2240
+ return ['read'];
2163
2241
  }
2164
2242
  }
2165
2243
 
2166
2244
  private async executeTaskWithAgent(task: TaskDefinition, agent: AgentState): Promise<any> {
2167
- this.logger.info('Executing task with agent', {
2168
- taskId: task.id.id,
2245
+ this.logger.info('Executing task with agent', {
2246
+ taskId: task.id.id,
2169
2247
  taskName: task.name,
2170
2248
  agentId: agent.id.id,
2171
- agentName: agent.name
2249
+ agentName: agent.name,
2172
2250
  });
2173
-
2251
+
2174
2252
  // Extract target directory from task
2175
2253
  const targetDir = this.extractTargetDirectory(task);
2176
-
2254
+
2177
2255
  try {
2178
2256
  // Use Claude Flow executor for full SPARC system in non-interactive mode
2179
2257
  const { ClaudeFlowExecutor } = await import('./claude-flow-executor.ts');
2180
- const executor = new ClaudeFlowExecutor({
2258
+ const executor = new ClaudeFlowExecutor({
2181
2259
  logger: this.logger,
2182
2260
  claudeFlowPath: getClaudeFlowBin(),
2183
2261
  enableSparc: true,
2184
2262
  verbose: this.config.logging?.level === 'debug',
2185
- timeoutMinutes: this.config.taskTimeoutMinutes
2263
+ timeoutMinutes: this.config.taskTimeoutMinutes,
2186
2264
  });
2187
-
2265
+
2188
2266
  const result = await executor.executeTask(task, agent, targetDir);
2189
-
2190
- this.logger.info('Task execution completed', {
2267
+
2268
+ this.logger.info('Task execution completed', {
2191
2269
  taskId: task.id.id,
2192
2270
  success: true,
2193
- outputLength: JSON.stringify(result).length
2271
+ outputLength: JSON.stringify(result).length,
2194
2272
  });
2195
-
2273
+
2196
2274
  return result;
2197
-
2198
2275
  } catch (error) {
2199
- this.logger.error('Task execution failed', {
2276
+ this.logger.error('Task execution failed', {
2200
2277
  taskId: task.id.id,
2201
- error: (error instanceof Error ? error.message : String(error))
2278
+ error: error instanceof Error ? error.message : String(error),
2202
2279
  });
2203
2280
  throw error;
2204
2281
  }
2205
2282
  }
2206
-
2283
+
2207
2284
  private createExecutionPrompt(task: TaskDefinition): string {
2208
2285
  // Create a prompt that Claude will understand
2209
2286
  let prompt = `# Swarm Task Execution\n\n`;
2210
2287
  prompt += `## Task: ${task.name}\n\n`;
2211
2288
  prompt += `${task.instructions || task.description}\n\n`;
2212
-
2289
+
2213
2290
  // Add working directory information if available
2214
2291
  const targetDir = this.extractTargetDirectory(task);
2215
2292
  if (targetDir) {
2216
2293
  prompt += `## Working Directory\n`;
2217
2294
  prompt += `Please create all files in: ${targetDir}\n\n`;
2218
2295
  }
2219
-
2296
+
2220
2297
  if (task.input && Object.keys(task.input).length > 0) {
2221
2298
  prompt += `## Additional Input\n`;
2222
2299
  prompt += `${JSON.stringify(task.input, null, 2)}\n\n`;
2223
2300
  }
2224
-
2301
+
2225
2302
  if (task.context && Object.keys(task.context).length > 0) {
2226
2303
  prompt += `## Context\n`;
2227
2304
  prompt += `${JSON.stringify(task.context, null, 2)}\n\n`;
2228
2305
  }
2229
-
2306
+
2230
2307
  // Add execution guidelines
2231
2308
  prompt += `## Guidelines\n`;
2232
2309
  prompt += `- Focus on completing this specific task\n`;
2233
2310
  prompt += `- Create all necessary files and directories\n`;
2234
2311
  prompt += `- Follow best practices for the technology being used\n`;
2235
2312
  prompt += `- Ensure the implementation is complete and functional\n`;
2236
-
2313
+
2237
2314
  return prompt;
2238
2315
  }
2239
-
2316
+
2240
2317
  private extractTargetDirectory(task: TaskDefinition): string | null {
2241
2318
  // Try multiple patterns to find the target directory
2242
2319
  const patterns = [
2243
- /in\s+([^\s]+\/?)$/i, // "in examples/dir" at end
2320
+ /in\s+([^\s]+\/?)$/i, // "in examples/dir" at end
2244
2321
  /(?:in|to|at)\s+([^\s]+\/[^\s]+)/i, // "in examples/gradio" anywhere
2245
- /([^\s]+\/[^\s]+)$/, // "examples/gradio" at end
2246
- /examples\/[^\s]+/i // specifically match examples/ paths
2322
+ /([^\s]+\/[^\s]+)$/, // "examples/gradio" at end
2323
+ /examples\/[^\s]+/i, // specifically match examples/ paths
2247
2324
  ];
2248
-
2325
+
2249
2326
  let targetDir = null;
2250
-
2327
+
2251
2328
  // First check task description and input
2252
2329
  for (const pattern of patterns) {
2253
2330
  const descMatch = task.description.match(pattern);
@@ -2257,12 +2334,12 @@ Ensure your implementation is complete, well-structured, and follows best practi
2257
2334
  break;
2258
2335
  }
2259
2336
  }
2260
-
2337
+
2261
2338
  // If not found and task has context with targetDir, use that
2262
2339
  if (!targetDir && task.context?.targetDir) {
2263
2340
  targetDir = task.context.targetDir;
2264
2341
  }
2265
-
2342
+
2266
2343
  // If still not found, check objective description from context
2267
2344
  if (!targetDir && task.context?.objectiveId) {
2268
2345
  const objective = this.objectives.get(task.context.objectiveId);
@@ -2276,7 +2353,7 @@ Ensure your implementation is complete, well-structured, and follows best practi
2276
2353
  }
2277
2354
  }
2278
2355
  }
2279
-
2356
+
2280
2357
  if (targetDir) {
2281
2358
  // Clean up the target directory
2282
2359
  targetDir = targetDir.replace(/\s+.*$/, '');
@@ -2285,40 +2362,40 @@ Ensure your implementation is complete, well-structured, and follows best practi
2285
2362
  targetDir = `${getClaudeFlowRoot()}/${targetDir}`;
2286
2363
  }
2287
2364
  }
2288
-
2365
+
2289
2366
  return targetDir;
2290
2367
  }
2291
-
2368
+
2292
2369
  private async executeClaudeTask(
2293
2370
  task: TaskDefinition,
2294
2371
  agent: AgentState,
2295
2372
  prompt: string,
2296
- targetDir: string | null
2373
+ targetDir: string | null,
2297
2374
  ): Promise<any> {
2298
2375
  // Create unique instance ID for this execution
2299
2376
  const instanceId = `swarm-${this.swarmId.id}-${task.id.id}-${Date.now()}`;
2300
-
2377
+
2301
2378
  // Build Claude arguments for non-interactive execution
2302
2379
  const claudeArgs = [prompt];
2303
-
2380
+
2304
2381
  // Always skip permissions for swarm automation
2305
- claudeArgs.push("--dangerously-skip-permissions");
2306
-
2382
+ claudeArgs.push('--dangerously-skip-permissions');
2383
+
2307
2384
  // Add non-interactive flags for automation
2308
- claudeArgs.push("-p"); // Print mode
2309
- claudeArgs.push("--output-format", "stream-json");
2310
- claudeArgs.push("--verbose"); // Required when using stream-json with -p
2311
-
2385
+ claudeArgs.push('-p'); // Print mode
2386
+ claudeArgs.push('--output-format', 'stream-json');
2387
+ claudeArgs.push('--verbose'); // Required when using stream-json with -p
2388
+
2312
2389
  // Set working directory if specified
2313
2390
  if (targetDir) {
2314
2391
  // Ensure directory exists
2315
2392
  await Deno.mkdir(targetDir, { recursive: true });
2316
-
2393
+
2317
2394
  // Add directory context to prompt
2318
2395
  const enhancedPrompt = `${prompt}\n\n## Important: Working Directory\nPlease ensure all files are created in: ${targetDir}`;
2319
2396
  claudeArgs[0] = enhancedPrompt;
2320
2397
  }
2321
-
2398
+
2322
2399
  try {
2323
2400
  // Check if claude command exists
2324
2401
  const checkCommand = new Deno.Command('which', {
@@ -2330,137 +2407,136 @@ Ensure your implementation is complete, well-structured, and follows best practi
2330
2407
  if (!checkResult.success) {
2331
2408
  throw new Error('Claude CLI not found. Please ensure claude is installed and in PATH.');
2332
2409
  }
2333
-
2410
+
2334
2411
  // Execute Claude with the prompt
2335
- const command = new Deno.Command("claude", {
2412
+ const command = new Deno.Command('claude', {
2336
2413
  args: claudeArgs,
2337
2414
  cwd: targetDir || process.cwd(),
2338
2415
  env: {
2339
2416
  ...Deno.env.toObject(),
2340
2417
  CLAUDE_INSTANCE_ID: instanceId,
2341
- CLAUDE_SWARM_MODE: "true",
2418
+ CLAUDE_SWARM_MODE: 'true',
2342
2419
  CLAUDE_SWARM_ID: this.swarmId.id,
2343
2420
  CLAUDE_TASK_ID: task.id.id,
2344
2421
  CLAUDE_AGENT_ID: agent.id.id,
2345
2422
  CLAUDE_WORKING_DIRECTORY: targetDir || process.cwd(),
2346
- CLAUDE_FLOW_MEMORY_ENABLED: "true",
2423
+ CLAUDE_FLOW_MEMORY_ENABLED: 'true',
2347
2424
  CLAUDE_FLOW_MEMORY_NAMESPACE: `swarm-${this.swarmId.id}`,
2348
2425
  },
2349
- stdin: "null",
2350
- stdout: "piped",
2351
- stderr: "piped",
2426
+ stdin: 'null',
2427
+ stdout: 'piped',
2428
+ stderr: 'piped',
2352
2429
  });
2353
-
2354
- this.logger.info('Spawning Claude agent for task', {
2430
+
2431
+ this.logger.info('Spawning Claude agent for task', {
2355
2432
  taskId: task.id.id,
2356
2433
  agentId: agent.id.id,
2357
2434
  instanceId,
2358
- targetDir
2435
+ targetDir,
2359
2436
  });
2360
-
2437
+
2361
2438
  const child = command.spawn();
2362
2439
  const { code, stdout, stderr } = await child.output();
2363
-
2440
+
2364
2441
  if (code === 0) {
2365
2442
  const output = new TextDecoder().decode(stdout);
2366
2443
  this.logger.info('Claude agent completed task successfully', {
2367
2444
  taskId: task.id.id,
2368
- outputLength: output.length
2445
+ outputLength: output.length,
2369
2446
  });
2370
-
2447
+
2371
2448
  return {
2372
2449
  success: true,
2373
2450
  output,
2374
2451
  instanceId,
2375
- targetDir
2452
+ targetDir,
2376
2453
  };
2377
2454
  } else {
2378
2455
  const errorOutput = new TextDecoder().decode(stderr);
2379
- this.logger.error(`Claude agent failed with code ${code}`, {
2456
+ this.logger.error(`Claude agent failed with code ${code}`, {
2380
2457
  taskId: task.id.id,
2381
- error: errorOutput
2458
+ error: errorOutput,
2382
2459
  });
2383
2460
  throw new Error(`Claude execution failed: ${errorOutput}`);
2384
2461
  }
2385
-
2386
2462
  } catch (error) {
2387
- this.logger.error('Failed to execute Claude agent', {
2463
+ this.logger.error('Failed to execute Claude agent', {
2388
2464
  taskId: task.id.id,
2389
- error: (error instanceof Error ? error.message : String(error))
2465
+ error: error instanceof Error ? error.message : String(error),
2390
2466
  });
2391
2467
  throw error;
2392
2468
  }
2393
2469
  }
2394
-
2470
+
2395
2471
  private determineToolsForTask(task: TaskDefinition, agent: AgentState): string[] {
2396
2472
  const tools = new Set<string>();
2397
-
2473
+
2398
2474
  // Basic tools for all tasks
2399
- tools.add("View");
2400
- tools.add("Edit");
2401
- tools.add("Bash");
2402
-
2475
+ tools.add('View');
2476
+ tools.add('Edit');
2477
+ tools.add('Bash');
2478
+
2403
2479
  // Add tools based on task type
2404
2480
  switch (task.type) {
2405
2481
  case 'coding':
2406
- tools.add("Create");
2407
- tools.add("Write");
2408
- tools.add("MultiEdit");
2409
- tools.add("Test");
2482
+ tools.add('Create');
2483
+ tools.add('Write');
2484
+ tools.add('MultiEdit');
2485
+ tools.add('Test');
2410
2486
  break;
2411
2487
  case 'testing':
2412
- tools.add("Test");
2413
- tools.add("View");
2488
+ tools.add('Test');
2489
+ tools.add('View');
2414
2490
  break;
2415
2491
  case 'documentation':
2416
- tools.add("Write");
2417
- tools.add("Create");
2492
+ tools.add('Write');
2493
+ tools.add('Create');
2418
2494
  break;
2419
2495
  case 'analysis':
2420
- tools.add("Analyze");
2421
- tools.add("Search");
2496
+ tools.add('Analyze');
2497
+ tools.add('Search');
2422
2498
  break;
2423
2499
  case 'research':
2424
- tools.add("WebSearch");
2425
- tools.add("Search");
2500
+ tools.add('WebSearch');
2501
+ tools.add('Search');
2426
2502
  break;
2427
2503
  }
2428
-
2504
+
2429
2505
  // Add tools based on agent capabilities
2430
2506
  if (agent.capabilities.fileSystem) {
2431
- tools.add("FileSystem");
2507
+ tools.add('FileSystem');
2432
2508
  }
2433
2509
  if (agent.capabilities.terminalAccess) {
2434
- tools.add("Terminal");
2510
+ tools.add('Terminal');
2435
2511
  }
2436
2512
  if (agent.capabilities.webSearch) {
2437
- tools.add("WebSearch");
2513
+ tools.add('WebSearch');
2438
2514
  }
2439
2515
  if (agent.capabilities.apiIntegration) {
2440
- tools.add("API");
2516
+ tools.add('API');
2441
2517
  }
2442
-
2518
+
2443
2519
  return Array.from(tools);
2444
2520
  }
2445
-
2521
+
2446
2522
  private async simulateTaskExecution(
2447
2523
  task: TaskDefinition,
2448
2524
  agent: AgentState,
2449
- prompt: string
2525
+ prompt: string,
2450
2526
  ): Promise<any> {
2451
2527
  // Simulate different task types with actual file operations
2452
2528
  // Check if task has a target directory in the description or context
2453
2529
  let workDir = `/tmp/swarm/${this.swarmId.id}/work`;
2454
-
2530
+
2455
2531
  // Extract target directory from task description or input
2456
2532
  // Try multiple patterns to find the target directory
2457
2533
  const patterns = [
2458
- /in\s+([^\s]+\/?)$/i, // "in examples/dir" at end
2534
+ /in\s+([^\s]+\/?)$/i, // "in examples/dir" at end
2459
2535
  /(?:in|to|at)\s+([^\s]+\/[^\s]+)/i, // "in examples/gradio" anywhere
2460
- /([^\s]+\/[^\s]+)$/, // "examples/gradio" at end
2461
- /examples\/[^\s]+/i // specifically match examples/ paths
2536
+ /([^\s]+\/[^\s]+)$/, // "examples/gradio" at end
2537
+ /examples\/[^\s]+/i, // specifically match examples/ paths
2462
2538
  ];
2463
-
2539
+
2464
2540
  let targetDir = null;
2465
2541
  for (const pattern of patterns) {
2466
2542
  const descMatch = task.description.match(pattern);
@@ -2470,55 +2546,65 @@ Ensure your implementation is complete, well-structured, and follows best practi
2470
2546
  break;
2471
2547
  }
2472
2548
  }
2473
-
2549
+
2474
2550
  if (targetDir) {
2475
2551
  // Clean up the target directory (remove trailing words if needed)
2476
2552
  targetDir = targetDir.replace(/\s+.*$/, '');
2477
2553
  // Use absolute path or resolve relative to current directory
2478
2554
  workDir = targetDir.startsWith('/') ? targetDir : `${getClaudeFlowRoot()}/${targetDir}`;
2479
-
2480
- this.logger.debug('Extracted target directory', {
2555
+
2556
+ this.logger.debug('Extracted target directory', {
2481
2557
  original: task.description,
2482
2558
  targetDir,
2483
- workDir
2559
+ workDir,
2484
2560
  });
2485
2561
  }
2486
-
2562
+
2487
2563
  try {
2488
2564
  // Ensure work directory exists
2489
2565
  await Deno.mkdir(workDir, { recursive: true });
2490
-
2566
+
2491
2567
  switch (task.type) {
2492
2568
  case 'coding':
2493
2569
  return await this.executeCodeGenerationTask(task, workDir, agent);
2494
-
2570
+
2495
2571
  case 'analysis':
2496
2572
  return await this.executeAnalysisTask(task, workDir, agent);
2497
-
2573
+
2498
2574
  case 'documentation':
2499
2575
  return await this.executeDocumentationTask(task, workDir, agent);
2500
-
2576
+
2501
2577
  case 'testing':
2502
2578
  return await this.executeTestingTask(task, workDir, agent);
2503
-
2579
+
2504
2580
  default:
2505
2581
  return await this.executeGenericTask(task, workDir, agent);
2506
2582
  }
2507
2583
  } catch (error) {
2508
- throw new Error(`Task execution failed: ${(error instanceof Error ? error.message : String(error))}`);
2584
+ throw new Error(
2585
+ `Task execution failed: ${error instanceof Error ? error.message : String(error)}`,
2586
+ );
2509
2587
  }
2510
2588
  }
2511
-
2512
- private async executeCodeGenerationTask(task: TaskDefinition, workDir: string, agent: AgentState): Promise<any> {
2589
+
2590
+ private async executeCodeGenerationTask(
2591
+ task: TaskDefinition,
2592
+ workDir: string,
2593
+ agent: AgentState,
2594
+ ): Promise<any> {
2513
2595
  this.logger.info('Executing code generation task', { taskId: task.id.id });
2514
-
2596
+
2515
2597
  // Detect technology from description
2516
2598
  const description = task.description.toLowerCase();
2517
2599
  const isGradio = description.includes('gradio');
2518
- const isPython = isGradio || description.includes('python') || description.includes('fastapi') || description.includes('django');
2600
+ const isPython =
2601
+ isGradio ||
2602
+ description.includes('python') ||
2603
+ description.includes('fastapi') ||
2604
+ description.includes('django');
2519
2605
  const isHelloWorld = description.includes('hello') && description.includes('world');
2520
2606
  const isRestAPI = description.includes('rest api') || description.includes('api');
2521
-
2607
+
2522
2608
  if (isGradio) {
2523
2609
  // Create a Gradio application
2524
2610
  return await this.createGradioApp(task, workDir);
@@ -2530,7 +2616,7 @@ Ensure your implementation is complete, well-structured, and follows best practi
2530
2616
  const projectName = 'rest-api';
2531
2617
  const projectDir = `${workDir}/${projectName}`;
2532
2618
  await Deno.mkdir(projectDir, { recursive: true });
2533
-
2619
+
2534
2620
  // Create main API file
2535
2621
  const apiCode = `const express = require('express');
2536
2622
  const app = express();
@@ -2608,44 +2694,41 @@ app.listen(port, () => {
2608
2694
 
2609
2695
  module.exports = app;
2610
2696
  `;
2611
-
2697
+
2612
2698
  await fs.writeFile(`${projectDir}/server.js`, apiCode);
2613
-
2699
+
2614
2700
  // Create package.json
2615
2701
  const packageJson = {
2616
2702
  name: projectName,
2617
- version: "1.0.0",
2618
- description: "REST API created by Claude Flow Swarm",
2619
- main: "server.js",
2703
+ version: '1.0.0',
2704
+ description: 'REST API created by Claude Flow Swarm',
2705
+ main: 'server.js',
2620
2706
  scripts: {
2621
- start: "node server.js",
2622
- dev: "nodemon server.js",
2623
- test: "jest"
2707
+ start: 'node server.js',
2708
+ dev: 'nodemon server.js',
2709
+ test: 'jest',
2624
2710
  },
2625
- keywords: ["rest", "api", "swarm", "claude-flow"],
2626
- author: "Claude Flow Swarm",
2627
- license: "MIT",
2711
+ keywords: ['rest', 'api', 'swarm', 'claude-flow'],
2712
+ author: 'Claude Flow Swarm',
2713
+ license: 'MIT',
2628
2714
  dependencies: {
2629
- express: "^4.18.2"
2715
+ express: '^4.18.2',
2630
2716
  },
2631
2717
  devDependencies: {
2632
- nodemon: "^3.0.1",
2633
- jest: "^29.7.0",
2634
- supertest: "^6.3.3"
2718
+ nodemon: '^3.0.1',
2719
+ jest: '^29.7.0',
2720
+ supertest: '^6.3.3',
2635
2721
  },
2636
2722
  swarmMetadata: {
2637
2723
  swarmId: this.swarmId.id,
2638
2724
  taskId: task.id.id,
2639
2725
  agentId: agent.id.id,
2640
- created: new Date().toISOString()
2641
- }
2726
+ created: new Date().toISOString(),
2727
+ },
2642
2728
  };
2643
-
2644
- await fs.writeFile(
2645
- `${projectDir}/package.json`,
2646
- JSON.stringify(packageJson, null, 2)
2647
- );
2648
-
2729
+
2730
+ await fs.writeFile(`${projectDir}/package.json`, JSON.stringify(packageJson, null, 2));
2731
+
2649
2732
  // Create README
2650
2733
  const readme = `# REST API
2651
2734
 
@@ -2690,9 +2773,9 @@ ${task.description}
2690
2773
  ---
2691
2774
  Created by Claude Flow Swarm
2692
2775
  `;
2693
-
2776
+
2694
2777
  await fs.writeFile(`${projectDir}/README.md`, readme);
2695
-
2778
+
2696
2779
  // Create .gitignore
2697
2780
  const gitignore = `node_modules/
2698
2781
  .env
@@ -2700,27 +2783,27 @@ Created by Claude Flow Swarm
2700
2783
  .DS_Store
2701
2784
  coverage/
2702
2785
  `;
2703
-
2786
+
2704
2787
  await fs.writeFile(`${projectDir}/.gitignore`, gitignore);
2705
-
2788
+
2706
2789
  return {
2707
2790
  success: true,
2708
2791
  output: {
2709
2792
  message: 'REST API created successfully',
2710
2793
  location: projectDir,
2711
- files: ['server.js', 'package.json', 'README.md', '.gitignore']
2794
+ files: ['server.js', 'package.json', 'README.md', '.gitignore'],
2712
2795
  },
2713
2796
  artifacts: {
2714
2797
  mainFile: `${projectDir}/server.js`,
2715
2798
  packageFile: `${projectDir}/package.json`,
2716
- readmeFile: `${projectDir}/README.md`
2717
- }
2799
+ readmeFile: `${projectDir}/README.md`,
2800
+ },
2718
2801
  };
2719
2802
  } else if (isHelloWorld) {
2720
2803
  // Create a simple hello world application
2721
2804
  const projectDir = `${workDir}/hello-world`;
2722
2805
  await Deno.mkdir(projectDir, { recursive: true });
2723
-
2806
+
2724
2807
  // Create main application file
2725
2808
  const mainCode = `#!/usr/bin/env node
2726
2809
 
@@ -2738,29 +2821,26 @@ if (typeof module !== 'undefined' && module.exports) {
2738
2821
  module.exports = { message: 'Hello, World!' };
2739
2822
  }
2740
2823
  `;
2741
-
2824
+
2742
2825
  await fs.writeFile(`${projectDir}/index.js`, mainCode);
2743
-
2826
+
2744
2827
  // Create package.json
2745
2828
  const packageJson = {
2746
- name: "hello-world",
2747
- version: "1.0.0",
2748
- description: "Hello World application created by Claude Flow Swarm",
2749
- main: "index.js",
2829
+ name: 'hello-world',
2830
+ version: '1.0.0',
2831
+ description: 'Hello World application created by Claude Flow Swarm',
2832
+ main: 'index.js',
2750
2833
  scripts: {
2751
- start: "node index.js",
2752
- test: "node test.js"
2834
+ start: 'node index.js',
2835
+ test: 'node test.js',
2753
2836
  },
2754
- keywords: ["hello-world", "swarm", "claude-flow"],
2755
- author: "Claude Flow Swarm",
2756
- license: "MIT"
2837
+ keywords: ['hello-world', 'swarm', 'claude-flow'],
2838
+ author: 'Claude Flow Swarm',
2839
+ license: 'MIT',
2757
2840
  };
2758
-
2759
- await fs.writeFile(
2760
- `${projectDir}/package.json`,
2761
- JSON.stringify(packageJson, null, 2)
2762
- );
2763
-
2841
+
2842
+ await fs.writeFile(`${projectDir}/package.json`, JSON.stringify(packageJson, null, 2));
2843
+
2764
2844
  // Create README
2765
2845
  const readme = `# Hello World
2766
2846
 
@@ -2780,28 +2860,28 @@ npm start
2780
2860
  ## Description
2781
2861
  ${task.description}
2782
2862
  `;
2783
-
2863
+
2784
2864
  await fs.writeFile(`${projectDir}/README.md`, readme);
2785
-
2865
+
2786
2866
  return {
2787
2867
  success: true,
2788
2868
  output: {
2789
2869
  message: 'Hello World application created successfully',
2790
2870
  location: projectDir,
2791
- files: ['index.js', 'package.json', 'README.md']
2871
+ files: ['index.js', 'package.json', 'README.md'],
2792
2872
  },
2793
2873
  artifacts: {
2794
2874
  mainFile: `${projectDir}/index.js`,
2795
2875
  packageFile: `${projectDir}/package.json`,
2796
- readmeFile: `${projectDir}/README.md`
2797
- }
2876
+ readmeFile: `${projectDir}/README.md`,
2877
+ },
2798
2878
  };
2799
2879
  }
2800
-
2880
+
2801
2881
  // For other code generation tasks, create a basic structure
2802
2882
  const projectDir = `${workDir}/generated-code`;
2803
2883
  await Deno.mkdir(projectDir, { recursive: true });
2804
-
2884
+
2805
2885
  const code = `// Generated code for: ${task.name}
2806
2886
  // ${task.description}
2807
2887
 
@@ -2812,25 +2892,29 @@ function main() {
2812
2892
 
2813
2893
  main();
2814
2894
  `;
2815
-
2895
+
2816
2896
  await fs.writeFile(`${projectDir}/main.js`, code);
2817
-
2897
+
2818
2898
  return {
2819
2899
  success: true,
2820
2900
  output: {
2821
2901
  message: 'Code generated successfully',
2822
2902
  location: projectDir,
2823
- files: ['main.js']
2824
- }
2903
+ files: ['main.js'],
2904
+ },
2825
2905
  };
2826
2906
  }
2827
-
2828
- private async executeAnalysisTask(task: TaskDefinition, workDir: string, agent: AgentState): Promise<any> {
2907
+
2908
+ private async executeAnalysisTask(
2909
+ task: TaskDefinition,
2910
+ workDir: string,
2911
+ agent: AgentState,
2912
+ ): Promise<any> {
2829
2913
  this.logger.info('Executing analysis task', { taskId: task.id.id });
2830
-
2914
+
2831
2915
  const analysisDir = `${workDir}/analysis`;
2832
2916
  await Deno.mkdir(analysisDir, { recursive: true });
2833
-
2917
+
2834
2918
  const analysis = {
2835
2919
  task: task.name,
2836
2920
  description: task.description,
@@ -2838,35 +2922,36 @@ main();
2838
2922
  findings: [
2839
2923
  'Analysis point 1: Task objectives are clear',
2840
2924
  'Analysis point 2: Resources are allocated',
2841
- 'Analysis point 3: Implementation path is defined'
2925
+ 'Analysis point 3: Implementation path is defined',
2842
2926
  ],
2843
2927
  recommendations: [
2844
2928
  'Proceed with implementation',
2845
2929
  'Monitor progress regularly',
2846
- 'Adjust resources as needed'
2847
- ]
2930
+ 'Adjust resources as needed',
2931
+ ],
2848
2932
  };
2849
-
2850
- await fs.writeFile(
2851
- `${analysisDir}/analysis-report.json`,
2852
- JSON.stringify(analysis, null, 2)
2853
- );
2854
-
2933
+
2934
+ await fs.writeFile(`${analysisDir}/analysis-report.json`, JSON.stringify(analysis, null, 2));
2935
+
2855
2936
  return {
2856
2937
  success: true,
2857
2938
  output: analysis,
2858
2939
  artifacts: {
2859
- report: `${analysisDir}/analysis-report.json`
2860
- }
2940
+ report: `${analysisDir}/analysis-report.json`,
2941
+ },
2861
2942
  };
2862
2943
  }
2863
-
2864
- private async executeDocumentationTask(task: TaskDefinition, workDir: string, agent: AgentState): Promise<any> {
2944
+
2945
+ private async executeDocumentationTask(
2946
+ task: TaskDefinition,
2947
+ workDir: string,
2948
+ agent: AgentState,
2949
+ ): Promise<any> {
2865
2950
  this.logger.info('Executing documentation task', { taskId: task.id.id });
2866
-
2951
+
2867
2952
  const docsDir = `${workDir}/docs`;
2868
2953
  await Deno.mkdir(docsDir, { recursive: true });
2869
-
2954
+
2870
2955
  const documentation = `# ${task.name}
2871
2956
 
2872
2957
  ${task.description}
@@ -2886,28 +2971,32 @@ ${task.instructions}
2886
2971
  - This is an automated documentation generated by the swarm
2887
2972
  - Further details would be added based on actual implementation
2888
2973
  `;
2889
-
2974
+
2890
2975
  await fs.writeFile(`${docsDir}/documentation.md`, documentation);
2891
-
2976
+
2892
2977
  return {
2893
2978
  success: true,
2894
2979
  output: {
2895
2980
  message: 'Documentation created successfully',
2896
2981
  location: docsDir,
2897
- files: ['documentation.md']
2982
+ files: ['documentation.md'],
2898
2983
  },
2899
2984
  artifacts: {
2900
- documentation: `${docsDir}/documentation.md`
2901
- }
2985
+ documentation: `${docsDir}/documentation.md`,
2986
+ },
2902
2987
  };
2903
2988
  }
2904
-
2905
- private async executeTestingTask(task: TaskDefinition, workDir: string, agent: AgentState): Promise<any> {
2989
+
2990
+ private async executeTestingTask(
2991
+ task: TaskDefinition,
2992
+ workDir: string,
2993
+ agent: AgentState,
2994
+ ): Promise<any> {
2906
2995
  this.logger.info('Executing testing task', { taskId: task.id.id });
2907
-
2996
+
2908
2997
  const testDir = `${workDir}/tests`;
2909
2998
  await Deno.mkdir(testDir, { recursive: true });
2910
-
2999
+
2911
3000
  const testCode = `// Test suite for: ${task.name}
2912
3001
  // ${task.description}
2913
3002
 
@@ -2926,9 +3015,9 @@ describe('${task.name}', () => {
2926
3015
 
2927
3016
  console.log('Tests completed for: ${task.name}');
2928
3017
  `;
2929
-
3018
+
2930
3019
  await fs.writeFile(`${testDir}/test.js`, testCode);
2931
-
3020
+
2932
3021
  return {
2933
3022
  success: true,
2934
3023
  output: {
@@ -2936,40 +3025,41 @@ console.log('Tests completed for: ${task.name}');
2936
3025
  location: testDir,
2937
3026
  files: ['test.js'],
2938
3027
  testsPassed: 2,
2939
- testsFailed: 0
3028
+ testsFailed: 0,
2940
3029
  },
2941
3030
  artifacts: {
2942
- testFile: `${testDir}/test.js`
2943
- }
3031
+ testFile: `${testDir}/test.js`,
3032
+ },
2944
3033
  };
2945
3034
  }
2946
-
2947
- private async executeGenericTask(task: TaskDefinition, workDir: string, agent: AgentState): Promise<any> {
3035
+
3036
+ private async executeGenericTask(
3037
+ task: TaskDefinition,
3038
+ workDir: string,
3039
+ agent: AgentState,
3040
+ ): Promise<any> {
2948
3041
  this.logger.info('Executing generic task', { taskId: task.id.id });
2949
-
3042
+
2950
3043
  const outputDir = `${workDir}/output`;
2951
3044
  await Deno.mkdir(outputDir, { recursive: true });
2952
-
3045
+
2953
3046
  const output = {
2954
3047
  task: task.name,
2955
3048
  type: task.type,
2956
3049
  description: task.description,
2957
3050
  status: 'completed',
2958
3051
  timestamp: new Date().toISOString(),
2959
- result: 'Task executed successfully'
3052
+ result: 'Task executed successfully',
2960
3053
  };
2961
-
2962
- await fs.writeFile(
2963
- `${outputDir}/result.json`,
2964
- JSON.stringify(output, null, 2)
2965
- );
2966
-
3054
+
3055
+ await fs.writeFile(`${outputDir}/result.json`, JSON.stringify(output, null, 2));
3056
+
2967
3057
  return {
2968
3058
  success: true,
2969
3059
  output,
2970
3060
  artifacts: {
2971
- result: `${outputDir}/result.json`
2972
- }
3061
+ result: `${outputDir}/result.json`,
3062
+ },
2973
3063
  };
2974
3064
  }
2975
3065
 
@@ -2981,12 +3071,12 @@ console.log('Tests completed for: ${task.name}');
2981
3071
  private updateAgentMetrics(agent: AgentState, task: TaskDefinition): void {
2982
3072
  // Update agent performance metrics
2983
3073
  const executionTime = task.completedAt!.getTime() - (task.startedAt?.getTime() || 0);
2984
-
2985
- agent.metrics.averageExecutionTime =
2986
- (agent.metrics.averageExecutionTime * agent.metrics.tasksCompleted + executionTime) /
3074
+
3075
+ agent.metrics.averageExecutionTime =
3076
+ (agent.metrics.averageExecutionTime * agent.metrics.tasksCompleted + executionTime) /
2987
3077
  (agent.metrics.tasksCompleted + 1);
2988
-
2989
- agent.metrics.successRate =
3078
+
3079
+ agent.metrics.successRate =
2990
3080
  agent.metrics.tasksCompleted / (agent.metrics.tasksCompleted + agent.metrics.tasksFailed);
2991
3081
  }
2992
3082
 
@@ -3015,17 +3105,17 @@ console.log('Tests completed for: ${task.name}');
3015
3105
  private processHeartbeats(): void {
3016
3106
  const now = new Date();
3017
3107
  const timeout = this.config.monitoring.heartbeatInterval * 10; // Increased multiplier for long-running Claude tasks
3018
-
3108
+
3019
3109
  for (const agent of this.agents.values()) {
3020
3110
  if (agent.status === 'offline' || agent.status === 'terminated') {
3021
3111
  continue;
3022
3112
  }
3023
-
3113
+
3024
3114
  const timeSinceHeartbeat = now.getTime() - agent.lastHeartbeat.getTime();
3025
3115
  if (timeSinceHeartbeat > timeout) {
3026
- this.logger.warn('Agent heartbeat timeout', {
3027
- agentId: agent.id.id,
3028
- timeSinceHeartbeat
3116
+ this.logger.warn('Agent heartbeat timeout', {
3117
+ agentId: agent.id.id,
3118
+ timeSinceHeartbeat,
3029
3119
  });
3030
3120
  agent.status = 'error';
3031
3121
  agent.health = 0;
@@ -3055,12 +3145,12 @@ console.log('Tests completed for: ${task.name}');
3055
3145
  agent.status = 'error';
3056
3146
  agent.health = 0;
3057
3147
  this.logger.error('Agent error', { agentId, error });
3058
-
3148
+
3059
3149
  // Track error in JSON output if enabled
3060
3150
  if (this.jsonOutputAggregator) {
3061
3151
  this.jsonOutputAggregator.addAgentError(
3062
- agentId,
3063
- error instanceof Error ? error.message : String(error)
3152
+ agentId,
3153
+ error instanceof Error ? error.message : String(error),
3064
3154
  );
3065
3155
  }
3066
3156
  }
@@ -3076,7 +3166,7 @@ console.log('Tests completed for: ${task.name}');
3076
3166
  this.jsonOutputAggregator = new SwarmJsonOutputAggregator(
3077
3167
  this.swarmId.id,
3078
3168
  objective,
3079
- this.config
3169
+ this.config,
3080
3170
  );
3081
3171
  this.logger.info('JSON output aggregation enabled', { swarmId: this.swarmId.id });
3082
3172
  }
@@ -3085,7 +3175,9 @@ console.log('Tests completed for: ${task.name}');
3085
3175
  /**
3086
3176
  * Get the final JSON output for the swarm
3087
3177
  */
3088
- getJsonOutput(status: 'completed' | 'failed' | 'timeout' | 'cancelled' = 'completed'): string | null {
3178
+ getJsonOutput(
3179
+ status: 'completed' | 'failed' | 'timeout' | 'cancelled' = 'completed',
3180
+ ): string | null {
3089
3181
  if (!this.jsonOutputAggregator) {
3090
3182
  return null;
3091
3183
  }
@@ -3096,8 +3188,8 @@ console.log('Tests completed for: ${task.name}');
3096
3188
  * Save JSON output to file
3097
3189
  */
3098
3190
  async saveJsonOutput(
3099
- filePath: string,
3100
- status: 'completed' | 'failed' | 'timeout' | 'cancelled' = 'completed'
3191
+ filePath: string,
3192
+ status: 'completed' | 'failed' | 'timeout' | 'cancelled' = 'completed',
3101
3193
  ): Promise<void> {
3102
3194
  if (!this.jsonOutputAggregator) {
3103
3195
  throw new Error('JSON output aggregation not enabled');
@@ -3149,4 +3241,4 @@ console.log('Tests completed for: ${task.name}');
3149
3241
  this.jsonOutputAggregator.addArtifact(key, artifact);
3150
3242
  }
3151
3243
  }
3152
- }
3244
+ }