@sparkleideas/cli 3.1.0-alpha.19 → 3.1.0-alpha.21

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