@sparkleideas/cli 3.1.0-alpha.37 → 3.1.0-alpha.64

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