kynjal-cli 4.0.0 → 4.0.1

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 (502) hide show
  1. package/dist/src/appliance/gguf-engine.d.ts +91 -0
  2. package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
  3. package/dist/src/appliance/gguf-engine.js +286 -525
  4. package/dist/src/appliance/gguf-engine.js.map +1 -1
  5. package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
  6. package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
  7. package/dist/src/appliance/ruvllm-bridge.js +203 -403
  8. package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
  9. package/dist/src/appliance/rvfa-builder.d.ts +44 -0
  10. package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
  11. package/dist/src/appliance/rvfa-builder.js +154 -208
  12. package/dist/src/appliance/rvfa-builder.js.map +1 -1
  13. package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
  14. package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
  15. package/dist/src/appliance/rvfa-distribution.js +260 -423
  16. package/dist/src/appliance/rvfa-distribution.js.map +1 -1
  17. package/dist/src/appliance/rvfa-format.d.ts +111 -0
  18. package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
  19. package/dist/src/appliance/rvfa-format.js +128 -200
  20. package/dist/src/appliance/rvfa-format.js.map +1 -1
  21. package/dist/src/appliance/rvfa-runner.d.ts +69 -0
  22. package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
  23. package/dist/src/appliance/rvfa-runner.js +168 -304
  24. package/dist/src/appliance/rvfa-runner.js.map +1 -1
  25. package/dist/src/appliance/rvfa-signing.d.ts +123 -0
  26. package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
  27. package/dist/src/appliance/rvfa-signing.js +173 -295
  28. package/dist/src/appliance/rvfa-signing.js.map +1 -1
  29. package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
  30. package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
  31. package/dist/src/benchmarks/pretrain/index.js +331 -542
  32. package/dist/src/benchmarks/pretrain/index.js.map +1 -1
  33. package/dist/src/commands/agent.js +574 -697
  34. package/dist/src/commands/agent.js.map +1 -1
  35. package/dist/src/commands/analyze.js +1218 -1548
  36. package/dist/src/commands/analyze.js.map +1 -1
  37. package/dist/src/commands/appliance-advanced.js +158 -267
  38. package/dist/src/commands/appliance-advanced.js.map +1 -1
  39. package/dist/src/commands/appliance.js +318 -493
  40. package/dist/src/commands/appliance.js.map +1 -1
  41. package/dist/src/commands/benchmark.js +372 -523
  42. package/dist/src/commands/benchmark.js.map +1 -1
  43. package/dist/src/commands/claims.js +274 -364
  44. package/dist/src/commands/claims.js.map +1 -1
  45. package/dist/src/commands/cleanup.js +113 -157
  46. package/dist/src/commands/cleanup.js.map +1 -1
  47. package/dist/src/commands/completions.js +477 -118
  48. package/dist/src/commands/completions.js.map +1 -1
  49. package/dist/src/commands/config.js +237 -303
  50. package/dist/src/commands/config.js.map +1 -1
  51. package/dist/src/commands/daemon.js +487 -596
  52. package/dist/src/commands/daemon.js.map +1 -1
  53. package/dist/src/commands/deployment.js +194 -275
  54. package/dist/src/commands/deployment.js.map +1 -1
  55. package/dist/src/commands/doctor.js +504 -686
  56. package/dist/src/commands/doctor.js.map +1 -1
  57. package/dist/src/commands/embeddings.js +1293 -1543
  58. package/dist/src/commands/embeddings.js.map +1 -1
  59. package/dist/src/commands/guidance.js +449 -596
  60. package/dist/src/commands/guidance.js.map +1 -1
  61. package/dist/src/commands/hive-mind.js +854 -938
  62. package/dist/src/commands/hive-mind.js.map +1 -1
  63. package/dist/src/commands/hooks.js +3112 -3519
  64. package/dist/src/commands/hooks.js.map +1 -1
  65. package/dist/src/commands/index.d.ts +115 -0
  66. package/dist/src/commands/index.d.ts.map +1 -0
  67. package/dist/src/commands/index.js +126 -308
  68. package/dist/src/commands/index.js.map +1 -1
  69. package/dist/src/commands/init.js +788 -940
  70. package/dist/src/commands/init.js.map +1 -1
  71. package/dist/src/commands/issues.js +383 -558
  72. package/dist/src/commands/issues.js.map +1 -1
  73. package/dist/src/commands/mcp.js +493 -605
  74. package/dist/src/commands/mcp.js.map +1 -1
  75. package/dist/src/commands/memory.js +833 -1026
  76. package/dist/src/commands/memory.js.map +1 -1
  77. package/dist/src/commands/migrate.js +282 -347
  78. package/dist/src/commands/migrate.js.map +1 -1
  79. package/dist/src/commands/neural.js +1289 -1563
  80. package/dist/src/commands/neural.js.map +1 -1
  81. package/dist/src/commands/performance.js +497 -643
  82. package/dist/src/commands/performance.js.map +1 -1
  83. package/dist/src/commands/plugins.js +668 -841
  84. package/dist/src/commands/plugins.js.map +1 -1
  85. package/dist/src/commands/process.js +392 -447
  86. package/dist/src/commands/process.js.map +1 -1
  87. package/dist/src/commands/progress.js +162 -256
  88. package/dist/src/commands/progress.js.map +1 -1
  89. package/dist/src/commands/providers.js +150 -220
  90. package/dist/src/commands/providers.js.map +1 -1
  91. package/dist/src/commands/route.js +520 -665
  92. package/dist/src/commands/route.js.map +1 -1
  93. package/dist/src/commands/ruvector/backup.js +505 -651
  94. package/dist/src/commands/ruvector/backup.js.map +1 -1
  95. package/dist/src/commands/ruvector/benchmark.js +349 -401
  96. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  97. package/dist/src/commands/ruvector/import.js +224 -266
  98. package/dist/src/commands/ruvector/import.js.map +1 -1
  99. package/dist/src/commands/ruvector/index.js +37 -75
  100. package/dist/src/commands/ruvector/index.js.map +1 -1
  101. package/dist/src/commands/ruvector/init.js +336 -359
  102. package/dist/src/commands/ruvector/init.js.map +1 -1
  103. package/dist/src/commands/ruvector/migrate.js +335 -322
  104. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  105. package/dist/src/commands/ruvector/optimize.js +375 -431
  106. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  107. package/dist/src/commands/ruvector/setup.js +703 -117
  108. package/dist/src/commands/ruvector/setup.js.map +1 -1
  109. package/dist/src/commands/ruvector/status.js +364 -419
  110. package/dist/src/commands/ruvector/status.js.map +1 -1
  111. package/dist/src/commands/security.js +485 -608
  112. package/dist/src/commands/security.js.map +1 -1
  113. package/dist/src/commands/session.js +504 -626
  114. package/dist/src/commands/session.js.map +1 -1
  115. package/dist/src/commands/start.js +267 -364
  116. package/dist/src/commands/start.js.map +1 -1
  117. package/dist/src/commands/status.js +380 -486
  118. package/dist/src/commands/status.js.map +1 -1
  119. package/dist/src/commands/swarm.js +408 -488
  120. package/dist/src/commands/swarm.js.map +1 -1
  121. package/dist/src/commands/task.js +423 -538
  122. package/dist/src/commands/task.js.map +1 -1
  123. package/dist/src/commands/transfer-store.js +322 -412
  124. package/dist/src/commands/transfer-store.js.map +1 -1
  125. package/dist/src/commands/update.js +196 -291
  126. package/dist/src/commands/update.js.map +1 -1
  127. package/dist/src/commands/workflow.js +386 -486
  128. package/dist/src/commands/workflow.js.map +1 -1
  129. package/dist/src/config-adapter.d.ts +15 -0
  130. package/dist/src/config-adapter.d.ts.map +1 -0
  131. package/dist/src/config-adapter.js +38 -39
  132. package/dist/src/config-adapter.js.map +1 -1
  133. package/dist/src/index.d.ts +77 -0
  134. package/dist/src/index.d.ts.map +1 -0
  135. package/dist/src/index.js +309 -411
  136. package/dist/src/index.js.map +1 -1
  137. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  138. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  139. package/dist/src/infrastructure/in-memory-repositories.js +246 -507
  140. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
  141. package/dist/src/init/claudemd-generator.d.ts +25 -0
  142. package/dist/src/init/claudemd-generator.d.ts.map +1 -0
  143. package/dist/src/init/claudemd-generator.js +368 -78
  144. package/dist/src/init/claudemd-generator.js.map +1 -1
  145. package/dist/src/init/executor.d.ts +41 -0
  146. package/dist/src/init/executor.d.ts.map +1 -0
  147. package/dist/src/init/executor.js +1307 -996
  148. package/dist/src/init/executor.js.map +1 -1
  149. package/dist/src/init/helpers-generator.d.ts +60 -0
  150. package/dist/src/init/helpers-generator.d.ts.map +1 -0
  151. package/dist/src/init/helpers-generator.js +657 -12
  152. package/dist/src/init/helpers-generator.js.map +1 -1
  153. package/dist/src/init/index.d.ts +1 -1
  154. package/dist/src/init/index.d.ts.map +1 -1
  155. package/dist/src/init/index.js +1 -1
  156. package/dist/src/init/index.js.map +1 -1
  157. package/dist/src/init/mcp-generator.js +33 -37
  158. package/dist/src/init/mcp-generator.js.map +1 -1
  159. package/dist/src/init/settings-generator.js +76 -77
  160. package/dist/src/init/settings-generator.js.map +1 -1
  161. package/dist/src/init/statusline-generator.js +801 -3
  162. package/dist/src/init/statusline-generator.js.map +1 -1
  163. package/dist/src/init/types.d.ts +1 -1
  164. package/dist/src/init/types.d.ts.map +1 -1
  165. package/dist/src/init/types.js +76 -59
  166. package/dist/src/init/types.js.map +1 -1
  167. package/dist/src/mcp-client.d.ts +92 -0
  168. package/dist/src/mcp-client.d.ts.map +1 -0
  169. package/dist/src/mcp-client.js +81 -125
  170. package/dist/src/mcp-client.js.map +1 -1
  171. package/dist/src/mcp-server.d.ts +161 -0
  172. package/dist/src/mcp-server.d.ts.map +1 -0
  173. package/dist/src/mcp-server.js +470 -757
  174. package/dist/src/mcp-server.js.map +1 -1
  175. package/dist/src/mcp-tools/agent-tools.js +391 -492
  176. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  177. package/dist/src/mcp-tools/agentdb-tools.js +332 -533
  178. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  179. package/dist/src/mcp-tools/analyze-tools.js +172 -236
  180. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  181. package/dist/src/mcp-tools/auto-install.d.ts +83 -0
  182. package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
  183. package/dist/src/mcp-tools/auto-install.js +80 -142
  184. package/dist/src/mcp-tools/auto-install.js.map +1 -1
  185. package/dist/src/mcp-tools/browser-tools.js +252 -375
  186. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  187. package/dist/src/mcp-tools/claims-tools.js +473 -565
  188. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  189. package/dist/src/mcp-tools/config-tools.js +197 -272
  190. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  191. package/dist/src/mcp-tools/coordination-tools.js +500 -572
  192. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  193. package/dist/src/mcp-tools/daa-tools.js +286 -364
  194. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  195. package/dist/src/mcp-tools/embeddings-tools.js +582 -693
  196. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  197. package/dist/src/mcp-tools/github-tools.js +260 -311
  198. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  199. package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
  200. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  201. package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
  202. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  203. package/dist/src/mcp-tools/memory-tools.js +350 -505
  204. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  205. package/dist/src/mcp-tools/neural-tools.js +315 -412
  206. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  207. package/dist/src/mcp-tools/performance-tools.js +420 -480
  208. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  209. package/dist/src/mcp-tools/progress-tools.js +204 -278
  210. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  211. package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
  212. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  213. package/dist/src/mcp-tools/security-tools.js +297 -429
  214. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  215. package/dist/src/mcp-tools/session-tools.js +185 -234
  216. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  217. package/dist/src/mcp-tools/swarm-tools.js +207 -260
  218. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  219. package/dist/src/mcp-tools/system-tools.js +276 -325
  220. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  221. package/dist/src/mcp-tools/task-tools.js +270 -336
  222. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  223. package/dist/src/mcp-tools/terminal-tools.js +148 -196
  224. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  225. package/dist/src/mcp-tools/transfer-tools.js +186 -333
  226. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  227. package/dist/src/mcp-tools/types.d.ts +31 -0
  228. package/dist/src/mcp-tools/types.d.ts.map +1 -0
  229. package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
  230. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  231. package/dist/src/mcp-tools/workflow-tools.js +405 -450
  232. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  233. package/dist/src/memory/ewc-consolidation.d.ts +295 -0
  234. package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
  235. package/dist/src/memory/ewc-consolidation.js +190 -303
  236. package/dist/src/memory/ewc-consolidation.js.map +1 -1
  237. package/dist/src/memory/intelligence.d.ts +338 -0
  238. package/dist/src/memory/intelligence.d.ts.map +1 -0
  239. package/dist/src/memory/intelligence.js +569 -794
  240. package/dist/src/memory/intelligence.js.map +1 -1
  241. package/dist/src/memory/memory-bridge.d.ts +407 -0
  242. package/dist/src/memory/memory-bridge.d.ts.map +1 -0
  243. package/dist/src/memory/memory-bridge.js +1170 -1640
  244. package/dist/src/memory/memory-bridge.js.map +1 -1
  245. package/dist/src/memory/memory-initializer.d.ts +412 -0
  246. package/dist/src/memory/memory-initializer.d.ts.map +1 -0
  247. package/dist/src/memory/memory-initializer.js +1836 -1851
  248. package/dist/src/memory/memory-initializer.js.map +1 -1
  249. package/dist/src/memory/sona-optimizer.d.ts +227 -0
  250. package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
  251. package/dist/src/memory/sona-optimizer.js +199 -329
  252. package/dist/src/memory/sona-optimizer.js.map +1 -1
  253. package/dist/src/output.d.ts +2 -2
  254. package/dist/src/output.d.ts.map +1 -1
  255. package/dist/src/output.js +242 -272
  256. package/dist/src/output.js.map +1 -1
  257. package/dist/src/parser.d.ts +51 -0
  258. package/dist/src/parser.d.ts.map +1 -0
  259. package/dist/src/parser.js +140 -187
  260. package/dist/src/parser.js.map +1 -1
  261. package/dist/src/plugins/manager.d.ts +133 -0
  262. package/dist/src/plugins/manager.d.ts.map +1 -0
  263. package/dist/src/plugins/manager.js +285 -521
  264. package/dist/src/plugins/manager.js.map +1 -1
  265. package/dist/src/plugins/store/discovery.d.ts +88 -0
  266. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  267. package/dist/src/plugins/store/discovery.js +271 -358
  268. package/dist/src/plugins/store/discovery.js.map +1 -1
  269. package/dist/src/plugins/store/index.d.ts +76 -0
  270. package/dist/src/plugins/store/index.d.ts.map +1 -0
  271. package/dist/src/plugins/store/index.js +48 -105
  272. package/dist/src/plugins/store/index.js.map +1 -1
  273. package/dist/src/plugins/store/search.d.ts +46 -0
  274. package/dist/src/plugins/store/search.d.ts.map +1 -0
  275. package/dist/src/plugins/store/search.js +69 -107
  276. package/dist/src/plugins/store/search.js.map +1 -1
  277. package/dist/src/plugins/store/types.d.ts +274 -0
  278. package/dist/src/plugins/store/types.d.ts.map +1 -0
  279. package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
  280. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
  281. package/dist/src/plugins/tests/standalone-test.js +172 -223
  282. package/dist/src/plugins/tests/standalone-test.js.map +1 -1
  283. package/dist/src/plugins/tests/test-plugin-store.js +190 -228
  284. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
  285. package/dist/src/production/circuit-breaker.d.ts +101 -0
  286. package/dist/src/production/circuit-breaker.d.ts.map +1 -0
  287. package/dist/src/production/circuit-breaker.js +62 -126
  288. package/dist/src/production/circuit-breaker.js.map +1 -1
  289. package/dist/src/production/error-handler.d.ts +92 -0
  290. package/dist/src/production/error-handler.d.ts.map +1 -0
  291. package/dist/src/production/error-handler.js +86 -156
  292. package/dist/src/production/error-handler.js.map +1 -1
  293. package/dist/src/production/monitoring.d.ts +161 -0
  294. package/dist/src/production/monitoring.d.ts.map +1 -0
  295. package/dist/src/production/monitoring.js +139 -220
  296. package/dist/src/production/monitoring.js.map +1 -1
  297. package/dist/src/production/rate-limiter.d.ts +80 -0
  298. package/dist/src/production/rate-limiter.d.ts.map +1 -0
  299. package/dist/src/production/rate-limiter.js +74 -93
  300. package/dist/src/production/rate-limiter.js.map +1 -1
  301. package/dist/src/production/retry.d.ts +48 -0
  302. package/dist/src/production/retry.d.ts.map +1 -0
  303. package/dist/src/production/retry.js +75 -167
  304. package/dist/src/production/retry.js.map +1 -1
  305. package/dist/src/prompt.d.ts +44 -0
  306. package/dist/src/prompt.d.ts.map +1 -0
  307. package/dist/src/prompt.js +436 -560
  308. package/dist/src/prompt.js.map +1 -1
  309. package/dist/src/runtime/headless.d.ts +60 -0
  310. package/dist/src/runtime/headless.d.ts.map +1 -0
  311. package/dist/src/runtime/headless.js +197 -286
  312. package/dist/src/runtime/headless.js.map +1 -1
  313. package/dist/src/ruvector/agent-wasm.d.ts +182 -0
  314. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
  315. package/dist/src/ruvector/agent-wasm.js +156 -351
  316. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  317. package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
  318. package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
  319. package/dist/src/ruvector/ast-analyzer.js +145 -232
  320. package/dist/src/ruvector/ast-analyzer.js.map +1 -1
  321. package/dist/src/ruvector/coverage-router.d.ts +160 -0
  322. package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
  323. package/dist/src/ruvector/coverage-router.js +287 -419
  324. package/dist/src/ruvector/coverage-router.js.map +1 -1
  325. package/dist/src/ruvector/coverage-tools.js +56 -101
  326. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  327. package/dist/src/ruvector/diff-classifier.d.ts +175 -0
  328. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
  329. package/dist/src/ruvector/diff-classifier.js +324 -451
  330. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  331. package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
  332. package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
  333. package/dist/src/ruvector/enhanced-model-router.js +260 -336
  334. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  335. package/dist/src/ruvector/flash-attention.d.ts +195 -0
  336. package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
  337. package/dist/src/ruvector/flash-attention.js +223 -254
  338. package/dist/src/ruvector/flash-attention.js.map +1 -1
  339. package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
  340. package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
  341. package/dist/src/ruvector/graph-analyzer.js +486 -680
  342. package/dist/src/ruvector/graph-analyzer.js.map +1 -1
  343. package/dist/src/ruvector/index.d.ts +40 -0
  344. package/dist/src/ruvector/index.d.ts.map +1 -0
  345. package/dist/src/ruvector/index.js +36 -106
  346. package/dist/src/ruvector/index.js.map +1 -1
  347. package/dist/src/ruvector/lora-adapter.d.ts +218 -0
  348. package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
  349. package/dist/src/ruvector/lora-adapter.js +155 -248
  350. package/dist/src/ruvector/lora-adapter.js.map +1 -1
  351. package/dist/src/ruvector/model-router.d.ts +220 -0
  352. package/dist/src/ruvector/model-router.d.ts.map +1 -0
  353. package/dist/src/ruvector/model-router.js +175 -248
  354. package/dist/src/ruvector/model-router.js.map +1 -1
  355. package/dist/src/ruvector/moe-router.d.ts +206 -0
  356. package/dist/src/ruvector/moe-router.d.ts.map +1 -0
  357. package/dist/src/ruvector/moe-router.js +228 -286
  358. package/dist/src/ruvector/moe-router.js.map +1 -1
  359. package/dist/src/ruvector/q-learning-router.d.ts +211 -0
  360. package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
  361. package/dist/src/ruvector/q-learning-router.js +257 -338
  362. package/dist/src/ruvector/q-learning-router.js.map +1 -1
  363. package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
  364. package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
  365. package/dist/src/ruvector/ruvllm-wasm.js +270 -434
  366. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
  367. package/dist/src/ruvector/semantic-router.d.ts +77 -0
  368. package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
  369. package/dist/src/ruvector/semantic-router.js +60 -67
  370. package/dist/src/ruvector/semantic-router.js.map +1 -1
  371. package/dist/src/ruvector/vector-db.d.ts +69 -0
  372. package/dist/src/ruvector/vector-db.d.ts.map +1 -0
  373. package/dist/src/ruvector/vector-db.js +119 -205
  374. package/dist/src/ruvector/vector-db.js.map +1 -1
  375. package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  376. package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
  377. package/dist/src/services/agentic-flow-bridge.js +32 -105
  378. package/dist/src/services/agentic-flow-bridge.js.map +1 -1
  379. package/dist/src/services/claim-service.d.ts +204 -0
  380. package/dist/src/services/claim-service.d.ts.map +1 -0
  381. package/dist/src/services/claim-service.js +615 -940
  382. package/dist/src/services/claim-service.js.map +1 -1
  383. package/dist/src/services/container-worker-pool.d.ts +197 -0
  384. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  385. package/dist/src/services/container-worker-pool.js +398 -666
  386. package/dist/src/services/container-worker-pool.js.map +1 -1
  387. package/dist/src/services/headless-worker-executor.d.ts +304 -0
  388. package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
  389. package/dist/src/services/headless-worker-executor.js +441 -467
  390. package/dist/src/services/headless-worker-executor.js.map +1 -1
  391. package/dist/src/services/index.d.ts +4 -4
  392. package/dist/src/services/index.d.ts.map +1 -1
  393. package/dist/src/services/index.js +4 -4
  394. package/dist/src/services/index.js.map +1 -1
  395. package/dist/src/services/registry-api.d.ts +58 -0
  396. package/dist/src/services/registry-api.d.ts.map +1 -0
  397. package/dist/src/services/registry-api.js +92 -200
  398. package/dist/src/services/registry-api.js.map +1 -1
  399. package/dist/src/services/ruvector-training.d.ts +222 -0
  400. package/dist/src/services/ruvector-training.d.ts.map +1 -0
  401. package/dist/src/services/ruvector-training.js +257 -337
  402. package/dist/src/services/ruvector-training.js.map +1 -1
  403. package/dist/src/services/worker-daemon.d.ts +228 -0
  404. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  405. package/dist/src/services/worker-daemon.js +591 -849
  406. package/dist/src/services/worker-daemon.js.map +1 -1
  407. package/dist/src/services/worker-queue.d.ts +194 -0
  408. package/dist/src/services/worker-queue.d.ts.map +1 -0
  409. package/dist/src/services/worker-queue.js +331 -548
  410. package/dist/src/services/worker-queue.js.map +1 -1
  411. package/dist/src/suggest.d.ts +53 -0
  412. package/dist/src/suggest.d.ts.map +1 -0
  413. package/dist/src/suggest.js +45 -55
  414. package/dist/src/suggest.js.map +1 -1
  415. package/dist/src/transfer/anonymization/index.js +29 -37
  416. package/dist/src/transfer/anonymization/index.js.map +1 -1
  417. package/dist/src/transfer/deploy-seraphine.js +128 -155
  418. package/dist/src/transfer/deploy-seraphine.js.map +1 -1
  419. package/dist/src/transfer/export.d.ts +25 -0
  420. package/dist/src/transfer/export.d.ts.map +1 -0
  421. package/dist/src/transfer/export.js +84 -142
  422. package/dist/src/transfer/export.js.map +1 -1
  423. package/dist/src/transfer/index.d.ts +1 -1
  424. package/dist/src/transfer/index.d.ts.map +1 -1
  425. package/dist/src/transfer/index.js +0 -2
  426. package/dist/src/transfer/index.js.map +1 -1
  427. package/dist/src/transfer/ipfs/client.d.ts +109 -0
  428. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  429. package/dist/src/transfer/ipfs/client.js +187 -337
  430. package/dist/src/transfer/ipfs/client.js.map +1 -1
  431. package/dist/src/transfer/ipfs/upload.d.ts +95 -0
  432. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  433. package/dist/src/transfer/ipfs/upload.js +288 -434
  434. package/dist/src/transfer/ipfs/upload.js.map +1 -1
  435. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  436. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  437. package/dist/src/transfer/models/seraphine.js +55 -55
  438. package/dist/src/transfer/models/seraphine.js.map +1 -1
  439. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  440. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  441. package/dist/src/transfer/serialization/cfp.js +30 -31
  442. package/dist/src/transfer/serialization/cfp.js.map +1 -1
  443. package/dist/src/transfer/storage/gcs.d.ts +82 -0
  444. package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
  445. package/dist/src/transfer/storage/gcs.js +165 -232
  446. package/dist/src/transfer/storage/gcs.js.map +1 -1
  447. package/dist/src/transfer/store/discovery.d.ts +84 -0
  448. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  449. package/dist/src/transfer/store/discovery.js +239 -349
  450. package/dist/src/transfer/store/discovery.js.map +1 -1
  451. package/dist/src/transfer/store/download.d.ts +70 -0
  452. package/dist/src/transfer/store/download.d.ts.map +1 -0
  453. package/dist/src/transfer/store/download.js +243 -365
  454. package/dist/src/transfer/store/download.js.map +1 -1
  455. package/dist/src/transfer/store/index.d.ts +84 -0
  456. package/dist/src/transfer/store/index.d.ts.map +1 -0
  457. package/dist/src/transfer/store/index.js +63 -130
  458. package/dist/src/transfer/store/index.js.map +1 -1
  459. package/dist/src/transfer/store/publish.d.ts +76 -0
  460. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  461. package/dist/src/transfer/store/publish.js +184 -258
  462. package/dist/src/transfer/store/publish.js.map +1 -1
  463. package/dist/src/transfer/store/registry.js +50 -72
  464. package/dist/src/transfer/store/registry.js.map +1 -1
  465. package/dist/src/transfer/store/search.d.ts +54 -0
  466. package/dist/src/transfer/store/search.d.ts.map +1 -0
  467. package/dist/src/transfer/store/search.js +64 -96
  468. package/dist/src/transfer/store/search.js.map +1 -1
  469. package/dist/src/transfer/store/tests/standalone-test.js +174 -231
  470. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
  471. package/dist/src/transfer/test-seraphine.js +95 -130
  472. package/dist/src/transfer/test-seraphine.js.map +1 -1
  473. package/dist/src/transfer/tests/test-store.js +194 -239
  474. package/dist/src/transfer/tests/test-store.js.map +1 -1
  475. package/dist/src/transfer/types.d.ts +245 -0
  476. package/dist/src/transfer/types.d.ts.map +1 -0
  477. package/dist/src/types.d.ts +198 -0
  478. package/dist/src/types.d.ts.map +1 -0
  479. package/dist/src/types.js +26 -55
  480. package/dist/src/types.js.map +1 -1
  481. package/dist/src/update/checker.d.ts +34 -0
  482. package/dist/src/update/checker.d.ts.map +1 -0
  483. package/dist/src/update/checker.js +106 -183
  484. package/dist/src/update/checker.js.map +1 -1
  485. package/dist/src/update/executor.d.ts +32 -0
  486. package/dist/src/update/executor.d.ts.map +1 -0
  487. package/dist/src/update/executor.js +135 -198
  488. package/dist/src/update/executor.js.map +1 -1
  489. package/dist/src/update/index.d.ts +33 -0
  490. package/dist/src/update/index.d.ts.map +1 -0
  491. package/dist/src/update/index.js +38 -85
  492. package/dist/src/update/index.js.map +1 -1
  493. package/dist/src/update/rate-limiter.d.ts +20 -0
  494. package/dist/src/update/rate-limiter.d.ts.map +1 -0
  495. package/dist/src/update/rate-limiter.js +19 -31
  496. package/dist/src/update/rate-limiter.js.map +1 -1
  497. package/dist/src/update/validator.d.ts +17 -0
  498. package/dist/src/update/validator.d.ts.map +1 -0
  499. package/dist/src/update/validator.js +38 -64
  500. package/dist/src/update/validator.js.map +1 -1
  501. package/dist/tsconfig.tsbuildinfo +1 -1
  502. package/package.json +1 -1
@@ -2,70 +2,14 @@
2
2
  * Init Executor
3
3
  * Main execution logic for V3 initialization
4
4
  */
5
- var __assign = (this && this.__assign) || function () {
6
- __assign = Object.assign || function(t) {
7
- for (var s, i = 1, n = arguments.length; i < n; i++) {
8
- s = arguments[i];
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
- t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (_) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
53
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
54
- if (ar || !(i in from)) {
55
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
56
- ar[i] = from[i];
57
- }
58
- }
59
- return to.concat(ar || Array.prototype.slice.call(from));
60
- };
61
5
  import * as fs from 'fs';
62
6
  import * as path from 'path';
63
7
  import { fileURLToPath } from 'url';
64
8
  import { createRequire } from 'module';
65
9
  import { dirname } from 'path';
66
10
  // ESM-compatible __dirname
67
- var __filename = fileURLToPath(import.meta.url);
68
- var __dirname = dirname(__filename);
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
69
13
  import { detectPlatform, DEFAULT_INIT_OPTIONS } from './types.js';
70
14
  import { generateSettingsJson, generateSettings } from './settings-generator.js';
71
15
  import { generateMCPJson } from './mcp-generator.js';
@@ -75,7 +19,7 @@ import { generateClaudeMd } from './claudemd-generator.js';
75
19
  /**
76
20
  * Skills to copy based on configuration
77
21
  */
78
- var SKILLS_MAP = {
22
+ const SKILLS_MAP = {
79
23
  core: [
80
24
  'swarm-orchestration',
81
25
  'swarm-advanced',
@@ -86,8 +30,8 @@ var SKILLS_MAP = {
86
30
  'stream-chain',
87
31
  'skill-builder',
88
32
  ],
89
- browser: ['browser'],
90
- dualMode: ['dual-mode'],
33
+ browser: ['browser'], // agent-browser integration
34
+ dualMode: ['dual-mode'], // Claude Code + Codex hybrid execution
91
35
  agentdb: [
92
36
  'agentdb-advanced',
93
37
  'agentdb-learning',
@@ -120,12 +64,12 @@ var SKILLS_MAP = {
120
64
  'v3-performance-optimization',
121
65
  'v3-security-overhaul',
122
66
  'v3-swarm-coordination',
123
- ]
67
+ ],
124
68
  };
125
69
  /**
126
70
  * Commands to copy based on configuration
127
71
  */
128
- var COMMANDS_MAP = {
72
+ const COMMANDS_MAP = {
129
73
  core: ['claude-flow-help.md', 'claude-flow-swarm.md', 'claude-flow-memory.md'],
130
74
  analysis: ['analysis'],
131
75
  automation: ['automation'],
@@ -133,20 +77,20 @@ var COMMANDS_MAP = {
133
77
  hooks: ['hooks'],
134
78
  monitoring: ['monitoring'],
135
79
  optimization: ['optimization'],
136
- sparc: ['sparc']
80
+ sparc: ['sparc'],
137
81
  };
138
82
  /**
139
83
  * Agents to copy based on configuration
140
84
  */
141
- var AGENTS_MAP = {
85
+ const AGENTS_MAP = {
142
86
  core: ['core'],
143
87
  consensus: ['consensus'],
144
88
  github: ['github'],
145
89
  hiveMind: ['hive-mind'],
146
90
  sparc: ['sparc'],
147
91
  swarm: ['swarm'],
148
- browser: ['browser'],
149
- dualMode: ['dual-mode'],
92
+ browser: ['browser'], // agent-browser integration
93
+ dualMode: ['dual-mode'], // Claude Code + Codex hybrid execution
150
94
  // V3-specific agents
151
95
  v3: ['v3'],
152
96
  optimization: ['optimization'],
@@ -165,12 +109,12 @@ var AGENTS_MAP = {
165
109
  payments: ['payments'],
166
110
  data: ['data'],
167
111
  design: ['design'],
168
- custom: ['custom']
112
+ custom: ['custom'],
169
113
  };
170
114
  /**
171
115
  * Directory structure to create
172
116
  */
173
- var DIRECTORIES = {
117
+ const DIRECTORIES = {
174
118
  claude: [
175
119
  '.claude',
176
120
  '.claude/skills',
@@ -186,115 +130,82 @@ var DIRECTORIES = {
186
130
  '.claude-flow/hooks',
187
131
  '.claude-flow/agents',
188
132
  '.claude-flow/workflows',
189
- ]
133
+ ],
190
134
  };
191
135
  /**
192
136
  * Execute initialization
193
137
  */
194
- export function executeInit(options) {
195
- return __awaiter(this, void 0, Promise, function () {
196
- var platform, result, targetDir, error_1;
197
- return __generator(this, function (_a) {
198
- switch (_a.label) {
199
- case 0:
200
- platform = detectPlatform();
201
- result = {
202
- success: true,
203
- platform: platform,
204
- created: {
205
- directories: [],
206
- files: []
207
- },
208
- skipped: [],
209
- errors: [],
210
- summary: {
211
- skillsCount: 0,
212
- commandsCount: 0,
213
- agentsCount: 0,
214
- hooksEnabled: 0
215
- }
216
- };
217
- targetDir = options.targetDir;
218
- _a.label = 1;
219
- case 1:
220
- _a.trys.push([1, 23, , 24]);
221
- // Create directory structure
222
- return [4 /*yield*/, createDirectories(targetDir, options, result)];
223
- case 2:
224
- // Create directory structure
225
- _a.sent();
226
- if (!options.components.settings) return [3 /*break*/, 4];
227
- return [4 /*yield*/, writeSettings(targetDir, options, result)];
228
- case 3:
229
- _a.sent();
230
- _a.label = 4;
231
- case 4:
232
- if (!options.components.mcp) return [3 /*break*/, 6];
233
- return [4 /*yield*/, writeMCPConfig(targetDir, options, result)];
234
- case 5:
235
- _a.sent();
236
- _a.label = 6;
237
- case 6:
238
- if (!options.components.skills) return [3 /*break*/, 8];
239
- return [4 /*yield*/, copySkills(targetDir, options, result)];
240
- case 7:
241
- _a.sent();
242
- _a.label = 8;
243
- case 8:
244
- if (!options.components.commands) return [3 /*break*/, 10];
245
- return [4 /*yield*/, copyCommands(targetDir, options, result)];
246
- case 9:
247
- _a.sent();
248
- _a.label = 10;
249
- case 10:
250
- if (!options.components.agents) return [3 /*break*/, 12];
251
- return [4 /*yield*/, copyAgents(targetDir, options, result)];
252
- case 11:
253
- _a.sent();
254
- _a.label = 12;
255
- case 12:
256
- if (!options.components.helpers) return [3 /*break*/, 14];
257
- return [4 /*yield*/, writeHelpers(targetDir, options, result)];
258
- case 13:
259
- _a.sent();
260
- _a.label = 14;
261
- case 14:
262
- if (!options.components.statusline) return [3 /*break*/, 16];
263
- return [4 /*yield*/, writeStatusline(targetDir, options, result)];
264
- case 15:
265
- _a.sent();
266
- _a.label = 16;
267
- case 16:
268
- if (!options.components.runtime) return [3 /*break*/, 18];
269
- return [4 /*yield*/, writeRuntimeConfig(targetDir, options, result)];
270
- case 17:
271
- _a.sent();
272
- _a.label = 18;
273
- case 18:
274
- if (!options.components.statusline) return [3 /*break*/, 20];
275
- return [4 /*yield*/, writeInitialMetrics(targetDir, options, result)];
276
- case 19:
277
- _a.sent();
278
- _a.label = 20;
279
- case 20:
280
- if (!options.components.claudeMd) return [3 /*break*/, 22];
281
- return [4 /*yield*/, writeClaudeMd(targetDir, options, result)];
282
- case 21:
283
- _a.sent();
284
- _a.label = 22;
285
- case 22:
286
- // Count enabled hooks
287
- result.summary.hooksEnabled = countEnabledHooks(options);
288
- return [3 /*break*/, 24];
289
- case 23:
290
- error_1 = _a.sent();
291
- result.success = false;
292
- result.errors.push(error_1 instanceof Error ? error_1.message : String(error_1));
293
- return [3 /*break*/, 24];
294
- case 24: return [2 /*return*/, result];
295
- }
296
- });
297
- });
138
+ export async function executeInit(options) {
139
+ // Detect platform
140
+ const platform = detectPlatform();
141
+ const result = {
142
+ success: true,
143
+ platform,
144
+ created: {
145
+ directories: [],
146
+ files: [],
147
+ },
148
+ skipped: [],
149
+ errors: [],
150
+ summary: {
151
+ skillsCount: 0,
152
+ commandsCount: 0,
153
+ agentsCount: 0,
154
+ hooksEnabled: 0,
155
+ },
156
+ };
157
+ const targetDir = options.targetDir;
158
+ try {
159
+ // Create directory structure
160
+ await createDirectories(targetDir, options, result);
161
+ // Generate and write settings.json
162
+ if (options.components.settings) {
163
+ await writeSettings(targetDir, options, result);
164
+ }
165
+ // Generate and write .mcp.json
166
+ if (options.components.mcp) {
167
+ await writeMCPConfig(targetDir, options, result);
168
+ }
169
+ // Copy skills
170
+ if (options.components.skills) {
171
+ await copySkills(targetDir, options, result);
172
+ }
173
+ // Copy commands
174
+ if (options.components.commands) {
175
+ await copyCommands(targetDir, options, result);
176
+ }
177
+ // Copy agents
178
+ if (options.components.agents) {
179
+ await copyAgents(targetDir, options, result);
180
+ }
181
+ // Generate helpers
182
+ if (options.components.helpers) {
183
+ await writeHelpers(targetDir, options, result);
184
+ }
185
+ // Generate statusline
186
+ if (options.components.statusline) {
187
+ await writeStatusline(targetDir, options, result);
188
+ }
189
+ // Generate runtime config
190
+ if (options.components.runtime) {
191
+ await writeRuntimeConfig(targetDir, options, result);
192
+ }
193
+ // Create initial metrics for statusline (prevents "all zeros" display)
194
+ if (options.components.statusline) {
195
+ await writeInitialMetrics(targetDir, options, result);
196
+ }
197
+ // Generate CLAUDE.md
198
+ if (options.components.claudeMd) {
199
+ await writeClaudeMd(targetDir, options, result);
200
+ }
201
+ // Count enabled hooks
202
+ result.summary.hooksEnabled = countEnabledHooks(options);
203
+ }
204
+ catch (error) {
205
+ result.success = false;
206
+ result.errors.push(error instanceof Error ? error.message : String(error));
207
+ }
208
+ return result;
298
209
  }
299
210
  /**
300
211
  * Merge new settings into existing settings.json
@@ -302,10 +213,9 @@ export function executeInit(options) {
302
213
  * Uses platform-specific commands for Mac, Linux, and Windows
303
214
  */
304
215
  function mergeSettingsForUpgrade(existing) {
305
- var _a, _b, _c;
306
- var merged = __assign({}, existing);
307
- var platform = detectPlatform();
308
- var isWindows = platform.os === 'windows';
216
+ const merged = { ...existing };
217
+ const platform = detectPlatform();
218
+ const isWindows = platform.os === 'windows';
309
219
  // Platform-specific command wrappers
310
220
  // Windows: Use PowerShell-compatible commands
311
221
  // Mac/Linux: Use bash-compatible commands with 2>/dev/null
@@ -313,46 +223,51 @@ function mergeSettingsForUpgrade(existing) {
313
223
  // TeammateIdle/TaskCompleted are not valid Claude Code hook events and caused warnings.
314
224
  // Agent Teams hook config lives in claudeFlow.agentTeams.hooks instead.
315
225
  // 1. Merge env vars (preserve existing, add new)
316
- var existingEnv = existing.env || {};
317
- merged.env = __assign(__assign({}, existingEnv), { CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1', CLAUDE_FLOW_V3_ENABLED: existingEnv.CLAUDE_FLOW_V3_ENABLED || 'true', CLAUDE_FLOW_HOOKS_ENABLED: existingEnv.CLAUDE_FLOW_HOOKS_ENABLED || 'true' });
226
+ const existingEnv = existing.env || {};
227
+ merged.env = {
228
+ ...existingEnv,
229
+ CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1',
230
+ CLAUDE_FLOW_V3_ENABLED: existingEnv.CLAUDE_FLOW_V3_ENABLED || 'true',
231
+ CLAUDE_FLOW_HOOKS_ENABLED: existingEnv.CLAUDE_FLOW_HOOKS_ENABLED || 'true',
232
+ };
318
233
  // 2. Merge hooks (preserve existing, add new Agent Teams + auto-memory hooks)
319
- var existingHooks = existing.hooks || {};
320
- merged.hooks = __assign({}, existingHooks);
234
+ const existingHooks = existing.hooks || {};
235
+ merged.hooks = { ...existingHooks };
321
236
  // Cross-platform auto-memory hook commands that resolve paths via git root.
322
237
  // Uses node -e with git rev-parse so hooks work regardless of CWD (#1259, #1284).
323
- var gitRootResolver = "var c=require('child_process'),p=require('path'),u=require('url'),r;"
238
+ const gitRootResolver = "var c=require('child_process'),p=require('path'),u=require('url'),r;"
324
239
  + "try{r=c.execSync('git rev-parse --show-toplevel',{encoding:'utf8'}).trim()}"
325
240
  + 'catch(e){r=process.cwd()}';
326
- var autoMemoryScript = '.claude/helpers/auto-memory-hook.mjs';
327
- var autoMemoryImportCmd = "node -e \"" + gitRootResolver + "var f=p.join(r,'" + autoMemoryScript + "');import(u.pathToFileURL(f).href)\" import";
328
- var autoMemorySyncCmd = "node -e \"" + gitRootResolver + "var f=p.join(r,'" + autoMemoryScript + "');import(u.pathToFileURL(f).href)\" sync";
241
+ const autoMemoryScript = '.claude/helpers/auto-memory-hook.mjs';
242
+ const autoMemoryImportCmd = `node -e "${gitRootResolver}var f=p.join(r,'${autoMemoryScript}');import(u.pathToFileURL(f).href)" import`;
243
+ const autoMemorySyncCmd = `node -e "${gitRootResolver}var f=p.join(r,'${autoMemoryScript}');import(u.pathToFileURL(f).href)" sync`;
329
244
  // Add auto-memory import to SessionStart (if not already present)
330
- var sessionStartHooks = existingHooks.SessionStart;
331
- var hasAutoMemoryImport = sessionStartHooks === null || sessionStartHooks === void 0 ? void 0 : sessionStartHooks.some(function (group) { var _a; return (_a = group.hooks) === null || _a === void 0 ? void 0 : _a.some(function (h) { var _a; return (_a = h.command) === null || _a === void 0 ? void 0 : _a.includes('auto-memory-hook'); }); });
245
+ const sessionStartHooks = existingHooks.SessionStart;
246
+ const hasAutoMemoryImport = sessionStartHooks?.some(group => group.hooks?.some(h => h.command?.includes('auto-memory-hook')));
332
247
  if (!hasAutoMemoryImport) {
333
- var startHooks = merged.hooks;
248
+ const startHooks = merged.hooks;
334
249
  if (!startHooks.SessionStart) {
335
250
  startHooks.SessionStart = [{ hooks: [] }];
336
251
  }
337
- var startGroup = startHooks.SessionStart[0];
252
+ const startGroup = startHooks.SessionStart[0];
338
253
  if (!startGroup.hooks)
339
254
  startGroup.hooks = [];
340
255
  startGroup.hooks.push({
341
256
  type: 'command',
342
257
  command: autoMemoryImportCmd,
343
258
  timeout: 6000,
344
- continueOnError: true
259
+ continueOnError: true,
345
260
  });
346
261
  }
347
262
  // Add auto-memory sync to SessionEnd (if not already present)
348
- var sessionEndHooks = existingHooks.SessionEnd;
349
- var hasAutoMemorySync = sessionEndHooks === null || sessionEndHooks === void 0 ? void 0 : sessionEndHooks.some(function (group) { var _a; return (_a = group.hooks) === null || _a === void 0 ? void 0 : _a.some(function (h) { var _a; return (_a = h.command) === null || _a === void 0 ? void 0 : _a.includes('auto-memory-hook'); }); });
263
+ const sessionEndHooks = existingHooks.SessionEnd;
264
+ const hasAutoMemorySync = sessionEndHooks?.some(group => group.hooks?.some(h => h.command?.includes('auto-memory-hook')));
350
265
  if (!hasAutoMemorySync) {
351
- var endHooks = merged.hooks;
266
+ const endHooks = merged.hooks;
352
267
  if (!endHooks.SessionEnd) {
353
268
  endHooks.SessionEnd = [{ hooks: [] }];
354
269
  }
355
- var endGroup = endHooks.SessionEnd[0];
270
+ const endGroup = endHooks.SessionEnd[0];
356
271
  if (!endGroup.hooks)
357
272
  endGroup.hooks = [];
358
273
  // Insert at beginning so sync runs before other cleanup
@@ -360,7 +275,7 @@ function mergeSettingsForUpgrade(existing) {
360
275
  type: 'command',
361
276
  command: autoMemorySyncCmd,
362
277
  timeout: 8000,
363
- continueOnError: true
278
+ continueOnError: true,
364
279
  });
365
280
  }
366
281
  // NOTE: TeammateIdle and TaskCompleted are NOT valid Claude Code hook events.
@@ -371,17 +286,22 @@ function mergeSettingsForUpgrade(existing) {
371
286
  // Their configuration lives in claudeFlow.agentTeams.hooks instead.
372
287
  // 3. Fix statusLine config (remove invalid fields, ensure correct format)
373
288
  // Claude Code only supports: type, command, padding
374
- var existingStatusLine = existing.statusLine;
289
+ const existingStatusLine = existing.statusLine;
375
290
  if (existingStatusLine) {
376
291
  merged.statusLine = {
377
292
  type: 'command',
378
- command: existingStatusLine.command || "node -e \"var c=require('child_process'),p=require('path'),r;try{r=c.execSync('git rev-parse --show-toplevel',{encoding:'utf8'}).trim()}catch(e){r=process.cwd()}var s=p.join(r,'.claude/helpers/statusline.cjs');process.argv.splice(1,0,s);require(s)\""
293
+ command: existingStatusLine.command || `node -e "var c=require('child_process'),p=require('path'),r;try{r=c.execSync('git rev-parse --show-toplevel',{encoding:'utf8'}).trim()}catch(e){r=process.cwd()}var s=p.join(r,'.claude/helpers/statusline.cjs');process.argv.splice(1,0,s);require(s)"`,
294
+ // Remove invalid fields: refreshMs, enabled (not supported by Claude Code)
379
295
  };
380
296
  }
381
297
  // 4. Merge claudeFlow settings (preserve existing, add agentTeams + memory)
382
- var existingClaudeFlow = existing.claudeFlow || {};
383
- var existingMemory = existingClaudeFlow.memory || {};
384
- merged.claudeFlow = __assign(__assign({}, existingClaudeFlow), { version: existingClaudeFlow.version || '3.0.0', enabled: existingClaudeFlow.enabled !== false, agentTeams: {
298
+ const existingClaudeFlow = existing.claudeFlow || {};
299
+ const existingMemory = existingClaudeFlow.memory || {};
300
+ merged.claudeFlow = {
301
+ ...existingClaudeFlow,
302
+ version: existingClaudeFlow.version || '3.0.0',
303
+ enabled: existingClaudeFlow.enabled !== false,
304
+ agentTeams: {
385
305
  enabled: true,
386
306
  teammateMode: 'auto',
387
307
  taskListEnabled: true,
@@ -390,13 +310,20 @@ function mergeSettingsForUpgrade(existing) {
390
310
  autoAssignOnIdle: true,
391
311
  trainPatternsOnComplete: true,
392
312
  notifyLeadOnComplete: true,
393
- sharedMemoryNamespace: 'agent-teams'
313
+ sharedMemoryNamespace: 'agent-teams',
394
314
  },
395
315
  hooks: {
396
316
  teammateIdle: { enabled: true, autoAssign: true, checkTaskList: true },
397
- taskCompleted: { enabled: true, trainPatterns: true, notifyLead: true }
398
- }
399
- }, memory: __assign(__assign({}, existingMemory), { learningBridge: (_a = existingMemory.learningBridge) !== null && _a !== void 0 ? _a : { enabled: true }, memoryGraph: (_b = existingMemory.memoryGraph) !== null && _b !== void 0 ? _b : { enabled: true }, agentScopes: (_c = existingMemory.agentScopes) !== null && _c !== void 0 ? _c : { enabled: true } }) });
317
+ taskCompleted: { enabled: true, trainPatterns: true, notifyLead: true },
318
+ },
319
+ },
320
+ memory: {
321
+ ...existingMemory,
322
+ learningBridge: existingMemory.learningBridge ?? { enabled: true },
323
+ memoryGraph: existingMemory.memoryGraph ?? { enabled: true },
324
+ agentScopes: existingMemory.agentScopes ?? { enabled: true },
325
+ },
326
+ };
400
327
  return merged;
401
328
  }
402
329
  /**
@@ -405,190 +332,200 @@ function mergeSettingsForUpgrade(existing) {
405
332
  * @param targetDir - Target directory
406
333
  * @param upgradeSettings - If true, merge new settings into existing settings.json
407
334
  */
408
- export function executeUpgrade(targetDir, upgradeSettings) {
409
- if (upgradeSettings === void 0) { upgradeSettings = false; }
410
- return __awaiter(this, void 0, Promise, function () {
411
- var result, dirs, _i, dirs_1, dir, fullPath, sourceHelpersForUpgrade, criticalHelpers, _a, criticalHelpers_1, helperName, targetPath, sourcePath, generatedCritical, _b, _c, _d, helperName, content, targetPath, statuslinePath, upgradeOptions, statuslineContent, metricsDir, securityDir, progressPath, progress, activityPath, activity, learningPath, learning, auditPath, audit, settingsPath, existingSettings, mergedSettings, defaultSettings;
412
- return __generator(this, function (_e) {
413
- result = {
414
- success: true,
415
- updated: [],
416
- created: [],
417
- preserved: [],
418
- errors: [],
419
- settingsUpdated: []
420
- };
421
- try {
422
- dirs = [
423
- '.claude/helpers',
424
- '.claude-flow/metrics',
425
- '.claude-flow/security',
426
- '.claude-flow/learning',
427
- ];
428
- for (_i = 0, dirs_1 = dirs; _i < dirs_1.length; _i++) {
429
- dir = dirs_1[_i];
430
- fullPath = path.join(targetDir, dir);
431
- if (!fs.existsSync(fullPath)) {
432
- fs.mkdirSync(fullPath, { recursive: true });
335
+ export async function executeUpgrade(targetDir, upgradeSettings = false) {
336
+ const result = {
337
+ success: true,
338
+ updated: [],
339
+ created: [],
340
+ preserved: [],
341
+ errors: [],
342
+ settingsUpdated: [],
343
+ };
344
+ try {
345
+ // Ensure required directories exist
346
+ const dirs = [
347
+ '.claude/helpers',
348
+ '.claude-flow/metrics',
349
+ '.claude-flow/security',
350
+ '.claude-flow/learning',
351
+ ];
352
+ for (const dir of dirs) {
353
+ const fullPath = path.join(targetDir, dir);
354
+ if (!fs.existsSync(fullPath)) {
355
+ fs.mkdirSync(fullPath, { recursive: true });
356
+ }
357
+ }
358
+ // 0. ALWAYS update critical helpers (force overwrite)
359
+ const sourceHelpersForUpgrade = findSourceHelpersDir();
360
+ if (sourceHelpersForUpgrade) {
361
+ const criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
362
+ for (const helperName of criticalHelpers) {
363
+ const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
364
+ const sourcePath = path.join(sourceHelpersForUpgrade, helperName);
365
+ if (fs.existsSync(sourcePath)) {
366
+ if (fs.existsSync(targetPath)) {
367
+ result.updated.push(`.claude/helpers/${helperName}`);
433
368
  }
434
- }
435
- sourceHelpersForUpgrade = findSourceHelpersDir();
436
- if (sourceHelpersForUpgrade) {
437
- criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
438
- for (_a = 0, criticalHelpers_1 = criticalHelpers; _a < criticalHelpers_1.length; _a++) {
439
- helperName = criticalHelpers_1[_a];
440
- targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
441
- sourcePath = path.join(sourceHelpersForUpgrade, helperName);
442
- if (fs.existsSync(sourcePath)) {
443
- if (fs.existsSync(targetPath)) {
444
- result.updated.push(".claude/helpers/" + helperName);
445
- }
446
- else {
447
- result.created.push(".claude/helpers/" + helperName);
448
- }
449
- fs.copyFileSync(sourcePath, targetPath);
450
- try {
451
- fs.chmodSync(targetPath, '755');
452
- }
453
- catch (_f) { }
454
- }
369
+ else {
370
+ result.created.push(`.claude/helpers/${helperName}`);
455
371
  }
456
- }
457
- else {
458
- generatedCritical = {
459
- 'hook-handler.cjs': generateHookHandler(),
460
- 'intelligence.cjs': generateIntelligenceStub(),
461
- 'auto-memory-hook.mjs': generateAutoMemoryHook()
462
- };
463
- for (_b = 0, _c = Object.entries(generatedCritical); _b < _c.length; _b++) {
464
- _d = _c[_b], helperName = _d[0], content = _d[1];
465
- targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
466
- if (fs.existsSync(targetPath)) {
467
- result.updated.push(".claude/helpers/" + helperName);
468
- }
469
- else {
470
- result.created.push(".claude/helpers/" + helperName);
471
- }
472
- fs.writeFileSync(targetPath, content, 'utf-8');
473
- try {
474
- fs.chmodSync(targetPath, '755');
475
- }
476
- catch (_g) { }
372
+ fs.copyFileSync(sourcePath, targetPath);
373
+ try {
374
+ fs.chmodSync(targetPath, '755');
477
375
  }
376
+ catch { }
478
377
  }
479
- statuslinePath = path.join(targetDir, '.claude', 'helpers', 'statusline.cjs');
480
- upgradeOptions = __assign(__assign({}, DEFAULT_INIT_OPTIONS), { targetDir: targetDir, force: true, statusline: __assign(__assign({}, DEFAULT_INIT_OPTIONS.statusline), { refreshInterval: 5000 }) });
481
- statuslineContent = generateStatuslineScript(upgradeOptions);
482
- if (fs.existsSync(statuslinePath)) {
483
- result.updated.push('.claude/helpers/statusline.cjs');
484
- }
485
- else {
486
- result.created.push('.claude/helpers/statusline.cjs');
487
- }
488
- fs.writeFileSync(statuslinePath, statuslineContent, 'utf-8');
489
- metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
490
- securityDir = path.join(targetDir, '.claude-flow', 'security');
491
- progressPath = path.join(metricsDir, 'v3-progress.json');
492
- if (!fs.existsSync(progressPath)) {
493
- progress = {
494
- version: '3.0.0',
495
- initialized: new Date().toISOString(),
496
- domains: { completed: 0, total: 5, status: 'INITIALIZING' },
497
- ddd: { progress: 0, modules: 0, totalFiles: 0, totalLines: 0 },
498
- swarm: { activeAgents: 0, maxAgents: 15, topology: 'hierarchical-mesh' },
499
- learning: { status: 'READY', patternsLearned: 0, sessionsCompleted: 0 },
500
- _note: 'Metrics will update as you use Ruflo'
501
- };
502
- fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
503
- result.created.push('.claude-flow/metrics/v3-progress.json');
504
- }
505
- else {
506
- result.preserved.push('.claude-flow/metrics/v3-progress.json');
507
- }
508
- activityPath = path.join(metricsDir, 'swarm-activity.json');
509
- if (!fs.existsSync(activityPath)) {
510
- activity = {
511
- timestamp: new Date().toISOString(),
512
- processes: { agentic_flow: 0, mcp_server: 0, estimated_agents: 0 },
513
- swarm: { active: false, agent_count: 0, coordination_active: false },
514
- integration: { agentic_flow_active: false, mcp_active: false },
515
- _initialized: true
516
- };
517
- fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
518
- result.created.push('.claude-flow/metrics/swarm-activity.json');
519
- }
520
- else {
521
- result.preserved.push('.claude-flow/metrics/swarm-activity.json');
522
- }
523
- learningPath = path.join(metricsDir, 'learning.json');
524
- if (!fs.existsSync(learningPath)) {
525
- learning = {
526
- initialized: new Date().toISOString(),
527
- routing: { accuracy: 0, decisions: 0 },
528
- patterns: { shortTerm: 0, longTerm: 0, quality: 0 },
529
- sessions: { total: 0, current: null },
530
- _note: 'Intelligence grows as you use Ruflo'
531
- };
532
- fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
533
- result.created.push('.claude-flow/metrics/learning.json');
378
+ }
379
+ }
380
+ else {
381
+ // Source not found (npx with broken paths) — use generated fallbacks
382
+ const generatedCritical = {
383
+ 'hook-handler.cjs': generateHookHandler(),
384
+ 'intelligence.cjs': generateIntelligenceStub(),
385
+ 'auto-memory-hook.mjs': generateAutoMemoryHook(),
386
+ };
387
+ for (const [helperName, content] of Object.entries(generatedCritical)) {
388
+ const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
389
+ if (fs.existsSync(targetPath)) {
390
+ result.updated.push(`.claude/helpers/${helperName}`);
534
391
  }
535
392
  else {
536
- result.preserved.push('.claude-flow/metrics/learning.json');
393
+ result.created.push(`.claude/helpers/${helperName}`);
537
394
  }
538
- auditPath = path.join(securityDir, 'audit-status.json');
539
- if (!fs.existsSync(auditPath)) {
540
- audit = {
541
- initialized: new Date().toISOString(),
542
- status: 'PENDING',
543
- cvesFixed: 0,
544
- totalCves: 3,
545
- lastScan: null,
546
- _note: 'Run: npx @claude-flow/cli@latest security scan'
547
- };
548
- fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
549
- result.created.push('.claude-flow/security/audit-status.json');
395
+ fs.writeFileSync(targetPath, content, 'utf-8');
396
+ try {
397
+ fs.chmodSync(targetPath, '755');
550
398
  }
551
- else {
552
- result.preserved.push('.claude-flow/security/audit-status.json');
399
+ catch { }
400
+ }
401
+ }
402
+ // 1. ALWAYS update statusline helper (force overwrite)
403
+ const statuslinePath = path.join(targetDir, '.claude', 'helpers', 'statusline.cjs');
404
+ // Use default options with statusline config
405
+ const upgradeOptions = {
406
+ ...DEFAULT_INIT_OPTIONS,
407
+ targetDir,
408
+ force: true,
409
+ statusline: {
410
+ ...DEFAULT_INIT_OPTIONS.statusline,
411
+ refreshInterval: 5000,
412
+ },
413
+ };
414
+ const statuslineContent = generateStatuslineScript(upgradeOptions);
415
+ if (fs.existsSync(statuslinePath)) {
416
+ result.updated.push('.claude/helpers/statusline.cjs');
417
+ }
418
+ else {
419
+ result.created.push('.claude/helpers/statusline.cjs');
420
+ }
421
+ fs.writeFileSync(statuslinePath, statuslineContent, 'utf-8');
422
+ // 2. Create MISSING metrics files only (preserve existing data)
423
+ const metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
424
+ const securityDir = path.join(targetDir, '.claude-flow', 'security');
425
+ // v3-progress.json
426
+ const progressPath = path.join(metricsDir, 'v3-progress.json');
427
+ if (!fs.existsSync(progressPath)) {
428
+ const progress = {
429
+ version: '3.0.0',
430
+ initialized: new Date().toISOString(),
431
+ domains: { completed: 0, total: 5, status: 'INITIALIZING' },
432
+ ddd: { progress: 0, modules: 0, totalFiles: 0, totalLines: 0 },
433
+ swarm: { activeAgents: 0, maxAgents: 15, topology: 'hierarchical-mesh' },
434
+ learning: { status: 'READY', patternsLearned: 0, sessionsCompleted: 0 },
435
+ _note: 'Metrics will update as you use Ruflo'
436
+ };
437
+ fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
438
+ result.created.push('.claude-flow/metrics/v3-progress.json');
439
+ }
440
+ else {
441
+ result.preserved.push('.claude-flow/metrics/v3-progress.json');
442
+ }
443
+ // swarm-activity.json
444
+ const activityPath = path.join(metricsDir, 'swarm-activity.json');
445
+ if (!fs.existsSync(activityPath)) {
446
+ const activity = {
447
+ timestamp: new Date().toISOString(),
448
+ processes: { agentic_flow: 0, mcp_server: 0, estimated_agents: 0 },
449
+ swarm: { active: false, agent_count: 0, coordination_active: false },
450
+ integration: { agentic_flow_active: false, mcp_active: false },
451
+ _initialized: true
452
+ };
453
+ fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
454
+ result.created.push('.claude-flow/metrics/swarm-activity.json');
455
+ }
456
+ else {
457
+ result.preserved.push('.claude-flow/metrics/swarm-activity.json');
458
+ }
459
+ // learning.json
460
+ const learningPath = path.join(metricsDir, 'learning.json');
461
+ if (!fs.existsSync(learningPath)) {
462
+ const learning = {
463
+ initialized: new Date().toISOString(),
464
+ routing: { accuracy: 0, decisions: 0 },
465
+ patterns: { shortTerm: 0, longTerm: 0, quality: 0 },
466
+ sessions: { total: 0, current: null },
467
+ _note: 'Intelligence grows as you use Ruflo'
468
+ };
469
+ fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
470
+ result.created.push('.claude-flow/metrics/learning.json');
471
+ }
472
+ else {
473
+ result.preserved.push('.claude-flow/metrics/learning.json');
474
+ }
475
+ // audit-status.json
476
+ const auditPath = path.join(securityDir, 'audit-status.json');
477
+ if (!fs.existsSync(auditPath)) {
478
+ const audit = {
479
+ initialized: new Date().toISOString(),
480
+ status: 'PENDING',
481
+ cvesFixed: 0,
482
+ totalCves: 3,
483
+ lastScan: null,
484
+ _note: 'Run: npx @claude-flow/cli@latest security scan'
485
+ };
486
+ fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
487
+ result.created.push('.claude-flow/security/audit-status.json');
488
+ }
489
+ else {
490
+ result.preserved.push('.claude-flow/security/audit-status.json');
491
+ }
492
+ // 3. Merge settings if requested
493
+ if (upgradeSettings) {
494
+ const settingsPath = path.join(targetDir, '.claude', 'settings.json');
495
+ if (fs.existsSync(settingsPath)) {
496
+ try {
497
+ const existingSettings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
498
+ const mergedSettings = mergeSettingsForUpgrade(existingSettings);
499
+ fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2), 'utf-8');
500
+ result.updated.push('.claude/settings.json');
501
+ result.settingsUpdated = [
502
+ 'env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS',
503
+ 'hooks.SessionStart (auto-memory import)',
504
+ 'hooks.SessionEnd (auto-memory sync)',
505
+ 'hooks.TeammateIdle (removed — not a valid Claude Code hook)',
506
+ 'hooks.TaskCompleted (removed — not a valid Claude Code hook)',
507
+ 'claudeFlow.agentTeams',
508
+ 'claudeFlow.memory (learningBridge, memoryGraph, agentScopes)',
509
+ ];
553
510
  }
554
- // 3. Merge settings if requested
555
- if (upgradeSettings) {
556
- settingsPath = path.join(targetDir, '.claude', 'settings.json');
557
- if (fs.existsSync(settingsPath)) {
558
- try {
559
- existingSettings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
560
- mergedSettings = mergeSettingsForUpgrade(existingSettings);
561
- fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2), 'utf-8');
562
- result.updated.push('.claude/settings.json');
563
- result.settingsUpdated = [
564
- 'env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS',
565
- 'hooks.SessionStart (auto-memory import)',
566
- 'hooks.SessionEnd (auto-memory sync)',
567
- 'hooks.TeammateIdle (removed — not a valid Claude Code hook)',
568
- 'hooks.TaskCompleted (removed — not a valid Claude Code hook)',
569
- 'claudeFlow.agentTeams',
570
- 'claudeFlow.memory (learningBridge, memoryGraph, agentScopes)',
571
- ];
572
- }
573
- catch (settingsError) {
574
- result.errors.push("Settings merge failed: " + (settingsError instanceof Error ? settingsError.message : String(settingsError)));
575
- }
576
- }
577
- else {
578
- defaultSettings = generateSettings(DEFAULT_INIT_OPTIONS);
579
- fs.writeFileSync(settingsPath, JSON.stringify(defaultSettings, null, 2), 'utf-8');
580
- result.created.push('.claude/settings.json');
581
- result.settingsUpdated = ['Created new settings.json with Agent Teams'];
582
- }
511
+ catch (settingsError) {
512
+ result.errors.push(`Settings merge failed: ${settingsError instanceof Error ? settingsError.message : String(settingsError)}`);
583
513
  }
584
514
  }
585
- catch (error) {
586
- result.success = false;
587
- result.errors.push(error instanceof Error ? error.message : String(error));
515
+ else {
516
+ // Create new settings.json with defaults
517
+ const defaultSettings = generateSettings(DEFAULT_INIT_OPTIONS);
518
+ fs.writeFileSync(settingsPath, JSON.stringify(defaultSettings, null, 2), 'utf-8');
519
+ result.created.push('.claude/settings.json');
520
+ result.settingsUpdated = ['Created new settings.json with Agent Teams'];
588
521
  }
589
- return [2 /*return*/, result];
590
- });
591
- });
522
+ }
523
+ }
524
+ catch (error) {
525
+ result.success = false;
526
+ result.errors.push(error instanceof Error ? error.message : String(error));
527
+ }
528
+ return result;
592
529
  }
593
530
  /**
594
531
  * Execute upgrade with --add-missing flag
@@ -596,351 +533,310 @@ export function executeUpgrade(targetDir, upgradeSettings) {
596
533
  * @param targetDir - Target directory
597
534
  * @param upgradeSettings - If true, merge new settings into existing settings.json
598
535
  */
599
- export function executeUpgradeWithMissing(targetDir, upgradeSettings) {
600
- if (upgradeSettings === void 0) { upgradeSettings = false; }
601
- return __awaiter(this, void 0, Promise, function () {
602
- var result, skillsDir, agentsDir, commandsDir, _i, _a, dir, sourceSkillsDir, sourceAgentsDir, sourceCommandsDir, allSkills, debugMode, _b, _c, skillName, sourcePath, targetPath, sourceExists, targetExists, allAgents, _d, _e, agentCategory, sourcePath, targetPath, allCommands, _f, _g, cmdName, sourcePath, targetPath;
603
- return __generator(this, function (_h) {
604
- switch (_h.label) {
605
- case 0: return [4 /*yield*/, executeUpgrade(targetDir, upgradeSettings)];
606
- case 1:
607
- result = _h.sent();
608
- if (!result.success) {
609
- return [2 /*return*/, result];
610
- }
611
- // Initialize tracking arrays
612
- result.addedSkills = [];
613
- result.addedAgents = [];
614
- result.addedCommands = [];
615
- try {
616
- skillsDir = path.join(targetDir, '.claude', 'skills');
617
- agentsDir = path.join(targetDir, '.claude', 'agents');
618
- commandsDir = path.join(targetDir, '.claude', 'commands');
619
- for (_i = 0, _a = [skillsDir, agentsDir, commandsDir]; _i < _a.length; _i++) {
620
- dir = _a[_i];
621
- if (!fs.existsSync(dir)) {
622
- fs.mkdirSync(dir, { recursive: true });
623
- }
624
- }
625
- sourceSkillsDir = findSourceDir('skills');
626
- sourceAgentsDir = findSourceDir('agents');
627
- sourceCommandsDir = findSourceDir('commands');
628
- // Debug: Log source directories found
629
- if (process.env.DEBUG || process.env.CLAUDE_FLOW_DEBUG) {
630
- console.log('[DEBUG] Source directories:');
631
- console.log(" Skills: " + (sourceSkillsDir || 'NOT FOUND'));
632
- console.log(" Agents: " + (sourceAgentsDir || 'NOT FOUND'));
633
- console.log(" Commands: " + (sourceCommandsDir || 'NOT FOUND'));
634
- }
635
- // Add missing skills
636
- if (sourceSkillsDir) {
637
- allSkills = Object.values(SKILLS_MAP).flat();
638
- debugMode = process.env.DEBUG || process.env.CLAUDE_FLOW_DEBUG;
639
- if (debugMode) {
640
- console.log("[DEBUG] Checking " + allSkills.length + " skills from SKILLS_MAP");
641
- }
642
- for (_b = 0, _c = __spreadArray([], new Set(allSkills), true); _b < _c.length; _b++) {
643
- skillName = _c[_b];
644
- sourcePath = path.join(sourceSkillsDir, skillName);
645
- targetPath = path.join(skillsDir, skillName);
646
- sourceExists = fs.existsSync(sourcePath);
647
- targetExists = fs.existsSync(targetPath);
648
- if (debugMode) {
649
- console.log("[DEBUG] Skill '" + skillName + "': source=" + sourceExists + ", target=" + targetExists);
650
- }
651
- if (sourceExists && !targetExists) {
652
- copyDirRecursive(sourcePath, targetPath);
653
- result.addedSkills.push(skillName);
654
- result.created.push(".claude/skills/" + skillName);
655
- }
656
- }
657
- }
658
- // Add missing agents
659
- if (sourceAgentsDir) {
660
- allAgents = Object.values(AGENTS_MAP).flat();
661
- for (_d = 0, _e = __spreadArray([], new Set(allAgents), true); _d < _e.length; _d++) {
662
- agentCategory = _e[_d];
663
- sourcePath = path.join(sourceAgentsDir, agentCategory);
664
- targetPath = path.join(agentsDir, agentCategory);
665
- if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
666
- copyDirRecursive(sourcePath, targetPath);
667
- result.addedAgents.push(agentCategory);
668
- result.created.push(".claude/agents/" + agentCategory);
669
- }
670
- }
671
- }
672
- // Add missing commands
673
- if (sourceCommandsDir) {
674
- allCommands = Object.values(COMMANDS_MAP).flat();
675
- for (_f = 0, _g = __spreadArray([], new Set(allCommands), true); _f < _g.length; _f++) {
676
- cmdName = _g[_f];
677
- sourcePath = path.join(sourceCommandsDir, cmdName);
678
- targetPath = path.join(commandsDir, cmdName);
679
- if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
680
- if (fs.statSync(sourcePath).isDirectory()) {
681
- copyDirRecursive(sourcePath, targetPath);
682
- }
683
- else {
684
- fs.copyFileSync(sourcePath, targetPath);
685
- }
686
- result.addedCommands.push(cmdName);
687
- result.created.push(".claude/commands/" + cmdName);
688
- }
689
- }
690
- }
536
+ export async function executeUpgradeWithMissing(targetDir, upgradeSettings = false) {
537
+ // First do the normal upgrade (pass through upgradeSettings)
538
+ const result = await executeUpgrade(targetDir, upgradeSettings);
539
+ if (!result.success) {
540
+ return result;
541
+ }
542
+ // Initialize tracking arrays
543
+ result.addedSkills = [];
544
+ result.addedAgents = [];
545
+ result.addedCommands = [];
546
+ try {
547
+ // Ensure target directories exist
548
+ const skillsDir = path.join(targetDir, '.claude', 'skills');
549
+ const agentsDir = path.join(targetDir, '.claude', 'agents');
550
+ const commandsDir = path.join(targetDir, '.claude', 'commands');
551
+ for (const dir of [skillsDir, agentsDir, commandsDir]) {
552
+ if (!fs.existsSync(dir)) {
553
+ fs.mkdirSync(dir, { recursive: true });
554
+ }
555
+ }
556
+ // Find source directories
557
+ const sourceSkillsDir = findSourceDir('skills');
558
+ const sourceAgentsDir = findSourceDir('agents');
559
+ const sourceCommandsDir = findSourceDir('commands');
560
+ // Debug: Log source directories found
561
+ if (process.env.DEBUG || process.env.CLAUDE_FLOW_DEBUG) {
562
+ console.log('[DEBUG] Source directories:');
563
+ console.log(` Skills: ${sourceSkillsDir || 'NOT FOUND'}`);
564
+ console.log(` Agents: ${sourceAgentsDir || 'NOT FOUND'}`);
565
+ console.log(` Commands: ${sourceCommandsDir || 'NOT FOUND'}`);
566
+ }
567
+ // Add missing skills
568
+ if (sourceSkillsDir) {
569
+ const allSkills = Object.values(SKILLS_MAP).flat();
570
+ const debugMode = process.env.DEBUG || process.env.CLAUDE_FLOW_DEBUG;
571
+ if (debugMode) {
572
+ console.log(`[DEBUG] Checking ${allSkills.length} skills from SKILLS_MAP`);
573
+ }
574
+ for (const skillName of [...new Set(allSkills)]) {
575
+ const sourcePath = path.join(sourceSkillsDir, skillName);
576
+ const targetPath = path.join(skillsDir, skillName);
577
+ const sourceExists = fs.existsSync(sourcePath);
578
+ const targetExists = fs.existsSync(targetPath);
579
+ if (debugMode) {
580
+ console.log(`[DEBUG] Skill '${skillName}': source=${sourceExists}, target=${targetExists}`);
581
+ }
582
+ if (sourceExists && !targetExists) {
583
+ copyDirRecursive(sourcePath, targetPath);
584
+ result.addedSkills.push(skillName);
585
+ result.created.push(`.claude/skills/${skillName}`);
586
+ }
587
+ }
588
+ }
589
+ // Add missing agents
590
+ if (sourceAgentsDir) {
591
+ const allAgents = Object.values(AGENTS_MAP).flat();
592
+ for (const agentCategory of [...new Set(allAgents)]) {
593
+ const sourcePath = path.join(sourceAgentsDir, agentCategory);
594
+ const targetPath = path.join(agentsDir, agentCategory);
595
+ if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
596
+ copyDirRecursive(sourcePath, targetPath);
597
+ result.addedAgents.push(agentCategory);
598
+ result.created.push(`.claude/agents/${agentCategory}`);
599
+ }
600
+ }
601
+ }
602
+ // Add missing commands
603
+ if (sourceCommandsDir) {
604
+ const allCommands = Object.values(COMMANDS_MAP).flat();
605
+ for (const cmdName of [...new Set(allCommands)]) {
606
+ const sourcePath = path.join(sourceCommandsDir, cmdName);
607
+ const targetPath = path.join(commandsDir, cmdName);
608
+ if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
609
+ if (fs.statSync(sourcePath).isDirectory()) {
610
+ copyDirRecursive(sourcePath, targetPath);
691
611
  }
692
- catch (error) {
693
- result.errors.push("Add missing failed: " + (error instanceof Error ? error.message : String(error)));
612
+ else {
613
+ fs.copyFileSync(sourcePath, targetPath);
694
614
  }
695
- return [2 /*return*/, result];
615
+ result.addedCommands.push(cmdName);
616
+ result.created.push(`.claude/commands/${cmdName}`);
617
+ }
696
618
  }
697
- });
698
- });
619
+ }
620
+ }
621
+ catch (error) {
622
+ result.errors.push(`Add missing failed: ${error instanceof Error ? error.message : String(error)}`);
623
+ }
624
+ return result;
699
625
  }
700
626
  /**
701
627
  * Create directory structure
702
628
  */
703
- function createDirectories(targetDir, options, result) {
704
- return __awaiter(this, void 0, Promise, function () {
705
- var dirs, _i, dirs_2, dir, fullPath;
706
- return __generator(this, function (_a) {
707
- dirs = __spreadArray(__spreadArray([], DIRECTORIES.claude, true), (options.components.runtime ? DIRECTORIES.runtime : []), true);
708
- for (_i = 0, dirs_2 = dirs; _i < dirs_2.length; _i++) {
709
- dir = dirs_2[_i];
710
- fullPath = path.join(targetDir, dir);
711
- if (!fs.existsSync(fullPath)) {
712
- fs.mkdirSync(fullPath, { recursive: true });
713
- result.created.directories.push(dir);
714
- }
715
- }
716
- return [2 /*return*/];
717
- });
718
- });
629
+ async function createDirectories(targetDir, options, result) {
630
+ const dirs = [
631
+ ...DIRECTORIES.claude,
632
+ ...(options.components.runtime ? DIRECTORIES.runtime : []),
633
+ ];
634
+ for (const dir of dirs) {
635
+ const fullPath = path.join(targetDir, dir);
636
+ if (!fs.existsSync(fullPath)) {
637
+ fs.mkdirSync(fullPath, { recursive: true });
638
+ result.created.directories.push(dir);
639
+ }
640
+ }
719
641
  }
720
642
  /**
721
643
  * Write settings.json
722
644
  */
723
- function writeSettings(targetDir, options, result) {
724
- return __awaiter(this, void 0, Promise, function () {
725
- var settingsPath, content;
726
- return __generator(this, function (_a) {
727
- settingsPath = path.join(targetDir, '.claude', 'settings.json');
728
- if (fs.existsSync(settingsPath) && !options.force) {
729
- result.skipped.push('.claude/settings.json');
730
- return [2 /*return*/];
731
- }
732
- content = generateSettingsJson(options);
733
- fs.writeFileSync(settingsPath, content, 'utf-8');
734
- result.created.files.push('.claude/settings.json');
735
- return [2 /*return*/];
736
- });
737
- });
645
+ async function writeSettings(targetDir, options, result) {
646
+ const settingsPath = path.join(targetDir, '.claude', 'settings.json');
647
+ if (fs.existsSync(settingsPath) && !options.force) {
648
+ result.skipped.push('.claude/settings.json');
649
+ return;
650
+ }
651
+ const content = generateSettingsJson(options);
652
+ fs.writeFileSync(settingsPath, content, 'utf-8');
653
+ result.created.files.push('.claude/settings.json');
738
654
  }
739
655
  /**
740
656
  * Write .mcp.json
741
657
  */
742
- function writeMCPConfig(targetDir, options, result) {
743
- return __awaiter(this, void 0, Promise, function () {
744
- var mcpPath, content;
745
- return __generator(this, function (_a) {
746
- mcpPath = path.join(targetDir, '.mcp.json');
747
- if (fs.existsSync(mcpPath) && !options.force) {
748
- result.skipped.push('.mcp.json');
749
- return [2 /*return*/];
750
- }
751
- content = generateMCPJson(options);
752
- fs.writeFileSync(mcpPath, content, 'utf-8');
753
- result.created.files.push('.mcp.json');
754
- return [2 /*return*/];
755
- });
756
- });
658
+ async function writeMCPConfig(targetDir, options, result) {
659
+ const mcpPath = path.join(targetDir, '.mcp.json');
660
+ if (fs.existsSync(mcpPath) && !options.force) {
661
+ result.skipped.push('.mcp.json');
662
+ return;
663
+ }
664
+ const content = generateMCPJson(options);
665
+ fs.writeFileSync(mcpPath, content, 'utf-8');
666
+ result.created.files.push('.mcp.json');
757
667
  }
758
668
  /**
759
669
  * Copy skills from source
760
670
  */
761
- function copySkills(targetDir, options, result) {
762
- return __awaiter(this, void 0, Promise, function () {
763
- var skillsConfig, targetSkillsDir, skillsToCopy, sourceSkillsDir, _i, _a, skillName, sourcePath, targetPath;
764
- return __generator(this, function (_b) {
765
- skillsConfig = options.skills;
766
- targetSkillsDir = path.join(targetDir, '.claude', 'skills');
767
- skillsToCopy = [];
768
- if (skillsConfig.all) {
769
- // Copy all available skills
770
- Object.values(SKILLS_MAP).forEach(function (skills) { return skillsToCopy.push.apply(skillsToCopy, skills); });
671
+ async function copySkills(targetDir, options, result) {
672
+ const skillsConfig = options.skills;
673
+ const targetSkillsDir = path.join(targetDir, '.claude', 'skills');
674
+ // Determine which skills to copy
675
+ const skillsToCopy = [];
676
+ if (skillsConfig.all) {
677
+ // Copy all available skills
678
+ Object.values(SKILLS_MAP).forEach(skills => skillsToCopy.push(...skills));
679
+ }
680
+ else {
681
+ if (skillsConfig.core)
682
+ skillsToCopy.push(...SKILLS_MAP.core);
683
+ if (skillsConfig.agentdb)
684
+ skillsToCopy.push(...SKILLS_MAP.agentdb);
685
+ if (skillsConfig.github)
686
+ skillsToCopy.push(...SKILLS_MAP.github);
687
+ if (skillsConfig.flowNexus)
688
+ skillsToCopy.push(...SKILLS_MAP.flowNexus);
689
+ if (skillsConfig.browser)
690
+ skillsToCopy.push(...SKILLS_MAP.browser);
691
+ if (skillsConfig.v3)
692
+ skillsToCopy.push(...SKILLS_MAP.v3);
693
+ if (skillsConfig.dualMode)
694
+ skillsToCopy.push(...SKILLS_MAP.dualMode);
695
+ if (skillsConfig.design)
696
+ skillsToCopy.push(...(SKILLS_MAP.design || []));
697
+ }
698
+ // Find source skills directory
699
+ const sourceSkillsDir = findSourceDir('skills', options.sourceBaseDir);
700
+ if (!sourceSkillsDir) {
701
+ result.errors.push('Could not find source skills directory');
702
+ return;
703
+ }
704
+ // Copy each skill
705
+ for (const skillName of [...new Set(skillsToCopy)]) {
706
+ const sourcePath = path.join(sourceSkillsDir, skillName);
707
+ const targetPath = path.join(targetSkillsDir, skillName);
708
+ if (fs.existsSync(sourcePath)) {
709
+ if (!fs.existsSync(targetPath) || options.force) {
710
+ copyDirRecursive(sourcePath, targetPath);
711
+ result.created.files.push(`.claude/skills/${skillName}`);
712
+ result.summary.skillsCount++;
771
713
  }
772
714
  else {
773
- if (skillsConfig.core)
774
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.core);
775
- if (skillsConfig.agentdb)
776
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.agentdb);
777
- if (skillsConfig.github)
778
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.github);
779
- if (skillsConfig.flowNexus)
780
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.flowNexus);
781
- if (skillsConfig.browser)
782
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.browser);
783
- if (skillsConfig.v3)
784
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.v3);
785
- if (skillsConfig.dualMode)
786
- skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.dualMode);
787
- if (skillsConfig.design)
788
- skillsToCopy.push.apply(skillsToCopy, (SKILLS_MAP.design || []));
789
- }
790
- sourceSkillsDir = findSourceDir('skills', options.sourceBaseDir);
791
- if (!sourceSkillsDir) {
792
- result.errors.push('Could not find source skills directory');
793
- return [2 /*return*/];
794
- }
795
- // Copy each skill
796
- for (_i = 0, _a = __spreadArray([], new Set(skillsToCopy), true); _i < _a.length; _i++) {
797
- skillName = _a[_i];
798
- sourcePath = path.join(sourceSkillsDir, skillName);
799
- targetPath = path.join(targetSkillsDir, skillName);
800
- if (fs.existsSync(sourcePath)) {
801
- if (!fs.existsSync(targetPath) || options.force) {
802
- copyDirRecursive(sourcePath, targetPath);
803
- result.created.files.push(".claude/skills/" + skillName);
804
- result.summary.skillsCount++;
805
- }
806
- else {
807
- result.skipped.push(".claude/skills/" + skillName);
808
- }
809
- }
715
+ result.skipped.push(`.claude/skills/${skillName}`);
810
716
  }
811
- return [2 /*return*/];
812
- });
813
- });
717
+ }
718
+ }
814
719
  }
815
720
  /**
816
721
  * Copy commands from source
817
722
  */
818
- function copyCommands(targetDir, options, result) {
819
- return __awaiter(this, void 0, Promise, function () {
820
- var commandsConfig, targetCommandsDir, commandsToCopy, sourceCommandsDir, _i, _a, cmdName, sourcePath, targetPath;
821
- return __generator(this, function (_b) {
822
- commandsConfig = options.commands;
823
- targetCommandsDir = path.join(targetDir, '.claude', 'commands');
824
- commandsToCopy = [];
825
- if (commandsConfig.all) {
826
- Object.values(COMMANDS_MAP).forEach(function (cmds) { return commandsToCopy.push.apply(commandsToCopy, cmds); });
723
+ async function copyCommands(targetDir, options, result) {
724
+ const commandsConfig = options.commands;
725
+ const targetCommandsDir = path.join(targetDir, '.claude', 'commands');
726
+ // Determine which commands to copy
727
+ const commandsToCopy = [];
728
+ if (commandsConfig.all) {
729
+ Object.values(COMMANDS_MAP).forEach(cmds => commandsToCopy.push(...cmds));
730
+ }
731
+ else {
732
+ if (commandsConfig.core)
733
+ commandsToCopy.push(...COMMANDS_MAP.core);
734
+ if (commandsConfig.analysis)
735
+ commandsToCopy.push(...COMMANDS_MAP.analysis);
736
+ if (commandsConfig.automation)
737
+ commandsToCopy.push(...COMMANDS_MAP.automation);
738
+ if (commandsConfig.github)
739
+ commandsToCopy.push(...COMMANDS_MAP.github);
740
+ if (commandsConfig.hooks)
741
+ commandsToCopy.push(...COMMANDS_MAP.hooks);
742
+ if (commandsConfig.monitoring)
743
+ commandsToCopy.push(...COMMANDS_MAP.monitoring);
744
+ if (commandsConfig.optimization)
745
+ commandsToCopy.push(...COMMANDS_MAP.optimization);
746
+ if (commandsConfig.sparc)
747
+ commandsToCopy.push(...COMMANDS_MAP.sparc);
748
+ }
749
+ // Find source commands directory
750
+ const sourceCommandsDir = findSourceDir('commands', options.sourceBaseDir);
751
+ if (!sourceCommandsDir) {
752
+ result.errors.push('Could not find source commands directory');
753
+ return;
754
+ }
755
+ // Copy each command/directory
756
+ for (const cmdName of [...new Set(commandsToCopy)]) {
757
+ const sourcePath = path.join(sourceCommandsDir, cmdName);
758
+ const targetPath = path.join(targetCommandsDir, cmdName);
759
+ if (fs.existsSync(sourcePath)) {
760
+ if (!fs.existsSync(targetPath) || options.force) {
761
+ if (fs.statSync(sourcePath).isDirectory()) {
762
+ copyDirRecursive(sourcePath, targetPath);
763
+ }
764
+ else {
765
+ fs.copyFileSync(sourcePath, targetPath);
766
+ }
767
+ result.created.files.push(`.claude/commands/${cmdName}`);
768
+ result.summary.commandsCount++;
827
769
  }
828
770
  else {
829
- if (commandsConfig.core)
830
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.core);
831
- if (commandsConfig.analysis)
832
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.analysis);
833
- if (commandsConfig.automation)
834
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.automation);
835
- if (commandsConfig.github)
836
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.github);
837
- if (commandsConfig.hooks)
838
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.hooks);
839
- if (commandsConfig.monitoring)
840
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.monitoring);
841
- if (commandsConfig.optimization)
842
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.optimization);
843
- if (commandsConfig.sparc)
844
- commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.sparc);
771
+ result.skipped.push(`.claude/commands/${cmdName}`);
845
772
  }
846
- sourceCommandsDir = findSourceDir('commands', options.sourceBaseDir);
847
- if (!sourceCommandsDir) {
848
- result.errors.push('Could not find source commands directory');
849
- return [2 /*return*/];
850
- }
851
- // Copy each command/directory
852
- for (_i = 0, _a = __spreadArray([], new Set(commandsToCopy), true); _i < _a.length; _i++) {
853
- cmdName = _a[_i];
854
- sourcePath = path.join(sourceCommandsDir, cmdName);
855
- targetPath = path.join(targetCommandsDir, cmdName);
856
- if (fs.existsSync(sourcePath)) {
857
- if (!fs.existsSync(targetPath) || options.force) {
858
- if (fs.statSync(sourcePath).isDirectory()) {
859
- copyDirRecursive(sourcePath, targetPath);
860
- }
861
- else {
862
- fs.copyFileSync(sourcePath, targetPath);
863
- }
864
- result.created.files.push(".claude/commands/" + cmdName);
865
- result.summary.commandsCount++;
866
- }
867
- else {
868
- result.skipped.push(".claude/commands/" + cmdName);
869
- }
870
- }
871
- }
872
- return [2 /*return*/];
873
- });
874
- });
773
+ }
774
+ }
875
775
  }
876
776
  /**
877
777
  * Copy agents from source
878
778
  */
879
- function copyAgents(targetDir, options, result) {
880
- return __awaiter(this, void 0, Promise, function () {
881
- var agentsConfig, targetAgentsDir, agentsToCopy, sourceAgentsDir, _i, _a, agentCategory, sourcePath, targetPath, yamlFiles, mdFiles;
882
- return __generator(this, function (_b) {
883
- agentsConfig = options.agents;
884
- targetAgentsDir = path.join(targetDir, '.claude', 'agents');
885
- agentsToCopy = [];
886
- if (agentsConfig.all) {
887
- Object.values(AGENTS_MAP).forEach(function (agents) { return agentsToCopy.push.apply(agentsToCopy, agents); });
779
+ async function copyAgents(targetDir, options, result) {
780
+ const agentsConfig = options.agents;
781
+ const targetAgentsDir = path.join(targetDir, '.claude', 'agents');
782
+ // Determine which agents to copy
783
+ const agentsToCopy = [];
784
+ if (agentsConfig.all) {
785
+ Object.values(AGENTS_MAP).forEach(agents => agentsToCopy.push(...agents));
786
+ }
787
+ else {
788
+ if (agentsConfig.core)
789
+ agentsToCopy.push(...AGENTS_MAP.core);
790
+ if (agentsConfig.consensus)
791
+ agentsToCopy.push(...AGENTS_MAP.consensus);
792
+ if (agentsConfig.github)
793
+ agentsToCopy.push(...AGENTS_MAP.github);
794
+ if (agentsConfig.hiveMind)
795
+ agentsToCopy.push(...AGENTS_MAP.hiveMind);
796
+ if (agentsConfig.sparc)
797
+ agentsToCopy.push(...AGENTS_MAP.sparc);
798
+ if (agentsConfig.swarm)
799
+ agentsToCopy.push(...AGENTS_MAP.swarm);
800
+ if (agentsConfig.browser)
801
+ agentsToCopy.push(...AGENTS_MAP.browser);
802
+ // V3-specific agent categories
803
+ if (agentsConfig.v3)
804
+ agentsToCopy.push(...(AGENTS_MAP.v3 || []));
805
+ if (agentsConfig.optimization)
806
+ agentsToCopy.push(...(AGENTS_MAP.optimization || []));
807
+ if (agentsConfig.testing)
808
+ agentsToCopy.push(...(AGENTS_MAP.testing || []));
809
+ // Design agents (design-architect, ux-researcher, ui-developer, accessibility-auditor)
810
+ if (agentsConfig.design)
811
+ agentsToCopy.push(...(AGENTS_MAP.design || []));
812
+ // Dual-mode agents (Claude Code + Codex hybrid)
813
+ if (agentsConfig.dualMode)
814
+ agentsToCopy.push(...(AGENTS_MAP.dualMode || []));
815
+ }
816
+ // Find source agents directory
817
+ const sourceAgentsDir = findSourceDir('agents', options.sourceBaseDir);
818
+ if (!sourceAgentsDir) {
819
+ result.errors.push('Could not find source agents directory');
820
+ return;
821
+ }
822
+ // Copy each agent category
823
+ for (const agentCategory of [...new Set(agentsToCopy)]) {
824
+ const sourcePath = path.join(sourceAgentsDir, agentCategory);
825
+ const targetPath = path.join(targetAgentsDir, agentCategory);
826
+ if (fs.existsSync(sourcePath)) {
827
+ if (!fs.existsSync(targetPath) || options.force) {
828
+ copyDirRecursive(sourcePath, targetPath);
829
+ // Count agent files (.yaml and .md)
830
+ const yamlFiles = countFiles(sourcePath, '.yaml');
831
+ const mdFiles = countFiles(sourcePath, '.md');
832
+ result.summary.agentsCount += yamlFiles + mdFiles;
833
+ result.created.files.push(`.claude/agents/${agentCategory}`);
888
834
  }
889
835
  else {
890
- if (agentsConfig.core)
891
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.core);
892
- if (agentsConfig.consensus)
893
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.consensus);
894
- if (agentsConfig.github)
895
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.github);
896
- if (agentsConfig.hiveMind)
897
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.hiveMind);
898
- if (agentsConfig.sparc)
899
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.sparc);
900
- if (agentsConfig.swarm)
901
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.swarm);
902
- if (agentsConfig.browser)
903
- agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.browser);
904
- // V3-specific agent categories
905
- if (agentsConfig.v3)
906
- agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.v3 || []));
907
- if (agentsConfig.optimization)
908
- agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.optimization || []));
909
- if (agentsConfig.testing)
910
- agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.testing || []));
911
- // Design agents (design-architect, ux-researcher, ui-developer, accessibility-auditor)
912
- if (agentsConfig.design)
913
- agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.design || []));
914
- // Dual-mode agents (Claude Code + Codex hybrid)
915
- if (agentsConfig.dualMode)
916
- agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.dualMode || []));
836
+ result.skipped.push(`.claude/agents/${agentCategory}`);
917
837
  }
918
- sourceAgentsDir = findSourceDir('agents', options.sourceBaseDir);
919
- if (!sourceAgentsDir) {
920
- result.errors.push('Could not find source agents directory');
921
- return [2 /*return*/];
922
- }
923
- // Copy each agent category
924
- for (_i = 0, _a = __spreadArray([], new Set(agentsToCopy), true); _i < _a.length; _i++) {
925
- agentCategory = _a[_i];
926
- sourcePath = path.join(sourceAgentsDir, agentCategory);
927
- targetPath = path.join(targetAgentsDir, agentCategory);
928
- if (fs.existsSync(sourcePath)) {
929
- if (!fs.existsSync(targetPath) || options.force) {
930
- copyDirRecursive(sourcePath, targetPath);
931
- yamlFiles = countFiles(sourcePath, '.yaml');
932
- mdFiles = countFiles(sourcePath, '.md');
933
- result.summary.agentsCount += yamlFiles + mdFiles;
934
- result.created.files.push(".claude/agents/" + agentCategory);
935
- }
936
- else {
937
- result.skipped.push(".claude/agents/" + agentCategory);
938
- }
939
- }
940
- }
941
- return [2 /*return*/];
942
- });
943
- });
838
+ }
839
+ }
944
840
  }
945
841
  /**
946
842
  * Find source helpers directory.
@@ -948,46 +844,45 @@ function copyAgents(targetDir, options, result) {
948
844
  * returning the target directory or an incomplete source.
949
845
  */
950
846
  function findSourceHelpersDir(sourceBaseDir) {
951
- var possiblePaths = [];
952
- var SENTINEL_FILE = 'hook-handler.cjs'; // Must exist in valid source
847
+ const possiblePaths = [];
848
+ const SENTINEL_FILE = 'hook-handler.cjs'; // Must exist in valid source
953
849
  // If explicit source base directory is provided, check it first
954
850
  if (sourceBaseDir) {
955
851
  possiblePaths.push(path.join(sourceBaseDir, '.claude', 'helpers'));
956
852
  }
957
853
  // Strategy 1: require.resolve to find package root (most reliable for npx)
958
854
  try {
959
- var esmRequire = createRequire(import.meta.url);
960
- var pkgJsonPath = esmRequire.resolve('@claude-flow/cli/package.json');
961
- var pkgRoot = path.dirname(pkgJsonPath);
855
+ const esmRequire = createRequire(import.meta.url);
856
+ const pkgJsonPath = esmRequire.resolve('@claude-flow/cli/package.json');
857
+ const pkgRoot = path.dirname(pkgJsonPath);
962
858
  possiblePaths.push(path.join(pkgRoot, '.claude', 'helpers'));
963
859
  }
964
- catch (_a) {
860
+ catch {
965
861
  // Not installed as a package — skip
966
862
  }
967
863
  // Strategy 2: __dirname-based (dist/src/init -> package root)
968
- var packageRoot = path.resolve(__dirname, '..', '..', '..');
969
- var packageHelpers = path.join(packageRoot, '.claude', 'helpers');
864
+ const packageRoot = path.resolve(__dirname, '..', '..', '..');
865
+ const packageHelpers = path.join(packageRoot, '.claude', 'helpers');
970
866
  possiblePaths.push(packageHelpers);
971
867
  // Strategy 3: Walk up from __dirname looking for package root
972
- var currentDir = __dirname;
973
- for (var i = 0; i < 10; i++) {
974
- var parentDir = path.dirname(currentDir);
868
+ let currentDir = __dirname;
869
+ for (let i = 0; i < 10; i++) {
870
+ const parentDir = path.dirname(currentDir);
975
871
  if (parentDir === currentDir)
976
872
  break; // hit filesystem root
977
- var helpersPath = path.join(parentDir, '.claude', 'helpers');
873
+ const helpersPath = path.join(parentDir, '.claude', 'helpers');
978
874
  possiblePaths.push(helpersPath);
979
875
  currentDir = parentDir;
980
876
  }
981
877
  // Strategy 4: Check cwd-relative paths (for local dev)
982
- var cwdBased = [
878
+ const cwdBased = [
983
879
  path.join(process.cwd(), '.claude', 'helpers'),
984
880
  path.join(process.cwd(), '..', '.claude', 'helpers'),
985
881
  path.join(process.cwd(), '..', '..', '.claude', 'helpers'),
986
882
  ];
987
- possiblePaths.push.apply(possiblePaths, cwdBased);
883
+ possiblePaths.push(...cwdBased);
988
884
  // Return first path that exists AND contains the sentinel file
989
- for (var _i = 0, possiblePaths_1 = possiblePaths; _i < possiblePaths_1.length; _i++) {
990
- var p = possiblePaths_1[_i];
885
+ for (const p of possiblePaths) {
991
886
  if (fs.existsSync(p) && fs.existsSync(path.join(p, SENTINEL_FILE))) {
992
887
  return p;
993
888
  }
@@ -997,97 +892,90 @@ function findSourceHelpersDir(sourceBaseDir) {
997
892
  /**
998
893
  * Write helper scripts
999
894
  */
1000
- function writeHelpers(targetDir, options, result) {
1001
- return __awaiter(this, void 0, Promise, function () {
1002
- var helpersDir, sourceHelpersDir, helperFiles, copiedCount, _i, helperFiles_1, file, sourcePath, destPath, helpers, _a, _b, _c, name, content, filePath;
1003
- return __generator(this, function (_d) {
1004
- helpersDir = path.join(targetDir, '.claude', 'helpers');
1005
- sourceHelpersDir = findSourceHelpersDir(options.sourceBaseDir);
1006
- // Try to copy existing helpers from source first
1007
- if (sourceHelpersDir && fs.existsSync(sourceHelpersDir)) {
1008
- helperFiles = fs.readdirSync(sourceHelpersDir);
1009
- copiedCount = 0;
1010
- for (_i = 0, helperFiles_1 = helperFiles; _i < helperFiles_1.length; _i++) {
1011
- file = helperFiles_1[_i];
1012
- sourcePath = path.join(sourceHelpersDir, file);
1013
- destPath = path.join(helpersDir, file);
1014
- // Skip directories and only copy files
1015
- if (!fs.statSync(sourcePath).isFile())
1016
- continue;
1017
- if (!fs.existsSync(destPath) || options.force) {
1018
- fs.copyFileSync(sourcePath, destPath);
1019
- // Make shell scripts and mjs files executable
1020
- if (file.endsWith('.sh') || file.endsWith('.mjs')) {
1021
- fs.chmodSync(destPath, '755');
1022
- }
1023
- result.created.files.push(".claude/helpers/" + file);
1024
- copiedCount++;
1025
- }
1026
- else {
1027
- result.skipped.push(".claude/helpers/" + file);
1028
- }
1029
- }
1030
- if (copiedCount > 0) {
1031
- return [2 /*return*/]; // Skip generating if we copied from source
895
+ async function writeHelpers(targetDir, options, result) {
896
+ const helpersDir = path.join(targetDir, '.claude', 'helpers');
897
+ // Find source helpers directory (works for npm package and local dev)
898
+ const sourceHelpersDir = findSourceHelpersDir(options.sourceBaseDir);
899
+ // Try to copy existing helpers from source first
900
+ if (sourceHelpersDir && fs.existsSync(sourceHelpersDir)) {
901
+ const helperFiles = fs.readdirSync(sourceHelpersDir);
902
+ let copiedCount = 0;
903
+ for (const file of helperFiles) {
904
+ const sourcePath = path.join(sourceHelpersDir, file);
905
+ const destPath = path.join(helpersDir, file);
906
+ // Skip directories and only copy files
907
+ if (!fs.statSync(sourcePath).isFile())
908
+ continue;
909
+ if (!fs.existsSync(destPath) || options.force) {
910
+ fs.copyFileSync(sourcePath, destPath);
911
+ // Make shell scripts and mjs files executable
912
+ if (file.endsWith('.sh') || file.endsWith('.mjs')) {
913
+ fs.chmodSync(destPath, '755');
1032
914
  }
915
+ result.created.files.push(`.claude/helpers/${file}`);
916
+ copiedCount++;
1033
917
  }
1034
- helpers = {
1035
- 'pre-commit': generatePreCommitHook(),
1036
- 'post-commit': generatePostCommitHook(),
1037
- 'session.js': generateSessionManager(),
1038
- 'router.js': generateAgentRouter(),
1039
- 'memory.js': generateMemoryHelper(),
1040
- 'hook-handler.cjs': generateHookHandler(),
1041
- 'intelligence.cjs': generateIntelligenceStub(),
1042
- 'auto-memory-hook.mjs': generateAutoMemoryHook()
1043
- };
1044
- for (_a = 0, _b = Object.entries(helpers); _a < _b.length; _a++) {
1045
- _c = _b[_a], name = _c[0], content = _c[1];
1046
- filePath = path.join(helpersDir, name);
1047
- if (!fs.existsSync(filePath) || options.force) {
1048
- fs.writeFileSync(filePath, content, 'utf-8');
1049
- // Make shell scripts executable
1050
- if (!name.endsWith('.js')) {
1051
- fs.chmodSync(filePath, '755');
1052
- }
1053
- result.created.files.push(".claude/helpers/" + name);
1054
- }
1055
- else {
1056
- result.skipped.push(".claude/helpers/" + name);
1057
- }
918
+ else {
919
+ result.skipped.push(`.claude/helpers/${file}`);
1058
920
  }
1059
- return [2 /*return*/];
1060
- });
1061
- });
921
+ }
922
+ if (copiedCount > 0) {
923
+ return; // Skip generating if we copied from source
924
+ }
925
+ }
926
+ // Fall back to generating helpers if source not available
927
+ const helpers = {
928
+ 'pre-commit': generatePreCommitHook(),
929
+ 'post-commit': generatePostCommitHook(),
930
+ 'session.js': generateSessionManager(),
931
+ 'router.js': generateAgentRouter(),
932
+ 'memory.js': generateMemoryHelper(),
933
+ 'hook-handler.cjs': generateHookHandler(),
934
+ 'intelligence.cjs': generateIntelligenceStub(),
935
+ 'auto-memory-hook.mjs': generateAutoMemoryHook(),
936
+ };
937
+ for (const [name, content] of Object.entries(helpers)) {
938
+ const filePath = path.join(helpersDir, name);
939
+ if (!fs.existsSync(filePath) || options.force) {
940
+ fs.writeFileSync(filePath, content, 'utf-8');
941
+ // Make shell scripts executable
942
+ if (!name.endsWith('.js')) {
943
+ fs.chmodSync(filePath, '755');
944
+ }
945
+ result.created.files.push(`.claude/helpers/${name}`);
946
+ }
947
+ else {
948
+ result.skipped.push(`.claude/helpers/${name}`);
949
+ }
950
+ }
1062
951
  }
1063
952
  /**
1064
953
  * Find source .claude directory for statusline files
1065
954
  */
1066
955
  function findSourceClaudeDir(sourceBaseDir) {
1067
- var possiblePaths = [];
956
+ const possiblePaths = [];
1068
957
  // If explicit source base directory is provided, check it first
1069
958
  if (sourceBaseDir) {
1070
959
  possiblePaths.push(path.join(sourceBaseDir, '.claude'));
1071
960
  }
1072
961
  // IMPORTANT: Check the package's own .claude directory
1073
962
  // Go up 3 levels: dist/src/init -> dist/src -> dist -> root
1074
- var packageRoot = path.resolve(__dirname, '..', '..', '..');
1075
- var packageClaude = path.join(packageRoot, '.claude');
963
+ const packageRoot = path.resolve(__dirname, '..', '..', '..');
964
+ const packageClaude = path.join(packageRoot, '.claude');
1076
965
  if (fs.existsSync(packageClaude)) {
1077
966
  possiblePaths.unshift(packageClaude); // Add to beginning (highest priority)
1078
967
  }
1079
968
  // From dist/src/init -> go up to project root
1080
- var currentDir = __dirname;
1081
- for (var i = 0; i < 10; i++) {
1082
- var parentDir = path.dirname(currentDir);
1083
- var claudePath = path.join(parentDir, '.claude');
969
+ let currentDir = __dirname;
970
+ for (let i = 0; i < 10; i++) {
971
+ const parentDir = path.dirname(currentDir);
972
+ const claudePath = path.join(parentDir, '.claude');
1084
973
  if (fs.existsSync(claudePath)) {
1085
974
  possiblePaths.push(claudePath);
1086
975
  }
1087
976
  currentDir = parentDir;
1088
977
  }
1089
- for (var _i = 0, possiblePaths_2 = possiblePaths; _i < possiblePaths_2.length; _i++) {
1090
- var p = possiblePaths_2[_i];
978
+ for (const p of possiblePaths) {
1091
979
  if (fs.existsSync(p)) {
1092
980
  return p;
1093
981
  }
@@ -1097,235 +985,661 @@ function findSourceClaudeDir(sourceBaseDir) {
1097
985
  /**
1098
986
  * Write statusline configuration
1099
987
  */
1100
- function writeStatusline(targetDir, options, result) {
1101
- return __awaiter(this, void 0, Promise, function () {
1102
- var claudeDir, helpersDir, sourceClaudeDir, advancedStatuslineFiles, _i, advancedStatuslineFiles_1, file, sourcePath, destPath, statuslineScript, statuslinePath;
1103
- return __generator(this, function (_a) {
1104
- claudeDir = path.join(targetDir, '.claude');
1105
- helpersDir = path.join(targetDir, '.claude', 'helpers');
1106
- sourceClaudeDir = findSourceClaudeDir(options.sourceBaseDir);
1107
- advancedStatuslineFiles = [
1108
- { src: 'statusline.sh', dest: 'statusline.sh', dir: claudeDir },
1109
- { src: 'statusline.mjs', dest: 'statusline.mjs', dir: claudeDir },
1110
- ];
1111
- if (sourceClaudeDir) {
1112
- for (_i = 0, advancedStatuslineFiles_1 = advancedStatuslineFiles; _i < advancedStatuslineFiles_1.length; _i++) {
1113
- file = advancedStatuslineFiles_1[_i];
1114
- sourcePath = path.join(sourceClaudeDir, file.src);
1115
- destPath = path.join(file.dir, file.dest);
1116
- if (fs.existsSync(sourcePath)) {
1117
- if (!fs.existsSync(destPath) || options.force) {
1118
- fs.copyFileSync(sourcePath, destPath);
1119
- // Make shell scripts and mjs executable
1120
- if (file.src.endsWith('.sh') || file.src.endsWith('.mjs')) {
1121
- fs.chmodSync(destPath, '755');
1122
- }
1123
- result.created.files.push(".claude/" + file.dest);
1124
- }
1125
- else {
1126
- result.skipped.push(".claude/" + file.dest);
1127
- }
988
+ async function writeStatusline(targetDir, options, result) {
989
+ const claudeDir = path.join(targetDir, '.claude');
990
+ const helpersDir = path.join(targetDir, '.claude', 'helpers');
991
+ // Find source .claude directory (works for npm package and local dev)
992
+ const sourceClaudeDir = findSourceClaudeDir(options.sourceBaseDir);
993
+ // Try to copy existing advanced statusline files from source
994
+ const advancedStatuslineFiles = [
995
+ { src: 'statusline.sh', dest: 'statusline.sh', dir: claudeDir },
996
+ { src: 'statusline.mjs', dest: 'statusline.mjs', dir: claudeDir },
997
+ ];
998
+ if (sourceClaudeDir) {
999
+ for (const file of advancedStatuslineFiles) {
1000
+ const sourcePath = path.join(sourceClaudeDir, file.src);
1001
+ const destPath = path.join(file.dir, file.dest);
1002
+ if (fs.existsSync(sourcePath)) {
1003
+ if (!fs.existsSync(destPath) || options.force) {
1004
+ fs.copyFileSync(sourcePath, destPath);
1005
+ // Make shell scripts and mjs executable
1006
+ if (file.src.endsWith('.sh') || file.src.endsWith('.mjs')) {
1007
+ fs.chmodSync(destPath, '755');
1128
1008
  }
1009
+ result.created.files.push(`.claude/${file.dest}`);
1010
+ }
1011
+ else {
1012
+ result.skipped.push(`.claude/${file.dest}`);
1129
1013
  }
1130
1014
  }
1131
- statuslineScript = generateStatuslineScript(options);
1132
- statuslinePath = path.join(helpersDir, 'statusline.cjs');
1133
- fs.writeFileSync(statuslinePath, statuslineScript, 'utf-8');
1134
- result.created.files.push('.claude/helpers/statusline.cjs');
1135
- return [2 /*return*/];
1136
- });
1137
- });
1015
+ }
1016
+ }
1017
+ // ALWAYS generate statusline.cjs the generated version includes AgentDB
1018
+ // vectors/size, tests, ADRs, hooks, and integration stats that the
1019
+ // pre-installed static copy in the npm package lacks.
1020
+ // This must overwrite any copy from writeHelpers() which copies the legacy file.
1021
+ const statuslineScript = generateStatuslineScript(options);
1022
+ const statuslinePath = path.join(helpersDir, 'statusline.cjs');
1023
+ fs.writeFileSync(statuslinePath, statuslineScript, 'utf-8');
1024
+ result.created.files.push('.claude/helpers/statusline.cjs');
1138
1025
  }
1139
1026
  /**
1140
1027
  * Write runtime configuration (.claude-flow/)
1141
1028
  */
1142
- function writeRuntimeConfig(targetDir, options, result) {
1143
- var _a, _b, _c;
1144
- return __awaiter(this, void 0, Promise, function () {
1145
- var configPath, config, gitignorePath, gitignore;
1146
- return __generator(this, function (_d) {
1147
- switch (_d.label) {
1148
- case 0:
1149
- configPath = path.join(targetDir, '.claude-flow', 'config.yaml');
1150
- if (fs.existsSync(configPath) && !options.force) {
1151
- result.skipped.push('.claude-flow/config.yaml');
1152
- return [2 /*return*/];
1153
- }
1154
- config = "# RuFlo V3 Runtime Configuration\n# Generated: " + new Date().toISOString() + "\n\nversion: \"3.0.0\"\n\nswarm:\n topology: " + options.runtime.topology + "\n maxAgents: " + options.runtime.maxAgents + "\n autoScale: true\n coordinationStrategy: consensus\n\nmemory:\n backend: " + options.runtime.memoryBackend + "\n enableHNSW: " + options.runtime.enableHNSW + "\n persistPath: .claude-flow/data\n cacheSize: 100\n # ADR-049: Self-Learning Memory\n learningBridge:\n enabled: " + ((_a = options.runtime.enableLearningBridge) !== null && _a !== void 0 ? _a : options.runtime.enableNeural) + "\n sonaMode: balanced\n confidenceDecayRate: 0.005\n accessBoostAmount: 0.03\n consolidationThreshold: 10\n memoryGraph:\n enabled: " + ((_b = options.runtime.enableMemoryGraph) !== null && _b !== void 0 ? _b : true) + "\n pageRankDamping: 0.85\n maxNodes: 5000\n similarityThreshold: 0.8\n agentScopes:\n enabled: " + ((_c = options.runtime.enableAgentScopes) !== null && _c !== void 0 ? _c : true) + "\n defaultScope: project\n\nneural:\n enabled: " + options.runtime.enableNeural + "\n modelPath: .claude-flow/neural\n\nhooks:\n enabled: true\n autoExecute: true\n\nmcp:\n autoStart: " + options.mcp.autoStart + "\n port: " + options.mcp.port + "\n";
1155
- fs.writeFileSync(configPath, config, 'utf-8');
1156
- result.created.files.push('.claude-flow/config.yaml');
1157
- gitignorePath = path.join(targetDir, '.claude-flow', '.gitignore');
1158
- gitignore = "# Claude Flow runtime files\ndata/\nlogs/\nsessions/\nneural/\n*.log\n*.tmp\n";
1159
- if (!fs.existsSync(gitignorePath) || options.force) {
1160
- fs.writeFileSync(gitignorePath, gitignore, 'utf-8');
1161
- result.created.files.push('.claude-flow/.gitignore');
1162
- }
1163
- // Write CAPABILITIES.md with full system overview
1164
- return [4 /*yield*/, writeCapabilitiesDoc(targetDir, options, result)];
1165
- case 1:
1166
- // Write CAPABILITIES.md with full system overview
1167
- _d.sent();
1168
- return [2 /*return*/];
1169
- }
1170
- });
1171
- });
1029
+ async function writeRuntimeConfig(targetDir, options, result) {
1030
+ const configPath = path.join(targetDir, '.claude-flow', 'config.yaml');
1031
+ if (fs.existsSync(configPath) && !options.force) {
1032
+ result.skipped.push('.claude-flow/config.yaml');
1033
+ return;
1034
+ }
1035
+ const config = `# RuFlo V3 Runtime Configuration
1036
+ # Generated: ${new Date().toISOString()}
1037
+
1038
+ version: "3.0.0"
1039
+
1040
+ swarm:
1041
+ topology: ${options.runtime.topology}
1042
+ maxAgents: ${options.runtime.maxAgents}
1043
+ autoScale: true
1044
+ coordinationStrategy: consensus
1045
+
1046
+ memory:
1047
+ backend: ${options.runtime.memoryBackend}
1048
+ enableHNSW: ${options.runtime.enableHNSW}
1049
+ persistPath: .claude-flow/data
1050
+ cacheSize: 100
1051
+ # ADR-049: Self-Learning Memory
1052
+ learningBridge:
1053
+ enabled: ${options.runtime.enableLearningBridge ?? options.runtime.enableNeural}
1054
+ sonaMode: balanced
1055
+ confidenceDecayRate: 0.005
1056
+ accessBoostAmount: 0.03
1057
+ consolidationThreshold: 10
1058
+ memoryGraph:
1059
+ enabled: ${options.runtime.enableMemoryGraph ?? true}
1060
+ pageRankDamping: 0.85
1061
+ maxNodes: 5000
1062
+ similarityThreshold: 0.8
1063
+ agentScopes:
1064
+ enabled: ${options.runtime.enableAgentScopes ?? true}
1065
+ defaultScope: project
1066
+
1067
+ neural:
1068
+ enabled: ${options.runtime.enableNeural}
1069
+ modelPath: .claude-flow/neural
1070
+
1071
+ hooks:
1072
+ enabled: true
1073
+ autoExecute: true
1074
+
1075
+ mcp:
1076
+ autoStart: ${options.mcp.autoStart}
1077
+ port: ${options.mcp.port}
1078
+ `;
1079
+ fs.writeFileSync(configPath, config, 'utf-8');
1080
+ result.created.files.push('.claude-flow/config.yaml');
1081
+ // Write .gitignore
1082
+ const gitignorePath = path.join(targetDir, '.claude-flow', '.gitignore');
1083
+ const gitignore = `# Claude Flow runtime files
1084
+ data/
1085
+ logs/
1086
+ sessions/
1087
+ neural/
1088
+ *.log
1089
+ *.tmp
1090
+ `;
1091
+ if (!fs.existsSync(gitignorePath) || options.force) {
1092
+ fs.writeFileSync(gitignorePath, gitignore, 'utf-8');
1093
+ result.created.files.push('.claude-flow/.gitignore');
1094
+ }
1095
+ // Write CAPABILITIES.md with full system overview
1096
+ await writeCapabilitiesDoc(targetDir, options, result);
1172
1097
  }
1173
1098
  /**
1174
1099
  * Write initial metrics files for statusline
1175
1100
  * Creates baseline data so statusline shows meaningful state instead of all zeros
1176
1101
  */
1177
- function writeInitialMetrics(targetDir, options, result) {
1178
- return __awaiter(this, void 0, Promise, function () {
1179
- var metricsDir, learningDir, securityDir, _i, _a, dir, progressPath, progress, activityPath, activity, learningPath, learning, auditPath, audit;
1180
- return __generator(this, function (_b) {
1181
- metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
1182
- learningDir = path.join(targetDir, '.claude-flow', 'learning');
1183
- securityDir = path.join(targetDir, '.claude-flow', 'security');
1184
- // Ensure directories exist
1185
- for (_i = 0, _a = [metricsDir, learningDir, securityDir]; _i < _a.length; _i++) {
1186
- dir = _a[_i];
1187
- if (!fs.existsSync(dir)) {
1188
- fs.mkdirSync(dir, { recursive: true });
1189
- }
1190
- }
1191
- progressPath = path.join(metricsDir, 'v3-progress.json');
1192
- if (!fs.existsSync(progressPath) || options.force) {
1193
- progress = {
1194
- version: '3.0.0',
1195
- initialized: new Date().toISOString(),
1196
- domains: {
1197
- completed: 0,
1198
- total: 5,
1199
- status: 'INITIALIZING'
1200
- },
1201
- ddd: {
1202
- progress: 0,
1203
- modules: 0,
1204
- totalFiles: 0,
1205
- totalLines: 0
1206
- },
1207
- swarm: {
1208
- activeAgents: 0,
1209
- maxAgents: options.runtime.maxAgents,
1210
- topology: options.runtime.topology
1211
- },
1212
- learning: {
1213
- status: 'READY',
1214
- patternsLearned: 0,
1215
- sessionsCompleted: 0
1216
- },
1217
- _note: 'Metrics will update as you use Ruflo. Run: npx ruflo@latest daemon start'
1218
- };
1219
- fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
1220
- result.created.files.push('.claude-flow/metrics/v3-progress.json');
1221
- }
1222
- activityPath = path.join(metricsDir, 'swarm-activity.json');
1223
- if (!fs.existsSync(activityPath) || options.force) {
1224
- activity = {
1225
- timestamp: new Date().toISOString(),
1226
- processes: {
1227
- agentic_flow: 0,
1228
- mcp_server: 0,
1229
- estimated_agents: 0
1230
- },
1231
- swarm: {
1232
- active: false,
1233
- agent_count: 0,
1234
- coordination_active: false
1235
- },
1236
- integration: {
1237
- agentic_flow_active: false,
1238
- mcp_active: false
1239
- },
1240
- _initialized: true
1241
- };
1242
- fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
1243
- result.created.files.push('.claude-flow/metrics/swarm-activity.json');
1244
- }
1245
- learningPath = path.join(metricsDir, 'learning.json');
1246
- if (!fs.existsSync(learningPath) || options.force) {
1247
- learning = {
1248
- initialized: new Date().toISOString(),
1249
- routing: {
1250
- accuracy: 0,
1251
- decisions: 0
1252
- },
1253
- patterns: {
1254
- shortTerm: 0,
1255
- longTerm: 0,
1256
- quality: 0
1257
- },
1258
- sessions: {
1259
- total: 0,
1260
- current: null
1261
- },
1262
- _note: 'Intelligence grows as you use Ruflo'
1263
- };
1264
- fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
1265
- result.created.files.push('.claude-flow/metrics/learning.json');
1266
- }
1267
- auditPath = path.join(securityDir, 'audit-status.json');
1268
- if (!fs.existsSync(auditPath) || options.force) {
1269
- audit = {
1270
- initialized: new Date().toISOString(),
1271
- status: 'PENDING',
1272
- cvesFixed: 0,
1273
- totalCves: 3,
1274
- lastScan: null,
1275
- _note: 'Run: npx @claude-flow/cli@latest security scan'
1276
- };
1277
- fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
1278
- result.created.files.push('.claude-flow/security/audit-status.json');
1279
- }
1280
- return [2 /*return*/];
1281
- });
1282
- });
1102
+ async function writeInitialMetrics(targetDir, options, result) {
1103
+ const metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
1104
+ const learningDir = path.join(targetDir, '.claude-flow', 'learning');
1105
+ const securityDir = path.join(targetDir, '.claude-flow', 'security');
1106
+ // Ensure directories exist
1107
+ for (const dir of [metricsDir, learningDir, securityDir]) {
1108
+ if (!fs.existsSync(dir)) {
1109
+ fs.mkdirSync(dir, { recursive: true });
1110
+ }
1111
+ }
1112
+ // Create initial v3-progress.json
1113
+ const progressPath = path.join(metricsDir, 'v3-progress.json');
1114
+ if (!fs.existsSync(progressPath) || options.force) {
1115
+ const progress = {
1116
+ version: '3.0.0',
1117
+ initialized: new Date().toISOString(),
1118
+ domains: {
1119
+ completed: 0,
1120
+ total: 5,
1121
+ status: 'INITIALIZING'
1122
+ },
1123
+ ddd: {
1124
+ progress: 0,
1125
+ modules: 0,
1126
+ totalFiles: 0,
1127
+ totalLines: 0
1128
+ },
1129
+ swarm: {
1130
+ activeAgents: 0,
1131
+ maxAgents: options.runtime.maxAgents,
1132
+ topology: options.runtime.topology
1133
+ },
1134
+ learning: {
1135
+ status: 'READY',
1136
+ patternsLearned: 0,
1137
+ sessionsCompleted: 0
1138
+ },
1139
+ _note: 'Metrics will update as you use Ruflo. Run: npx ruflo@latest daemon start'
1140
+ };
1141
+ fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
1142
+ result.created.files.push('.claude-flow/metrics/v3-progress.json');
1143
+ }
1144
+ // Create initial swarm-activity.json
1145
+ const activityPath = path.join(metricsDir, 'swarm-activity.json');
1146
+ if (!fs.existsSync(activityPath) || options.force) {
1147
+ const activity = {
1148
+ timestamp: new Date().toISOString(),
1149
+ processes: {
1150
+ agentic_flow: 0,
1151
+ mcp_server: 0,
1152
+ estimated_agents: 0
1153
+ },
1154
+ swarm: {
1155
+ active: false,
1156
+ agent_count: 0,
1157
+ coordination_active: false
1158
+ },
1159
+ integration: {
1160
+ agentic_flow_active: false,
1161
+ mcp_active: false
1162
+ },
1163
+ _initialized: true
1164
+ };
1165
+ fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
1166
+ result.created.files.push('.claude-flow/metrics/swarm-activity.json');
1167
+ }
1168
+ // Create initial learning.json
1169
+ const learningPath = path.join(metricsDir, 'learning.json');
1170
+ if (!fs.existsSync(learningPath) || options.force) {
1171
+ const learning = {
1172
+ initialized: new Date().toISOString(),
1173
+ routing: {
1174
+ accuracy: 0,
1175
+ decisions: 0
1176
+ },
1177
+ patterns: {
1178
+ shortTerm: 0,
1179
+ longTerm: 0,
1180
+ quality: 0
1181
+ },
1182
+ sessions: {
1183
+ total: 0,
1184
+ current: null
1185
+ },
1186
+ _note: 'Intelligence grows as you use Ruflo'
1187
+ };
1188
+ fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
1189
+ result.created.files.push('.claude-flow/metrics/learning.json');
1190
+ }
1191
+ // Create initial audit-status.json
1192
+ const auditPath = path.join(securityDir, 'audit-status.json');
1193
+ if (!fs.existsSync(auditPath) || options.force) {
1194
+ const audit = {
1195
+ initialized: new Date().toISOString(),
1196
+ status: 'PENDING',
1197
+ cvesFixed: 0,
1198
+ totalCves: 3,
1199
+ lastScan: null,
1200
+ _note: 'Run: npx @claude-flow/cli@latest security scan'
1201
+ };
1202
+ fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
1203
+ result.created.files.push('.claude-flow/security/audit-status.json');
1204
+ }
1283
1205
  }
1284
1206
  /**
1285
1207
  * Write CAPABILITIES.md - comprehensive overview of all Ruflo features
1286
1208
  */
1287
- function writeCapabilitiesDoc(targetDir, options, result) {
1288
- return __awaiter(this, void 0, Promise, function () {
1289
- var capabilitiesPath, capabilities;
1290
- return __generator(this, function (_a) {
1291
- capabilitiesPath = path.join(targetDir, '.claude-flow', 'CAPABILITIES.md');
1292
- if (fs.existsSync(capabilitiesPath) && !options.force) {
1293
- result.skipped.push('.claude-flow/CAPABILITIES.md');
1294
- return [2 /*return*/];
1295
- }
1296
- capabilities = "# RuFlo V3 - Complete Capabilities Reference\n> Generated: " + new Date().toISOString() + "\n> Full documentation: https://github.com/ruvnet/claude-flow\n\n## \uD83D\uDCCB Table of Contents\n\n1. [Overview](#overview)\n2. [Swarm Orchestration](#swarm-orchestration)\n3. [Available Agents (60+)](#available-agents)\n4. [CLI Commands (26 Commands, 140+ Subcommands)](#cli-commands)\n5. [Hooks System (27 Hooks + 12 Workers)](#hooks-system)\n6. [Memory & Intelligence (RuVector)](#memory--intelligence)\n7. [Hive-Mind Consensus](#hive-mind-consensus)\n8. [Performance Targets](#performance-targets)\n9. [Integration Ecosystem](#integration-ecosystem)\n\n---\n\n## Overview\n\nRuFlo V3 is a domain-driven design architecture for multi-agent AI coordination with:\n\n- **15-Agent Swarm Coordination** with hierarchical and mesh topologies\n- **HNSW Vector Search** - 150x-12,500x faster pattern retrieval\n- **SONA Neural Learning** - Self-optimizing with <0.05ms adaptation\n- **Byzantine Fault Tolerance** - Queen-led consensus mechanisms\n- **MCP Server Integration** - Model Context Protocol support\n\n### Current Configuration\n| Setting | Value |\n|---------|-------|\n| Topology | " + options.runtime.topology + " |\n| Max Agents | " + options.runtime.maxAgents + " |\n| Memory Backend | " + options.runtime.memoryBackend + " |\n| HNSW Indexing | " + (options.runtime.enableHNSW ? 'Enabled' : 'Disabled') + " |\n| Neural Learning | " + (options.runtime.enableNeural ? 'Enabled' : 'Disabled') + " |\n| LearningBridge | " + (options.runtime.enableLearningBridge ? 'Enabled (SONA + ReasoningBank)' : 'Disabled') + " |\n| Knowledge Graph | " + (options.runtime.enableMemoryGraph ? 'Enabled (PageRank + Communities)' : 'Disabled') + " |\n| Agent Scopes | " + (options.runtime.enableAgentScopes ? 'Enabled (project/local/user)' : 'Disabled') + " |\n\n---\n\n## Swarm Orchestration\n\n### Topologies\n| Topology | Description | Best For |\n|----------|-------------|----------|\n| `hierarchical` | Queen controls workers directly | Anti-drift, tight control |\n| `mesh` | Fully connected peer network | Distributed tasks |\n| `hierarchical-mesh` | V3 hybrid (recommended) | 10+ agents |\n| `ring` | Circular communication | Sequential workflows |\n| `star` | Central coordinator | Simple coordination |\n| `adaptive` | Dynamic based on load | Variable workloads |\n\n### Strategies\n- `balanced` - Even distribution across agents\n- `specialized` - Clear roles, no overlap (anti-drift)\n- `adaptive` - Dynamic task routing\n\n### Quick Commands\n```bash\n# Initialize swarm\nnpx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized\n\n# Check status\nnpx @claude-flow/cli@latest swarm status\n\n# Monitor activity\nnpx @claude-flow/cli@latest swarm monitor\n```\n\n---\n\n## Available Agents\n\n### Core Development (5)\n`coder`, `reviewer`, `tester`, `planner`, `researcher`\n\n### V3 Specialized (4)\n`security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`\n\n### Swarm Coordination (5)\n`hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`\n\n### Consensus & Distributed (7)\n`byzantine-coordinator`, `raft-manager`, `gossip-coordinator`, `consensus-builder`, `crdt-synchronizer`, `quorum-manager`, `security-manager`\n\n### Performance & Optimization (5)\n`perf-analyzer`, `performance-benchmarker`, `task-orchestrator`, `memory-coordinator`, `smart-agent`\n\n### GitHub & Repository (9)\n`github-modes`, `pr-manager`, `code-review-swarm`, `issue-tracker`, `release-manager`, `workflow-automation`, `project-board-sync`, `repo-architect`, `multi-repo-swarm`\n\n### SPARC Methodology (6)\n`sparc-coord`, `sparc-coder`, `specification`, `pseudocode`, `architecture`, `refinement`\n\n### Specialized Development (8)\n`backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`, `api-docs`, `system-architect`, `code-analyzer`, `base-template-generator`\n\n### Testing & Validation (2)\n`tdd-london-swarm`, `production-validator`\n\n### Agent Routing by Task\n| Task Type | Recommended Agents | Topology |\n|-----------|-------------------|----------|\n| Bug Fix | researcher, coder, tester | mesh |\n| New Feature | coordinator, architect, coder, tester, reviewer | hierarchical |\n| Refactoring | architect, coder, reviewer | mesh |\n| Performance | researcher, perf-engineer, coder | hierarchical |\n| Security | security-architect, auditor, reviewer | hierarchical |\n| Docs | researcher, api-docs | mesh |\n\n---\n\n## CLI Commands\n\n### Core Commands (12)\n| Command | Subcommands | Description |\n|---------|-------------|-------------|\n| `init` | 4 | Project initialization |\n| `agent` | 8 | Agent lifecycle management |\n| `swarm` | 6 | Multi-agent coordination |\n| `memory` | 11 | AgentDB with HNSW search |\n| `mcp` | 9 | MCP server management |\n| `task` | 6 | Task assignment |\n| `session` | 7 | Session persistence |\n| `config` | 7 | Configuration |\n| `status` | 3 | System monitoring |\n| `workflow` | 6 | Workflow templates |\n| `hooks` | 17 | Self-learning hooks |\n| `hive-mind` | 6 | Consensus coordination |\n\n### Advanced Commands (14)\n| Command | Subcommands | Description |\n|---------|-------------|-------------|\n| `daemon` | 5 | Background workers |\n| `neural` | 5 | Pattern training |\n| `security` | 6 | Security scanning |\n| `performance` | 5 | Profiling & benchmarks |\n| `providers` | 5 | AI provider config |\n| `plugins` | 5 | Plugin management |\n| `deployment` | 5 | Deploy management |\n| `embeddings` | 4 | Vector embeddings |\n| `claims` | 4 | Authorization |\n| `migrate` | 5 | V2\u2192V3 migration |\n| `process` | 4 | Process management |\n| `doctor` | 1 | Health diagnostics |\n| `completions` | 4 | Shell completions |\n\n### Example Commands\n```bash\n# Initialize\nnpx @claude-flow/cli@latest init --wizard\n\n# Spawn agent\nnpx @claude-flow/cli@latest agent spawn -t coder --name my-coder\n\n# Memory operations\nnpx @claude-flow/cli@latest memory store --key \"pattern\" --value \"data\" --namespace patterns\nnpx @claude-flow/cli@latest memory search --query \"authentication\"\n\n# Diagnostics\nnpx @claude-flow/cli@latest doctor --fix\n```\n\n---\n\n## Hooks System\n\n### 27 Available Hooks\n\n#### Core Hooks (6)\n| Hook | Description |\n|------|-------------|\n| `pre-edit` | Context before file edits |\n| `post-edit` | Record edit outcomes |\n| `pre-command` | Risk assessment |\n| `post-command` | Command metrics |\n| `pre-task` | Task start + agent suggestions |\n| `post-task` | Task completion learning |\n\n#### Session Hooks (4)\n| Hook | Description |\n|------|-------------|\n| `session-start` | Start/restore session |\n| `session-end` | Persist state |\n| `session-restore` | Restore previous |\n| `notify` | Cross-agent notifications |\n\n#### Intelligence Hooks (5)\n| Hook | Description |\n|------|-------------|\n| `route` | Optimal agent routing |\n| `explain` | Routing decisions |\n| `pretrain` | Bootstrap intelligence |\n| `build-agents` | Generate configs |\n| `transfer` | Pattern transfer |\n\n#### Coverage Hooks (3)\n| Hook | Description |\n|------|-------------|\n| `coverage-route` | Coverage-based routing |\n| `coverage-suggest` | Improvement suggestions |\n| `coverage-gaps` | Gap analysis |\n\n### 12 Background Workers\n| Worker | Priority | Purpose |\n|--------|----------|---------|\n| `ultralearn` | normal | Deep knowledge |\n| `optimize` | high | Performance |\n| `consolidate` | low | Memory consolidation |\n| `predict` | normal | Predictive preload |\n| `audit` | critical | Security |\n| `map` | normal | Codebase mapping |\n| `preload` | low | Resource preload |\n| `deepdive` | normal | Deep analysis |\n| `document` | normal | Auto-docs |\n| `refactor` | normal | Suggestions |\n| `benchmark` | normal | Benchmarking |\n| `testgaps` | normal | Coverage gaps |\n\n---\n\n## Memory & Intelligence\n\n### RuVector Intelligence System\n- **SONA**: Self-Optimizing Neural Architecture (<0.05ms)\n- **MoE**: Mixture of Experts routing\n- **HNSW**: 150x-12,500x faster search\n- **EWC++**: Prevents catastrophic forgetting\n- **Flash Attention**: 2.49x-7.47x speedup\n- **Int8 Quantization**: 3.92x memory reduction\n\n### 4-Step Intelligence Pipeline\n1. **RETRIEVE** - HNSW pattern search\n2. **JUDGE** - Success/failure verdicts\n3. **DISTILL** - LoRA learning extraction\n4. **CONSOLIDATE** - EWC++ preservation\n\n### Self-Learning Memory (ADR-049)\n\n| Component | Status | Description |\n|-----------|--------|-------------|\n| **LearningBridge** | " + (options.runtime.enableLearningBridge ? '✅ Enabled' : '⏸ Disabled') + " | Connects insights to SONA/ReasoningBank neural pipeline |\n| **MemoryGraph** | " + (options.runtime.enableMemoryGraph ? '✅ Enabled' : '⏸ Disabled') + " | PageRank knowledge graph + community detection |\n| **AgentMemoryScope** | " + (options.runtime.enableAgentScopes ? '✅ Enabled' : '⏸ Disabled') + " | 3-scope agent memory (project/local/user) |\n\n**LearningBridge** - Insights trigger learning trajectories. Confidence evolves: +0.03 on access, -0.005/hour decay. Consolidation runs the JUDGE/DISTILL/CONSOLIDATE pipeline.\n\n**MemoryGraph** - Builds a knowledge graph from entry references. PageRank identifies influential insights. Communities group related knowledge. Graph-aware ranking blends vector + structural scores.\n\n**AgentMemoryScope** - Maps Claude Code 3-scope directories:\n- `project`: `<gitRoot>/.claude/agent-memory/<agent>/`\n- `local`: `<gitRoot>/.claude/agent-memory-local/<agent>/`\n- `user`: `~/.claude/agent-memory/<agent>/`\n\nHigh-confidence insights (>0.8) can transfer between agents.\n\n### Memory Commands\n```bash\n# Store pattern\nnpx @claude-flow/cli@latest memory store --key \"name\" --value \"data\" --namespace patterns\n\n# Semantic search\nnpx @claude-flow/cli@latest memory search --query \"authentication\"\n\n# List entries\nnpx @claude-flow/cli@latest memory list --namespace patterns\n\n# Initialize database\nnpx @claude-flow/cli@latest memory init --force\n```\n\n---\n\n## Hive-Mind Consensus\n\n### Queen Types\n| Type | Role |\n|------|------|\n| Strategic Queen | Long-term planning |\n| Tactical Queen | Execution coordination |\n| Adaptive Queen | Dynamic optimization |\n\n### Worker Types (8)\n`researcher`, `coder`, `analyst`, `tester`, `architect`, `reviewer`, `optimizer`, `documenter`\n\n### Consensus Mechanisms\n| Mechanism | Fault Tolerance | Use Case |\n|-----------|-----------------|----------|\n| `byzantine` | f < n/3 faulty | Adversarial |\n| `raft` | f < n/2 failed | Leader-based |\n| `gossip` | Eventually consistent | Large scale |\n| `crdt` | Conflict-free | Distributed |\n| `quorum` | Configurable | Flexible |\n\n### Hive-Mind Commands\n```bash\n# Initialize\nnpx @claude-flow/cli@latest hive-mind init --queen-type strategic\n\n# Status\nnpx @claude-flow/cli@latest hive-mind status\n\n# Spawn workers\nnpx @claude-flow/cli@latest hive-mind spawn --count 5 --type worker\n\n# Consensus\nnpx @claude-flow/cli@latest hive-mind consensus --propose \"task\"\n```\n\n---\n\n## Performance Targets\n\n| Metric | Target | Status |\n|--------|--------|--------|\n| HNSW Search | 150x-12,500x faster | \u2705 Implemented |\n| Memory Reduction | 50-75% | \u2705 Implemented (3.92x) |\n| SONA Integration | Pattern learning | \u2705 Implemented |\n| Flash Attention | 2.49x-7.47x | \uD83D\uDD04 In Progress |\n| MCP Response | <100ms | \u2705 Achieved |\n| CLI Startup | <500ms | \u2705 Achieved |\n| SONA Adaptation | <0.05ms | \uD83D\uDD04 In Progress |\n| Graph Build (1k) | <200ms | \u2705 2.78ms (71.9x headroom) |\n| PageRank (1k) | <100ms | \u2705 12.21ms (8.2x headroom) |\n| Insight Recording | <5ms/each | \u2705 0.12ms (41x headroom) |\n| Consolidation | <500ms | \u2705 0.26ms (1,955x headroom) |\n| Knowledge Transfer | <100ms | \u2705 1.25ms (80x headroom) |\n\n---\n\n## Integration Ecosystem\n\n### Integrated Packages\n| Package | Version | Purpose |\n|---------|---------|---------|\n| agentic-flow | 3.0.0-alpha.1 | Core coordination + ReasoningBank + Router |\n| agentdb | 3.0.0-alpha.10 | Vector database + 8 controllers |\n| @ruvector/attention | 0.1.3 | Flash attention |\n| @ruvector/sona | 0.1.5 | Neural learning |\n\n### Optional Integrations\n| Package | Command |\n|---------|---------|\n| ruv-swarm | `npx ruv-swarm mcp start` |\n| flow-nexus | `npx flow-nexus@latest mcp start` |\n| agentic-jujutsu | `npx agentic-jujutsu@latest` |\n\n### MCP Server Setup\n```bash\n# Add Ruflo MCP\nclaude mcp add ruflo -- npx -y ruflo@latest\n\n# Optional servers\nclaude mcp add ruv-swarm -- npx -y ruv-swarm mcp start\nclaude mcp add flow-nexus -- npx -y flow-nexus@latest mcp start\n```\n\n---\n\n## Quick Reference\n\n### Essential Commands\n```bash\n# Setup\nnpx ruflo@latest init --wizard\nnpx ruflo@latest daemon start\nnpx ruflo@latest doctor --fix\n\n# Swarm\nnpx ruflo@latest swarm init --topology hierarchical --max-agents 8\nnpx ruflo@latest swarm status\n\n# Agents\nnpx ruflo@latest agent spawn -t coder\nnpx ruflo@latest agent list\n\n# Memory\nnpx ruflo@latest memory search --query \"patterns\"\n\n# Hooks\nnpx ruflo@latest hooks pre-task --description \"task\"\nnpx ruflo@latest hooks worker dispatch --trigger optimize\n```\n\n### File Structure\n```\n.claude-flow/\n\u251C\u2500\u2500 config.yaml # Runtime configuration\n\u251C\u2500\u2500 CAPABILITIES.md # This file\n\u251C\u2500\u2500 data/ # Memory storage\n\u251C\u2500\u2500 logs/ # Operation logs\n\u251C\u2500\u2500 sessions/ # Session state\n\u251C\u2500\u2500 hooks/ # Custom hooks\n\u251C\u2500\u2500 agents/ # Agent configs\n\u2514\u2500\u2500 workflows/ # Workflow templates\n```\n\n---\n\n**Full Documentation**: https://github.com/ruvnet/claude-flow\n**Issues**: https://github.com/ruvnet/claude-flow/issues\n";
1297
- fs.writeFileSync(capabilitiesPath, capabilities, 'utf-8');
1298
- result.created.files.push('.claude-flow/CAPABILITIES.md');
1299
- return [2 /*return*/];
1300
- });
1301
- });
1209
+ async function writeCapabilitiesDoc(targetDir, options, result) {
1210
+ const capabilitiesPath = path.join(targetDir, '.claude-flow', 'CAPABILITIES.md');
1211
+ if (fs.existsSync(capabilitiesPath) && !options.force) {
1212
+ result.skipped.push('.claude-flow/CAPABILITIES.md');
1213
+ return;
1214
+ }
1215
+ const capabilities = `# RuFlo V3 - Complete Capabilities Reference
1216
+ > Generated: ${new Date().toISOString()}
1217
+ > Full documentation: https://github.com/ruvnet/claude-flow
1218
+
1219
+ ## 📋 Table of Contents
1220
+
1221
+ 1. [Overview](#overview)
1222
+ 2. [Swarm Orchestration](#swarm-orchestration)
1223
+ 3. [Available Agents (60+)](#available-agents)
1224
+ 4. [CLI Commands (26 Commands, 140+ Subcommands)](#cli-commands)
1225
+ 5. [Hooks System (27 Hooks + 12 Workers)](#hooks-system)
1226
+ 6. [Memory & Intelligence (RuVector)](#memory--intelligence)
1227
+ 7. [Hive-Mind Consensus](#hive-mind-consensus)
1228
+ 8. [Performance Targets](#performance-targets)
1229
+ 9. [Integration Ecosystem](#integration-ecosystem)
1230
+
1231
+ ---
1232
+
1233
+ ## Overview
1234
+
1235
+ RuFlo V3 is a domain-driven design architecture for multi-agent AI coordination with:
1236
+
1237
+ - **15-Agent Swarm Coordination** with hierarchical and mesh topologies
1238
+ - **HNSW Vector Search** - 150x-12,500x faster pattern retrieval
1239
+ - **SONA Neural Learning** - Self-optimizing with <0.05ms adaptation
1240
+ - **Byzantine Fault Tolerance** - Queen-led consensus mechanisms
1241
+ - **MCP Server Integration** - Model Context Protocol support
1242
+
1243
+ ### Current Configuration
1244
+ | Setting | Value |
1245
+ |---------|-------|
1246
+ | Topology | ${options.runtime.topology} |
1247
+ | Max Agents | ${options.runtime.maxAgents} |
1248
+ | Memory Backend | ${options.runtime.memoryBackend} |
1249
+ | HNSW Indexing | ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'} |
1250
+ | Neural Learning | ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'} |
1251
+ | LearningBridge | ${options.runtime.enableLearningBridge ? 'Enabled (SONA + ReasoningBank)' : 'Disabled'} |
1252
+ | Knowledge Graph | ${options.runtime.enableMemoryGraph ? 'Enabled (PageRank + Communities)' : 'Disabled'} |
1253
+ | Agent Scopes | ${options.runtime.enableAgentScopes ? 'Enabled (project/local/user)' : 'Disabled'} |
1254
+
1255
+ ---
1256
+
1257
+ ## Swarm Orchestration
1258
+
1259
+ ### Topologies
1260
+ | Topology | Description | Best For |
1261
+ |----------|-------------|----------|
1262
+ | \`hierarchical\` | Queen controls workers directly | Anti-drift, tight control |
1263
+ | \`mesh\` | Fully connected peer network | Distributed tasks |
1264
+ | \`hierarchical-mesh\` | V3 hybrid (recommended) | 10+ agents |
1265
+ | \`ring\` | Circular communication | Sequential workflows |
1266
+ | \`star\` | Central coordinator | Simple coordination |
1267
+ | \`adaptive\` | Dynamic based on load | Variable workloads |
1268
+
1269
+ ### Strategies
1270
+ - \`balanced\` - Even distribution across agents
1271
+ - \`specialized\` - Clear roles, no overlap (anti-drift)
1272
+ - \`adaptive\` - Dynamic task routing
1273
+
1274
+ ### Quick Commands
1275
+ \`\`\`bash
1276
+ # Initialize swarm
1277
+ npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized
1278
+
1279
+ # Check status
1280
+ npx @claude-flow/cli@latest swarm status
1281
+
1282
+ # Monitor activity
1283
+ npx @claude-flow/cli@latest swarm monitor
1284
+ \`\`\`
1285
+
1286
+ ---
1287
+
1288
+ ## Available Agents
1289
+
1290
+ ### Core Development (5)
1291
+ \`coder\`, \`reviewer\`, \`tester\`, \`planner\`, \`researcher\`
1292
+
1293
+ ### V3 Specialized (4)
1294
+ \`security-architect\`, \`security-auditor\`, \`memory-specialist\`, \`performance-engineer\`
1295
+
1296
+ ### Swarm Coordination (5)
1297
+ \`hierarchical-coordinator\`, \`mesh-coordinator\`, \`adaptive-coordinator\`, \`collective-intelligence-coordinator\`, \`swarm-memory-manager\`
1298
+
1299
+ ### Consensus & Distributed (7)
1300
+ \`byzantine-coordinator\`, \`raft-manager\`, \`gossip-coordinator\`, \`consensus-builder\`, \`crdt-synchronizer\`, \`quorum-manager\`, \`security-manager\`
1301
+
1302
+ ### Performance & Optimization (5)
1303
+ \`perf-analyzer\`, \`performance-benchmarker\`, \`task-orchestrator\`, \`memory-coordinator\`, \`smart-agent\`
1304
+
1305
+ ### GitHub & Repository (9)
1306
+ \`github-modes\`, \`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`, \`workflow-automation\`, \`project-board-sync\`, \`repo-architect\`, \`multi-repo-swarm\`
1307
+
1308
+ ### SPARC Methodology (6)
1309
+ \`sparc-coord\`, \`sparc-coder\`, \`specification\`, \`pseudocode\`, \`architecture\`, \`refinement\`
1310
+
1311
+ ### Specialized Development (8)
1312
+ \`backend-dev\`, \`mobile-dev\`, \`ml-developer\`, \`cicd-engineer\`, \`api-docs\`, \`system-architect\`, \`code-analyzer\`, \`base-template-generator\`
1313
+
1314
+ ### Testing & Validation (2)
1315
+ \`tdd-london-swarm\`, \`production-validator\`
1316
+
1317
+ ### Agent Routing by Task
1318
+ | Task Type | Recommended Agents | Topology |
1319
+ |-----------|-------------------|----------|
1320
+ | Bug Fix | researcher, coder, tester | mesh |
1321
+ | New Feature | coordinator, architect, coder, tester, reviewer | hierarchical |
1322
+ | Refactoring | architect, coder, reviewer | mesh |
1323
+ | Performance | researcher, perf-engineer, coder | hierarchical |
1324
+ | Security | security-architect, auditor, reviewer | hierarchical |
1325
+ | Docs | researcher, api-docs | mesh |
1326
+
1327
+ ---
1328
+
1329
+ ## CLI Commands
1330
+
1331
+ ### Core Commands (12)
1332
+ | Command | Subcommands | Description |
1333
+ |---------|-------------|-------------|
1334
+ | \`init\` | 4 | Project initialization |
1335
+ | \`agent\` | 8 | Agent lifecycle management |
1336
+ | \`swarm\` | 6 | Multi-agent coordination |
1337
+ | \`memory\` | 11 | AgentDB with HNSW search |
1338
+ | \`mcp\` | 9 | MCP server management |
1339
+ | \`task\` | 6 | Task assignment |
1340
+ | \`session\` | 7 | Session persistence |
1341
+ | \`config\` | 7 | Configuration |
1342
+ | \`status\` | 3 | System monitoring |
1343
+ | \`workflow\` | 6 | Workflow templates |
1344
+ | \`hooks\` | 17 | Self-learning hooks |
1345
+ | \`hive-mind\` | 6 | Consensus coordination |
1346
+
1347
+ ### Advanced Commands (14)
1348
+ | Command | Subcommands | Description |
1349
+ |---------|-------------|-------------|
1350
+ | \`daemon\` | 5 | Background workers |
1351
+ | \`neural\` | 5 | Pattern training |
1352
+ | \`security\` | 6 | Security scanning |
1353
+ | \`performance\` | 5 | Profiling & benchmarks |
1354
+ | \`providers\` | 5 | AI provider config |
1355
+ | \`plugins\` | 5 | Plugin management |
1356
+ | \`deployment\` | 5 | Deploy management |
1357
+ | \`embeddings\` | 4 | Vector embeddings |
1358
+ | \`claims\` | 4 | Authorization |
1359
+ | \`migrate\` | 5 | V2→V3 migration |
1360
+ | \`process\` | 4 | Process management |
1361
+ | \`doctor\` | 1 | Health diagnostics |
1362
+ | \`completions\` | 4 | Shell completions |
1363
+
1364
+ ### Example Commands
1365
+ \`\`\`bash
1366
+ # Initialize
1367
+ npx @claude-flow/cli@latest init --wizard
1368
+
1369
+ # Spawn agent
1370
+ npx @claude-flow/cli@latest agent spawn -t coder --name my-coder
1371
+
1372
+ # Memory operations
1373
+ npx @claude-flow/cli@latest memory store --key "pattern" --value "data" --namespace patterns
1374
+ npx @claude-flow/cli@latest memory search --query "authentication"
1375
+
1376
+ # Diagnostics
1377
+ npx @claude-flow/cli@latest doctor --fix
1378
+ \`\`\`
1379
+
1380
+ ---
1381
+
1382
+ ## Hooks System
1383
+
1384
+ ### 27 Available Hooks
1385
+
1386
+ #### Core Hooks (6)
1387
+ | Hook | Description |
1388
+ |------|-------------|
1389
+ | \`pre-edit\` | Context before file edits |
1390
+ | \`post-edit\` | Record edit outcomes |
1391
+ | \`pre-command\` | Risk assessment |
1392
+ | \`post-command\` | Command metrics |
1393
+ | \`pre-task\` | Task start + agent suggestions |
1394
+ | \`post-task\` | Task completion learning |
1395
+
1396
+ #### Session Hooks (4)
1397
+ | Hook | Description |
1398
+ |------|-------------|
1399
+ | \`session-start\` | Start/restore session |
1400
+ | \`session-end\` | Persist state |
1401
+ | \`session-restore\` | Restore previous |
1402
+ | \`notify\` | Cross-agent notifications |
1403
+
1404
+ #### Intelligence Hooks (5)
1405
+ | Hook | Description |
1406
+ |------|-------------|
1407
+ | \`route\` | Optimal agent routing |
1408
+ | \`explain\` | Routing decisions |
1409
+ | \`pretrain\` | Bootstrap intelligence |
1410
+ | \`build-agents\` | Generate configs |
1411
+ | \`transfer\` | Pattern transfer |
1412
+
1413
+ #### Coverage Hooks (3)
1414
+ | Hook | Description |
1415
+ |------|-------------|
1416
+ | \`coverage-route\` | Coverage-based routing |
1417
+ | \`coverage-suggest\` | Improvement suggestions |
1418
+ | \`coverage-gaps\` | Gap analysis |
1419
+
1420
+ ### 12 Background Workers
1421
+ | Worker | Priority | Purpose |
1422
+ |--------|----------|---------|
1423
+ | \`ultralearn\` | normal | Deep knowledge |
1424
+ | \`optimize\` | high | Performance |
1425
+ | \`consolidate\` | low | Memory consolidation |
1426
+ | \`predict\` | normal | Predictive preload |
1427
+ | \`audit\` | critical | Security |
1428
+ | \`map\` | normal | Codebase mapping |
1429
+ | \`preload\` | low | Resource preload |
1430
+ | \`deepdive\` | normal | Deep analysis |
1431
+ | \`document\` | normal | Auto-docs |
1432
+ | \`refactor\` | normal | Suggestions |
1433
+ | \`benchmark\` | normal | Benchmarking |
1434
+ | \`testgaps\` | normal | Coverage gaps |
1435
+
1436
+ ---
1437
+
1438
+ ## Memory & Intelligence
1439
+
1440
+ ### RuVector Intelligence System
1441
+ - **SONA**: Self-Optimizing Neural Architecture (<0.05ms)
1442
+ - **MoE**: Mixture of Experts routing
1443
+ - **HNSW**: 150x-12,500x faster search
1444
+ - **EWC++**: Prevents catastrophic forgetting
1445
+ - **Flash Attention**: 2.49x-7.47x speedup
1446
+ - **Int8 Quantization**: 3.92x memory reduction
1447
+
1448
+ ### 4-Step Intelligence Pipeline
1449
+ 1. **RETRIEVE** - HNSW pattern search
1450
+ 2. **JUDGE** - Success/failure verdicts
1451
+ 3. **DISTILL** - LoRA learning extraction
1452
+ 4. **CONSOLIDATE** - EWC++ preservation
1453
+
1454
+ ### Self-Learning Memory (ADR-049)
1455
+
1456
+ | Component | Status | Description |
1457
+ |-----------|--------|-------------|
1458
+ | **LearningBridge** | ${options.runtime.enableLearningBridge ? '✅ Enabled' : '⏸ Disabled'} | Connects insights to SONA/ReasoningBank neural pipeline |
1459
+ | **MemoryGraph** | ${options.runtime.enableMemoryGraph ? '✅ Enabled' : '⏸ Disabled'} | PageRank knowledge graph + community detection |
1460
+ | **AgentMemoryScope** | ${options.runtime.enableAgentScopes ? '✅ Enabled' : '⏸ Disabled'} | 3-scope agent memory (project/local/user) |
1461
+
1462
+ **LearningBridge** - Insights trigger learning trajectories. Confidence evolves: +0.03 on access, -0.005/hour decay. Consolidation runs the JUDGE/DISTILL/CONSOLIDATE pipeline.
1463
+
1464
+ **MemoryGraph** - Builds a knowledge graph from entry references. PageRank identifies influential insights. Communities group related knowledge. Graph-aware ranking blends vector + structural scores.
1465
+
1466
+ **AgentMemoryScope** - Maps Claude Code 3-scope directories:
1467
+ - \`project\`: \`<gitRoot>/.claude/agent-memory/<agent>/\`
1468
+ - \`local\`: \`<gitRoot>/.claude/agent-memory-local/<agent>/\`
1469
+ - \`user\`: \`~/.claude/agent-memory/<agent>/\`
1470
+
1471
+ High-confidence insights (>0.8) can transfer between agents.
1472
+
1473
+ ### Memory Commands
1474
+ \`\`\`bash
1475
+ # Store pattern
1476
+ npx @claude-flow/cli@latest memory store --key "name" --value "data" --namespace patterns
1477
+
1478
+ # Semantic search
1479
+ npx @claude-flow/cli@latest memory search --query "authentication"
1480
+
1481
+ # List entries
1482
+ npx @claude-flow/cli@latest memory list --namespace patterns
1483
+
1484
+ # Initialize database
1485
+ npx @claude-flow/cli@latest memory init --force
1486
+ \`\`\`
1487
+
1488
+ ---
1489
+
1490
+ ## Hive-Mind Consensus
1491
+
1492
+ ### Queen Types
1493
+ | Type | Role |
1494
+ |------|------|
1495
+ | Strategic Queen | Long-term planning |
1496
+ | Tactical Queen | Execution coordination |
1497
+ | Adaptive Queen | Dynamic optimization |
1498
+
1499
+ ### Worker Types (8)
1500
+ \`researcher\`, \`coder\`, \`analyst\`, \`tester\`, \`architect\`, \`reviewer\`, \`optimizer\`, \`documenter\`
1501
+
1502
+ ### Consensus Mechanisms
1503
+ | Mechanism | Fault Tolerance | Use Case |
1504
+ |-----------|-----------------|----------|
1505
+ | \`byzantine\` | f < n/3 faulty | Adversarial |
1506
+ | \`raft\` | f < n/2 failed | Leader-based |
1507
+ | \`gossip\` | Eventually consistent | Large scale |
1508
+ | \`crdt\` | Conflict-free | Distributed |
1509
+ | \`quorum\` | Configurable | Flexible |
1510
+
1511
+ ### Hive-Mind Commands
1512
+ \`\`\`bash
1513
+ # Initialize
1514
+ npx @claude-flow/cli@latest hive-mind init --queen-type strategic
1515
+
1516
+ # Status
1517
+ npx @claude-flow/cli@latest hive-mind status
1518
+
1519
+ # Spawn workers
1520
+ npx @claude-flow/cli@latest hive-mind spawn --count 5 --type worker
1521
+
1522
+ # Consensus
1523
+ npx @claude-flow/cli@latest hive-mind consensus --propose "task"
1524
+ \`\`\`
1525
+
1526
+ ---
1527
+
1528
+ ## Performance Targets
1529
+
1530
+ | Metric | Target | Status |
1531
+ |--------|--------|--------|
1532
+ | HNSW Search | 150x-12,500x faster | ✅ Implemented |
1533
+ | Memory Reduction | 50-75% | ✅ Implemented (3.92x) |
1534
+ | SONA Integration | Pattern learning | ✅ Implemented |
1535
+ | Flash Attention | 2.49x-7.47x | 🔄 In Progress |
1536
+ | MCP Response | <100ms | ✅ Achieved |
1537
+ | CLI Startup | <500ms | ✅ Achieved |
1538
+ | SONA Adaptation | <0.05ms | 🔄 In Progress |
1539
+ | Graph Build (1k) | <200ms | ✅ 2.78ms (71.9x headroom) |
1540
+ | PageRank (1k) | <100ms | ✅ 12.21ms (8.2x headroom) |
1541
+ | Insight Recording | <5ms/each | ✅ 0.12ms (41x headroom) |
1542
+ | Consolidation | <500ms | ✅ 0.26ms (1,955x headroom) |
1543
+ | Knowledge Transfer | <100ms | ✅ 1.25ms (80x headroom) |
1544
+
1545
+ ---
1546
+
1547
+ ## Integration Ecosystem
1548
+
1549
+ ### Integrated Packages
1550
+ | Package | Version | Purpose |
1551
+ |---------|---------|---------|
1552
+ | agentic-flow | 3.0.0-alpha.1 | Core coordination + ReasoningBank + Router |
1553
+ | agentdb | 3.0.0-alpha.10 | Vector database + 8 controllers |
1554
+ | @ruvector/attention | 0.1.3 | Flash attention |
1555
+ | @ruvector/sona | 0.1.5 | Neural learning |
1556
+
1557
+ ### Optional Integrations
1558
+ | Package | Command |
1559
+ |---------|---------|
1560
+ | ruv-swarm | \`npx ruv-swarm mcp start\` |
1561
+ | flow-nexus | \`npx flow-nexus@latest mcp start\` |
1562
+ | agentic-jujutsu | \`npx agentic-jujutsu@latest\` |
1563
+
1564
+ ### MCP Server Setup
1565
+ \`\`\`bash
1566
+ # Add Ruflo MCP
1567
+ claude mcp add ruflo -- npx -y ruflo@latest
1568
+
1569
+ # Optional servers
1570
+ claude mcp add ruv-swarm -- npx -y ruv-swarm mcp start
1571
+ claude mcp add flow-nexus -- npx -y flow-nexus@latest mcp start
1572
+ \`\`\`
1573
+
1574
+ ---
1575
+
1576
+ ## Quick Reference
1577
+
1578
+ ### Essential Commands
1579
+ \`\`\`bash
1580
+ # Setup
1581
+ npx ruflo@latest init --wizard
1582
+ npx ruflo@latest daemon start
1583
+ npx ruflo@latest doctor --fix
1584
+
1585
+ # Swarm
1586
+ npx ruflo@latest swarm init --topology hierarchical --max-agents 8
1587
+ npx ruflo@latest swarm status
1588
+
1589
+ # Agents
1590
+ npx ruflo@latest agent spawn -t coder
1591
+ npx ruflo@latest agent list
1592
+
1593
+ # Memory
1594
+ npx ruflo@latest memory search --query "patterns"
1595
+
1596
+ # Hooks
1597
+ npx ruflo@latest hooks pre-task --description "task"
1598
+ npx ruflo@latest hooks worker dispatch --trigger optimize
1599
+ \`\`\`
1600
+
1601
+ ### File Structure
1602
+ \`\`\`
1603
+ .claude-flow/
1604
+ ├── config.yaml # Runtime configuration
1605
+ ├── CAPABILITIES.md # This file
1606
+ ├── data/ # Memory storage
1607
+ ├── logs/ # Operation logs
1608
+ ├── sessions/ # Session state
1609
+ ├── hooks/ # Custom hooks
1610
+ ├── agents/ # Agent configs
1611
+ └── workflows/ # Workflow templates
1612
+ \`\`\`
1613
+
1614
+ ---
1615
+
1616
+ **Full Documentation**: https://github.com/ruvnet/claude-flow
1617
+ **Issues**: https://github.com/ruvnet/claude-flow/issues
1618
+ `;
1619
+ fs.writeFileSync(capabilitiesPath, capabilities, 'utf-8');
1620
+ result.created.files.push('.claude-flow/CAPABILITIES.md');
1302
1621
  }
1303
1622
  /**
1304
1623
  * Write CLAUDE.md with swarm guidance
1305
1624
  */
1306
- function writeClaudeMd(targetDir, options, result) {
1307
- return __awaiter(this, void 0, Promise, function () {
1308
- var claudeMdPath, inferredTemplate, content;
1309
- return __generator(this, function (_a) {
1310
- claudeMdPath = path.join(targetDir, 'CLAUDE.md');
1311
- if (fs.existsSync(claudeMdPath) && !options.force) {
1312
- result.skipped.push('CLAUDE.md');
1313
- return [2 /*return*/];
1314
- }
1315
- inferredTemplate = (!options.components.commands && !options.components.agents) ? 'minimal' : undefined;
1316
- content = generateClaudeMd(options, inferredTemplate);
1317
- fs.writeFileSync(claudeMdPath, content, 'utf-8');
1318
- result.created.files.push('CLAUDE.md');
1319
- return [2 /*return*/];
1320
- });
1321
- });
1625
+ async function writeClaudeMd(targetDir, options, result) {
1626
+ const claudeMdPath = path.join(targetDir, 'CLAUDE.md');
1627
+ if (fs.existsSync(claudeMdPath) && !options.force) {
1628
+ result.skipped.push('CLAUDE.md');
1629
+ return;
1630
+ }
1631
+ // Determine template: explicit option > infer from components > 'standard'
1632
+ const inferredTemplate = (!options.components.commands && !options.components.agents) ? 'minimal' : undefined;
1633
+ const content = generateClaudeMd(options, inferredTemplate);
1634
+ fs.writeFileSync(claudeMdPath, content, 'utf-8');
1635
+ result.created.files.push('CLAUDE.md');
1322
1636
  }
1323
1637
  /**
1324
1638
  * Find source directory for skills/commands/agents
1325
1639
  */
1326
1640
  function findSourceDir(type, sourceBaseDir) {
1327
1641
  // Build list of possible paths to check
1328
- var possiblePaths = [];
1642
+ const possiblePaths = [];
1329
1643
  // If explicit source base directory is provided, use it first
1330
1644
  if (sourceBaseDir) {
1331
1645
  possiblePaths.push(path.join(sourceBaseDir, '.claude', type));
@@ -1334,38 +1648,37 @@ function findSourceDir(type, sourceBaseDir) {
1334
1648
  // This is the primary path when running as an npm package
1335
1649
  // __dirname is typically /path/to/node_modules/@claude-flow/cli/dist/src/init
1336
1650
  // We need to go up 3 levels to reach the package root (dist/src/init -> dist/src -> dist -> root)
1337
- var packageRoot = path.resolve(__dirname, '..', '..', '..');
1338
- var packageDotClaude = path.join(packageRoot, '.claude', type);
1651
+ const packageRoot = path.resolve(__dirname, '..', '..', '..');
1652
+ const packageDotClaude = path.join(packageRoot, '.claude', type);
1339
1653
  if (fs.existsSync(packageDotClaude)) {
1340
1654
  possiblePaths.unshift(packageDotClaude); // Add to beginning (highest priority)
1341
1655
  }
1342
1656
  // From dist/src/init -> go up to project root
1343
- var distPath = __dirname;
1657
+ const distPath = __dirname;
1344
1658
  // Try to find the project root by looking for .claude directory
1345
- var currentDir = distPath;
1346
- for (var i = 0; i < 10; i++) {
1347
- var parentDir = path.dirname(currentDir);
1348
- var dotClaudePath = path.join(parentDir, '.claude', type);
1659
+ let currentDir = distPath;
1660
+ for (let i = 0; i < 10; i++) {
1661
+ const parentDir = path.dirname(currentDir);
1662
+ const dotClaudePath = path.join(parentDir, '.claude', type);
1349
1663
  if (fs.existsSync(dotClaudePath)) {
1350
1664
  possiblePaths.push(dotClaudePath);
1351
1665
  }
1352
1666
  currentDir = parentDir;
1353
1667
  }
1354
1668
  // Also check relative to process.cwd() for development
1355
- var cwdBased = [
1669
+ const cwdBased = [
1356
1670
  path.join(process.cwd(), '.claude', type),
1357
1671
  path.join(process.cwd(), '..', '.claude', type),
1358
1672
  path.join(process.cwd(), '..', '..', '.claude', type),
1359
1673
  ];
1360
- possiblePaths.push.apply(possiblePaths, cwdBased);
1674
+ possiblePaths.push(...cwdBased);
1361
1675
  // Check v2 directory for agents
1362
1676
  if (type === 'agents') {
1363
1677
  possiblePaths.push(path.join(process.cwd(), 'v2', '.claude', type), path.join(process.cwd(), '..', 'v2', '.claude', type));
1364
1678
  }
1365
1679
  // Plugin directory
1366
1680
  possiblePaths.push(path.join(process.cwd(), 'plugin', type), path.join(process.cwd(), '..', 'plugin', type));
1367
- for (var _i = 0, possiblePaths_3 = possiblePaths; _i < possiblePaths_3.length; _i++) {
1368
- var p = possiblePaths_3[_i];
1681
+ for (const p of possiblePaths) {
1369
1682
  if (fs.existsSync(p)) {
1370
1683
  return p;
1371
1684
  }
@@ -1377,11 +1690,10 @@ function findSourceDir(type, sourceBaseDir) {
1377
1690
  */
1378
1691
  function copyDirRecursive(src, dest) {
1379
1692
  fs.mkdirSync(dest, { recursive: true });
1380
- var entries = fs.readdirSync(src, { withFileTypes: true });
1381
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1382
- var entry = entries_1[_i];
1383
- var srcPath = path.join(src, entry.name);
1384
- var destPath = path.join(dest, entry.name);
1693
+ const entries = fs.readdirSync(src, { withFileTypes: true });
1694
+ for (const entry of entries) {
1695
+ const srcPath = path.join(src, entry.name);
1696
+ const destPath = path.join(dest, entry.name);
1385
1697
  if (entry.isDirectory()) {
1386
1698
  copyDirRecursive(srcPath, destPath);
1387
1699
  }
@@ -1394,11 +1706,10 @@ function copyDirRecursive(src, dest) {
1394
1706
  * Count files with extension in directory
1395
1707
  */
1396
1708
  function countFiles(dir, ext) {
1397
- var count = 0;
1398
- var entries = fs.readdirSync(dir, { withFileTypes: true });
1399
- for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
1400
- var entry = entries_2[_i];
1401
- var fullPath = path.join(dir, entry.name);
1709
+ let count = 0;
1710
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
1711
+ for (const entry of entries) {
1712
+ const fullPath = path.join(dir, entry.name);
1402
1713
  if (entry.isDirectory()) {
1403
1714
  count += countFiles(fullPath, ext);
1404
1715
  }
@@ -1412,8 +1723,8 @@ function countFiles(dir, ext) {
1412
1723
  * Count enabled hooks
1413
1724
  */
1414
1725
  function countEnabledHooks(options) {
1415
- var hooks = options.hooks;
1416
- var count = 0;
1726
+ const hooks = options.hooks;
1727
+ let count = 0;
1417
1728
  if (hooks.preToolUse)
1418
1729
  count++;
1419
1730
  if (hooks.postToolUse)