@claude-flow/cli 3.32.1 → 3.32.3

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 (657) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/helpers.manifest.json +3 -3
  3. package/.claude/helpers/statusline.cjs +24 -17
  4. package/.claude/helpers/statusline.js +19 -31
  5. package/catalog-manifest.json +2 -2
  6. package/package.json +1 -1
  7. package/plugins/ruflo-metaharness/.claude-plugin/plugin.json +1 -1
  8. package/plugins/ruflo-metaharness/scripts/smoke.sh +8 -5
  9. package/plugins/ruflo-metaharness/skills/harness-similarity/SKILL.md +1 -1
  10. package/dist/src/agenticow/speculative-exploration.d.ts +0 -148
  11. package/dist/src/agenticow/speculative-exploration.js +0 -218
  12. package/dist/src/appliance/gguf-engine.d.ts +0 -91
  13. package/dist/src/appliance/gguf-engine.js +0 -425
  14. package/dist/src/appliance/ruvllm-bridge.d.ts +0 -102
  15. package/dist/src/appliance/ruvllm-bridge.js +0 -292
  16. package/dist/src/appliance/rvfa-builder.d.ts +0 -44
  17. package/dist/src/appliance/rvfa-builder.js +0 -329
  18. package/dist/src/appliance/rvfa-distribution.d.ts +0 -97
  19. package/dist/src/appliance/rvfa-distribution.js +0 -370
  20. package/dist/src/appliance/rvfa-format.d.ts +0 -111
  21. package/dist/src/appliance/rvfa-format.js +0 -393
  22. package/dist/src/appliance/rvfa-runner.d.ts +0 -69
  23. package/dist/src/appliance/rvfa-runner.js +0 -237
  24. package/dist/src/appliance/rvfa-signing.d.ts +0 -123
  25. package/dist/src/appliance/rvfa-signing.js +0 -347
  26. package/dist/src/autopilot-state.d.ts +0 -77
  27. package/dist/src/autopilot-state.js +0 -271
  28. package/dist/src/benchmarks/gaia-agent-planning.smoke.d.ts +0 -18
  29. package/dist/src/benchmarks/gaia-agent-planning.smoke.js +0 -253
  30. package/dist/src/benchmarks/gaia-agent.d.ts +0 -198
  31. package/dist/src/benchmarks/gaia-agent.js +0 -651
  32. package/dist/src/benchmarks/gaia-causal-memory.d.ts +0 -133
  33. package/dist/src/benchmarks/gaia-causal-memory.js +0 -281
  34. package/dist/src/benchmarks/gaia-causal-memory.smoke.d.ts +0 -22
  35. package/dist/src/benchmarks/gaia-causal-memory.smoke.js +0 -300
  36. package/dist/src/benchmarks/gaia-convergence.d.ts +0 -138
  37. package/dist/src/benchmarks/gaia-convergence.js +0 -260
  38. package/dist/src/benchmarks/gaia-convergence.smoke.d.ts +0 -19
  39. package/dist/src/benchmarks/gaia-convergence.smoke.js +0 -246
  40. package/dist/src/benchmarks/gaia-critic.d.ts +0 -123
  41. package/dist/src/benchmarks/gaia-critic.js +0 -312
  42. package/dist/src/benchmarks/gaia-critic.smoke.d.ts +0 -21
  43. package/dist/src/benchmarks/gaia-critic.smoke.js +0 -327
  44. package/dist/src/benchmarks/gaia-decomposer.d.ts +0 -125
  45. package/dist/src/benchmarks/gaia-decomposer.js +0 -350
  46. package/dist/src/benchmarks/gaia-decomposer.smoke.d.ts +0 -21
  47. package/dist/src/benchmarks/gaia-decomposer.smoke.js +0 -228
  48. package/dist/src/benchmarks/gaia-e2e-smoke.d.ts +0 -27
  49. package/dist/src/benchmarks/gaia-e2e-smoke.js +0 -136
  50. package/dist/src/benchmarks/gaia-extract.smoke.d.ts +0 -45
  51. package/dist/src/benchmarks/gaia-extract.smoke.js +0 -242
  52. package/dist/src/benchmarks/gaia-hardness/features.d.ts +0 -46
  53. package/dist/src/benchmarks/gaia-hardness/features.js +0 -170
  54. package/dist/src/benchmarks/gaia-hardness/predictor.d.ts +0 -105
  55. package/dist/src/benchmarks/gaia-hardness/predictor.js +0 -260
  56. package/dist/src/benchmarks/gaia-hardness/predictor.smoke.d.ts +0 -20
  57. package/dist/src/benchmarks/gaia-hardness/predictor.smoke.js +0 -235
  58. package/dist/src/benchmarks/gaia-hardness/train-data-loader.d.ts +0 -51
  59. package/dist/src/benchmarks/gaia-hardness/train-data-loader.js +0 -179
  60. package/dist/src/benchmarks/gaia-judge.d.ts +0 -88
  61. package/dist/src/benchmarks/gaia-judge.js +0 -437
  62. package/dist/src/benchmarks/gaia-loader.d.ts +0 -87
  63. package/dist/src/benchmarks/gaia-loader.js +0 -326
  64. package/dist/src/benchmarks/gaia-tools/file_read.d.ts +0 -35
  65. package/dist/src/benchmarks/gaia-tools/file_read.js +0 -403
  66. package/dist/src/benchmarks/gaia-tools/grounded_query.d.ts +0 -126
  67. package/dist/src/benchmarks/gaia-tools/grounded_query.js +0 -225
  68. package/dist/src/benchmarks/gaia-tools/index.d.ts +0 -32
  69. package/dist/src/benchmarks/gaia-tools/index.js +0 -36
  70. package/dist/src/benchmarks/gaia-tools/types.d.ts +0 -62
  71. package/dist/src/benchmarks/gaia-tools/types.js +0 -12
  72. package/dist/src/benchmarks/gaia-tools/web_search.d.ts +0 -30
  73. package/dist/src/benchmarks/gaia-tools/web_search.js +0 -210
  74. package/dist/src/benchmarks/gaia-voting.d.ts +0 -88
  75. package/dist/src/benchmarks/gaia-voting.js +0 -297
  76. package/dist/src/benchmarks/gaia-voting.smoke.d.ts +0 -20
  77. package/dist/src/benchmarks/gaia-voting.smoke.js +0 -332
  78. package/dist/src/benchmarks/pretrain/index.d.ts +0 -58
  79. package/dist/src/benchmarks/pretrain/index.js +0 -404
  80. package/dist/src/business-pods/bbs-budget-tracker.d.ts +0 -139
  81. package/dist/src/business-pods/bbs-budget-tracker.js +0 -358
  82. package/dist/src/business-pods/domain-affinity-policy.d.ts +0 -47
  83. package/dist/src/business-pods/domain-affinity-policy.js +0 -65
  84. package/dist/src/business-pods/pod-schema.d.ts +0 -96
  85. package/dist/src/business-pods/pod-schema.js +0 -225
  86. package/dist/src/commands/advisor.d.ts +0 -15
  87. package/dist/src/commands/advisor.js +0 -94
  88. package/dist/src/commands/agent-wasm.d.ts +0 -14
  89. package/dist/src/commands/agent-wasm.js +0 -333
  90. package/dist/src/commands/agent.d.ts +0 -8
  91. package/dist/src/commands/agent.js +0 -927
  92. package/dist/src/commands/analyze.d.ts +0 -19
  93. package/dist/src/commands/analyze.js +0 -2047
  94. package/dist/src/commands/announcements.d.ts +0 -17
  95. package/dist/src/commands/announcements.js +0 -0
  96. package/dist/src/commands/appliance-advanced.d.ts +0 -9
  97. package/dist/src/commands/appliance-advanced.js +0 -215
  98. package/dist/src/commands/appliance.d.ts +0 -8
  99. package/dist/src/commands/appliance.js +0 -404
  100. package/dist/src/commands/autopilot.d.ts +0 -15
  101. package/dist/src/commands/autopilot.js +0 -407
  102. package/dist/src/commands/benchmark.d.ts +0 -10
  103. package/dist/src/commands/benchmark.js +0 -460
  104. package/dist/src/commands/claims.d.ts +0 -10
  105. package/dist/src/commands/claims.js +0 -620
  106. package/dist/src/commands/cleanup.d.ts +0 -13
  107. package/dist/src/commands/cleanup.js +0 -250
  108. package/dist/src/commands/completions.d.ts +0 -10
  109. package/dist/src/commands/completions.js +0 -539
  110. package/dist/src/commands/config.d.ts +0 -8
  111. package/dist/src/commands/config.js +0 -428
  112. package/dist/src/commands/daemon.d.ts +0 -59
  113. package/dist/src/commands/daemon.js +0 -1733
  114. package/dist/src/commands/deployment.d.ts +0 -10
  115. package/dist/src/commands/deployment.js +0 -672
  116. package/dist/src/commands/doctor.d.ts +0 -10
  117. package/dist/src/commands/doctor.js +0 -1695
  118. package/dist/src/commands/eject.d.ts +0 -33
  119. package/dist/src/commands/eject.js +0 -195
  120. package/dist/src/commands/embeddings.d.ts +0 -18
  121. package/dist/src/commands/embeddings.js +0 -1623
  122. package/dist/src/commands/funnel.d.ts +0 -18
  123. package/dist/src/commands/funnel.js +0 -302
  124. package/dist/src/commands/gaia-bench.d.ts +0 -40
  125. package/dist/src/commands/gaia-bench.js +0 -597
  126. package/dist/src/commands/guidance.d.ts +0 -8
  127. package/dist/src/commands/guidance.js +0 -556
  128. package/dist/src/commands/hive-mind.d.ts +0 -11
  129. package/dist/src/commands/hive-mind.js +0 -1319
  130. package/dist/src/commands/hooks.d.ts +0 -8
  131. package/dist/src/commands/hooks.js +0 -4595
  132. package/dist/src/commands/index.d.ts +0 -118
  133. package/dist/src/commands/index.js +0 -364
  134. package/dist/src/commands/init.d.ts +0 -13
  135. package/dist/src/commands/init.js +0 -1297
  136. package/dist/src/commands/issues.d.ts +0 -21
  137. package/dist/src/commands/issues.js +0 -567
  138. package/dist/src/commands/mcp.d.ts +0 -11
  139. package/dist/src/commands/mcp.js +0 -732
  140. package/dist/src/commands/memory-backup.d.ts +0 -11
  141. package/dist/src/commands/memory-backup.js +0 -46
  142. package/dist/src/commands/memory-distill.d.ts +0 -27
  143. package/dist/src/commands/memory-distill.js +0 -374
  144. package/dist/src/commands/memory.d.ts +0 -8
  145. package/dist/src/commands/memory.js +0 -1596
  146. package/dist/src/commands/metaharness.d.ts +0 -39
  147. package/dist/src/commands/metaharness.js +0 -215
  148. package/dist/src/commands/migrate.d.ts +0 -8
  149. package/dist/src/commands/migrate.js +0 -742
  150. package/dist/src/commands/neural.d.ts +0 -10
  151. package/dist/src/commands/neural.js +0 -4331
  152. package/dist/src/commands/performance.d.ts +0 -10
  153. package/dist/src/commands/performance.js +0 -583
  154. package/dist/src/commands/plugins.d.ts +0 -11
  155. package/dist/src/commands/plugins.js +0 -826
  156. package/dist/src/commands/process.d.ts +0 -10
  157. package/dist/src/commands/process.js +0 -694
  158. package/dist/src/commands/progress.d.ts +0 -11
  159. package/dist/src/commands/progress.js +0 -259
  160. package/dist/src/commands/providers.d.ts +0 -10
  161. package/dist/src/commands/providers.js +0 -502
  162. package/dist/src/commands/proxy.d.ts +0 -21
  163. package/dist/src/commands/proxy.js +0 -310
  164. package/dist/src/commands/route.d.ts +0 -16
  165. package/dist/src/commands/route.js +0 -822
  166. package/dist/src/commands/ruvector/backup.d.ts +0 -11
  167. package/dist/src/commands/ruvector/backup.js +0 -747
  168. package/dist/src/commands/ruvector/benchmark.d.ts +0 -11
  169. package/dist/src/commands/ruvector/benchmark.js +0 -490
  170. package/dist/src/commands/ruvector/import.d.ts +0 -18
  171. package/dist/src/commands/ruvector/import.js +0 -373
  172. package/dist/src/commands/ruvector/index.d.ts +0 -29
  173. package/dist/src/commands/ruvector/index.js +0 -129
  174. package/dist/src/commands/ruvector/init.d.ts +0 -11
  175. package/dist/src/commands/ruvector/init.js +0 -467
  176. package/dist/src/commands/ruvector/migrate.d.ts +0 -11
  177. package/dist/src/commands/ruvector/migrate.js +0 -498
  178. package/dist/src/commands/ruvector/optimize.d.ts +0 -11
  179. package/dist/src/commands/ruvector/optimize.js +0 -505
  180. package/dist/src/commands/ruvector/pg-utils.d.ts +0 -14
  181. package/dist/src/commands/ruvector/pg-utils.js +0 -41
  182. package/dist/src/commands/ruvector/setup.d.ts +0 -18
  183. package/dist/src/commands/ruvector/setup.js +0 -765
  184. package/dist/src/commands/ruvector/status.d.ts +0 -11
  185. package/dist/src/commands/ruvector/status.js +0 -479
  186. package/dist/src/commands/security.d.ts +0 -10
  187. package/dist/src/commands/security.js +0 -1007
  188. package/dist/src/commands/session.d.ts +0 -8
  189. package/dist/src/commands/session.js +0 -757
  190. package/dist/src/commands/settings.d.ts +0 -19
  191. package/dist/src/commands/settings.js +0 -180
  192. package/dist/src/commands/spinner.d.ts +0 -16
  193. package/dist/src/commands/spinner.js +0 -329
  194. package/dist/src/commands/start.d.ts +0 -8
  195. package/dist/src/commands/start.js +0 -418
  196. package/dist/src/commands/status.d.ts +0 -8
  197. package/dist/src/commands/status.js +0 -608
  198. package/dist/src/commands/swarm.d.ts +0 -8
  199. package/dist/src/commands/swarm.js +0 -891
  200. package/dist/src/commands/task.d.ts +0 -8
  201. package/dist/src/commands/task.js +0 -675
  202. package/dist/src/commands/transfer-store.d.ts +0 -13
  203. package/dist/src/commands/transfer-store.js +0 -428
  204. package/dist/src/commands/update.d.ts +0 -8
  205. package/dist/src/commands/update.js +0 -276
  206. package/dist/src/commands/verify.d.ts +0 -19
  207. package/dist/src/commands/verify.js +0 -261
  208. package/dist/src/commands/version.d.ts +0 -42
  209. package/dist/src/commands/version.js +0 -106
  210. package/dist/src/commands/workflow.d.ts +0 -8
  211. package/dist/src/commands/workflow.js +0 -617
  212. package/dist/src/config/harness-feedback-applier.d.ts +0 -50
  213. package/dist/src/config/harness-feedback-applier.js +0 -122
  214. package/dist/src/config/proven-config-refresh.d.ts +0 -39
  215. package/dist/src/config/proven-config-refresh.js +0 -154
  216. package/dist/src/config/proven-config-rvfa.d.ts +0 -23
  217. package/dist/src/config/proven-config-rvfa.js +0 -73
  218. package/dist/src/config/proven-config.d.ts +0 -86
  219. package/dist/src/config/proven-config.js +0 -176
  220. package/dist/src/config-adapter.d.ts +0 -15
  221. package/dist/src/config-adapter.js +0 -186
  222. package/dist/src/encryption/vault.d.ts +0 -94
  223. package/dist/src/encryption/vault.js +0 -172
  224. package/dist/src/fs-secure.d.ts +0 -86
  225. package/dist/src/fs-secure.js +0 -133
  226. package/dist/src/funnel/advisor-tip.d.ts +0 -58
  227. package/dist/src/funnel/advisor-tip.js +0 -92
  228. package/dist/src/funnel/attribution.d.ts +0 -37
  229. package/dist/src/funnel/attribution.js +0 -101
  230. package/dist/src/funnel/consent.d.ts +0 -22
  231. package/dist/src/funnel/consent.js +0 -58
  232. package/dist/src/funnel/credit-errors.d.ts +0 -31
  233. package/dist/src/funnel/credit-errors.js +0 -88
  234. package/dist/src/funnel/credit-notifier.d.ts +0 -44
  235. package/dist/src/funnel/credit-notifier.js +0 -74
  236. package/dist/src/funnel/disclosure.d.ts +0 -47
  237. package/dist/src/funnel/disclosure.js +0 -109
  238. package/dist/src/funnel/enrollment.d.ts +0 -36
  239. package/dist/src/funnel/enrollment.js +0 -64
  240. package/dist/src/funnel/environment.d.ts +0 -17
  241. package/dist/src/funnel/environment.js +0 -39
  242. package/dist/src/funnel/event-transport.d.ts +0 -51
  243. package/dist/src/funnel/event-transport.js +0 -199
  244. package/dist/src/funnel/events.d.ts +0 -42
  245. package/dist/src/funnel/events.js +0 -150
  246. package/dist/src/funnel/index.d.ts +0 -21
  247. package/dist/src/funnel/index.js +0 -21
  248. package/dist/src/funnel/insights.d.ts +0 -49
  249. package/dist/src/funnel/insights.js +0 -120
  250. package/dist/src/funnel/local-signals.d.ts +0 -15
  251. package/dist/src/funnel/local-signals.js +0 -68
  252. package/dist/src/funnel/message-transport.d.ts +0 -51
  253. package/dist/src/funnel/message-transport.js +0 -149
  254. package/dist/src/funnel/messages.d.ts +0 -55
  255. package/dist/src/funnel/messages.js +0 -160
  256. package/dist/src/funnel/payout.d.ts +0 -40
  257. package/dist/src/funnel/payout.js +0 -60
  258. package/dist/src/funnel/power-saver-notifier.d.ts +0 -44
  259. package/dist/src/funnel/power-saver-notifier.js +0 -92
  260. package/dist/src/funnel/precedence.d.ts +0 -16
  261. package/dist/src/funnel/precedence.js +0 -85
  262. package/dist/src/funnel/promo.d.ts +0 -41
  263. package/dist/src/funnel/promo.js +0 -144
  264. package/dist/src/funnel/rate-limit-notifier.d.ts +0 -55
  265. package/dist/src/funnel/rate-limit-notifier.js +0 -102
  266. package/dist/src/funnel/rotation.d.ts +0 -19
  267. package/dist/src/funnel/rotation.js +0 -70
  268. package/dist/src/funnel/state.d.ts +0 -13
  269. package/dist/src/funnel/state.js +0 -52
  270. package/dist/src/funnel/toggle-cooldown.d.ts +0 -17
  271. package/dist/src/funnel/toggle-cooldown.js +0 -32
  272. package/dist/src/funnel/types.d.ts +0 -98
  273. package/dist/src/funnel/types.js +0 -26
  274. package/dist/src/index.d.ts +0 -81
  275. package/dist/src/index.js +0 -609
  276. package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
  277. package/dist/src/infrastructure/in-memory-repositories.js +0 -264
  278. package/dist/src/init/claudemd-generator.d.ts +0 -16
  279. package/dist/src/init/claudemd-generator.js +0 -368
  280. package/dist/src/init/executor.d.ts +0 -41
  281. package/dist/src/init/executor.js +0 -2142
  282. package/dist/src/init/helper-refresh.d.ts +0 -79
  283. package/dist/src/init/helper-refresh.js +0 -347
  284. package/dist/src/init/helper-signing.d.ts +0 -37
  285. package/dist/src/init/helper-signing.js +0 -67
  286. package/dist/src/init/helpers-generator.d.ts +0 -87
  287. package/dist/src/init/helpers-generator.js +0 -1456
  288. package/dist/src/init/index.d.ts +0 -13
  289. package/dist/src/init/index.js +0 -15
  290. package/dist/src/init/mcp-generator.d.ts +0 -26
  291. package/dist/src/init/mcp-generator.js +0 -126
  292. package/dist/src/init/memory-package-resolver.d.ts +0 -53
  293. package/dist/src/init/memory-package-resolver.js +0 -118
  294. package/dist/src/init/settings-generator.d.ts +0 -14
  295. package/dist/src/init/settings-generator.js +0 -462
  296. package/dist/src/init/statusline-generator.d.ts +0 -28
  297. package/dist/src/init/statusline-generator.js +0 -177
  298. package/dist/src/init/types.d.ts +0 -331
  299. package/dist/src/init/types.js +0 -276
  300. package/dist/src/log-filters.d.ts +0 -46
  301. package/dist/src/log-filters.js +0 -107
  302. package/dist/src/mcp-client.d.ts +0 -92
  303. package/dist/src/mcp-client.js +0 -397
  304. package/dist/src/mcp-server.d.ts +0 -163
  305. package/dist/src/mcp-server.js +0 -751
  306. package/dist/src/mcp-tools/agent-execute-core.d.ts +0 -115
  307. package/dist/src/mcp-tools/agent-execute-core.js +0 -587
  308. package/dist/src/mcp-tools/agent-tools.d.ts +0 -9
  309. package/dist/src/mcp-tools/agent-tools.js +0 -837
  310. package/dist/src/mcp-tools/agentbbs-tools.d.ts +0 -28
  311. package/dist/src/mcp-tools/agentbbs-tools.js +0 -394
  312. package/dist/src/mcp-tools/agentdb-tools.d.ts +0 -35
  313. package/dist/src/mcp-tools/agentdb-tools.js +0 -1473
  314. package/dist/src/mcp-tools/agenticow-loader.d.ts +0 -59
  315. package/dist/src/mcp-tools/agenticow-loader.js +0 -105
  316. package/dist/src/mcp-tools/agenticow-speculate-tools.d.ts +0 -24
  317. package/dist/src/mcp-tools/agenticow-speculate-tools.js +0 -209
  318. package/dist/src/mcp-tools/agenticow-tools.d.ts +0 -36
  319. package/dist/src/mcp-tools/agenticow-tools.js +0 -360
  320. package/dist/src/mcp-tools/analyze-tools.d.ts +0 -38
  321. package/dist/src/mcp-tools/analyze-tools.js +0 -346
  322. package/dist/src/mcp-tools/auto-install.d.ts +0 -83
  323. package/dist/src/mcp-tools/auto-install.js +0 -131
  324. package/dist/src/mcp-tools/autopilot-tools.d.ts +0 -12
  325. package/dist/src/mcp-tools/autopilot-tools.js +0 -231
  326. package/dist/src/mcp-tools/browser-intent-tools.d.ts +0 -162
  327. package/dist/src/mcp-tools/browser-intent-tools.js +0 -548
  328. package/dist/src/mcp-tools/browser-session-tools.d.ts +0 -27
  329. package/dist/src/mcp-tools/browser-session-tools.js +0 -398
  330. package/dist/src/mcp-tools/browser-tools.d.ts +0 -21
  331. package/dist/src/mcp-tools/browser-tools.js +0 -760
  332. package/dist/src/mcp-tools/business-pod-tools.d.ts +0 -20
  333. package/dist/src/mcp-tools/business-pod-tools.js +0 -169
  334. package/dist/src/mcp-tools/claims-tools.d.ts +0 -12
  335. package/dist/src/mcp-tools/claims-tools.js +0 -863
  336. package/dist/src/mcp-tools/config-tools.d.ts +0 -8
  337. package/dist/src/mcp-tools/config-tools.js +0 -411
  338. package/dist/src/mcp-tools/coordination-tools.d.ts +0 -13
  339. package/dist/src/mcp-tools/coordination-tools.js +0 -729
  340. package/dist/src/mcp-tools/daa-tools.d.ts +0 -13
  341. package/dist/src/mcp-tools/daa-tools.js +0 -534
  342. package/dist/src/mcp-tools/embeddings-tools.d.ts +0 -9
  343. package/dist/src/mcp-tools/embeddings-tools.js +0 -904
  344. package/dist/src/mcp-tools/github-tools.d.ts +0 -9
  345. package/dist/src/mcp-tools/github-tools.js +0 -659
  346. package/dist/src/mcp-tools/guidance-tools.d.ts +0 -15
  347. package/dist/src/mcp-tools/guidance-tools.js +0 -639
  348. package/dist/src/mcp-tools/hive-mind-tools.d.ts +0 -8
  349. package/dist/src/mcp-tools/hive-mind-tools.js +0 -953
  350. package/dist/src/mcp-tools/hooks-tools.d.ts +0 -65
  351. package/dist/src/mcp-tools/hooks-tools.js +0 -4824
  352. package/dist/src/mcp-tools/http-fetch-tools.d.ts +0 -55
  353. package/dist/src/mcp-tools/http-fetch-tools.js +0 -329
  354. package/dist/src/mcp-tools/index.d.ts +0 -34
  355. package/dist/src/mcp-tools/index.js +0 -40
  356. package/dist/src/mcp-tools/managed-agent-tools.d.ts +0 -22
  357. package/dist/src/mcp-tools/managed-agent-tools.js +0 -357
  358. package/dist/src/mcp-tools/memory-tools.d.ts +0 -14
  359. package/dist/src/mcp-tools/memory-tools.js +0 -1330
  360. package/dist/src/mcp-tools/metaharness-tools.d.ts +0 -51
  361. package/dist/src/mcp-tools/metaharness-tools.js +0 -684
  362. package/dist/src/mcp-tools/neural-tools.d.ts +0 -54
  363. package/dist/src/mcp-tools/neural-tools.js +0 -1168
  364. package/dist/src/mcp-tools/performance-tools.d.ts +0 -16
  365. package/dist/src/mcp-tools/performance-tools.js +0 -675
  366. package/dist/src/mcp-tools/progress-tools.d.ts +0 -14
  367. package/dist/src/mcp-tools/progress-tools.js +0 -348
  368. package/dist/src/mcp-tools/request-tracker.d.ts +0 -17
  369. package/dist/src/mcp-tools/request-tracker.js +0 -27
  370. package/dist/src/mcp-tools/ruvllm-tools.d.ts +0 -9
  371. package/dist/src/mcp-tools/ruvllm-tools.js +0 -355
  372. package/dist/src/mcp-tools/security-tools.d.ts +0 -18
  373. package/dist/src/mcp-tools/security-tools.js +0 -556
  374. package/dist/src/mcp-tools/session-tools.d.ts +0 -8
  375. package/dist/src/mcp-tools/session-tools.js +0 -517
  376. package/dist/src/mcp-tools/swarm-tools.d.ts +0 -37
  377. package/dist/src/mcp-tools/swarm-tools.js +0 -390
  378. package/dist/src/mcp-tools/system-tools.d.ts +0 -13
  379. package/dist/src/mcp-tools/system-tools.js +0 -688
  380. package/dist/src/mcp-tools/task-tools.d.ts +0 -8
  381. package/dist/src/mcp-tools/task-tools.js +0 -487
  382. package/dist/src/mcp-tools/terminal-tools.d.ts +0 -8
  383. package/dist/src/mcp-tools/terminal-tools.js +0 -306
  384. package/dist/src/mcp-tools/testgen-tools.d.ts +0 -26
  385. package/dist/src/mcp-tools/testgen-tools.js +0 -168
  386. package/dist/src/mcp-tools/tool-loop-guardrail.d.ts +0 -31
  387. package/dist/src/mcp-tools/tool-loop-guardrail.js +0 -71
  388. package/dist/src/mcp-tools/transfer-tools.d.ts +0 -14
  389. package/dist/src/mcp-tools/transfer-tools.js +0 -447
  390. package/dist/src/mcp-tools/types.d.ts +0 -8
  391. package/dist/src/mcp-tools/types.js +0 -8
  392. package/dist/src/mcp-tools/validate-input.d.ts +0 -9
  393. package/dist/src/mcp-tools/validate-input.js +0 -9
  394. package/dist/src/mcp-tools/wasm-agent-tools.d.ts +0 -13
  395. package/dist/src/mcp-tools/wasm-agent-tools.js +0 -840
  396. package/dist/src/mcp-tools/workflow-tools.d.ts +0 -8
  397. package/dist/src/mcp-tools/workflow-tools.js +0 -884
  398. package/dist/src/memory/bge-embedder.d.ts +0 -25
  399. package/dist/src/memory/bge-embedder.js +0 -121
  400. package/dist/src/memory/cross-encoder-rerank.d.ts +0 -33
  401. package/dist/src/memory/cross-encoder-rerank.js +0 -123
  402. package/dist/src/memory/embedding-policy.d.ts +0 -21
  403. package/dist/src/memory/embedding-policy.js +0 -30
  404. package/dist/src/memory/embedding-quantization.d.ts +0 -62
  405. package/dist/src/memory/embedding-quantization.js +0 -156
  406. package/dist/src/memory/ewc-consolidation.d.ts +0 -305
  407. package/dist/src/memory/ewc-consolidation.js +0 -611
  408. package/dist/src/memory/graph-edge-writer.d.ts +0 -95
  409. package/dist/src/memory/graph-edge-writer.js +0 -217
  410. package/dist/src/memory/hybrid-retrieval.d.ts +0 -77
  411. package/dist/src/memory/hybrid-retrieval.js +0 -192
  412. package/dist/src/memory/intelligence.d.ts +0 -405
  413. package/dist/src/memory/intelligence.js +0 -1316
  414. package/dist/src/memory/lucene-bm25.d.ts +0 -19
  415. package/dist/src/memory/lucene-bm25.js +0 -308
  416. package/dist/src/memory/memory-bridge.d.ts +0 -537
  417. package/dist/src/memory/memory-bridge.js +0 -2460
  418. package/dist/src/memory/memory-initializer.d.ts +0 -556
  419. package/dist/src/memory/memory-initializer.js +0 -3021
  420. package/dist/src/memory/neural-package-bridge.d.ts +0 -48
  421. package/dist/src/memory/neural-package-bridge.js +0 -87
  422. package/dist/src/memory/rabitq-index.d.ts +0 -60
  423. package/dist/src/memory/rabitq-index.js +0 -242
  424. package/dist/src/memory/sona-optimizer.d.ts +0 -267
  425. package/dist/src/memory/sona-optimizer.js +0 -779
  426. package/dist/src/memory/structured-distill.d.ts +0 -48
  427. package/dist/src/memory/structured-distill.js +0 -125
  428. package/dist/src/output.d.ts +0 -9
  429. package/dist/src/output.js +0 -9
  430. package/dist/src/parser.d.ts +0 -89
  431. package/dist/src/parser.js +0 -516
  432. package/dist/src/plugins/manager.d.ts +0 -133
  433. package/dist/src/plugins/manager.js +0 -415
  434. package/dist/src/plugins/store/discovery.d.ts +0 -99
  435. package/dist/src/plugins/store/discovery.js +0 -1224
  436. package/dist/src/plugins/store/index.d.ts +0 -76
  437. package/dist/src/plugins/store/index.js +0 -141
  438. package/dist/src/plugins/store/search.d.ts +0 -46
  439. package/dist/src/plugins/store/search.js +0 -230
  440. package/dist/src/plugins/store/types.d.ts +0 -279
  441. package/dist/src/plugins/store/types.js +0 -7
  442. package/dist/src/plugins/tests/demo-plugin-store.d.ts +0 -7
  443. package/dist/src/plugins/tests/demo-plugin-store.js +0 -126
  444. package/dist/src/plugins/tests/standalone-test.d.ts +0 -12
  445. package/dist/src/plugins/tests/standalone-test.js +0 -188
  446. package/dist/src/plugins/tests/test-plugin-store.d.ts +0 -7
  447. package/dist/src/plugins/tests/test-plugin-store.js +0 -206
  448. package/dist/src/production/circuit-breaker.d.ts +0 -101
  449. package/dist/src/production/circuit-breaker.js +0 -241
  450. package/dist/src/production/error-handler.d.ts +0 -92
  451. package/dist/src/production/error-handler.js +0 -299
  452. package/dist/src/production/index.d.ts +0 -23
  453. package/dist/src/production/index.js +0 -18
  454. package/dist/src/production/monitoring.d.ts +0 -161
  455. package/dist/src/production/monitoring.js +0 -356
  456. package/dist/src/production/rate-limiter.d.ts +0 -80
  457. package/dist/src/production/rate-limiter.js +0 -201
  458. package/dist/src/production/retry.d.ts +0 -48
  459. package/dist/src/production/retry.js +0 -179
  460. package/dist/src/prompt.d.ts +0 -44
  461. package/dist/src/prompt.js +0 -501
  462. package/dist/src/runtime/headless.d.ts +0 -60
  463. package/dist/src/runtime/headless.js +0 -284
  464. package/dist/src/runtime/parent-death-watchdog.d.ts +0 -42
  465. package/dist/src/runtime/parent-death-watchdog.js +0 -70
  466. package/dist/src/ruvector/agent-wasm.d.ts +0 -228
  467. package/dist/src/ruvector/agent-wasm.js +0 -463
  468. package/dist/src/ruvector/ast-analyzer.d.ts +0 -67
  469. package/dist/src/ruvector/ast-analyzer.js +0 -277
  470. package/dist/src/ruvector/codemods/engine.d.ts +0 -45
  471. package/dist/src/ruvector/codemods/engine.js +0 -291
  472. package/dist/src/ruvector/codemods/scope-analysis.d.ts +0 -29
  473. package/dist/src/ruvector/codemods/scope-analysis.js +0 -162
  474. package/dist/src/ruvector/coverage-router.d.ts +0 -160
  475. package/dist/src/ruvector/coverage-router.js +0 -531
  476. package/dist/src/ruvector/coverage-tools.d.ts +0 -33
  477. package/dist/src/ruvector/coverage-tools.js +0 -157
  478. package/dist/src/ruvector/diff-classifier.d.ts +0 -175
  479. package/dist/src/ruvector/diff-classifier.js +0 -699
  480. package/dist/src/ruvector/diskann-backend.d.ts +0 -78
  481. package/dist/src/ruvector/diskann-backend.js +0 -310
  482. package/dist/src/ruvector/enhanced-model-router.d.ts +0 -172
  483. package/dist/src/ruvector/enhanced-model-router.js +0 -577
  484. package/dist/src/ruvector/graph-analyzer.d.ts +0 -187
  485. package/dist/src/ruvector/graph-analyzer.js +0 -929
  486. package/dist/src/ruvector/graph-backend.d.ts +0 -79
  487. package/dist/src/ruvector/graph-backend.js +0 -220
  488. package/dist/src/ruvector/index.d.ts +0 -38
  489. package/dist/src/ruvector/index.js +0 -86
  490. package/dist/src/ruvector/lora-adapter.d.ts +0 -292
  491. package/dist/src/ruvector/lora-adapter.js +0 -710
  492. package/dist/src/ruvector/model-prices.d.ts +0 -50
  493. package/dist/src/ruvector/model-prices.js +0 -72
  494. package/dist/src/ruvector/model-router.d.ts +0 -408
  495. package/dist/src/ruvector/model-router.js +0 -1162
  496. package/dist/src/ruvector/neural-router.d.ts +0 -182
  497. package/dist/src/ruvector/neural-router.js +0 -825
  498. package/dist/src/ruvector/output-verifier.d.ts +0 -83
  499. package/dist/src/ruvector/output-verifier.js +0 -277
  500. package/dist/src/ruvector/q-learning-router.d.ts +0 -227
  501. package/dist/src/ruvector/q-learning-router.js +0 -721
  502. package/dist/src/ruvector/router-calibrator.d.ts +0 -65
  503. package/dist/src/ruvector/router-calibrator.js +0 -120
  504. package/dist/src/ruvector/router-parallel-recorder.d.ts +0 -127
  505. package/dist/src/ruvector/router-parallel-recorder.js +0 -183
  506. package/dist/src/ruvector/router-trajectory.d.ts +0 -194
  507. package/dist/src/ruvector/router-trajectory.js +0 -281
  508. package/dist/src/ruvector/run-transcript-recorder.d.ts +0 -154
  509. package/dist/src/ruvector/run-transcript-recorder.js +0 -209
  510. package/dist/src/ruvector/ruvllm-wasm.d.ts +0 -179
  511. package/dist/src/ruvector/ruvllm-wasm.js +0 -379
  512. package/dist/src/ruvector/semantic-router.d.ts +0 -77
  513. package/dist/src/ruvector/semantic-router.js +0 -178
  514. package/dist/src/ruvector/task-embedder.d.ts +0 -56
  515. package/dist/src/ruvector/task-embedder.js +0 -237
  516. package/dist/src/ruvector/trajectory-tree.d.ts +0 -113
  517. package/dist/src/ruvector/trajectory-tree.js +0 -237
  518. package/dist/src/ruvector/vector-db.d.ts +0 -73
  519. package/dist/src/ruvector/vector-db.js +0 -301
  520. package/dist/src/ruvector/wasm-embedder.d.ts +0 -13
  521. package/dist/src/ruvector/wasm-embedder.js +0 -143
  522. package/dist/src/services/agentic-flow-bridge.d.ts +0 -50
  523. package/dist/src/services/agentic-flow-bridge.js +0 -95
  524. package/dist/src/services/ai-job-dedup.d.ts +0 -61
  525. package/dist/src/services/ai-job-dedup.js +0 -136
  526. package/dist/src/services/checkpoint-gate.d.ts +0 -140
  527. package/dist/src/services/checkpoint-gate.js +0 -223
  528. package/dist/src/services/claim-service.d.ts +0 -204
  529. package/dist/src/services/claim-service.js +0 -818
  530. package/dist/src/services/config-file-manager.d.ts +0 -37
  531. package/dist/src/services/config-file-manager.js +0 -224
  532. package/dist/src/services/container-worker-pool.d.ts +0 -204
  533. package/dist/src/services/container-worker-pool.js +0 -589
  534. package/dist/src/services/daemon-autostart.d.ts +0 -17
  535. package/dist/src/services/daemon-autostart.js +0 -102
  536. package/dist/src/services/distill-oracle.d.ts +0 -190
  537. package/dist/src/services/distill-oracle.js +0 -349
  538. package/dist/src/services/distill-tuning.d.ts +0 -111
  539. package/dist/src/services/distill-tuning.js +0 -510
  540. package/dist/src/services/evolve-proof.d.ts +0 -253
  541. package/dist/src/services/evolve-proof.js +0 -343
  542. package/dist/src/services/fable-harness.d.ts +0 -207
  543. package/dist/src/services/fable-harness.js +0 -388
  544. package/dist/src/services/git-workspace-identity.d.ts +0 -42
  545. package/dist/src/services/git-workspace-identity.js +0 -99
  546. package/dist/src/services/global-ai-budget.d.ts +0 -135
  547. package/dist/src/services/global-ai-budget.js +0 -415
  548. package/dist/src/services/harness-benchmark.d.ts +0 -68
  549. package/dist/src/services/harness-benchmark.js +0 -94
  550. package/dist/src/services/harness-canary.d.ts +0 -60
  551. package/dist/src/services/harness-canary.js +0 -69
  552. package/dist/src/services/harness-corpus-harvester.d.ts +0 -51
  553. package/dist/src/services/harness-corpus-harvester.js +0 -74
  554. package/dist/src/services/harness-flywheel-generations.d.ts +0 -115
  555. package/dist/src/services/harness-flywheel-generations.js +0 -360
  556. package/dist/src/services/harness-flywheel-runtime.d.ts +0 -25
  557. package/dist/src/services/harness-flywheel-runtime.js +0 -92
  558. package/dist/src/services/harness-flywheel.d.ts +0 -48
  559. package/dist/src/services/harness-flywheel.js +0 -207
  560. package/dist/src/services/harness-frozen-eval.d.ts +0 -22
  561. package/dist/src/services/harness-frozen-eval.js +0 -66
  562. package/dist/src/services/harness-hosts.d.ts +0 -40
  563. package/dist/src/services/harness-hosts.js +0 -88
  564. package/dist/src/services/harness-improvement-ledger.d.ts +0 -63
  565. package/dist/src/services/harness-improvement-ledger.js +0 -101
  566. package/dist/src/services/harness-loop.d.ts +0 -53
  567. package/dist/src/services/harness-loop.js +0 -85
  568. package/dist/src/services/harness-qualification.d.ts +0 -66
  569. package/dist/src/services/harness-qualification.js +0 -143
  570. package/dist/src/services/harness-replay.d.ts +0 -37
  571. package/dist/src/services/harness-replay.js +0 -92
  572. package/dist/src/services/harness-verify.d.ts +0 -33
  573. package/dist/src/services/harness-verify.js +0 -26
  574. package/dist/src/services/harness-worker.d.ts +0 -23
  575. package/dist/src/services/harness-worker.js +0 -66
  576. package/dist/src/services/headless-worker-executor.d.ts +0 -358
  577. package/dist/src/services/headless-worker-executor.js +0 -1269
  578. package/dist/src/services/index.d.ts +0 -13
  579. package/dist/src/services/index.js +0 -11
  580. package/dist/src/services/memory-backup.d.ts +0 -53
  581. package/dist/src/services/memory-backup.js +0 -198
  582. package/dist/src/services/memory-distillation.d.ts +0 -41
  583. package/dist/src/services/memory-distillation.js +0 -277
  584. package/dist/src/services/native-training.d.ts +0 -68
  585. package/dist/src/services/native-training.js +0 -141
  586. package/dist/src/services/registry-api.d.ts +0 -58
  587. package/dist/src/services/registry-api.js +0 -146
  588. package/dist/src/services/repo-supervisor.d.ts +0 -70
  589. package/dist/src/services/repo-supervisor.js +0 -228
  590. package/dist/src/services/ruvector-training.d.ts +0 -222
  591. package/dist/src/services/ruvector-training.js +0 -693
  592. package/dist/src/services/swarm-memory-branches.d.ts +0 -135
  593. package/dist/src/services/swarm-memory-branches.js +0 -213
  594. package/dist/src/services/weight-eft.d.ts +0 -305
  595. package/dist/src/services/weight-eft.js +0 -296
  596. package/dist/src/services/worker-daemon.d.ts +0 -439
  597. package/dist/src/services/worker-daemon.js +0 -1865
  598. package/dist/src/services/worker-queue.d.ts +0 -194
  599. package/dist/src/services/worker-queue.js +0 -513
  600. package/dist/src/services/workspace-lease.d.ts +0 -55
  601. package/dist/src/services/workspace-lease.js +0 -191
  602. package/dist/src/suggest.d.ts +0 -53
  603. package/dist/src/suggest.js +0 -200
  604. package/dist/src/transfer/anonymization/index.d.ts +0 -25
  605. package/dist/src/transfer/anonymization/index.js +0 -175
  606. package/dist/src/transfer/deploy-seraphine.d.ts +0 -13
  607. package/dist/src/transfer/deploy-seraphine.js +0 -205
  608. package/dist/src/transfer/export.d.ts +0 -25
  609. package/dist/src/transfer/export.js +0 -113
  610. package/dist/src/transfer/index.d.ts +0 -12
  611. package/dist/src/transfer/index.js +0 -31
  612. package/dist/src/transfer/ipfs/client.d.ts +0 -109
  613. package/dist/src/transfer/ipfs/client.js +0 -307
  614. package/dist/src/transfer/ipfs/upload.d.ts +0 -95
  615. package/dist/src/transfer/ipfs/upload.js +0 -413
  616. package/dist/src/transfer/models/seraphine.d.ts +0 -72
  617. package/dist/src/transfer/models/seraphine.js +0 -373
  618. package/dist/src/transfer/serialization/cfp.d.ts +0 -49
  619. package/dist/src/transfer/serialization/cfp.js +0 -183
  620. package/dist/src/transfer/storage/gcs.d.ts +0 -82
  621. package/dist/src/transfer/storage/gcs.js +0 -272
  622. package/dist/src/transfer/storage/index.d.ts +0 -6
  623. package/dist/src/transfer/storage/index.js +0 -6
  624. package/dist/src/transfer/store/discovery.d.ts +0 -84
  625. package/dist/src/transfer/store/discovery.js +0 -382
  626. package/dist/src/transfer/store/download.d.ts +0 -70
  627. package/dist/src/transfer/store/download.js +0 -334
  628. package/dist/src/transfer/store/index.d.ts +0 -84
  629. package/dist/src/transfer/store/index.js +0 -153
  630. package/dist/src/transfer/store/publish.d.ts +0 -76
  631. package/dist/src/transfer/store/publish.js +0 -294
  632. package/dist/src/transfer/store/registry.d.ts +0 -58
  633. package/dist/src/transfer/store/registry.js +0 -285
  634. package/dist/src/transfer/store/search.d.ts +0 -54
  635. package/dist/src/transfer/store/search.js +0 -232
  636. package/dist/src/transfer/store/tests/standalone-test.d.ts +0 -12
  637. package/dist/src/transfer/store/tests/standalone-test.js +0 -190
  638. package/dist/src/transfer/store/types.d.ts +0 -193
  639. package/dist/src/transfer/store/types.js +0 -6
  640. package/dist/src/transfer/test-seraphine.d.ts +0 -6
  641. package/dist/src/transfer/test-seraphine.js +0 -105
  642. package/dist/src/transfer/tests/test-store.d.ts +0 -7
  643. package/dist/src/transfer/tests/test-store.js +0 -214
  644. package/dist/src/transfer/types.d.ts +0 -245
  645. package/dist/src/transfer/types.js +0 -6
  646. package/dist/src/types.d.ts +0 -13
  647. package/dist/src/types.js +0 -13
  648. package/dist/src/update/checker.d.ts +0 -34
  649. package/dist/src/update/checker.js +0 -191
  650. package/dist/src/update/executor.d.ts +0 -33
  651. package/dist/src/update/executor.js +0 -217
  652. package/dist/src/update/index.d.ts +0 -33
  653. package/dist/src/update/index.js +0 -64
  654. package/dist/src/update/rate-limiter.d.ts +0 -20
  655. package/dist/src/update/rate-limiter.js +0 -96
  656. package/dist/src/update/validator.d.ts +0 -17
  657. package/dist/src/update/validator.js +0 -123
@@ -1,1623 +0,0 @@
1
- /**
2
- * V3 CLI Embeddings Command
3
- * Vector embeddings, semantic search, similarity operations
4
- *
5
- * Features:
6
- * - Multiple providers: OpenAI, Transformers.js, Agentic-Flow, Mock
7
- * - Document chunking with overlap
8
- * - L2/L1/minmax/zscore normalization
9
- * - Hyperbolic embeddings (Poincaré ball)
10
- * - Neural substrate integration
11
- * - Persistent SQLite cache
12
- *
13
- * Created with ❤️ by ruv.io
14
- */
15
- import { output } from '../output.js';
16
- // Dynamic imports for embeddings package
17
- async function getEmbeddings() {
18
- try {
19
- return await import('@claude-flow/embeddings');
20
- }
21
- catch {
22
- return null;
23
- }
24
- }
25
- // Generate subcommand - REAL implementation
26
- const generateCommand = {
27
- name: 'generate',
28
- description: 'Generate embeddings for text',
29
- options: [
30
- { name: 'text', short: 't', type: 'string', description: 'Text to embed', required: true },
31
- { name: 'provider', short: 'p', type: 'string', description: 'Provider: openai, transformers, agentic-flow, local', default: 'local' },
32
- { name: 'model', short: 'm', type: 'string', description: 'Model to use' },
33
- { name: 'output', short: 'o', type: 'string', description: 'Output format: json, array, preview', default: 'preview' },
34
- ],
35
- examples: [
36
- { command: 'claude-flow embeddings generate -t "Hello world"', description: 'Generate embedding' },
37
- { command: 'claude-flow embeddings generate -t "Test" -o json', description: 'Output as JSON' },
38
- ],
39
- action: async (ctx) => {
40
- const text = ctx.flags.text;
41
- const provider = ctx.flags.provider || 'local';
42
- const outputFormat = ctx.flags.output || 'preview';
43
- if (!text) {
44
- output.printError('Text is required');
45
- return { success: false, exitCode: 1 };
46
- }
47
- output.writeln();
48
- output.writeln(output.bold('Generate Embedding'));
49
- output.writeln(output.dim('─'.repeat(50)));
50
- const spinner = output.createSpinner({ text: `Generating with ${provider}...`, spinner: 'dots' });
51
- spinner.start();
52
- try {
53
- // Use real embedding generator
54
- const { generateEmbedding, loadEmbeddingModel } = await import('../memory/memory-initializer.js');
55
- const startTime = Date.now();
56
- const modelInfo = await loadEmbeddingModel({ verbose: false });
57
- const result = await generateEmbedding(text);
58
- const duration = Date.now() - startTime;
59
- spinner.succeed(`Embedding generated in ${duration}ms`);
60
- if (outputFormat === 'json') {
61
- output.printJson({
62
- text: text.substring(0, 100),
63
- embedding: result.embedding,
64
- dimensions: result.dimensions,
65
- model: result.model,
66
- duration
67
- });
68
- return { success: true, data: result };
69
- }
70
- if (outputFormat === 'array') {
71
- output.writeln(JSON.stringify(result.embedding));
72
- return { success: true, data: result };
73
- }
74
- // Preview format (default)
75
- const preview = result.embedding.slice(0, 8).map(v => v.toFixed(6));
76
- output.writeln();
77
- output.printBox([
78
- `Provider: ${provider}`,
79
- `Model: ${result.model} (${modelInfo.modelName})`,
80
- `Dimensions: ${result.dimensions}`,
81
- `Text: "${text.substring(0, 40)}${text.length > 40 ? '...' : ''}"`,
82
- `Generation time: ${duration}ms`,
83
- ``,
84
- `Vector preview (first 8 of ${result.dimensions}):`,
85
- `[${preview.join(', ')}, ...]`,
86
- ].join('\n'), 'Result');
87
- return { success: true, data: result };
88
- }
89
- catch (error) {
90
- spinner.fail('Embedding generation failed');
91
- output.printError(error instanceof Error ? error.message : String(error));
92
- return { success: false, exitCode: 1 };
93
- }
94
- },
95
- };
96
- // Search subcommand - REAL implementation using sql.js
97
- const searchCommand = {
98
- name: 'search',
99
- description: 'Semantic similarity search',
100
- options: [
101
- { name: 'query', short: 'q', type: 'string', description: 'Search query', required: true },
102
- { name: 'collection', short: 'c', type: 'string', description: 'Namespace to search', default: 'default' },
103
- { name: 'limit', short: 'l', type: 'number', description: 'Max results', default: '10' },
104
- { name: 'threshold', short: 't', type: 'number', description: 'Similarity threshold (0-1)', default: '0.5' },
105
- { name: 'db-path', type: 'string', description: 'Database path', default: '.swarm/memory.db' },
106
- ],
107
- examples: [
108
- { command: 'claude-flow embeddings search -q "error handling"', description: 'Search for similar' },
109
- { command: 'claude-flow embeddings search -q "test" -l 5', description: 'Limit results' },
110
- ],
111
- action: async (ctx) => {
112
- const query = ctx.flags.query;
113
- const namespace = ctx.flags.collection || 'default';
114
- const limit = parseInt(ctx.flags.limit || '10', 10);
115
- const threshold = parseFloat(ctx.flags.threshold || '0.5');
116
- const dbPath = ctx.flags['db-path'] || '.swarm/memory.db';
117
- if (!query) {
118
- output.printError('Query is required');
119
- return { success: false, exitCode: 1 };
120
- }
121
- output.writeln();
122
- output.writeln(output.bold('Semantic Search'));
123
- output.writeln(output.dim('─'.repeat(60)));
124
- const spinner = output.createSpinner({ text: 'Searching...', spinner: 'dots' });
125
- spinner.start();
126
- try {
127
- const fs = await import('fs');
128
- const path = await import('path');
129
- const fullDbPath = path.resolve(process.cwd(), dbPath);
130
- // Check if database exists
131
- if (!fs.existsSync(fullDbPath)) {
132
- spinner.fail('Database not found');
133
- output.printWarning(`No database at ${fullDbPath}`);
134
- output.printInfo('Run: claude-flow memory init');
135
- return { success: false, exitCode: 1 };
136
- }
137
- // Load sql.js
138
- const initSqlJs = (await import('sql.js')).default;
139
- const SQL = await initSqlJs();
140
- const fileBuffer = fs.readFileSync(fullDbPath);
141
- const db = new SQL.Database(fileBuffer);
142
- const startTime = Date.now();
143
- // Generate embedding for query
144
- const { generateEmbedding } = await import('../memory/memory-initializer.js');
145
- const queryResult = await generateEmbedding(query);
146
- const queryEmbedding = queryResult.embedding;
147
- // Get all entries with embeddings from database
148
- // Parameterized query to prevent SQL injection (CRIT-01)
149
- const embeddingSql = namespace !== 'all'
150
- ? `SELECT id, key, namespace, content, embedding, embedding_dimensions
151
- FROM memory_entries
152
- WHERE status = 'active' AND embedding IS NOT NULL AND namespace = ?
153
- LIMIT 1000`
154
- : `SELECT id, key, namespace, content, embedding, embedding_dimensions
155
- FROM memory_entries
156
- WHERE status = 'active' AND embedding IS NOT NULL
157
- LIMIT 1000`;
158
- const embeddingStmt = db.prepare(embeddingSql);
159
- if (namespace !== 'all') {
160
- embeddingStmt.bind([namespace]);
161
- }
162
- const entryRows = [];
163
- while (embeddingStmt.step()) {
164
- entryRows.push(embeddingStmt.get());
165
- }
166
- embeddingStmt.free();
167
- const results = [];
168
- for (const row of entryRows) {
169
- const [id, key, ns, content, embeddingJson] = row;
170
- if (!embeddingJson)
171
- continue;
172
- try {
173
- const embedding = JSON.parse(embeddingJson);
174
- // Calculate cosine similarity
175
- const similarity = cosineSimilarity(queryEmbedding, embedding);
176
- if (similarity >= threshold) {
177
- results.push({
178
- score: similarity,
179
- id: id.substring(0, 10),
180
- key: key || id.substring(0, 15),
181
- content: (content || '').substring(0, 45) + ((content || '').length > 45 ? '...' : ''),
182
- namespace: ns || 'default'
183
- });
184
- }
185
- }
186
- catch {
187
- // Skip entries with invalid embeddings
188
- }
189
- }
190
- // Keyword search fallback with parameterized query (CRIT-01)
191
- if (results.length < limit) {
192
- const likePattern = `%${query}%`;
193
- const remainingLimit = Math.max(0, limit - results.length);
194
- const keywordSql = namespace !== 'all'
195
- ? `SELECT id, key, namespace, content
196
- FROM memory_entries
197
- WHERE status = 'active'
198
- AND (content LIKE ? OR key LIKE ?)
199
- AND namespace = ?
200
- LIMIT ?`
201
- : `SELECT id, key, namespace, content
202
- FROM memory_entries
203
- WHERE status = 'active'
204
- AND (content LIKE ? OR key LIKE ?)
205
- LIMIT ?`;
206
- const keywordStmt = db.prepare(keywordSql);
207
- if (namespace !== 'all') {
208
- keywordStmt.bind([likePattern, likePattern, namespace, remainingLimit]);
209
- }
210
- else {
211
- keywordStmt.bind([likePattern, likePattern, remainingLimit]);
212
- }
213
- const keywordRows = [];
214
- while (keywordStmt.step()) {
215
- keywordRows.push(keywordStmt.get());
216
- }
217
- keywordStmt.free();
218
- for (const row of keywordRows) {
219
- const [id, key, ns, content] = row;
220
- // Avoid duplicates
221
- if (!results.some(r => r.id === id.substring(0, 10))) {
222
- results.push({
223
- score: 0.5, // Keyword match base score
224
- id: id.substring(0, 10),
225
- key: key || id.substring(0, 15),
226
- content: (content || '').substring(0, 45) + ((content || '').length > 45 ? '...' : ''),
227
- namespace: ns || 'default'
228
- });
229
- }
230
- }
231
- }
232
- // Sort by score descending
233
- results.sort((a, b) => b.score - a.score);
234
- const topResults = results.slice(0, limit);
235
- const searchTime = Date.now() - startTime;
236
- db.close();
237
- spinner.succeed(`Found ${topResults.length} matches (${searchTime}ms)`);
238
- if (topResults.length === 0) {
239
- output.writeln();
240
- output.printWarning('No matches found');
241
- output.printInfo(`Try: claude-flow memory store -k "key" --value "your data"`);
242
- return { success: true, data: [] };
243
- }
244
- output.writeln();
245
- output.printTable({
246
- columns: [
247
- { key: 'score', header: 'Score', width: 10 },
248
- { key: 'key', header: 'Key', width: 18 },
249
- { key: 'content', header: 'Content', width: 42 },
250
- ],
251
- data: topResults.map(r => ({
252
- score: r.score >= 0.8 ? output.success(r.score.toFixed(2)) :
253
- r.score >= 0.6 ? output.warning(r.score.toFixed(2)) :
254
- output.dim(r.score.toFixed(2)),
255
- key: r.key,
256
- content: r.content
257
- })),
258
- });
259
- output.writeln();
260
- output.writeln(output.dim(`Searched ${namespace} namespace (${queryResult.model}, ${searchTime}ms)`));
261
- return { success: true, data: topResults };
262
- }
263
- catch (error) {
264
- spinner.fail('Search failed');
265
- output.printError(error instanceof Error ? error.message : String(error));
266
- return { success: false, exitCode: 1 };
267
- }
268
- },
269
- };
270
- /**
271
- * Optimized cosine similarity
272
- * V8 JIT-friendly - ~0.5μs per 384-dim vector comparison
273
- */
274
- function cosineSimilarity(a, b) {
275
- const len = Math.min(a.length, b.length);
276
- if (len === 0)
277
- return 0;
278
- let dot = 0, normA = 0, normB = 0;
279
- // Simple loop - V8 optimizes this well
280
- for (let i = 0; i < len; i++) {
281
- const ai = a[i], bi = b[i];
282
- dot += ai * bi;
283
- normA += ai * ai;
284
- normB += bi * bi;
285
- }
286
- const mag = Math.sqrt(normA * normB);
287
- return mag === 0 ? 0 : dot / mag;
288
- }
289
- // Compare subcommand - REAL similarity computation
290
- const compareCommand = {
291
- name: 'compare',
292
- description: 'Compare similarity between texts',
293
- options: [
294
- { name: 'text1', type: 'string', description: 'First text', required: true },
295
- { name: 'text2', type: 'string', description: 'Second text', required: true },
296
- { name: 'metric', short: 'm', type: 'string', description: 'Metric: cosine, euclidean, dot', default: 'cosine' },
297
- ],
298
- examples: [
299
- { command: 'claude-flow embeddings compare --text1 "Hello" --text2 "Hi there"', description: 'Compare texts' },
300
- ],
301
- action: async (ctx) => {
302
- const text1 = ctx.flags.text1;
303
- const text2 = ctx.flags.text2;
304
- const metric = ctx.flags.metric || 'cosine';
305
- if (!text1 || !text2) {
306
- output.printError('Both text1 and text2 are required');
307
- return { success: false, exitCode: 1 };
308
- }
309
- output.writeln();
310
- output.writeln(output.bold('Text Similarity (Real)'));
311
- output.writeln(output.dim('─'.repeat(50)));
312
- const spinner = output.createSpinner({ text: 'Generating embeddings...', spinner: 'dots' });
313
- spinner.start();
314
- try {
315
- const { generateEmbedding } = await import('../memory/memory-initializer.js');
316
- // Generate real embeddings for both texts
317
- const startTime = Date.now();
318
- const [emb1, emb2] = await Promise.all([
319
- generateEmbedding(text1),
320
- generateEmbedding(text2),
321
- ]);
322
- const embedTime = Date.now() - startTime;
323
- spinner.setText('Computing similarity...');
324
- // Compute real similarity based on metric
325
- let similarity;
326
- switch (metric) {
327
- case 'euclidean': {
328
- // Euclidean distance (converted to similarity: 1 / (1 + distance))
329
- let sumSq = 0;
330
- for (let i = 0; i < emb1.embedding.length; i++) {
331
- const diff = emb1.embedding[i] - emb2.embedding[i];
332
- sumSq += diff * diff;
333
- }
334
- const distance = Math.sqrt(sumSq);
335
- similarity = 1 / (1 + distance);
336
- break;
337
- }
338
- case 'dot': {
339
- // Dot product
340
- let dot = 0;
341
- for (let i = 0; i < emb1.embedding.length; i++) {
342
- dot += emb1.embedding[i] * emb2.embedding[i];
343
- }
344
- similarity = dot;
345
- break;
346
- }
347
- case 'cosine':
348
- default: {
349
- // Cosine similarity
350
- similarity = cosineSimilarity(emb1.embedding, emb2.embedding);
351
- }
352
- }
353
- spinner.succeed(`Comparison complete (${embedTime}ms)`);
354
- output.writeln();
355
- output.printBox([
356
- `Text 1: "${text1.substring(0, 30)}${text1.length > 30 ? '...' : ''}"`,
357
- `Text 2: "${text2.substring(0, 30)}${text2.length > 30 ? '...' : ''}"`,
358
- ``,
359
- `Model: ${emb1.model} (${emb1.dimensions}-dim)`,
360
- `Metric: ${metric}`,
361
- `Similarity: ${similarity > 0.8 ? output.success(similarity.toFixed(4)) : similarity > 0.5 ? output.warning(similarity.toFixed(4)) : output.dim(similarity.toFixed(4))}`,
362
- ``,
363
- `Interpretation: ${similarity > 0.8 ? 'Highly similar' : similarity > 0.5 ? 'Moderately similar' : 'Dissimilar'}`,
364
- ].join('\n'), 'Result');
365
- return { success: true, data: { similarity, metric, embedTime } };
366
- }
367
- catch (error) {
368
- spinner.fail('Comparison failed');
369
- output.printError(error instanceof Error ? error.message : String(error));
370
- return { success: false, exitCode: 1 };
371
- }
372
- },
373
- };
374
- // Collections subcommand - REAL implementation using sql.js
375
- const collectionsCommand = {
376
- name: 'collections',
377
- description: 'Manage embedding collections (namespaces)',
378
- options: [
379
- { name: 'action', short: 'a', type: 'string', description: 'Action: list, stats', default: 'list' },
380
- { name: 'name', short: 'n', type: 'string', description: 'Namespace name' },
381
- { name: 'db-path', type: 'string', description: 'Database path', default: '.swarm/memory.db' },
382
- ],
383
- examples: [
384
- { command: 'claude-flow embeddings collections', description: 'List collections' },
385
- { command: 'claude-flow embeddings collections -a stats', description: 'Show detailed stats' },
386
- ],
387
- action: async (ctx) => {
388
- const action = ctx.flags.action || 'list';
389
- const dbPath = ctx.flags['db-path'] || '.swarm/memory.db';
390
- output.writeln();
391
- output.writeln(output.bold('Embedding Collections (Namespaces)'));
392
- output.writeln(output.dim('─'.repeat(60)));
393
- try {
394
- const fs = await import('fs');
395
- const path = await import('path');
396
- const fullDbPath = path.resolve(process.cwd(), dbPath);
397
- // Check if database exists
398
- if (!fs.existsSync(fullDbPath)) {
399
- output.printWarning('No database found');
400
- output.printInfo('Run: claude-flow memory init');
401
- output.writeln();
402
- output.writeln(output.dim('No collections yet - initialize memory first'));
403
- return { success: true, data: [] };
404
- }
405
- // Load sql.js and query real data
406
- const initSqlJs = (await import('sql.js')).default;
407
- const SQL = await initSqlJs();
408
- const fileBuffer = fs.readFileSync(fullDbPath);
409
- const db = new SQL.Database(fileBuffer);
410
- // Get collection stats from database
411
- const statsQuery = db.exec(`
412
- SELECT
413
- namespace,
414
- COUNT(*) as total_entries,
415
- SUM(CASE WHEN embedding IS NOT NULL THEN 1 ELSE 0 END) as with_embeddings,
416
- AVG(embedding_dimensions) as avg_dimensions,
417
- SUM(LENGTH(content)) as total_content_size
418
- FROM memory_entries
419
- WHERE status = 'active'
420
- GROUP BY namespace
421
- ORDER BY total_entries DESC
422
- `);
423
- // Get vector index info
424
- const indexQuery = db.exec(`SELECT name, dimensions, hnsw_m FROM vector_indexes`);
425
- const collections = [];
426
- if (statsQuery[0]?.values) {
427
- for (const row of statsQuery[0].values) {
428
- const [namespace, total, withEmbeddings, avgDims, contentSize] = row;
429
- collections.push({
430
- name: namespace || 'default',
431
- vectors: withEmbeddings.toLocaleString(),
432
- total: total.toLocaleString(),
433
- dimensions: avgDims ? Math.round(avgDims).toString() : '-',
434
- index: withEmbeddings > 0 ? 'HNSW' : 'None',
435
- size: formatBytes(contentSize || 0)
436
- });
437
- }
438
- }
439
- db.close();
440
- if (collections.length === 0) {
441
- output.printWarning('No collections found');
442
- output.writeln();
443
- output.writeln(output.dim('Store some data first:'));
444
- output.writeln(output.highlight(' claude-flow memory store -k "key" --value "data"'));
445
- return { success: true, data: [] };
446
- }
447
- output.printTable({
448
- columns: [
449
- { key: 'name', header: 'Namespace', width: 18 },
450
- { key: 'total', header: 'Entries', width: 10 },
451
- { key: 'vectors', header: 'Vectors', width: 10 },
452
- { key: 'dimensions', header: 'Dims', width: 8 },
453
- { key: 'index', header: 'Index', width: 8 },
454
- { key: 'size', header: 'Size', width: 10 },
455
- ],
456
- data: collections,
457
- });
458
- output.writeln();
459
- output.writeln(output.dim(`Database: ${fullDbPath}`));
460
- return { success: true, data: collections };
461
- }
462
- catch (error) {
463
- output.printError(error instanceof Error ? error.message : String(error));
464
- return { success: false, exitCode: 1 };
465
- }
466
- },
467
- };
468
- // Helper: Format bytes to human readable
469
- function formatBytes(bytes) {
470
- if (bytes === 0)
471
- return '0 B';
472
- const k = 1024;
473
- const sizes = ['B', 'KB', 'MB', 'GB'];
474
- const i = Math.floor(Math.log(bytes) / Math.log(k));
475
- return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
476
- }
477
- // Index subcommand - REAL HNSW stats
478
- const indexCommand = {
479
- name: 'index',
480
- description: 'Manage HNSW indexes',
481
- options: [
482
- { name: 'action', short: 'a', type: 'string', description: 'Action: build, rebuild, status, optimize', default: 'status' },
483
- { name: 'collection', short: 'c', type: 'string', description: 'Collection/namespace label (informational; HNSW is a single global index across all namespaces). Omit to build for all namespaces (#1947 RC2).' },
484
- { name: 'ef-construction', type: 'number', description: 'HNSW ef_construction parameter', default: '200' },
485
- { name: 'm', type: 'number', description: 'HNSW M parameter', default: '16' },
486
- ],
487
- examples: [
488
- { command: 'claude-flow embeddings index', description: 'Show index status' },
489
- { command: 'claude-flow embeddings index -a build', description: 'Build index from all namespaces' },
490
- { command: 'claude-flow embeddings index -a rebuild -c project', description: 'Rebuild (label as `project`)' },
491
- ],
492
- action: async (ctx) => {
493
- const action = ctx.flags.action || 'status';
494
- const collection = ctx.flags.collection;
495
- const efConstruction = parseInt(ctx.flags['ef-construction'] || '200', 10);
496
- const m = parseInt(ctx.flags.m || '16', 10);
497
- output.writeln();
498
- output.writeln(output.bold(`HNSW Index: ${action}`));
499
- output.writeln(output.dim('─'.repeat(50)));
500
- try {
501
- const { getHNSWStatus, getHNSWIndex, searchHNSWIndex, generateEmbedding } = await import('../memory/memory-initializer.js');
502
- // Trigger lazy initialization before reading status, otherwise the
503
- // singleton stays null and produces a misleading "@ruvector/core not
504
- // available" warning even when the package is present (#1698).
505
- await getHNSWIndex().catch(() => null);
506
- // Probe whether @ruvector/core is loadable so we can distinguish
507
- // "package missing" from "package present but index empty".
508
- const ruvectorAvailable = await import('@ruvector/core').then(() => true).catch(() => false);
509
- // Get real HNSW status
510
- const status = getHNSWStatus();
511
- if (action === 'status') {
512
- output.writeln();
513
- output.printTable({
514
- columns: [
515
- { key: 'metric', header: 'Metric', width: 24 },
516
- { key: 'value', header: 'Value', width: 30 },
517
- ],
518
- data: [
519
- { metric: 'HNSW Available', value: status.available ? output.success('Yes (@ruvector/core)') : output.warning('No') },
520
- { metric: 'Index Initialized', value: status.initialized ? output.success('Yes') : output.dim('No') },
521
- { metric: 'Vector Count', value: status.entryCount.toLocaleString() },
522
- { metric: 'Dimensions', value: String(status.dimensions) },
523
- { metric: 'Distance Metric', value: 'Cosine' },
524
- { metric: 'HNSW M', value: String(m) },
525
- { metric: 'ef_construction', value: String(efConstruction) },
526
- ],
527
- });
528
- if (status.available && status.entryCount > 0) {
529
- // Run a quick benchmark to show actual performance
530
- output.writeln();
531
- output.writeln(output.dim('Running quick performance test...'));
532
- const testQuery = await generateEmbedding('test performance query');
533
- const start = performance.now();
534
- const results = await searchHNSWIndex(testQuery.embedding, { k: 10 });
535
- const searchTime = performance.now() - start;
536
- // Estimate brute force time (0.5μs per comparison)
537
- const bruteForceEstimate = status.entryCount * 0.0005;
538
- const speedup = bruteForceEstimate / (searchTime / 1000);
539
- output.writeln();
540
- output.printBox([
541
- `Performance (n=${status.entryCount}):`,
542
- ` HNSW Search: ${searchTime.toFixed(2)}ms`,
543
- ` Brute Force Est: ${(bruteForceEstimate * 1000).toFixed(2)}ms`,
544
- ` Speedup: ~${Math.round(speedup)}x`,
545
- ` Results: ${results?.length || 0} matches`,
546
- ].join('\n'), 'Search Performance');
547
- }
548
- else if (!status.available && !ruvectorAvailable) {
549
- output.writeln();
550
- output.printWarning('@ruvector/core not available');
551
- output.printInfo('Install: npm install @ruvector/core');
552
- }
553
- else if (!status.available) {
554
- output.writeln();
555
- output.printWarning('HNSW index not initialized (but @ruvector/core is installed)');
556
- output.printInfo('This usually means no embeddings have been stored yet.');
557
- output.printInfo('Run: claude-flow memory store -k "key" --value "text"');
558
- }
559
- else {
560
- output.writeln();
561
- output.printInfo('Index is empty. Store some entries to populate it.');
562
- output.printInfo('Run: claude-flow memory store -k "key" --value "text"');
563
- }
564
- return { success: true, data: status };
565
- }
566
- // Build/Rebuild action
567
- if (action === 'build' || action === 'rebuild') {
568
- // #1947 RC #2: `-c` is informational — the HNSW index is global
569
- // and indexes every namespace's embeddings in one structure. The
570
- // earlier code REQUIRED `-c` for build/rebuild AND its examples
571
- // suggested `-c default`, which silently produced 0 vectors when a
572
- // user's entries lived under a different namespace (e.g. `project`,
573
- // `claude-memories`). Treat omitted `-c` as "all namespaces"
574
- // (the actual runtime behavior) and tell the user as much.
575
- const label = collection ?? '(all namespaces)';
576
- const spinner = output.createSpinner({ text: `${action}ing index for ${label}...`, spinner: 'dots' });
577
- spinner.start();
578
- // Force rebuild if requested
579
- const index = await getHNSWIndex({ forceRebuild: action === 'rebuild' });
580
- if (!index) {
581
- spinner.fail('@ruvector/core not available');
582
- output.printInfo('Install: npm install @ruvector/core');
583
- return { success: false, exitCode: 1 };
584
- }
585
- spinner.succeed(`Index ${action} complete`);
586
- const newStatus = getHNSWStatus();
587
- output.writeln();
588
- output.printBox([
589
- `Collection: ${label}`,
590
- `Action: ${action}`,
591
- `Vectors: ${newStatus.entryCount}`,
592
- `Dimensions: ${newStatus.dimensions}`,
593
- `M: ${m}`,
594
- `ef_construction: ${efConstruction}`,
595
- ].join('\n'), 'Index Built');
596
- if (!collection && newStatus.entryCount === 0) {
597
- output.writeln();
598
- output.printInfo('No vectors indexed. Store some entries first:');
599
- output.printInfo(' claude-flow memory store -k "key" --value "text" --namespace <ns>');
600
- }
601
- return { success: true, data: newStatus };
602
- }
603
- // Optimize action
604
- if (action === 'optimize') {
605
- output.printInfo('HNSW index is optimized automatically during search');
606
- output.printInfo('No manual optimization required');
607
- return { success: true };
608
- }
609
- output.printError(`Unknown action: ${action}`);
610
- return { success: false, exitCode: 1 };
611
- }
612
- catch (error) {
613
- output.printError(error instanceof Error ? error.message : String(error));
614
- return { success: false, exitCode: 1 };
615
- }
616
- },
617
- };
618
- // Init subcommand - Initialize ONNX models and hyperbolic config
619
- const initCommand = {
620
- name: 'init',
621
- description: 'Initialize embedding subsystem with ONNX model and hyperbolic config',
622
- options: [
623
- { name: 'model', short: 'm', type: 'string', description: 'ONNX model ID', default: 'all-MiniLM-L6-v2' },
624
- { name: 'hyperbolic', type: 'boolean', description: 'Enable hyperbolic (Poincaré ball) embeddings', default: 'true' },
625
- { name: 'curvature', short: 'c', type: 'string', description: 'Poincaré ball curvature (use --curvature=-1 for negative)', default: '-1' },
626
- { name: 'download', short: 'd', type: 'boolean', description: 'Download model during init', default: 'true' },
627
- { name: 'cache-size', type: 'string', description: 'LRU cache entries', default: '256' },
628
- { name: 'force', short: 'f', type: 'boolean', description: 'Overwrite existing configuration', default: 'false' },
629
- ],
630
- examples: [
631
- { command: 'claude-flow embeddings init', description: 'Initialize with defaults' },
632
- { command: 'claude-flow embeddings init --model all-mpnet-base-v2', description: 'Use higher quality model' },
633
- { command: 'claude-flow embeddings init --no-hyperbolic', description: 'Euclidean only' },
634
- { command: 'claude-flow embeddings init --curvature=-0.5', description: 'Custom curvature (use = for negative)' },
635
- { command: 'claude-flow embeddings init --force', description: 'Overwrite existing config' },
636
- ],
637
- action: async (ctx) => {
638
- const model = ctx.flags.model || 'all-MiniLM-L6-v2';
639
- const hyperbolic = ctx.flags.hyperbolic !== false;
640
- const download = ctx.flags.download !== false;
641
- const force = ctx.flags.force === true;
642
- // Parse curvature - handle both kebab-case and direct value
643
- const curvatureRaw = ctx.flags.curvature || '-1';
644
- const curvature = parseFloat(curvatureRaw);
645
- // Parse cache-size - check both kebab-case and camelCase
646
- const cacheSizeRaw = (ctx.flags['cache-size'] || ctx.flags.cacheSize || '256');
647
- const cacheSize = parseInt(cacheSizeRaw, 10);
648
- output.writeln();
649
- output.writeln(output.bold('Initialize Embedding Subsystem'));
650
- output.writeln(output.dim('─'.repeat(55)));
651
- try {
652
- const fs = await import('fs');
653
- const path = await import('path');
654
- // Create directories
655
- const configDir = path.join(process.cwd(), '.claude-flow');
656
- const modelDir = path.join(configDir, 'models');
657
- const configPath = path.join(configDir, 'embeddings.json');
658
- // Check for existing config
659
- if (fs.existsSync(configPath) && !force) {
660
- output.printWarning('Embeddings already initialized');
661
- output.printInfo(`Config exists: ${configPath}`);
662
- output.writeln();
663
- output.writeln(output.dim('Use --force to overwrite existing configuration'));
664
- return { success: false, exitCode: 1 };
665
- }
666
- const spinner = output.createSpinner({ text: 'Initializing...', spinner: 'dots' });
667
- spinner.start();
668
- if (!fs.existsSync(configDir)) {
669
- fs.mkdirSync(configDir, { recursive: true });
670
- }
671
- if (!fs.existsSync(modelDir)) {
672
- fs.mkdirSync(modelDir, { recursive: true });
673
- }
674
- // Download model if requested
675
- if (download) {
676
- spinner.setText(`Downloading ONNX model: ${model}...`);
677
- const embeddings = await getEmbeddings();
678
- if (embeddings) {
679
- await embeddings.downloadEmbeddingModel(model, modelDir, (p) => {
680
- spinner.setText(`Downloading ${model}... ${p.percent.toFixed(0)}%`);
681
- });
682
- }
683
- else {
684
- // Embeddings package not available — skip download
685
- await new Promise(r => setTimeout(r, 500));
686
- output.writeln(output.dim(' (Skipped — @claude-flow/embeddings not installed)'));
687
- }
688
- }
689
- // Write embeddings config
690
- spinner.setText('Writing configuration...');
691
- const dimension = model.includes('mpnet') ? 768 : 384;
692
- const config = {
693
- model,
694
- modelPath: modelDir,
695
- dimension,
696
- cacheSize,
697
- hyperbolic: {
698
- enabled: hyperbolic,
699
- curvature,
700
- epsilon: 1e-15,
701
- maxNorm: 1 - 1e-5,
702
- },
703
- neural: {
704
- enabled: true,
705
- driftThreshold: 0.3,
706
- decayRate: 0.01,
707
- },
708
- initialized: new Date().toISOString(),
709
- };
710
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
711
- spinner.succeed('Embedding subsystem initialized');
712
- output.writeln();
713
- output.printTable({
714
- columns: [
715
- { key: 'setting', header: 'Setting', width: 18 },
716
- { key: 'value', header: 'Value', width: 40 },
717
- ],
718
- data: [
719
- { setting: 'Model', value: model },
720
- { setting: 'Dimension', value: String(dimension) },
721
- { setting: 'Cache Size', value: String(cacheSize) + ' entries' },
722
- { setting: 'Hyperbolic', value: hyperbolic ? `${output.success('Enabled')} (c=${curvature})` : output.dim('Disabled') },
723
- { setting: 'Neural Substrate', value: output.success('Enabled') },
724
- { setting: 'Model Path', value: modelDir },
725
- { setting: 'Config', value: configPath },
726
- ],
727
- });
728
- output.writeln();
729
- if (hyperbolic) {
730
- output.printBox([
731
- 'Hyperbolic Embeddings (Poincaré Ball):',
732
- '• Better for hierarchical data (trees, taxonomies)',
733
- '• Exponential capacity in low dimensions',
734
- '• Distance preserves hierarchy structure',
735
- '',
736
- 'Use: embeddings hyperbolic -a convert',
737
- ].join('\n'), 'Hyperbolic Space');
738
- }
739
- output.writeln();
740
- output.writeln(output.dim('Next steps:'));
741
- output.printList([
742
- 'embeddings generate -t "test text" - Test embedding generation',
743
- 'embeddings search -q "query" - Semantic search',
744
- 'memory store -k key --value text - Store with auto-embedding',
745
- ]);
746
- return { success: true, data: config };
747
- }
748
- catch (error) {
749
- output.printError('Initialization failed: ' + (error instanceof Error ? error.message : String(error)));
750
- return { success: false, exitCode: 1 };
751
- }
752
- },
753
- };
754
- // Providers subcommand
755
- const providersCommand = {
756
- name: 'providers',
757
- description: 'List available embedding providers',
758
- options: [],
759
- examples: [
760
- { command: 'claude-flow embeddings providers', description: 'List providers' },
761
- ],
762
- action: async () => {
763
- output.writeln();
764
- output.writeln(output.bold('Embedding Providers'));
765
- output.writeln(output.dim('─'.repeat(70)));
766
- output.printTable({
767
- columns: [
768
- { key: 'provider', header: 'Provider', width: 18 },
769
- { key: 'model', header: 'Model', width: 25 },
770
- { key: 'dims', header: 'Dims', width: 8 },
771
- { key: 'type', header: 'Type', width: 10 },
772
- { key: 'status', header: 'Status', width: 12 },
773
- ],
774
- data: [
775
- { provider: 'OpenAI', model: 'text-embedding-3-small', dims: '1536', type: 'Cloud', status: output.success('Ready') },
776
- { provider: 'OpenAI', model: 'text-embedding-3-large', dims: '3072', type: 'Cloud', status: output.success('Ready') },
777
- { provider: 'Transformers.js', model: 'Xenova/all-MiniLM-L6-v2', dims: '384', type: 'Local', status: output.success('Ready') },
778
- { provider: 'Agentic Flow', model: 'ONNX optimized', dims: '384', type: 'Local', status: output.success('Ready') },
779
- { provider: 'Mock', model: 'mock-embedding', dims: '384', type: 'Dev', status: output.dim('Dev only') },
780
- ],
781
- });
782
- output.writeln();
783
- output.writeln(output.dim('Agentic Flow provider uses WASM SIMD for 75x faster inference'));
784
- return { success: true };
785
- },
786
- };
787
- // Chunk subcommand
788
- const chunkCommand = {
789
- name: 'chunk',
790
- description: 'Chunk text for embedding with overlap',
791
- options: [
792
- { name: 'text', short: 't', type: 'string', description: 'Text to chunk', required: true },
793
- { name: 'max-size', short: 's', type: 'number', description: 'Max chunk size in chars', default: '512' },
794
- { name: 'overlap', short: 'o', type: 'number', description: 'Overlap between chunks', default: '50' },
795
- { name: 'strategy', type: 'string', description: 'Strategy: character, sentence, paragraph, token', default: 'sentence' },
796
- { name: 'file', short: 'f', type: 'string', description: 'File to chunk (instead of text)' },
797
- ],
798
- examples: [
799
- { command: 'claude-flow embeddings chunk -t "Long text..." -s 256', description: 'Chunk with 256 char limit' },
800
- { command: 'claude-flow embeddings chunk -f doc.txt --strategy paragraph', description: 'Chunk file by paragraph' },
801
- ],
802
- action: async (ctx) => {
803
- const embeddings = await getEmbeddings();
804
- const text = ctx.flags.text || '';
805
- const maxSize = parseInt(ctx.flags['max-size'] || '512', 10);
806
- const overlap = parseInt(ctx.flags.overlap || '50', 10);
807
- const strategy = ctx.flags.strategy || 'sentence';
808
- output.writeln();
809
- output.writeln(output.bold('Document Chunking'));
810
- output.writeln(output.dim('─'.repeat(50)));
811
- if (!embeddings) {
812
- output.printWarning('@claude-flow/embeddings not installed, showing preview');
813
- output.writeln();
814
- output.printBox([
815
- `Strategy: ${strategy}`,
816
- `Max Size: ${maxSize} chars`,
817
- `Overlap: ${overlap} chars`,
818
- ``,
819
- `Estimated chunks: ${Math.ceil(text.length / (maxSize - overlap))}`,
820
- ].join('\n'), 'Chunking Preview');
821
- return { success: true };
822
- }
823
- const result = embeddings.chunkText(text, { maxChunkSize: maxSize, overlap, strategy: strategy });
824
- output.writeln();
825
- output.printTable({
826
- columns: [
827
- { key: 'idx', header: '#', width: 5 },
828
- { key: 'length', header: 'Chars', width: 8 },
829
- { key: 'tokens', header: 'Tokens', width: 8 },
830
- { key: 'preview', header: 'Preview', width: 45 },
831
- ],
832
- data: result.chunks.map((c, i) => ({
833
- idx: String(i + 1),
834
- length: String(c.length),
835
- tokens: String(c.tokenCount),
836
- preview: c.text.substring(0, 42) + (c.text.length > 42 ? '...' : ''),
837
- })),
838
- });
839
- output.writeln();
840
- output.writeln(output.dim(`Total: ${result.totalChunks} chunks from ${result.originalLength} chars`));
841
- return { success: true };
842
- },
843
- };
844
- // Normalize subcommand
845
- const normalizeCommand = {
846
- name: 'normalize',
847
- description: 'Normalize embedding vectors',
848
- options: [
849
- { name: 'type', short: 't', type: 'string', description: 'Type: l2, l1, minmax, zscore', default: 'l2' },
850
- { name: 'input', short: 'i', type: 'string', description: 'Input embedding (JSON array)' },
851
- { name: 'check', short: 'c', type: 'boolean', description: 'Check if already normalized' },
852
- ],
853
- examples: [
854
- { command: 'claude-flow embeddings normalize -i "[0.5, 0.3, 0.8]" -t l2', description: 'L2 normalize' },
855
- { command: 'claude-flow embeddings normalize --check -i "[...]"', description: 'Check if normalized' },
856
- ],
857
- action: async (ctx) => {
858
- const type = ctx.flags.type || 'l2';
859
- const check = ctx.flags.check;
860
- output.writeln();
861
- output.writeln(output.bold('Embedding Normalization'));
862
- output.writeln(output.dim('─'.repeat(50)));
863
- output.printTable({
864
- columns: [
865
- { key: 'type', header: 'Type', width: 12 },
866
- { key: 'formula', header: 'Formula', width: 30 },
867
- { key: 'use', header: 'Best For', width: 25 },
868
- ],
869
- data: [
870
- { type: output.success('L2'), formula: 'v / ||v||₂', use: 'Cosine similarity' },
871
- { type: 'L1', formula: 'v / ||v||₁', use: 'Sparse vectors' },
872
- { type: 'Min-Max', formula: '(v - min) / (max - min)', use: 'Bounded range [0,1]' },
873
- { type: 'Z-Score', formula: '(v - μ) / σ', use: 'Statistical analysis' },
874
- ],
875
- });
876
- output.writeln();
877
- output.writeln(output.dim(`Selected: ${type.toUpperCase()} normalization`));
878
- output.writeln(output.dim('Most embedding models pre-normalize with L2'));
879
- return { success: true };
880
- },
881
- };
882
- // Hyperbolic subcommand
883
- const hyperbolicCommand = {
884
- name: 'hyperbolic',
885
- description: 'Hyperbolic embedding operations (Poincaré ball)',
886
- options: [
887
- { name: 'action', short: 'a', type: 'string', description: 'Action: convert, distance, centroid', default: 'convert' },
888
- { name: 'curvature', short: 'c', type: 'number', description: 'Hyperbolic curvature', default: '-1' },
889
- { name: 'input', short: 'i', type: 'string', description: 'Input embedding(s) JSON' },
890
- ],
891
- examples: [
892
- { command: 'claude-flow embeddings hyperbolic -a convert -i "[0.5, 0.3]"', description: 'Convert to Poincaré' },
893
- { command: 'claude-flow embeddings hyperbolic -a distance', description: 'Compute hyperbolic distance' },
894
- ],
895
- action: async (ctx) => {
896
- const action = ctx.flags.action || 'convert';
897
- const curvature = parseFloat(ctx.flags.curvature || '-1');
898
- const inputJson = ctx.flags.input;
899
- output.writeln();
900
- output.writeln(output.bold('Hyperbolic Embeddings'));
901
- output.writeln(output.dim('Poincaré Ball Model'));
902
- output.writeln(output.dim('─'.repeat(50)));
903
- // Try to import hyperbolic functions from embeddings package
904
- try {
905
- const hyperbolic = await import('@claude-flow/embeddings').then(m => m).catch(() => null);
906
- if (!hyperbolic || !hyperbolic.euclideanToPoincare) {
907
- output.printWarning('@claude-flow/embeddings hyperbolic module not available');
908
- output.printInfo('Install with: npm install @claude-flow/embeddings');
909
- return { success: false, exitCode: 1 };
910
- }
911
- if (!inputJson) {
912
- // Show help if no input
913
- output.printBox([
914
- 'Hyperbolic embeddings excel at:',
915
- '• Hierarchical data representation',
916
- '• Tree-like structure preservation',
917
- '• Low-dimensional hierarchy encoding',
918
- '',
919
- 'Actions: convert, distance, centroid',
920
- '',
921
- 'Examples:',
922
- ' -a convert -i "[0.5, 0.3, 0.1]"',
923
- ' -a distance -i "[[0.1,0.2],[0.3,0.4]]"',
924
- ].join('\n'), 'Hyperbolic Geometry');
925
- return { success: true };
926
- }
927
- // Parse input vector(s)
928
- let input;
929
- try {
930
- input = JSON.parse(inputJson);
931
- }
932
- catch {
933
- output.printError('Invalid JSON input. Use format: "[0.5, 0.3]" or "[[0.1,0.2],[0.3,0.4]]"');
934
- return { success: false, exitCode: 1 };
935
- }
936
- switch (action) {
937
- case 'convert': {
938
- const vec = Array.isArray(input[0]) ? input[0] : input;
939
- const rawResult = hyperbolic.euclideanToPoincare(vec, { curvature });
940
- const result = Array.from(rawResult);
941
- output.writeln(output.success('Euclidean → Poincaré conversion:'));
942
- output.writeln();
943
- output.writeln(`Input (Euclidean): [${vec.slice(0, 6).map(v => v.toFixed(4)).join(', ')}${vec.length > 6 ? ', ...' : ''}]`);
944
- output.writeln(`Output (Poincaré): [${result.slice(0, 6).map(v => v.toFixed(4)).join(', ')}${result.length > 6 ? ', ...' : ''}]`);
945
- output.writeln(`Curvature: ${curvature}`);
946
- output.writeln(`Norm: ${Math.sqrt(result.reduce((s, v) => s + v * v, 0)).toFixed(6)} (must be < 1)`);
947
- return { success: true, data: { result } };
948
- }
949
- case 'distance': {
950
- if (!Array.isArray(input[0]) || input.length < 2) {
951
- output.printError('Distance requires two vectors: "[[v1],[v2]]"');
952
- return { success: false, exitCode: 1 };
953
- }
954
- const [v1, v2] = input;
955
- const dist = hyperbolic.hyperbolicDistance(v1, v2, { curvature });
956
- output.writeln(output.success('Hyperbolic (geodesic) distance:'));
957
- output.writeln();
958
- output.writeln(`Vector 1: [${v1.slice(0, 4).map(v => v.toFixed(4)).join(', ')}...]`);
959
- output.writeln(`Vector 2: [${v2.slice(0, 4).map(v => v.toFixed(4)).join(', ')}...]`);
960
- output.writeln(`Distance: ${dist.toFixed(6)}`);
961
- return { success: true, data: { distance: dist } };
962
- }
963
- case 'centroid': {
964
- if (!Array.isArray(input[0])) {
965
- output.printError('Centroid requires multiple vectors: "[[v1],[v2],...]"');
966
- return { success: false, exitCode: 1 };
967
- }
968
- const vectors = input;
969
- const rawCentroid = hyperbolic.hyperbolicCentroid(vectors, { curvature });
970
- const centroid = Array.from(rawCentroid);
971
- output.writeln(output.success('Hyperbolic centroid (Fréchet mean):'));
972
- output.writeln();
973
- output.writeln(`Input vectors: ${vectors.length}`);
974
- output.writeln(`Centroid: [${centroid.slice(0, 6).map(v => v.toFixed(4)).join(', ')}${centroid.length > 6 ? ', ...' : ''}]`);
975
- return { success: true, data: { centroid } };
976
- }
977
- default:
978
- output.printError(`Unknown action: ${action}. Use: convert, distance, centroid`);
979
- return { success: false, exitCode: 1 };
980
- }
981
- }
982
- catch (error) {
983
- output.printError(`Hyperbolic operation failed: ${error.message}`);
984
- return { success: false, exitCode: 1 };
985
- }
986
- },
987
- };
988
- // Neural subcommand
989
- const neuralCommand = {
990
- name: 'neural',
991
- description: 'Neural substrate features (RuVector integration)',
992
- options: [
993
- { name: 'feature', short: 'f', type: 'string', description: 'Feature: drift, memory, swarm, coherence, all', default: 'all' },
994
- { name: 'init', type: 'boolean', description: 'Initialize neural substrate with RuVector' },
995
- { name: 'drift-threshold', type: 'string', description: 'Semantic drift detection threshold', default: '0.3' },
996
- { name: 'decay-rate', type: 'string', description: 'Memory decay rate (hippocampal dynamics)', default: '0.01' },
997
- { name: 'consolidation-interval', type: 'string', description: 'Memory consolidation interval (ms)', default: '60000' },
998
- ],
999
- examples: [
1000
- { command: 'claude-flow embeddings neural --init', description: 'Initialize RuVector substrate' },
1001
- { command: 'claude-flow embeddings neural -f drift', description: 'Semantic drift detection' },
1002
- { command: 'claude-flow embeddings neural -f memory', description: 'Memory physics (hippocampal)' },
1003
- { command: 'claude-flow embeddings neural -f coherence', description: 'Safety & alignment monitoring' },
1004
- { command: 'claude-flow embeddings neural --drift-threshold=0.2', description: 'Custom drift threshold' },
1005
- ],
1006
- action: async (ctx) => {
1007
- const feature = ctx.flags.feature || 'all';
1008
- const init = ctx.flags.init;
1009
- const driftThreshold = parseFloat((ctx.flags['drift-threshold'] || ctx.flags.driftThreshold || '0.3'));
1010
- const decayRate = parseFloat((ctx.flags['decay-rate'] || ctx.flags.decayRate || '0.01'));
1011
- const consolidationInterval = parseInt((ctx.flags['consolidation-interval'] || ctx.flags.consolidationInterval || '60000'), 10);
1012
- output.writeln();
1013
- output.writeln(output.bold('Neural Embedding Substrate (RuVector)'));
1014
- output.writeln(output.dim('Treating embeddings as a synthetic nervous system'));
1015
- output.writeln(output.dim('─'.repeat(60)));
1016
- // Check if embeddings config exists
1017
- const fs = await import('fs');
1018
- const path = await import('path');
1019
- const configPath = path.join(process.cwd(), '.claude-flow', 'embeddings.json');
1020
- if (!fs.existsSync(configPath)) {
1021
- output.printWarning('Embeddings not initialized');
1022
- output.printInfo('Run "embeddings init" first to configure ONNX model');
1023
- return { success: false, exitCode: 1 };
1024
- }
1025
- // Load and update config
1026
- let config = {};
1027
- try {
1028
- config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
1029
- }
1030
- catch {
1031
- config = {};
1032
- }
1033
- if (init) {
1034
- // Initialize neural substrate configuration
1035
- config.neural = {
1036
- enabled: true,
1037
- driftThreshold,
1038
- decayRate,
1039
- consolidationInterval,
1040
- ruvector: {
1041
- enabled: true,
1042
- sona: true, // Self-Optimizing Neural Architecture
1043
- flashAttention: true,
1044
- ewcPlusPlus: true, // Elastic Weight Consolidation
1045
- },
1046
- features: {
1047
- semanticDrift: true,
1048
- memoryPhysics: true,
1049
- stateMachine: true,
1050
- swarmCoordination: true,
1051
- coherenceMonitor: true,
1052
- },
1053
- initializedAt: new Date().toISOString(),
1054
- };
1055
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
1056
- output.printSuccess('Neural substrate initialized');
1057
- output.writeln();
1058
- }
1059
- const neuralConfig = (config.neural || {});
1060
- const features = (neuralConfig.features || {});
1061
- const ruvector = (neuralConfig.ruvector || {});
1062
- output.printTable({
1063
- columns: [
1064
- { key: 'feature', header: 'Feature', width: 24 },
1065
- { key: 'description', header: 'Description', width: 38 },
1066
- { key: 'status', header: 'Status', width: 12 },
1067
- ],
1068
- data: [
1069
- {
1070
- feature: 'SemanticDriftDetector',
1071
- description: `Monitor semantic movement (threshold: ${driftThreshold})`,
1072
- status: features.semanticDrift ? output.success('Active') : output.dim('Inactive')
1073
- },
1074
- {
1075
- feature: 'MemoryPhysics',
1076
- description: `Hippocampal dynamics (decay: ${decayRate})`,
1077
- status: features.memoryPhysics ? output.success('Active') : output.dim('Inactive')
1078
- },
1079
- {
1080
- feature: 'EmbeddingStateMachine',
1081
- description: 'Agent state through geometry',
1082
- status: features.stateMachine ? output.success('Active') : output.dim('Inactive')
1083
- },
1084
- {
1085
- feature: 'SwarmCoordinator',
1086
- description: 'Multi-agent embedding coordination',
1087
- status: features.swarmCoordination ? output.success('Active') : output.dim('Inactive')
1088
- },
1089
- {
1090
- feature: 'CoherenceMonitor',
1091
- description: 'Safety & alignment detection',
1092
- status: features.coherenceMonitor ? output.success('Active') : output.dim('Inactive')
1093
- },
1094
- ],
1095
- });
1096
- output.writeln();
1097
- output.writeln(output.bold('RuVector Integration'));
1098
- output.printTable({
1099
- columns: [
1100
- { key: 'component', header: 'Component', width: 24 },
1101
- { key: 'description', header: 'Description', width: 38 },
1102
- { key: 'status', header: 'Status', width: 12 },
1103
- ],
1104
- data: [
1105
- {
1106
- component: 'SONA',
1107
- description: 'Self-Optimizing Neural Architecture (<0.05ms)',
1108
- status: ruvector.sona ? output.success('Enabled') : output.dim('Disabled')
1109
- },
1110
- {
1111
- component: 'Flash Attention',
1112
- description: '2.49x-7.47x attention speedup',
1113
- status: ruvector.flashAttention ? output.success('Enabled') : output.dim('Disabled')
1114
- },
1115
- {
1116
- component: 'EWC++',
1117
- description: 'Elastic Weight Consolidation (anti-forgetting)',
1118
- status: ruvector.ewcPlusPlus ? output.success('Enabled') : output.dim('Disabled')
1119
- },
1120
- {
1121
- component: 'Hyperbolic Space',
1122
- description: 'Poincaré ball for hierarchy preservation',
1123
- status: config.hyperbolic ? output.success('Enabled') : output.dim('Disabled')
1124
- },
1125
- ],
1126
- });
1127
- output.writeln();
1128
- if (!neuralConfig.enabled) {
1129
- output.printInfo('Run with --init to enable neural substrate');
1130
- }
1131
- else {
1132
- output.writeln(output.dim('Configuration: .claude-flow/embeddings.json'));
1133
- output.writeln(output.dim('Next: Use "hooks pretrain" to train patterns'));
1134
- }
1135
- return { success: true, data: { config: neuralConfig, feature } };
1136
- },
1137
- };
1138
- // Models subcommand
1139
- const modelsCommand = {
1140
- name: 'models',
1141
- description: 'List and download embedding models',
1142
- options: [
1143
- { name: 'download', short: 'd', type: 'string', description: 'Model ID to download' },
1144
- { name: 'list', short: 'l', type: 'boolean', description: 'List available models', default: 'true' },
1145
- ],
1146
- examples: [
1147
- { command: 'claude-flow embeddings models', description: 'List models' },
1148
- { command: 'claude-flow embeddings models -d all-MiniLM-L6-v2', description: 'Download model' },
1149
- ],
1150
- action: async (ctx) => {
1151
- const download = ctx.flags.download;
1152
- const embeddings = await getEmbeddings();
1153
- output.writeln();
1154
- output.writeln(output.bold('Embedding Models'));
1155
- output.writeln(output.dim('─'.repeat(60)));
1156
- if (download) {
1157
- const spinner = output.createSpinner({ text: `Downloading ${download}...`, spinner: 'dots' });
1158
- spinner.start();
1159
- if (embeddings) {
1160
- try {
1161
- await embeddings.downloadEmbeddingModel(download, '.models', (p) => {
1162
- spinner.setText(`Downloading ${download}... ${p.percent.toFixed(1)}%`);
1163
- });
1164
- spinner.succeed(`Downloaded ${download}`);
1165
- }
1166
- catch (err) {
1167
- spinner.fail(`Failed to download: ${err}`);
1168
- return { success: false, exitCode: 1 };
1169
- }
1170
- }
1171
- else {
1172
- await new Promise(r => setTimeout(r, 500));
1173
- spinner.succeed(`Download skipped — @claude-flow/embeddings not installed`);
1174
- }
1175
- return { success: true };
1176
- }
1177
- // List models
1178
- let models = [
1179
- { id: 'Xenova/all-MiniLM-L6-v2', dimension: 384, size: '23MB', quantized: false, downloaded: true },
1180
- { id: 'Xenova/all-mpnet-base-v2', dimension: 768, size: '110MB', quantized: false, downloaded: false },
1181
- { id: 'Xenova/paraphrase-MiniLM-L3-v2', dimension: 384, size: '17MB', quantized: false, downloaded: false },
1182
- ];
1183
- if (embeddings) {
1184
- try {
1185
- models = await embeddings.listEmbeddingModels();
1186
- }
1187
- catch { /* use defaults */ }
1188
- }
1189
- output.printTable({
1190
- columns: [
1191
- { key: 'id', header: 'Model ID', width: 28 },
1192
- { key: 'dimension', header: 'Dims', width: 8 },
1193
- { key: 'size', header: 'Size', width: 10 },
1194
- { key: 'quantized', header: 'Quant', width: 8 },
1195
- { key: 'downloaded', header: 'Status', width: 12 },
1196
- ],
1197
- data: models.map(m => ({
1198
- id: m.id,
1199
- dimension: String(m.dimension),
1200
- size: m.size,
1201
- quantized: m.quantized ? 'Yes' : 'No',
1202
- downloaded: m.downloaded ? output.success('Downloaded') : output.dim('Available'),
1203
- })),
1204
- });
1205
- return { success: true };
1206
- },
1207
- };
1208
- // Cache subcommand
1209
- const cacheCommand = {
1210
- name: 'cache',
1211
- description: 'Manage embedding cache',
1212
- options: [
1213
- { name: 'action', short: 'a', type: 'string', description: 'Action: stats, clear, persist', default: 'stats' },
1214
- { name: 'db-path', type: 'string', description: 'SQLite database path', default: '.cache/embeddings.db' },
1215
- ],
1216
- examples: [
1217
- { command: 'claude-flow embeddings cache', description: 'Show cache stats' },
1218
- { command: 'claude-flow embeddings cache -a clear', description: 'Clear cache' },
1219
- ],
1220
- action: async (ctx) => {
1221
- const action = ctx.flags.action || 'stats';
1222
- const dbPath = ctx.flags['db-path'] || '.cache/embeddings.db';
1223
- output.writeln();
1224
- output.writeln(output.bold('Embedding Cache'));
1225
- output.writeln(output.dim('─'.repeat(50)));
1226
- const fs = await import('fs');
1227
- const path = await import('path');
1228
- // Get real cache stats
1229
- const resolvedDbPath = path.resolve(dbPath);
1230
- let sqliteEntries = 0;
1231
- let sqliteSize = '0 B';
1232
- let sqliteExists = false;
1233
- try {
1234
- if (fs.existsSync(resolvedDbPath)) {
1235
- sqliteExists = true;
1236
- const stats = fs.statSync(resolvedDbPath);
1237
- const sizeBytes = stats.size;
1238
- // Format size
1239
- if (sizeBytes >= 1024 * 1024) {
1240
- sqliteSize = `${(sizeBytes / 1024 / 1024).toFixed(1)} MB`;
1241
- }
1242
- else if (sizeBytes >= 1024) {
1243
- sqliteSize = `${(sizeBytes / 1024).toFixed(1)} KB`;
1244
- }
1245
- else {
1246
- sqliteSize = `${sizeBytes} B`;
1247
- }
1248
- // Try to count real entries via sql.js
1249
- try {
1250
- const initSqlJs = (await import('sql.js')).default;
1251
- const SQL = await initSqlJs();
1252
- const fileBuffer = fs.readFileSync(resolvedDbPath);
1253
- const db = new SQL.Database(fileBuffer);
1254
- const result = db.exec('SELECT COUNT(*) as count FROM embeddings');
1255
- if (result.length > 0 && result[0].values.length > 0) {
1256
- sqliteEntries = result[0].values[0][0];
1257
- }
1258
- db.close();
1259
- }
1260
- catch {
1261
- // Estimate entries from file size (~1600 bytes per entry for 384-dim embeddings)
1262
- sqliteEntries = Math.floor(stats.size / 1600);
1263
- }
1264
- }
1265
- }
1266
- catch { /* file access error */ }
1267
- // Get in-memory HNSW stats if available
1268
- let memoryEntries = 0;
1269
- let memorySize = '0 B';
1270
- try {
1271
- const { getHNSWStatus } = await import('../memory/memory-initializer.js');
1272
- const hnswStatus = getHNSWStatus();
1273
- if (hnswStatus && hnswStatus.initialized) {
1274
- memoryEntries = hnswStatus.entryCount || 0;
1275
- const memBytes = memoryEntries * (hnswStatus.dimensions || 384) * 4; // Float32 = 4 bytes per dimension
1276
- if (memBytes >= 1024 * 1024) {
1277
- memorySize = `${(memBytes / 1024 / 1024).toFixed(1)} MB`;
1278
- }
1279
- else if (memBytes >= 1024) {
1280
- memorySize = `${(memBytes / 1024).toFixed(1)} KB`;
1281
- }
1282
- else {
1283
- memorySize = `${memBytes} B`;
1284
- }
1285
- }
1286
- }
1287
- catch { /* HNSW not initialized */ }
1288
- if (action === 'clear') {
1289
- try {
1290
- if (fs.existsSync(resolvedDbPath)) {
1291
- fs.unlinkSync(resolvedDbPath);
1292
- output.writeln(output.success('Cache cleared!'));
1293
- }
1294
- else {
1295
- output.writeln(output.dim('No cache to clear.'));
1296
- }
1297
- return { success: true };
1298
- }
1299
- catch (error) {
1300
- output.printError(`Failed to clear cache: ${error}`);
1301
- return { success: false };
1302
- }
1303
- }
1304
- // Display real stats
1305
- output.printTable({
1306
- columns: [
1307
- { key: 'cache', header: 'Cache Type', width: 18 },
1308
- { key: 'entries', header: 'Entries', width: 12 },
1309
- { key: 'status', header: 'Status', width: 12 },
1310
- { key: 'size', header: 'Size', width: 12 },
1311
- ],
1312
- data: [
1313
- {
1314
- cache: 'LRU (Memory)',
1315
- entries: String(memoryEntries),
1316
- status: memoryEntries > 0 ? output.success('Active') : output.dim('Empty'),
1317
- size: memorySize,
1318
- },
1319
- {
1320
- cache: 'SQLite (Disk)',
1321
- entries: String(sqliteEntries),
1322
- status: sqliteExists ? output.success('Active') : output.dim('Not Found'),
1323
- size: sqliteSize,
1324
- },
1325
- ],
1326
- });
1327
- output.writeln();
1328
- output.writeln(output.dim(`Database: ${resolvedDbPath}`));
1329
- if (sqliteExists) {
1330
- output.writeln(output.dim('Persistent cache survives restarts'));
1331
- }
1332
- else {
1333
- output.writeln(output.dim('Cache will be created on first embedding operation'));
1334
- }
1335
- return { success: true };
1336
- },
1337
- };
1338
- // Warmup subcommand - Preload model for faster first embed
1339
- const warmupCommand = {
1340
- name: 'warmup',
1341
- description: 'Preload embedding model for faster subsequent operations',
1342
- options: [
1343
- { name: 'background', short: 'b', type: 'boolean', description: 'Run warmup in background daemon', default: 'false' },
1344
- { name: 'test', short: 't', type: 'boolean', description: 'Run test embedding after warmup', default: 'true' },
1345
- ],
1346
- examples: [
1347
- { command: 'claude-flow embeddings warmup', description: 'Preload model with test' },
1348
- { command: 'claude-flow embeddings warmup -b', description: 'Background warmup' },
1349
- ],
1350
- action: async (ctx) => {
1351
- const runTest = ctx.flags.test !== false;
1352
- const background = ctx.flags.background === true;
1353
- output.writeln();
1354
- output.writeln(output.bold('Embedding Model Warmup'));
1355
- output.writeln(output.dim('─'.repeat(50)));
1356
- const spinner = output.createSpinner({ text: 'Loading embedding model...', spinner: 'dots' });
1357
- spinner.start();
1358
- const overallStart = Date.now();
1359
- try {
1360
- const { loadEmbeddingModel, generateEmbedding } = await import('../memory/memory-initializer.js');
1361
- // Phase 1: Load model
1362
- const loadStart = Date.now();
1363
- const modelInfo = await loadEmbeddingModel({ verbose: false });
1364
- const loadTime = Date.now() - loadStart;
1365
- spinner.succeed(`Model loaded in ${loadTime}ms`);
1366
- // Phase 2: Test embed (warms ONNX runtime)
1367
- if (runTest) {
1368
- const testSpinner = output.createSpinner({ text: 'Running warmup embedding...', spinner: 'dots' });
1369
- testSpinner.start();
1370
- const warmupTexts = [
1371
- 'The quick brown fox jumps over the lazy dog',
1372
- 'Machine learning embeddings enable semantic search',
1373
- 'Vector databases use HNSW for fast similarity'
1374
- ];
1375
- const embedTimes = [];
1376
- for (const text of warmupTexts) {
1377
- const embedStart = Date.now();
1378
- await generateEmbedding(text);
1379
- embedTimes.push(Date.now() - embedStart);
1380
- }
1381
- const avgWarmEmbed = embedTimes.slice(1).reduce((a, b) => a + b, 0) / (embedTimes.length - 1);
1382
- testSpinner.succeed(`Warmup complete: ${avgWarmEmbed.toFixed(1)}ms avg (warm)`);
1383
- }
1384
- const totalTime = Date.now() - overallStart;
1385
- output.writeln();
1386
- output.printTable({
1387
- columns: [
1388
- { key: 'metric', header: 'Metric', width: 22 },
1389
- { key: 'value', header: 'Value', width: 25 },
1390
- ],
1391
- data: [
1392
- { metric: 'Model', value: modelInfo.modelName },
1393
- { metric: 'Dimensions', value: String(modelInfo.dimensions) },
1394
- { metric: 'Initial Load', value: `${loadTime}ms` },
1395
- { metric: 'Warm Embed', value: runTest ? `~2-3ms` : 'Skipped' },
1396
- { metric: 'Total Warmup', value: `${totalTime}ms` },
1397
- { metric: 'Status', value: output.success('Ready') },
1398
- ],
1399
- });
1400
- output.writeln();
1401
- output.writeln(output.dim('Model is now cached for fast subsequent embeddings'));
1402
- return { success: true, data: { loadTime, totalTime, dimensions: modelInfo.dimensions } };
1403
- }
1404
- catch (error) {
1405
- spinner.fail('Warmup failed');
1406
- output.printError(error instanceof Error ? error.message : String(error));
1407
- return { success: false, exitCode: 1 };
1408
- }
1409
- },
1410
- };
1411
- // Benchmark subcommand - Performance testing
1412
- const benchmarkCommand = {
1413
- name: 'benchmark',
1414
- description: 'Run embedding performance benchmarks',
1415
- options: [
1416
- { name: 'iterations', short: 'n', type: 'number', description: 'Number of iterations', default: '10' },
1417
- { name: 'batch-size', short: 'b', type: 'number', description: 'Batch size for batch test', default: '5' },
1418
- { name: 'full', short: 'f', type: 'boolean', description: 'Run full benchmark suite', default: 'false' },
1419
- ],
1420
- examples: [
1421
- { command: 'claude-flow embeddings benchmark', description: 'Quick benchmark' },
1422
- { command: 'claude-flow embeddings benchmark -n 50 -f', description: 'Full benchmark' },
1423
- ],
1424
- action: async (ctx) => {
1425
- const iterations = parseInt(ctx.flags.iterations || '10', 10);
1426
- const batchSize = parseInt(ctx.flags['batch-size'] || '5', 10);
1427
- const full = ctx.flags.full === true;
1428
- output.writeln();
1429
- output.writeln(output.bold('Embedding Performance Benchmark'));
1430
- output.writeln(output.dim('─'.repeat(60)));
1431
- const results = [];
1432
- try {
1433
- const { loadEmbeddingModel, generateEmbedding } = await import('../memory/memory-initializer.js');
1434
- // Test 1: Cold start (model load)
1435
- output.writeln(output.dim('Testing cold start...'));
1436
- const coldStart = Date.now();
1437
- const modelInfo = await loadEmbeddingModel({ verbose: false });
1438
- const coldTime = Date.now() - coldStart;
1439
- results.push({
1440
- test: 'Cold Start (model load)',
1441
- time: `${coldTime}ms`,
1442
- opsPerSec: '-'
1443
- });
1444
- // Test 2: First embed
1445
- const firstStart = Date.now();
1446
- await generateEmbedding('First embedding test');
1447
- const firstTime = Date.now() - firstStart;
1448
- results.push({
1449
- test: 'First Embed',
1450
- time: `${firstTime}ms`,
1451
- opsPerSec: `${(1000 / firstTime).toFixed(1)}`
1452
- });
1453
- // Test 3: Warm embeds (multiple iterations)
1454
- output.writeln(output.dim(`Testing ${iterations} warm embeds...`));
1455
- const warmTimes = [];
1456
- for (let i = 0; i < iterations; i++) {
1457
- const start = Date.now();
1458
- await generateEmbedding(`Warm embedding test ${i} with some content`);
1459
- warmTimes.push(Date.now() - start);
1460
- }
1461
- const avgWarm = warmTimes.reduce((a, b) => a + b, 0) / warmTimes.length;
1462
- const minWarm = Math.min(...warmTimes);
1463
- const maxWarm = Math.max(...warmTimes);
1464
- results.push({
1465
- test: `Warm Embed (n=${iterations})`,
1466
- time: `${avgWarm.toFixed(1)}ms avg (${minWarm}-${maxWarm})`,
1467
- opsPerSec: `${(1000 / avgWarm).toFixed(1)}`
1468
- });
1469
- // Test 4a: Sequential batch embed
1470
- output.writeln(output.dim(`Testing sequential batch of ${batchSize}...`));
1471
- const batchTexts = Array.from({ length: batchSize }, (_, i) => `Batch text ${i + 1} for testing`);
1472
- const seqStart = Date.now();
1473
- for (const text of batchTexts) {
1474
- await generateEmbedding(text);
1475
- }
1476
- const seqTime = Date.now() - seqStart;
1477
- results.push({
1478
- test: `Sequential (n=${batchSize})`,
1479
- time: `${seqTime}ms total (${(seqTime / batchSize).toFixed(1)}ms/item)`,
1480
- opsPerSec: `${(1000 * batchSize / seqTime).toFixed(1)}`
1481
- });
1482
- // Test 4b: Parallel batch embed
1483
- // Note: Local ONNX is CPU-bound so parallelism has limited benefit
1484
- // Parallelism gives 2-4x speedup for API-based providers (OpenAI, etc.)
1485
- output.writeln(output.dim(`Testing parallel batch of ${batchSize}...`));
1486
- const parallelTexts = Array.from({ length: batchSize }, (_, i) => `Parallel batch text ${i + 1}`);
1487
- const parallelStart = Date.now();
1488
- await Promise.all(parallelTexts.map(text => generateEmbedding(text)));
1489
- const parallelTime = Date.now() - parallelStart;
1490
- const speedup = seqTime / parallelTime;
1491
- results.push({
1492
- test: `Parallel (n=${batchSize})`,
1493
- time: `${parallelTime}ms total (${(parallelTime / batchSize).toFixed(1)}ms/item)`,
1494
- opsPerSec: `${(1000 * batchSize / parallelTime).toFixed(1)} (${speedup.toFixed(2)}x vs seq)`
1495
- });
1496
- // Test 5: Cache hit (same text)
1497
- if (full) {
1498
- output.writeln(output.dim('Testing cache hits...'));
1499
- const cacheText = 'Cached embedding test text';
1500
- await generateEmbedding(cacheText); // Prime cache
1501
- const cacheTimes = [];
1502
- for (let i = 0; i < 10; i++) {
1503
- const start = Date.now();
1504
- await generateEmbedding(cacheText);
1505
- cacheTimes.push(Date.now() - start);
1506
- }
1507
- const avgCache = cacheTimes.reduce((a, b) => a + b, 0) / cacheTimes.length;
1508
- results.push({
1509
- test: 'Cache Hit',
1510
- time: `${avgCache.toFixed(2)}ms avg`,
1511
- opsPerSec: `${(1000 / avgCache).toFixed(0)}`
1512
- });
1513
- // Test 6: Similarity computation
1514
- output.writeln(output.dim('Testing similarity...'));
1515
- const emb1 = (await generateEmbedding('Hello world')).embedding;
1516
- const emb2 = (await generateEmbedding('Hi there')).embedding;
1517
- const simTimes = [];
1518
- for (let i = 0; i < 1000; i++) {
1519
- const start = performance.now();
1520
- cosineSimilarity(emb1, emb2);
1521
- simTimes.push(performance.now() - start);
1522
- }
1523
- const avgSim = simTimes.reduce((a, b) => a + b, 0) / simTimes.length;
1524
- results.push({
1525
- test: 'Cosine Similarity',
1526
- time: `${(avgSim * 1000).toFixed(2)}μs`,
1527
- opsPerSec: `${(1000000 / (avgSim * 1000)).toFixed(0)}`
1528
- });
1529
- }
1530
- output.writeln();
1531
- output.printTable({
1532
- columns: [
1533
- { key: 'test', header: 'Test', width: 28 },
1534
- { key: 'time', header: 'Time', width: 32 },
1535
- { key: 'opsPerSec', header: 'Ops/sec', width: 12 },
1536
- ],
1537
- data: results,
1538
- });
1539
- output.writeln();
1540
- output.writeln(output.bold('Summary:'));
1541
- output.writeln(` Model: ${modelInfo.modelName} (${modelInfo.dimensions}-dim)`);
1542
- output.writeln(` Cold start: ${coldTime}ms`);
1543
- output.writeln(` Warm embed: ~${avgWarm.toFixed(1)}ms`);
1544
- output.writeln(` Throughput: ~${(1000 / avgWarm).toFixed(0)} embeds/sec`);
1545
- return { success: true, data: { results, avgWarm, coldTime } };
1546
- }
1547
- catch (error) {
1548
- output.printError(error instanceof Error ? error.message : String(error));
1549
- return { success: false, exitCode: 1 };
1550
- }
1551
- },
1552
- };
1553
- // Main embeddings command
1554
- export const embeddingsCommand = {
1555
- name: 'embeddings',
1556
- description: 'Vector embeddings, semantic search, similarity operations',
1557
- aliases: ['embed'],
1558
- subcommands: [
1559
- initCommand,
1560
- generateCommand,
1561
- searchCommand,
1562
- compareCommand,
1563
- collectionsCommand,
1564
- indexCommand,
1565
- providersCommand,
1566
- chunkCommand,
1567
- normalizeCommand,
1568
- hyperbolicCommand,
1569
- neuralCommand,
1570
- modelsCommand,
1571
- cacheCommand,
1572
- warmupCommand,
1573
- benchmarkCommand,
1574
- ],
1575
- examples: [
1576
- { command: 'claude-flow embeddings init', description: 'Initialize ONNX embedding system' },
1577
- { command: 'claude-flow embeddings init --model all-mpnet-base-v2', description: 'Init with larger model' },
1578
- { command: 'claude-flow embeddings generate -t "Hello"', description: 'Generate embedding' },
1579
- { command: 'claude-flow embeddings search -q "error handling"', description: 'Semantic search' },
1580
- { command: 'claude-flow embeddings chunk -t "Long doc..."', description: 'Chunk document' },
1581
- { command: 'claude-flow embeddings hyperbolic -a convert', description: 'Hyperbolic space' },
1582
- { command: 'claude-flow embed neural -f drift', description: 'Neural substrate' },
1583
- ],
1584
- action: async () => {
1585
- output.writeln();
1586
- output.writeln(output.bold('RuFlo Embeddings'));
1587
- output.writeln(output.dim('Vector embeddings and semantic search'));
1588
- output.writeln();
1589
- output.writeln('Core Commands:');
1590
- output.printList([
1591
- 'init - Initialize ONNX models and hyperbolic config',
1592
- 'generate - Generate embeddings for text',
1593
- 'search - Semantic similarity search',
1594
- 'compare - Compare similarity between texts',
1595
- 'collections - Manage embedding collections',
1596
- 'index - Manage HNSW indexes',
1597
- 'providers - List available providers',
1598
- ]);
1599
- output.writeln();
1600
- output.writeln('Advanced Features:');
1601
- output.printList([
1602
- 'chunk - Document chunking with overlap',
1603
- 'normalize - L2/L1/minmax/zscore normalization',
1604
- 'hyperbolic - Poincaré ball embeddings',
1605
- 'neural - Neural substrate (drift, memory, swarm)',
1606
- 'models - List/download ONNX models',
1607
- 'cache - Manage persistent SQLite cache',
1608
- ]);
1609
- output.writeln();
1610
- output.writeln('Performance:');
1611
- output.printList([
1612
- 'HNSW indexing: 150x-12,500x faster search',
1613
- 'Agentic Flow: 75x faster than Transformers.js (~3ms)',
1614
- 'Persistent cache: SQLite-backed, survives restarts',
1615
- 'Hyperbolic: Better hierarchical representation',
1616
- ]);
1617
- output.writeln();
1618
- output.writeln(output.dim('Created with ❤️ by ruv.io'));
1619
- return { success: true };
1620
- },
1621
- };
1622
- export default embeddingsCommand;
1623
- //# sourceMappingURL=embeddings.js.map