kynjal-cli 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (502) hide show
  1. package/dist/src/appliance/gguf-engine.d.ts +91 -0
  2. package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
  3. package/dist/src/appliance/gguf-engine.js +286 -525
  4. package/dist/src/appliance/gguf-engine.js.map +1 -1
  5. package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
  6. package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
  7. package/dist/src/appliance/ruvllm-bridge.js +203 -403
  8. package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
  9. package/dist/src/appliance/rvfa-builder.d.ts +44 -0
  10. package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
  11. package/dist/src/appliance/rvfa-builder.js +154 -208
  12. package/dist/src/appliance/rvfa-builder.js.map +1 -1
  13. package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
  14. package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
  15. package/dist/src/appliance/rvfa-distribution.js +260 -423
  16. package/dist/src/appliance/rvfa-distribution.js.map +1 -1
  17. package/dist/src/appliance/rvfa-format.d.ts +111 -0
  18. package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
  19. package/dist/src/appliance/rvfa-format.js +128 -200
  20. package/dist/src/appliance/rvfa-format.js.map +1 -1
  21. package/dist/src/appliance/rvfa-runner.d.ts +69 -0
  22. package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
  23. package/dist/src/appliance/rvfa-runner.js +168 -304
  24. package/dist/src/appliance/rvfa-runner.js.map +1 -1
  25. package/dist/src/appliance/rvfa-signing.d.ts +123 -0
  26. package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
  27. package/dist/src/appliance/rvfa-signing.js +173 -295
  28. package/dist/src/appliance/rvfa-signing.js.map +1 -1
  29. package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
  30. package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
  31. package/dist/src/benchmarks/pretrain/index.js +331 -542
  32. package/dist/src/benchmarks/pretrain/index.js.map +1 -1
  33. package/dist/src/commands/agent.js +574 -697
  34. package/dist/src/commands/agent.js.map +1 -1
  35. package/dist/src/commands/analyze.js +1218 -1548
  36. package/dist/src/commands/analyze.js.map +1 -1
  37. package/dist/src/commands/appliance-advanced.js +158 -267
  38. package/dist/src/commands/appliance-advanced.js.map +1 -1
  39. package/dist/src/commands/appliance.js +318 -493
  40. package/dist/src/commands/appliance.js.map +1 -1
  41. package/dist/src/commands/benchmark.js +372 -523
  42. package/dist/src/commands/benchmark.js.map +1 -1
  43. package/dist/src/commands/claims.js +274 -364
  44. package/dist/src/commands/claims.js.map +1 -1
  45. package/dist/src/commands/cleanup.js +113 -157
  46. package/dist/src/commands/cleanup.js.map +1 -1
  47. package/dist/src/commands/completions.js +477 -118
  48. package/dist/src/commands/completions.js.map +1 -1
  49. package/dist/src/commands/config.js +237 -303
  50. package/dist/src/commands/config.js.map +1 -1
  51. package/dist/src/commands/daemon.js +487 -596
  52. package/dist/src/commands/daemon.js.map +1 -1
  53. package/dist/src/commands/deployment.js +194 -275
  54. package/dist/src/commands/deployment.js.map +1 -1
  55. package/dist/src/commands/doctor.js +504 -686
  56. package/dist/src/commands/doctor.js.map +1 -1
  57. package/dist/src/commands/embeddings.js +1293 -1543
  58. package/dist/src/commands/embeddings.js.map +1 -1
  59. package/dist/src/commands/guidance.js +449 -596
  60. package/dist/src/commands/guidance.js.map +1 -1
  61. package/dist/src/commands/hive-mind.js +854 -938
  62. package/dist/src/commands/hive-mind.js.map +1 -1
  63. package/dist/src/commands/hooks.js +3112 -3519
  64. package/dist/src/commands/hooks.js.map +1 -1
  65. package/dist/src/commands/index.d.ts +115 -0
  66. package/dist/src/commands/index.d.ts.map +1 -0
  67. package/dist/src/commands/index.js +126 -308
  68. package/dist/src/commands/index.js.map +1 -1
  69. package/dist/src/commands/init.js +788 -940
  70. package/dist/src/commands/init.js.map +1 -1
  71. package/dist/src/commands/issues.js +383 -558
  72. package/dist/src/commands/issues.js.map +1 -1
  73. package/dist/src/commands/mcp.js +493 -605
  74. package/dist/src/commands/mcp.js.map +1 -1
  75. package/dist/src/commands/memory.js +833 -1026
  76. package/dist/src/commands/memory.js.map +1 -1
  77. package/dist/src/commands/migrate.js +282 -347
  78. package/dist/src/commands/migrate.js.map +1 -1
  79. package/dist/src/commands/neural.js +1289 -1563
  80. package/dist/src/commands/neural.js.map +1 -1
  81. package/dist/src/commands/performance.js +497 -643
  82. package/dist/src/commands/performance.js.map +1 -1
  83. package/dist/src/commands/plugins.js +668 -841
  84. package/dist/src/commands/plugins.js.map +1 -1
  85. package/dist/src/commands/process.js +392 -447
  86. package/dist/src/commands/process.js.map +1 -1
  87. package/dist/src/commands/progress.js +162 -256
  88. package/dist/src/commands/progress.js.map +1 -1
  89. package/dist/src/commands/providers.js +150 -220
  90. package/dist/src/commands/providers.js.map +1 -1
  91. package/dist/src/commands/route.js +520 -665
  92. package/dist/src/commands/route.js.map +1 -1
  93. package/dist/src/commands/ruvector/backup.js +505 -651
  94. package/dist/src/commands/ruvector/backup.js.map +1 -1
  95. package/dist/src/commands/ruvector/benchmark.js +349 -401
  96. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  97. package/dist/src/commands/ruvector/import.js +224 -266
  98. package/dist/src/commands/ruvector/import.js.map +1 -1
  99. package/dist/src/commands/ruvector/index.js +37 -75
  100. package/dist/src/commands/ruvector/index.js.map +1 -1
  101. package/dist/src/commands/ruvector/init.js +336 -359
  102. package/dist/src/commands/ruvector/init.js.map +1 -1
  103. package/dist/src/commands/ruvector/migrate.js +335 -322
  104. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  105. package/dist/src/commands/ruvector/optimize.js +375 -431
  106. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  107. package/dist/src/commands/ruvector/setup.js +703 -117
  108. package/dist/src/commands/ruvector/setup.js.map +1 -1
  109. package/dist/src/commands/ruvector/status.js +364 -419
  110. package/dist/src/commands/ruvector/status.js.map +1 -1
  111. package/dist/src/commands/security.js +485 -608
  112. package/dist/src/commands/security.js.map +1 -1
  113. package/dist/src/commands/session.js +504 -626
  114. package/dist/src/commands/session.js.map +1 -1
  115. package/dist/src/commands/start.js +267 -364
  116. package/dist/src/commands/start.js.map +1 -1
  117. package/dist/src/commands/status.js +380 -486
  118. package/dist/src/commands/status.js.map +1 -1
  119. package/dist/src/commands/swarm.js +408 -488
  120. package/dist/src/commands/swarm.js.map +1 -1
  121. package/dist/src/commands/task.js +423 -538
  122. package/dist/src/commands/task.js.map +1 -1
  123. package/dist/src/commands/transfer-store.js +322 -412
  124. package/dist/src/commands/transfer-store.js.map +1 -1
  125. package/dist/src/commands/update.js +196 -291
  126. package/dist/src/commands/update.js.map +1 -1
  127. package/dist/src/commands/workflow.js +386 -486
  128. package/dist/src/commands/workflow.js.map +1 -1
  129. package/dist/src/config-adapter.d.ts +15 -0
  130. package/dist/src/config-adapter.d.ts.map +1 -0
  131. package/dist/src/config-adapter.js +38 -39
  132. package/dist/src/config-adapter.js.map +1 -1
  133. package/dist/src/index.d.ts +77 -0
  134. package/dist/src/index.d.ts.map +1 -0
  135. package/dist/src/index.js +309 -411
  136. package/dist/src/index.js.map +1 -1
  137. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  138. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  139. package/dist/src/infrastructure/in-memory-repositories.js +246 -507
  140. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
  141. package/dist/src/init/claudemd-generator.d.ts +25 -0
  142. package/dist/src/init/claudemd-generator.d.ts.map +1 -0
  143. package/dist/src/init/claudemd-generator.js +368 -78
  144. package/dist/src/init/claudemd-generator.js.map +1 -1
  145. package/dist/src/init/executor.d.ts +41 -0
  146. package/dist/src/init/executor.d.ts.map +1 -0
  147. package/dist/src/init/executor.js +1307 -996
  148. package/dist/src/init/executor.js.map +1 -1
  149. package/dist/src/init/helpers-generator.d.ts +60 -0
  150. package/dist/src/init/helpers-generator.d.ts.map +1 -0
  151. package/dist/src/init/helpers-generator.js +657 -12
  152. package/dist/src/init/helpers-generator.js.map +1 -1
  153. package/dist/src/init/index.d.ts +1 -1
  154. package/dist/src/init/index.d.ts.map +1 -1
  155. package/dist/src/init/index.js +1 -1
  156. package/dist/src/init/index.js.map +1 -1
  157. package/dist/src/init/mcp-generator.js +33 -37
  158. package/dist/src/init/mcp-generator.js.map +1 -1
  159. package/dist/src/init/settings-generator.js +76 -77
  160. package/dist/src/init/settings-generator.js.map +1 -1
  161. package/dist/src/init/statusline-generator.js +801 -3
  162. package/dist/src/init/statusline-generator.js.map +1 -1
  163. package/dist/src/init/types.d.ts +1 -1
  164. package/dist/src/init/types.d.ts.map +1 -1
  165. package/dist/src/init/types.js +76 -59
  166. package/dist/src/init/types.js.map +1 -1
  167. package/dist/src/mcp-client.d.ts +92 -0
  168. package/dist/src/mcp-client.d.ts.map +1 -0
  169. package/dist/src/mcp-client.js +81 -125
  170. package/dist/src/mcp-client.js.map +1 -1
  171. package/dist/src/mcp-server.d.ts +161 -0
  172. package/dist/src/mcp-server.d.ts.map +1 -0
  173. package/dist/src/mcp-server.js +470 -757
  174. package/dist/src/mcp-server.js.map +1 -1
  175. package/dist/src/mcp-tools/agent-tools.js +391 -492
  176. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  177. package/dist/src/mcp-tools/agentdb-tools.js +332 -533
  178. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  179. package/dist/src/mcp-tools/analyze-tools.js +172 -236
  180. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  181. package/dist/src/mcp-tools/auto-install.d.ts +83 -0
  182. package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
  183. package/dist/src/mcp-tools/auto-install.js +80 -142
  184. package/dist/src/mcp-tools/auto-install.js.map +1 -1
  185. package/dist/src/mcp-tools/browser-tools.js +252 -375
  186. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  187. package/dist/src/mcp-tools/claims-tools.js +473 -565
  188. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  189. package/dist/src/mcp-tools/config-tools.js +197 -272
  190. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  191. package/dist/src/mcp-tools/coordination-tools.js +500 -572
  192. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  193. package/dist/src/mcp-tools/daa-tools.js +286 -364
  194. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  195. package/dist/src/mcp-tools/embeddings-tools.js +582 -693
  196. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  197. package/dist/src/mcp-tools/github-tools.js +260 -311
  198. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  199. package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
  200. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  201. package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
  202. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  203. package/dist/src/mcp-tools/memory-tools.js +350 -505
  204. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  205. package/dist/src/mcp-tools/neural-tools.js +315 -412
  206. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  207. package/dist/src/mcp-tools/performance-tools.js +420 -480
  208. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  209. package/dist/src/mcp-tools/progress-tools.js +204 -278
  210. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  211. package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
  212. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  213. package/dist/src/mcp-tools/security-tools.js +297 -429
  214. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  215. package/dist/src/mcp-tools/session-tools.js +185 -234
  216. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  217. package/dist/src/mcp-tools/swarm-tools.js +207 -260
  218. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  219. package/dist/src/mcp-tools/system-tools.js +276 -325
  220. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  221. package/dist/src/mcp-tools/task-tools.js +270 -336
  222. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  223. package/dist/src/mcp-tools/terminal-tools.js +148 -196
  224. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  225. package/dist/src/mcp-tools/transfer-tools.js +186 -333
  226. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  227. package/dist/src/mcp-tools/types.d.ts +31 -0
  228. package/dist/src/mcp-tools/types.d.ts.map +1 -0
  229. package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
  230. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  231. package/dist/src/mcp-tools/workflow-tools.js +405 -450
  232. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  233. package/dist/src/memory/ewc-consolidation.d.ts +295 -0
  234. package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
  235. package/dist/src/memory/ewc-consolidation.js +190 -303
  236. package/dist/src/memory/ewc-consolidation.js.map +1 -1
  237. package/dist/src/memory/intelligence.d.ts +338 -0
  238. package/dist/src/memory/intelligence.d.ts.map +1 -0
  239. package/dist/src/memory/intelligence.js +569 -794
  240. package/dist/src/memory/intelligence.js.map +1 -1
  241. package/dist/src/memory/memory-bridge.d.ts +407 -0
  242. package/dist/src/memory/memory-bridge.d.ts.map +1 -0
  243. package/dist/src/memory/memory-bridge.js +1170 -1640
  244. package/dist/src/memory/memory-bridge.js.map +1 -1
  245. package/dist/src/memory/memory-initializer.d.ts +412 -0
  246. package/dist/src/memory/memory-initializer.d.ts.map +1 -0
  247. package/dist/src/memory/memory-initializer.js +1836 -1851
  248. package/dist/src/memory/memory-initializer.js.map +1 -1
  249. package/dist/src/memory/sona-optimizer.d.ts +227 -0
  250. package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
  251. package/dist/src/memory/sona-optimizer.js +199 -329
  252. package/dist/src/memory/sona-optimizer.js.map +1 -1
  253. package/dist/src/output.d.ts +2 -2
  254. package/dist/src/output.d.ts.map +1 -1
  255. package/dist/src/output.js +242 -272
  256. package/dist/src/output.js.map +1 -1
  257. package/dist/src/parser.d.ts +51 -0
  258. package/dist/src/parser.d.ts.map +1 -0
  259. package/dist/src/parser.js +140 -187
  260. package/dist/src/parser.js.map +1 -1
  261. package/dist/src/plugins/manager.d.ts +133 -0
  262. package/dist/src/plugins/manager.d.ts.map +1 -0
  263. package/dist/src/plugins/manager.js +285 -521
  264. package/dist/src/plugins/manager.js.map +1 -1
  265. package/dist/src/plugins/store/discovery.d.ts +88 -0
  266. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  267. package/dist/src/plugins/store/discovery.js +271 -358
  268. package/dist/src/plugins/store/discovery.js.map +1 -1
  269. package/dist/src/plugins/store/index.d.ts +76 -0
  270. package/dist/src/plugins/store/index.d.ts.map +1 -0
  271. package/dist/src/plugins/store/index.js +48 -105
  272. package/dist/src/plugins/store/index.js.map +1 -1
  273. package/dist/src/plugins/store/search.d.ts +46 -0
  274. package/dist/src/plugins/store/search.d.ts.map +1 -0
  275. package/dist/src/plugins/store/search.js +69 -107
  276. package/dist/src/plugins/store/search.js.map +1 -1
  277. package/dist/src/plugins/store/types.d.ts +274 -0
  278. package/dist/src/plugins/store/types.d.ts.map +1 -0
  279. package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
  280. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
  281. package/dist/src/plugins/tests/standalone-test.js +172 -223
  282. package/dist/src/plugins/tests/standalone-test.js.map +1 -1
  283. package/dist/src/plugins/tests/test-plugin-store.js +190 -228
  284. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
  285. package/dist/src/production/circuit-breaker.d.ts +101 -0
  286. package/dist/src/production/circuit-breaker.d.ts.map +1 -0
  287. package/dist/src/production/circuit-breaker.js +62 -126
  288. package/dist/src/production/circuit-breaker.js.map +1 -1
  289. package/dist/src/production/error-handler.d.ts +92 -0
  290. package/dist/src/production/error-handler.d.ts.map +1 -0
  291. package/dist/src/production/error-handler.js +86 -156
  292. package/dist/src/production/error-handler.js.map +1 -1
  293. package/dist/src/production/monitoring.d.ts +161 -0
  294. package/dist/src/production/monitoring.d.ts.map +1 -0
  295. package/dist/src/production/monitoring.js +139 -220
  296. package/dist/src/production/monitoring.js.map +1 -1
  297. package/dist/src/production/rate-limiter.d.ts +80 -0
  298. package/dist/src/production/rate-limiter.d.ts.map +1 -0
  299. package/dist/src/production/rate-limiter.js +74 -93
  300. package/dist/src/production/rate-limiter.js.map +1 -1
  301. package/dist/src/production/retry.d.ts +48 -0
  302. package/dist/src/production/retry.d.ts.map +1 -0
  303. package/dist/src/production/retry.js +75 -167
  304. package/dist/src/production/retry.js.map +1 -1
  305. package/dist/src/prompt.d.ts +44 -0
  306. package/dist/src/prompt.d.ts.map +1 -0
  307. package/dist/src/prompt.js +436 -560
  308. package/dist/src/prompt.js.map +1 -1
  309. package/dist/src/runtime/headless.d.ts +60 -0
  310. package/dist/src/runtime/headless.d.ts.map +1 -0
  311. package/dist/src/runtime/headless.js +197 -286
  312. package/dist/src/runtime/headless.js.map +1 -1
  313. package/dist/src/ruvector/agent-wasm.d.ts +182 -0
  314. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
  315. package/dist/src/ruvector/agent-wasm.js +156 -351
  316. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  317. package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
  318. package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
  319. package/dist/src/ruvector/ast-analyzer.js +145 -232
  320. package/dist/src/ruvector/ast-analyzer.js.map +1 -1
  321. package/dist/src/ruvector/coverage-router.d.ts +160 -0
  322. package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
  323. package/dist/src/ruvector/coverage-router.js +287 -419
  324. package/dist/src/ruvector/coverage-router.js.map +1 -1
  325. package/dist/src/ruvector/coverage-tools.js +56 -101
  326. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  327. package/dist/src/ruvector/diff-classifier.d.ts +175 -0
  328. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
  329. package/dist/src/ruvector/diff-classifier.js +324 -451
  330. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  331. package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
  332. package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
  333. package/dist/src/ruvector/enhanced-model-router.js +260 -336
  334. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  335. package/dist/src/ruvector/flash-attention.d.ts +195 -0
  336. package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
  337. package/dist/src/ruvector/flash-attention.js +223 -254
  338. package/dist/src/ruvector/flash-attention.js.map +1 -1
  339. package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
  340. package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
  341. package/dist/src/ruvector/graph-analyzer.js +486 -680
  342. package/dist/src/ruvector/graph-analyzer.js.map +1 -1
  343. package/dist/src/ruvector/index.d.ts +40 -0
  344. package/dist/src/ruvector/index.d.ts.map +1 -0
  345. package/dist/src/ruvector/index.js +36 -106
  346. package/dist/src/ruvector/index.js.map +1 -1
  347. package/dist/src/ruvector/lora-adapter.d.ts +218 -0
  348. package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
  349. package/dist/src/ruvector/lora-adapter.js +155 -248
  350. package/dist/src/ruvector/lora-adapter.js.map +1 -1
  351. package/dist/src/ruvector/model-router.d.ts +220 -0
  352. package/dist/src/ruvector/model-router.d.ts.map +1 -0
  353. package/dist/src/ruvector/model-router.js +175 -248
  354. package/dist/src/ruvector/model-router.js.map +1 -1
  355. package/dist/src/ruvector/moe-router.d.ts +206 -0
  356. package/dist/src/ruvector/moe-router.d.ts.map +1 -0
  357. package/dist/src/ruvector/moe-router.js +228 -286
  358. package/dist/src/ruvector/moe-router.js.map +1 -1
  359. package/dist/src/ruvector/q-learning-router.d.ts +211 -0
  360. package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
  361. package/dist/src/ruvector/q-learning-router.js +257 -338
  362. package/dist/src/ruvector/q-learning-router.js.map +1 -1
  363. package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
  364. package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
  365. package/dist/src/ruvector/ruvllm-wasm.js +270 -434
  366. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
  367. package/dist/src/ruvector/semantic-router.d.ts +77 -0
  368. package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
  369. package/dist/src/ruvector/semantic-router.js +60 -67
  370. package/dist/src/ruvector/semantic-router.js.map +1 -1
  371. package/dist/src/ruvector/vector-db.d.ts +69 -0
  372. package/dist/src/ruvector/vector-db.d.ts.map +1 -0
  373. package/dist/src/ruvector/vector-db.js +119 -205
  374. package/dist/src/ruvector/vector-db.js.map +1 -1
  375. package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  376. package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
  377. package/dist/src/services/agentic-flow-bridge.js +32 -105
  378. package/dist/src/services/agentic-flow-bridge.js.map +1 -1
  379. package/dist/src/services/claim-service.d.ts +204 -0
  380. package/dist/src/services/claim-service.d.ts.map +1 -0
  381. package/dist/src/services/claim-service.js +615 -940
  382. package/dist/src/services/claim-service.js.map +1 -1
  383. package/dist/src/services/container-worker-pool.d.ts +197 -0
  384. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  385. package/dist/src/services/container-worker-pool.js +398 -666
  386. package/dist/src/services/container-worker-pool.js.map +1 -1
  387. package/dist/src/services/headless-worker-executor.d.ts +304 -0
  388. package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
  389. package/dist/src/services/headless-worker-executor.js +441 -467
  390. package/dist/src/services/headless-worker-executor.js.map +1 -1
  391. package/dist/src/services/index.d.ts +4 -4
  392. package/dist/src/services/index.d.ts.map +1 -1
  393. package/dist/src/services/index.js +4 -4
  394. package/dist/src/services/index.js.map +1 -1
  395. package/dist/src/services/registry-api.d.ts +58 -0
  396. package/dist/src/services/registry-api.d.ts.map +1 -0
  397. package/dist/src/services/registry-api.js +92 -200
  398. package/dist/src/services/registry-api.js.map +1 -1
  399. package/dist/src/services/ruvector-training.d.ts +222 -0
  400. package/dist/src/services/ruvector-training.d.ts.map +1 -0
  401. package/dist/src/services/ruvector-training.js +257 -337
  402. package/dist/src/services/ruvector-training.js.map +1 -1
  403. package/dist/src/services/worker-daemon.d.ts +228 -0
  404. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  405. package/dist/src/services/worker-daemon.js +591 -849
  406. package/dist/src/services/worker-daemon.js.map +1 -1
  407. package/dist/src/services/worker-queue.d.ts +194 -0
  408. package/dist/src/services/worker-queue.d.ts.map +1 -0
  409. package/dist/src/services/worker-queue.js +331 -548
  410. package/dist/src/services/worker-queue.js.map +1 -1
  411. package/dist/src/suggest.d.ts +53 -0
  412. package/dist/src/suggest.d.ts.map +1 -0
  413. package/dist/src/suggest.js +45 -55
  414. package/dist/src/suggest.js.map +1 -1
  415. package/dist/src/transfer/anonymization/index.js +29 -37
  416. package/dist/src/transfer/anonymization/index.js.map +1 -1
  417. package/dist/src/transfer/deploy-seraphine.js +128 -155
  418. package/dist/src/transfer/deploy-seraphine.js.map +1 -1
  419. package/dist/src/transfer/export.d.ts +25 -0
  420. package/dist/src/transfer/export.d.ts.map +1 -0
  421. package/dist/src/transfer/export.js +84 -142
  422. package/dist/src/transfer/export.js.map +1 -1
  423. package/dist/src/transfer/index.d.ts +1 -1
  424. package/dist/src/transfer/index.d.ts.map +1 -1
  425. package/dist/src/transfer/index.js +0 -2
  426. package/dist/src/transfer/index.js.map +1 -1
  427. package/dist/src/transfer/ipfs/client.d.ts +109 -0
  428. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  429. package/dist/src/transfer/ipfs/client.js +187 -337
  430. package/dist/src/transfer/ipfs/client.js.map +1 -1
  431. package/dist/src/transfer/ipfs/upload.d.ts +95 -0
  432. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  433. package/dist/src/transfer/ipfs/upload.js +288 -434
  434. package/dist/src/transfer/ipfs/upload.js.map +1 -1
  435. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  436. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  437. package/dist/src/transfer/models/seraphine.js +55 -55
  438. package/dist/src/transfer/models/seraphine.js.map +1 -1
  439. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  440. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  441. package/dist/src/transfer/serialization/cfp.js +30 -31
  442. package/dist/src/transfer/serialization/cfp.js.map +1 -1
  443. package/dist/src/transfer/storage/gcs.d.ts +82 -0
  444. package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
  445. package/dist/src/transfer/storage/gcs.js +165 -232
  446. package/dist/src/transfer/storage/gcs.js.map +1 -1
  447. package/dist/src/transfer/store/discovery.d.ts +84 -0
  448. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  449. package/dist/src/transfer/store/discovery.js +239 -349
  450. package/dist/src/transfer/store/discovery.js.map +1 -1
  451. package/dist/src/transfer/store/download.d.ts +70 -0
  452. package/dist/src/transfer/store/download.d.ts.map +1 -0
  453. package/dist/src/transfer/store/download.js +243 -365
  454. package/dist/src/transfer/store/download.js.map +1 -1
  455. package/dist/src/transfer/store/index.d.ts +84 -0
  456. package/dist/src/transfer/store/index.d.ts.map +1 -0
  457. package/dist/src/transfer/store/index.js +63 -130
  458. package/dist/src/transfer/store/index.js.map +1 -1
  459. package/dist/src/transfer/store/publish.d.ts +76 -0
  460. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  461. package/dist/src/transfer/store/publish.js +184 -258
  462. package/dist/src/transfer/store/publish.js.map +1 -1
  463. package/dist/src/transfer/store/registry.js +50 -72
  464. package/dist/src/transfer/store/registry.js.map +1 -1
  465. package/dist/src/transfer/store/search.d.ts +54 -0
  466. package/dist/src/transfer/store/search.d.ts.map +1 -0
  467. package/dist/src/transfer/store/search.js +64 -96
  468. package/dist/src/transfer/store/search.js.map +1 -1
  469. package/dist/src/transfer/store/tests/standalone-test.js +174 -231
  470. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
  471. package/dist/src/transfer/test-seraphine.js +95 -130
  472. package/dist/src/transfer/test-seraphine.js.map +1 -1
  473. package/dist/src/transfer/tests/test-store.js +194 -239
  474. package/dist/src/transfer/tests/test-store.js.map +1 -1
  475. package/dist/src/transfer/types.d.ts +245 -0
  476. package/dist/src/transfer/types.d.ts.map +1 -0
  477. package/dist/src/types.d.ts +198 -0
  478. package/dist/src/types.d.ts.map +1 -0
  479. package/dist/src/types.js +26 -55
  480. package/dist/src/types.js.map +1 -1
  481. package/dist/src/update/checker.d.ts +34 -0
  482. package/dist/src/update/checker.d.ts.map +1 -0
  483. package/dist/src/update/checker.js +106 -183
  484. package/dist/src/update/checker.js.map +1 -1
  485. package/dist/src/update/executor.d.ts +32 -0
  486. package/dist/src/update/executor.d.ts.map +1 -0
  487. package/dist/src/update/executor.js +135 -198
  488. package/dist/src/update/executor.js.map +1 -1
  489. package/dist/src/update/index.d.ts +33 -0
  490. package/dist/src/update/index.d.ts.map +1 -0
  491. package/dist/src/update/index.js +38 -85
  492. package/dist/src/update/index.js.map +1 -1
  493. package/dist/src/update/rate-limiter.d.ts +20 -0
  494. package/dist/src/update/rate-limiter.d.ts.map +1 -0
  495. package/dist/src/update/rate-limiter.js +19 -31
  496. package/dist/src/update/rate-limiter.js.map +1 -1
  497. package/dist/src/update/validator.d.ts +17 -0
  498. package/dist/src/update/validator.d.ts.map +1 -0
  499. package/dist/src/update/validator.js +38 -64
  500. package/dist/src/update/validator.js.map +1 -1
  501. package/dist/tsconfig.tsbuildinfo +1 -1
  502. package/package.json +1 -1
@@ -4,595 +4,467 @@
4
4
  *
5
5
  * Created with ❤️ by ruv.io
6
6
  */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- var __generator = (this && this.__generator) || function (thisArg, body) {
17
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
18
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
19
- function verb(n) { return function (v) { return step([n, v]); }; }
20
- function step(op) {
21
- if (f) throw new TypeError("Generator is already executing.");
22
- while (_) try {
23
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
24
- if (y = 0, t) op = [op[0] & 2, t.value];
25
- switch (op[0]) {
26
- case 0: case 1: t = op; break;
27
- case 4: _.label++; return { value: op[1], done: false };
28
- case 5: _.label++; y = op[1]; op = [0]; continue;
29
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
30
- default:
31
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
32
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
33
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
34
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
35
- if (t[2]) _.ops.pop();
36
- _.trys.pop(); continue;
37
- }
38
- op = body.call(thisArg, _);
39
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
40
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
41
- }
42
- };
43
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
44
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
- if (ar || !(i in from)) {
46
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
- ar[i] = from[i];
48
- }
49
- }
50
- return to.concat(ar || Array.prototype.slice.call(from));
51
- };
52
7
  import { output } from '../output.js';
53
8
  // Benchmark subcommand - REAL measurements
54
- var benchmarkCommand = {
9
+ const benchmarkCommand = {
55
10
  name: 'benchmark',
56
11
  description: 'Run performance benchmarks',
57
12
  options: [
58
- { name: 'suite', short: 's', type: 'string', description: 'Benchmark suite: all, wasm, neural, memory, search', "default": 'all' },
59
- { name: 'iterations', short: 'i', type: 'number', description: 'Number of iterations', "default": '100' },
60
- { name: 'warmup', short: 'w', type: 'number', description: 'Warmup iterations', "default": '10' },
61
- { name: 'output', short: 'o', type: 'string', description: 'Output format: text, json, csv', "default": 'text' },
13
+ { name: 'suite', short: 's', type: 'string', description: 'Benchmark suite: all, wasm, neural, memory, search', default: 'all' },
14
+ { name: 'iterations', short: 'i', type: 'number', description: 'Number of iterations', default: '100' },
15
+ { name: 'warmup', short: 'w', type: 'number', description: 'Warmup iterations', default: '10' },
16
+ { name: 'output', short: 'o', type: 'string', description: 'Output format: text, json, csv', default: 'text' },
62
17
  ],
63
18
  examples: [
64
19
  { command: 'claude-flow performance benchmark -s neural', description: 'Benchmark neural operations' },
65
20
  { command: 'claude-flow performance benchmark -i 1000', description: 'Run with 1000 iterations' },
66
21
  ],
67
- action: function (ctx) { return __awaiter(void 0, void 0, Promise, function () {
68
- var suite, iterations, warmup, outputFormat, spinner, _a, generateEmbedding, batchCosineSim, flashAttentionSearch, getHNSWStatus, storeEntry, searchEntries, _b, benchmarkAdaptation, initializeIntelligence, results, startTotal, percentile, embedTimes, i, i, start, mean, flashTimes, testVectors, queryVector, i, i, start, mean, baselineMs, speedup, hnswStatus, searchTimes, testQueries, _i, _c, q, i, query, start, mean, baselineBruteForce, speedup, sonaResult, storeTimes, i, start, mean, totalTime, allTargetsMet;
69
- return __generator(this, function (_d) {
70
- switch (_d.label) {
71
- case 0:
72
- suite = ctx.flags.suite || 'all';
73
- iterations = parseInt(ctx.flags.iterations || '100', 10);
74
- warmup = parseInt(ctx.flags.warmup || '10', 10);
75
- outputFormat = ctx.flags.output || 'text';
76
- output.writeln();
77
- output.writeln(output.bold('Performance Benchmark (Real Measurements)'));
78
- output.writeln(output.dim('─'.repeat(60)));
79
- spinner = output.createSpinner({ text: "Running " + suite + " benchmarks...", spinner: 'dots' });
80
- spinner.start();
81
- return [4 /*yield*/, import('../memory/memory-initializer.js')];
82
- case 1:
83
- _a = _d.sent(), generateEmbedding = _a.generateEmbedding, batchCosineSim = _a.batchCosineSim, flashAttentionSearch = _a.flashAttentionSearch, getHNSWStatus = _a.getHNSWStatus, storeEntry = _a.storeEntry, searchEntries = _a.searchEntries;
84
- return [4 /*yield*/, import('../memory/intelligence.js')];
85
- case 2:
86
- _b = _d.sent(), benchmarkAdaptation = _b.benchmarkAdaptation, initializeIntelligence = _b.initializeIntelligence;
87
- results = [];
88
- startTotal = Date.now();
89
- percentile = function (arr, p) {
90
- var sorted = __spreadArray([], arr, true).sort(function (a, b) { return a - b; });
91
- var idx = Math.ceil((p / 100) * sorted.length) - 1;
92
- return sorted[Math.max(0, idx)];
93
- };
94
- if (!(suite === 'all' || suite === 'neural' || suite === 'memory')) return [3 /*break*/, 11];
95
- spinner.setText('Benchmarking embedding generation...');
96
- embedTimes = [];
97
- i = 0;
98
- _d.label = 3;
99
- case 3:
100
- if (!(i < warmup)) return [3 /*break*/, 6];
101
- return [4 /*yield*/, generateEmbedding("warmup text " + i)];
102
- case 4:
103
- _d.sent();
104
- _d.label = 5;
105
- case 5:
106
- i++;
107
- return [3 /*break*/, 3];
108
- case 6:
109
- i = 0;
110
- _d.label = 7;
111
- case 7:
112
- if (!(i < iterations)) return [3 /*break*/, 10];
113
- start = performance.now();
114
- return [4 /*yield*/, generateEmbedding("benchmark text number " + i + " with some varied content")];
115
- case 8:
116
- _d.sent();
117
- embedTimes.push(performance.now() - start);
118
- _d.label = 9;
119
- case 9:
120
- i++;
121
- return [3 /*break*/, 7];
122
- case 10:
123
- mean = embedTimes.reduce(function (a, b) { return a + b; }, 0) / embedTimes.length;
124
- results.push({
125
- operation: 'Embedding Gen',
126
- mean: mean.toFixed(2) + "ms",
127
- p95: percentile(embedTimes, 95).toFixed(2) + "ms",
128
- p99: percentile(embedTimes, 99).toFixed(2) + "ms",
129
- improvement: mean < 10 ? output.success('Target met') : output.warning('Below target')
130
- });
131
- _d.label = 11;
132
- case 11:
133
- // 2. Flash Attention-style Batch Operations
134
- if (suite === 'all' || suite === 'wasm') {
135
- spinner.setText('Benchmarking Flash Attention batch ops...');
136
- flashTimes = [];
137
- testVectors = Array.from({ length: 100 }, function () {
138
- return new Float32Array(Array.from({ length: 384 }, function () { return Math.random(); }));
139
- });
140
- queryVector = new Float32Array(Array.from({ length: 384 }, function () { return Math.random(); }));
141
- // Warmup
142
- for (i = 0; i < warmup; i++) {
143
- batchCosineSim(queryVector, testVectors);
144
- }
145
- // Actual measurement
146
- for (i = 0; i < iterations; i++) {
147
- start = performance.now();
148
- flashAttentionSearch(queryVector, testVectors, { k: 10 });
149
- flashTimes.push(performance.now() - start);
150
- }
151
- mean = flashTimes.reduce(function (a, b) { return a + b; }, 0) / flashTimes.length;
152
- baselineMs = 0.05;
153
- speedup = baselineMs / mean;
154
- results.push({
155
- operation: 'Flash Attention',
156
- mean: mean.toFixed(3) + "ms",
157
- p95: percentile(flashTimes, 95).toFixed(3) + "ms",
158
- p99: percentile(flashTimes, 99).toFixed(3) + "ms",
159
- improvement: speedup > 1 ? output.success(speedup.toFixed(2) + "x") : output.dim(speedup.toFixed(2) + "x")
160
- });
161
- }
162
- if (!(suite === 'all' || suite === 'search')) return [3 /*break*/, 21];
163
- spinner.setText('Benchmarking HNSW search...');
164
- hnswStatus = getHNSWStatus();
165
- if (!(hnswStatus.available && hnswStatus.entryCount > 0)) return [3 /*break*/, 20];
166
- searchTimes = [];
167
- testQueries = [
168
- 'error handling patterns',
169
- 'authentication flow',
170
- 'database optimization',
171
- 'API design patterns',
172
- 'test coverage strategies',
173
- ];
174
- _i = 0, _c = testQueries.slice(0, 2);
175
- _d.label = 12;
176
- case 12:
177
- if (!(_i < _c.length)) return [3 /*break*/, 15];
178
- q = _c[_i];
179
- return [4 /*yield*/, searchEntries({ query: q, limit: 10 })];
180
- case 13:
181
- _d.sent();
182
- _d.label = 14;
183
- case 14:
184
- _i++;
185
- return [3 /*break*/, 12];
186
- case 15:
187
- i = 0;
188
- _d.label = 16;
189
- case 16:
190
- if (!(i < Math.min(iterations, 50))) return [3 /*break*/, 19];
191
- query = testQueries[i % testQueries.length];
192
- start = performance.now();
193
- return [4 /*yield*/, searchEntries({ query: query, limit: 10 })];
194
- case 17:
195
- _d.sent();
22
+ action: async (ctx) => {
23
+ const suite = ctx.flags.suite || 'all';
24
+ const iterations = parseInt(ctx.flags.iterations || '100', 10);
25
+ const warmup = parseInt(ctx.flags.warmup || '10', 10);
26
+ const outputFormat = ctx.flags.output || 'text';
27
+ output.writeln();
28
+ output.writeln(output.bold('Performance Benchmark (Real Measurements)'));
29
+ output.writeln(output.dim(''.repeat(60)));
30
+ const spinner = output.createSpinner({ text: `Running ${suite} benchmarks...`, spinner: 'dots' });
31
+ spinner.start();
32
+ // Import real implementations
33
+ const { generateEmbedding, batchCosineSim, flashAttentionSearch, getHNSWStatus, storeEntry, searchEntries, } = await import('../memory/memory-initializer.js');
34
+ const { benchmarkAdaptation, initializeIntelligence } = await import('../memory/intelligence.js');
35
+ const results = [];
36
+ const startTotal = Date.now();
37
+ // Helper to compute percentiles
38
+ const percentile = (arr, p) => {
39
+ const sorted = [...arr].sort((a, b) => a - b);
40
+ const idx = Math.ceil((p / 100) * sorted.length) - 1;
41
+ return sorted[Math.max(0, idx)];
42
+ };
43
+ // 1. Embedding Generation Benchmark
44
+ if (suite === 'all' || suite === 'neural' || suite === 'memory') {
45
+ spinner.setText('Benchmarking embedding generation...');
46
+ const embedTimes = [];
47
+ // Warmup
48
+ for (let i = 0; i < warmup; i++) {
49
+ await generateEmbedding(`warmup text ${i}`);
50
+ }
51
+ // Actual measurement
52
+ for (let i = 0; i < iterations; i++) {
53
+ const start = performance.now();
54
+ await generateEmbedding(`benchmark text number ${i} with some varied content`);
55
+ embedTimes.push(performance.now() - start);
56
+ }
57
+ const mean = embedTimes.reduce((a, b) => a + b, 0) / embedTimes.length;
58
+ results.push({
59
+ operation: 'Embedding Gen',
60
+ mean: `${mean.toFixed(2)}ms`,
61
+ p95: `${percentile(embedTimes, 95).toFixed(2)}ms`,
62
+ p99: `${percentile(embedTimes, 99).toFixed(2)}ms`,
63
+ improvement: mean < 10 ? output.success('Target met') : output.warning('Below target'),
64
+ });
65
+ }
66
+ // 2. Flash Attention-style Batch Operations
67
+ if (suite === 'all' || suite === 'wasm') {
68
+ spinner.setText('Benchmarking Flash Attention batch ops...');
69
+ const flashTimes = [];
70
+ // Generate test vectors
71
+ const testVectors = Array.from({ length: 100 }, () => new Float32Array(Array.from({ length: 384 }, () => Math.random())));
72
+ const queryVector = new Float32Array(Array.from({ length: 384 }, () => Math.random()));
73
+ // Warmup
74
+ for (let i = 0; i < warmup; i++) {
75
+ batchCosineSim(queryVector, testVectors);
76
+ }
77
+ // Actual measurement
78
+ for (let i = 0; i < iterations; i++) {
79
+ const start = performance.now();
80
+ flashAttentionSearch(queryVector, testVectors, { k: 10 });
81
+ flashTimes.push(performance.now() - start);
82
+ }
83
+ const mean = flashTimes.reduce((a, b) => a + b, 0) / flashTimes.length;
84
+ // Compare to baseline (single-vector comparison takes ~0.5μs, so 100 vectors baseline ~0.05ms)
85
+ const baselineMs = 0.05;
86
+ const speedup = baselineMs / mean;
87
+ results.push({
88
+ operation: 'Flash Attention',
89
+ mean: `${mean.toFixed(3)}ms`,
90
+ p95: `${percentile(flashTimes, 95).toFixed(3)}ms`,
91
+ p99: `${percentile(flashTimes, 99).toFixed(3)}ms`,
92
+ improvement: speedup > 1 ? output.success(`${speedup.toFixed(2)}x`) : output.dim(`${speedup.toFixed(2)}x`),
93
+ });
94
+ }
95
+ // 3. HNSW Search Benchmark
96
+ if (suite === 'all' || suite === 'search') {
97
+ spinner.setText('Benchmarking HNSW search...');
98
+ const hnswStatus = getHNSWStatus();
99
+ if (hnswStatus.available && hnswStatus.entryCount > 0) {
100
+ const searchTimes = [];
101
+ const testQueries = [
102
+ 'error handling patterns',
103
+ 'authentication flow',
104
+ 'database optimization',
105
+ 'API design patterns',
106
+ 'test coverage strategies',
107
+ ];
108
+ // Warmup
109
+ for (const q of testQueries.slice(0, 2)) {
110
+ await searchEntries({ query: q, limit: 10 });
111
+ }
112
+ // Actual measurement
113
+ for (let i = 0; i < Math.min(iterations, 50); i++) {
114
+ const query = testQueries[i % testQueries.length];
115
+ const start = performance.now();
116
+ await searchEntries({ query, limit: 10 });
196
117
  searchTimes.push(performance.now() - start);
197
- _d.label = 18;
198
- case 18:
199
- i++;
200
- return [3 /*break*/, 16];
201
- case 19:
202
- mean = searchTimes.reduce(function (a, b) { return a + b; }, 0) / searchTimes.length;
203
- baselineBruteForce = hnswStatus.entryCount * 0.0005;
204
- speedup = baselineBruteForce / (mean / 1000);
205
- results.push({
206
- operation: "HNSW Search (n=" + hnswStatus.entryCount + ")",
207
- mean: mean.toFixed(2) + "ms",
208
- p95: percentile(searchTimes, 95).toFixed(2) + "ms",
209
- p99: percentile(searchTimes, 99).toFixed(2) + "ms",
210
- improvement: speedup > 10 ? output.success("~" + Math.round(speedup) + "x") : output.dim(speedup.toFixed(1) + "x")
211
- });
212
- return [3 /*break*/, 21];
213
- case 20:
214
- results.push({
215
- operation: 'HNSW Search',
216
- mean: 'N/A',
217
- p95: 'N/A',
218
- p99: 'N/A',
219
- improvement: output.warning('No index')
220
- });
221
- _d.label = 21;
222
- case 21:
223
- if (!(suite === 'all' || suite === 'neural')) return [3 /*break*/, 23];
224
- spinner.setText('Benchmarking SONA adaptation...');
225
- return [4 /*yield*/, initializeIntelligence()];
226
- case 22:
227
- _d.sent();
228
- sonaResult = benchmarkAdaptation(iterations);
229
- results.push({
230
- operation: 'SONA Adaptation',
231
- mean: (sonaResult.avgMs * 1000).toFixed(2) + "\u03BCs",
232
- p95: (sonaResult.maxMs * 1000).toFixed(2) + "\u03BCs",
233
- p99: (sonaResult.maxMs * 1000).toFixed(2) + "\u03BCs",
234
- improvement: sonaResult.targetMet ? output.success('<0.05ms ✓') : output.warning('Above target')
235
- });
236
- _d.label = 23;
237
- case 23:
238
- if (!(suite === 'all' || suite === 'memory')) return [3 /*break*/, 28];
239
- spinner.setText('Benchmarking memory operations...');
240
- storeTimes = [];
241
- i = 0;
242
- _d.label = 24;
243
- case 24:
244
- if (!(i < Math.min(iterations, 20))) return [3 /*break*/, 27];
245
- start = performance.now();
246
- return [4 /*yield*/, storeEntry({
247
- key: "bench_" + Date.now() + "_" + i,
248
- value: "Benchmark test entry " + i + " with some content for testing storage performance",
249
- namespace: 'benchmark',
250
- generateEmbeddingFlag: true
251
- })];
252
- case 25:
253
- _d.sent();
254
- storeTimes.push(performance.now() - start);
255
- _d.label = 26;
256
- case 26:
257
- i++;
258
- return [3 /*break*/, 24];
259
- case 27:
260
- mean = storeTimes.reduce(function (a, b) { return a + b; }, 0) / storeTimes.length;
261
- results.push({
262
- operation: 'Memory Store+Embed',
263
- mean: mean.toFixed(1) + "ms",
264
- p95: percentile(storeTimes, 95).toFixed(1) + "ms",
265
- p99: percentile(storeTimes, 99).toFixed(1) + "ms",
266
- improvement: mean < 50 ? output.success('Target met') : output.warning('Slow')
267
- });
268
- _d.label = 28;
269
- case 28:
270
- totalTime = ((Date.now() - startTotal) / 1000).toFixed(2);
271
- spinner.succeed("Completed " + iterations + " iterations in " + totalTime + "s");
272
- // Output results
273
- if (outputFormat === 'json') {
274
- output.printJson({ suite: suite, iterations: iterations, totalTime: totalTime + "s", results: results });
275
- }
276
- else {
277
- output.writeln();
278
- output.printTable({
279
- columns: [
280
- { key: 'operation', header: 'Operation', width: 22 },
281
- { key: 'mean', header: 'Mean', width: 12 },
282
- { key: 'p95', header: 'P95', width: 12 },
283
- { key: 'p99', header: 'P99', width: 12 },
284
- { key: 'improvement', header: 'Status', width: 15 },
285
- ],
286
- data: results
287
- });
288
- output.writeln();
289
- allTargetsMet = results.every(function (r) { return !r.improvement.includes('warning') && !r.improvement.includes('Slow'); });
290
- output.printBox([
291
- "Suite: " + suite,
292
- "Iterations: " + iterations,
293
- "Total Time: " + totalTime + "s",
294
- "",
295
- "Overall: " + (allTargetsMet ? output.success('All targets met') : output.warning('Some targets missed')),
296
- ].join('\n'), 'Benchmark Summary');
297
- }
298
- return [2 /*return*/, { success: true, data: { results: results, totalTime: totalTime } }];
118
+ }
119
+ const mean = searchTimes.reduce((a, b) => a + b, 0) / searchTimes.length;
120
+ // Brute force baseline: ~0.5μs per vector comparison, 1000 vectors = 0.5ms
121
+ // HNSW should be O(log n) ~150x faster
122
+ const baselineBruteForce = hnswStatus.entryCount * 0.0005;
123
+ const speedup = baselineBruteForce / (mean / 1000);
124
+ results.push({
125
+ operation: `HNSW Search (n=${hnswStatus.entryCount})`,
126
+ mean: `${mean.toFixed(2)}ms`,
127
+ p95: `${percentile(searchTimes, 95).toFixed(2)}ms`,
128
+ p99: `${percentile(searchTimes, 99).toFixed(2)}ms`,
129
+ improvement: speedup > 10 ? output.success(`~${Math.round(speedup)}x`) : output.dim(`${speedup.toFixed(1)}x`),
130
+ });
299
131
  }
300
- });
301
- }); }
132
+ else {
133
+ results.push({
134
+ operation: 'HNSW Search',
135
+ mean: 'N/A',
136
+ p95: 'N/A',
137
+ p99: 'N/A',
138
+ improvement: output.warning('No index'),
139
+ });
140
+ }
141
+ }
142
+ // 4. SONA Adaptation Benchmark
143
+ if (suite === 'all' || suite === 'neural') {
144
+ spinner.setText('Benchmarking SONA adaptation...');
145
+ await initializeIntelligence();
146
+ const sonaResult = benchmarkAdaptation(iterations);
147
+ results.push({
148
+ operation: 'SONA Adaptation',
149
+ mean: `${(sonaResult.avgMs * 1000).toFixed(2)}μs`,
150
+ p95: `${(sonaResult.maxMs * 1000).toFixed(2)}μs`,
151
+ p99: `${(sonaResult.maxMs * 1000).toFixed(2)}μs`,
152
+ improvement: sonaResult.targetMet ? output.success('<0.05ms ✓') : output.warning('Above target'),
153
+ });
154
+ }
155
+ // 5. Memory Store/Retrieve
156
+ if (suite === 'all' || suite === 'memory') {
157
+ spinner.setText('Benchmarking memory operations...');
158
+ const storeTimes = [];
159
+ // Use in-memory operations for benchmark (don't persist)
160
+ for (let i = 0; i < Math.min(iterations, 20); i++) {
161
+ const start = performance.now();
162
+ await storeEntry({
163
+ key: `bench_${Date.now()}_${i}`,
164
+ value: `Benchmark test entry ${i} with some content for testing storage performance`,
165
+ namespace: 'benchmark',
166
+ generateEmbeddingFlag: true,
167
+ });
168
+ storeTimes.push(performance.now() - start);
169
+ }
170
+ const mean = storeTimes.reduce((a, b) => a + b, 0) / storeTimes.length;
171
+ results.push({
172
+ operation: 'Memory Store+Embed',
173
+ mean: `${mean.toFixed(1)}ms`,
174
+ p95: `${percentile(storeTimes, 95).toFixed(1)}ms`,
175
+ p99: `${percentile(storeTimes, 99).toFixed(1)}ms`,
176
+ improvement: mean < 50 ? output.success('Target met') : output.warning('Slow'),
177
+ });
178
+ }
179
+ const totalTime = ((Date.now() - startTotal) / 1000).toFixed(2);
180
+ spinner.succeed(`Completed ${iterations} iterations in ${totalTime}s`);
181
+ // Output results
182
+ if (outputFormat === 'json') {
183
+ output.printJson({ suite, iterations, totalTime: `${totalTime}s`, results });
184
+ }
185
+ else {
186
+ output.writeln();
187
+ output.printTable({
188
+ columns: [
189
+ { key: 'operation', header: 'Operation', width: 22 },
190
+ { key: 'mean', header: 'Mean', width: 12 },
191
+ { key: 'p95', header: 'P95', width: 12 },
192
+ { key: 'p99', header: 'P99', width: 12 },
193
+ { key: 'improvement', header: 'Status', width: 15 },
194
+ ],
195
+ data: results,
196
+ });
197
+ output.writeln();
198
+ const allTargetsMet = results.every(r => !r.improvement.includes('warning') && !r.improvement.includes('Slow'));
199
+ output.printBox([
200
+ `Suite: ${suite}`,
201
+ `Iterations: ${iterations}`,
202
+ `Total Time: ${totalTime}s`,
203
+ ``,
204
+ `Overall: ${allTargetsMet ? output.success('All targets met') : output.warning('Some targets missed')}`,
205
+ ].join('\n'), 'Benchmark Summary');
206
+ }
207
+ return { success: true, data: { results, totalTime } };
208
+ },
302
209
  };
303
210
  // Profile subcommand
304
- var profileCommand = {
211
+ const profileCommand = {
305
212
  name: 'profile',
306
213
  description: 'Profile application performance',
307
214
  options: [
308
- { name: 'type', short: 't', type: 'string', description: 'Profile type: cpu, memory, io, all', "default": 'all' },
309
- { name: 'duration', short: 'd', type: 'number', description: 'Duration in seconds', "default": '30' },
215
+ { name: 'type', short: 't', type: 'string', description: 'Profile type: cpu, memory, io, all', default: 'all' },
216
+ { name: 'duration', short: 'd', type: 'number', description: 'Duration in seconds', default: '30' },
310
217
  { name: 'output', short: 'o', type: 'string', description: 'Output file for profile data' },
311
218
  ],
312
219
  examples: [
313
220
  { command: 'claude-flow performance profile -t cpu', description: 'Profile CPU usage' },
314
221
  { command: 'claude-flow performance profile -d 60', description: 'Profile for 60 seconds' },
315
222
  ],
316
- action: function (ctx) { return __awaiter(void 0, void 0, Promise, function () {
317
- var type, duration, spinner, startCpu, startMem, startTime, endCpu, endMem, endTime, elapsedMs, cpuPercent, heapUsedMB, heapTotalMB, rssMB, externalMB, lagStart, eventLoopLag, heapStatus, lagStatus;
318
- return __generator(this, function (_a) {
319
- switch (_a.label) {
320
- case 0:
321
- type = ctx.flags.type || 'all';
322
- duration = parseInt(ctx.flags.duration || '30', 10);
323
- output.writeln();
324
- output.writeln(output.bold('Performance Profiler'));
325
- output.writeln(output.dim('─'.repeat(50)));
326
- spinner = output.createSpinner({ text: 'Collecting profile data...', spinner: 'dots' });
327
- spinner.start();
328
- startCpu = process.cpuUsage();
329
- startMem = process.memoryUsage();
330
- startTime = process.hrtime.bigint();
331
- // Sample for a brief period
332
- return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, Math.min(duration * 100, 2000)); })];
333
- case 1:
334
- // Sample for a brief period
335
- _a.sent();
336
- endCpu = process.cpuUsage(startCpu);
337
- endMem = process.memoryUsage();
338
- endTime = process.hrtime.bigint();
339
- spinner.succeed('Profile complete');
340
- elapsedMs = Number(endTime - startTime) / 1000000;
341
- cpuPercent = ((endCpu.user + endCpu.system) / 1000 / elapsedMs * 100).toFixed(1);
342
- heapUsedMB = (endMem.heapUsed / 1024 / 1024).toFixed(1);
343
- heapTotalMB = (endMem.heapTotal / 1024 / 1024).toFixed(1);
344
- rssMB = (endMem.rss / 1024 / 1024).toFixed(1);
345
- externalMB = (endMem.external / 1024 / 1024).toFixed(1);
346
- lagStart = Date.now();
347
- return [4 /*yield*/, new Promise(function (r) { return setImmediate(r); })];
348
- case 2:
349
- _a.sent();
350
- eventLoopLag = (Date.now() - lagStart).toFixed(1);
351
- heapStatus = endMem.heapUsed / endMem.heapTotal > 0.9 ? output.error('High') :
352
- endMem.heapUsed / endMem.heapTotal > 0.7 ? output.warning('Elevated') : output.success('Normal');
353
- lagStatus = parseFloat(eventLoopLag) > 50 ? output.error('High') :
354
- parseFloat(eventLoopLag) > 10 ? output.warning('Elevated') : output.success('Normal');
355
- output.writeln();
356
- output.printTable({
357
- columns: [
358
- { key: 'metric', header: 'Metric', width: 25 },
359
- { key: 'current', header: 'Current', width: 15 },
360
- { key: 'peak', header: 'Peak/Total', width: 15 },
361
- { key: 'status', header: 'Status', width: 15 },
362
- ],
363
- data: [
364
- { metric: 'CPU Usage', current: cpuPercent + "%", peak: '-', status: output.success('Sampled') },
365
- { metric: 'Memory (Heap Used)', current: heapUsedMB + " MB", peak: heapTotalMB + " MB", status: heapStatus },
366
- { metric: 'Memory (RSS)', current: rssMB + " MB", peak: '-', status: output.success('Normal') },
367
- { metric: 'Memory (External)', current: externalMB + " MB", peak: '-', status: output.success('Normal') },
368
- { metric: 'Event Loop Lag', current: eventLoopLag + "ms", peak: '-', status: lagStatus },
369
- { metric: 'Node.js Uptime', current: process.uptime().toFixed(1) + "s", peak: '-', status: output.success('Running') },
370
- ]
371
- });
372
- output.writeln();
373
- output.writeln(output.dim("Profile duration: " + elapsedMs.toFixed(0) + "ms"));
374
- return [2 /*return*/, { success: true }];
375
- }
223
+ action: async (ctx) => {
224
+ const type = ctx.flags.type || 'all';
225
+ const duration = parseInt(ctx.flags.duration || '30', 10);
226
+ output.writeln();
227
+ output.writeln(output.bold('Performance Profiler'));
228
+ output.writeln(output.dim(''.repeat(50)));
229
+ const spinner = output.createSpinner({ text: 'Collecting profile data...', spinner: 'dots' });
230
+ spinner.start();
231
+ // Collect real metrics
232
+ const startCpu = process.cpuUsage();
233
+ const startMem = process.memoryUsage();
234
+ const startTime = process.hrtime.bigint();
235
+ // Sample for a brief period
236
+ await new Promise(r => setTimeout(r, Math.min(duration * 100, 2000)));
237
+ const endCpu = process.cpuUsage(startCpu);
238
+ const endMem = process.memoryUsage();
239
+ const endTime = process.hrtime.bigint();
240
+ spinner.succeed('Profile complete');
241
+ // Calculate real values
242
+ const elapsedMs = Number(endTime - startTime) / 1_000_000;
243
+ const cpuPercent = ((endCpu.user + endCpu.system) / 1000 / elapsedMs * 100).toFixed(1);
244
+ const heapUsedMB = (endMem.heapUsed / 1024 / 1024).toFixed(1);
245
+ const heapTotalMB = (endMem.heapTotal / 1024 / 1024).toFixed(1);
246
+ const rssMB = (endMem.rss / 1024 / 1024).toFixed(1);
247
+ const externalMB = (endMem.external / 1024 / 1024).toFixed(1);
248
+ // Get event loop lag (approximate)
249
+ const lagStart = Date.now();
250
+ await new Promise(r => setImmediate(r));
251
+ const eventLoopLag = (Date.now() - lagStart).toFixed(1);
252
+ // Determine status based on thresholds
253
+ const heapStatus = endMem.heapUsed / endMem.heapTotal > 0.9 ? output.error('High') :
254
+ endMem.heapUsed / endMem.heapTotal > 0.7 ? output.warning('Elevated') : output.success('Normal');
255
+ const lagStatus = parseFloat(eventLoopLag) > 50 ? output.error('High') :
256
+ parseFloat(eventLoopLag) > 10 ? output.warning('Elevated') : output.success('Normal');
257
+ output.writeln();
258
+ output.printTable({
259
+ columns: [
260
+ { key: 'metric', header: 'Metric', width: 25 },
261
+ { key: 'current', header: 'Current', width: 15 },
262
+ { key: 'peak', header: 'Peak/Total', width: 15 },
263
+ { key: 'status', header: 'Status', width: 15 },
264
+ ],
265
+ data: [
266
+ { metric: 'CPU Usage', current: `${cpuPercent}%`, peak: '-', status: output.success('Sampled') },
267
+ { metric: 'Memory (Heap Used)', current: `${heapUsedMB} MB`, peak: `${heapTotalMB} MB`, status: heapStatus },
268
+ { metric: 'Memory (RSS)', current: `${rssMB} MB`, peak: '-', status: output.success('Normal') },
269
+ { metric: 'Memory (External)', current: `${externalMB} MB`, peak: '-', status: output.success('Normal') },
270
+ { metric: 'Event Loop Lag', current: `${eventLoopLag}ms`, peak: '-', status: lagStatus },
271
+ { metric: 'Node.js Uptime', current: `${process.uptime().toFixed(1)}s`, peak: '-', status: output.success('Running') },
272
+ ],
376
273
  });
377
- }); }
274
+ output.writeln();
275
+ output.writeln(output.dim(`Profile duration: ${elapsedMs.toFixed(0)}ms`));
276
+ return { success: true };
277
+ },
378
278
  };
379
279
  // Metrics subcommand
380
- var metricsCommand = {
280
+ const metricsCommand = {
381
281
  name: 'metrics',
382
282
  description: 'View and export performance metrics',
383
283
  options: [
384
- { name: 'timeframe', short: 't', type: 'string', description: 'Timeframe: 1h, 24h, 7d, 30d', "default": '24h' },
385
- { name: 'format', short: 'f', type: 'string', description: 'Output format: text, json, prometheus', "default": 'text' },
284
+ { name: 'timeframe', short: 't', type: 'string', description: 'Timeframe: 1h, 24h, 7d, 30d', default: '24h' },
285
+ { name: 'format', short: 'f', type: 'string', description: 'Output format: text, json, prometheus', default: 'text' },
386
286
  { name: 'component', short: 'c', type: 'string', description: 'Component to filter' },
387
287
  ],
388
288
  examples: [
389
289
  { command: 'claude-flow performance metrics -t 7d', description: 'Show 7-day metrics' },
390
290
  { command: 'claude-flow performance metrics -f prometheus', description: 'Export as Prometheus format' },
391
291
  ],
392
- action: function (ctx) { return __awaiter(void 0, void 0, Promise, function () {
393
- var timeframe, format, os, fs, path, memUsage, cpuUsage, uptime, loadAvg, freeMem, totalMem, heapUsedMB, heapTotalMB, rssMB, memPercent, cpuUserMs, cpuSystemMs, cacheHitRate, hnswEntries, getHNSWStatus, status, _a, cacheEntries, cachePath, stats, avgLatencyMs, times, i, start, _b, metrics;
394
- return __generator(this, function (_c) {
395
- switch (_c.label) {
396
- case 0:
397
- timeframe = ctx.flags.timeframe || '24h';
398
- format = ctx.flags.format || 'text';
399
- output.writeln();
400
- output.writeln(output.bold("Performance Metrics (" + timeframe + ")"));
401
- output.writeln(output.dim('─'.repeat(50)));
402
- return [4 /*yield*/, import('os')];
403
- case 1:
404
- os = _c.sent();
405
- return [4 /*yield*/, import('fs')];
406
- case 2:
407
- fs = _c.sent();
408
- return [4 /*yield*/, import('path')];
409
- case 3:
410
- path = _c.sent();
411
- memUsage = process.memoryUsage();
412
- cpuUsage = process.cpuUsage();
413
- uptime = process.uptime();
414
- loadAvg = os.loadavg();
415
- freeMem = os.freemem();
416
- totalMem = os.totalmem();
417
- heapUsedMB = (memUsage.heapUsed / 1024 / 1024).toFixed(1);
418
- heapTotalMB = (memUsage.heapTotal / 1024 / 1024).toFixed(1);
419
- rssMB = (memUsage.rss / 1024 / 1024).toFixed(1);
420
- memPercent = ((1 - freeMem / totalMem) * 100).toFixed(1);
421
- cpuUserMs = (cpuUsage.user / 1000).toFixed(0);
422
- cpuSystemMs = (cpuUsage.system / 1000).toFixed(0);
423
- cacheHitRate = 'N/A';
424
- hnswEntries = 0;
425
- _c.label = 4;
426
- case 4:
427
- _c.trys.push([4, 6, , 7]);
428
- return [4 /*yield*/, import('../memory/memory-initializer.js')];
429
- case 5:
430
- getHNSWStatus = (_c.sent()).getHNSWStatus;
431
- status = getHNSWStatus();
432
- hnswEntries = (status === null || status === void 0 ? void 0 : status.entryCount) || 0;
433
- return [3 /*break*/, 7];
434
- case 6:
435
- _a = _c.sent();
436
- return [3 /*break*/, 7];
437
- case 7:
438
- cacheEntries = 0;
439
- try {
440
- cachePath = path.resolve('.cache/embeddings.db');
441
- if (fs.existsSync(cachePath)) {
442
- stats = fs.statSync(cachePath);
443
- cacheEntries = Math.floor(stats.size / 1600); // Approximate entries
444
- }
445
- }
446
- catch ( /* no cache */_d) { /* no cache */ }
447
- avgLatencyMs = 0;
448
- _c.label = 8;
449
- case 8:
450
- _c.trys.push([8, 13, , 14]);
451
- times = [];
452
- i = 0;
453
- _c.label = 9;
454
- case 9:
455
- if (!(i < 10)) return [3 /*break*/, 12];
456
- start = performance.now();
457
- return [4 /*yield*/, new Promise(function (r) { return setImmediate(r); })];
458
- case 10:
459
- _c.sent(); // Event loop turn
460
- times.push(performance.now() - start);
461
- _c.label = 11;
462
- case 11:
463
- i++;
464
- return [3 /*break*/, 9];
465
- case 12:
466
- avgLatencyMs = times.reduce(function (a, b) { return a + b; }, 0) / times.length;
467
- return [3 /*break*/, 14];
468
- case 13:
469
- _b = _c.sent();
470
- return [3 /*break*/, 14];
471
- case 14:
472
- // JSON/Prometheus output
473
- if (format === 'json') {
474
- metrics = {
475
- timestamp: new Date().toISOString(),
476
- timeframe: timeframe,
477
- memory: {
478
- heapUsed: memUsage.heapUsed,
479
- heapTotal: memUsage.heapTotal,
480
- rss: memUsage.rss,
481
- external: memUsage.external,
482
- systemPercent: parseFloat(memPercent)
483
- },
484
- cpu: {
485
- user: cpuUsage.user,
486
- system: cpuUsage.system,
487
- loadAverage: loadAvg
488
- },
489
- process: {
490
- uptime: uptime,
491
- pid: process.pid
492
- },
493
- cache: {
494
- entries: cacheEntries,
495
- hnswEntries: hnswEntries
496
- },
497
- latency: {
498
- avgMs: avgLatencyMs
499
- }
500
- };
501
- output.writeln(JSON.stringify(metrics, null, 2));
502
- return [2 /*return*/, { success: true }];
503
- }
504
- if (format === 'prometheus') {
505
- output.writeln("# HELP claude_flow_heap_used_bytes Heap memory used");
506
- output.writeln("claude_flow_heap_used_bytes " + memUsage.heapUsed);
507
- output.writeln("# HELP claude_flow_heap_total_bytes Total heap memory");
508
- output.writeln("claude_flow_heap_total_bytes " + memUsage.heapTotal);
509
- output.writeln("# HELP claude_flow_rss_bytes Resident set size");
510
- output.writeln("claude_flow_rss_bytes " + memUsage.rss);
511
- output.writeln("# HELP claude_flow_cpu_user_microseconds CPU user time");
512
- output.writeln("claude_flow_cpu_user_microseconds " + cpuUsage.user);
513
- output.writeln("# HELP claude_flow_cpu_system_microseconds CPU system time");
514
- output.writeln("claude_flow_cpu_system_microseconds " + cpuUsage.system);
515
- output.writeln("# HELP claude_flow_cache_entries Embedding cache entries");
516
- output.writeln("claude_flow_cache_entries " + cacheEntries);
517
- output.writeln("# HELP claude_flow_hnsw_entries HNSW index entries");
518
- output.writeln("claude_flow_hnsw_entries " + hnswEntries);
519
- output.writeln("# HELP claude_flow_uptime_seconds Process uptime");
520
- output.writeln("claude_flow_uptime_seconds " + uptime);
521
- return [2 /*return*/, { success: true }];
522
- }
523
- // Text table output with real values
524
- output.printTable({
525
- columns: [
526
- { key: 'metric', header: 'Metric', width: 25 },
527
- { key: 'current', header: 'Current', width: 15 },
528
- { key: 'limit', header: 'Limit', width: 15 },
529
- { key: 'status', header: 'Status', width: 12 },
530
- ],
531
- data: [
532
- {
533
- metric: 'Heap Memory',
534
- current: heapUsedMB + " MB",
535
- limit: heapTotalMB + " MB",
536
- status: parseFloat(heapUsedMB) < parseFloat(heapTotalMB) * 0.8 ? output.success('OK') : output.warning('High')
537
- },
538
- {
539
- metric: 'RSS Memory',
540
- current: rssMB + " MB",
541
- limit: '-',
542
- status: parseFloat(rssMB) < 500 ? output.success('OK') : output.warning('High')
543
- },
544
- {
545
- metric: 'System Memory',
546
- current: memPercent + "%",
547
- limit: '100%',
548
- status: parseFloat(memPercent) < 80 ? output.success('OK') : output.warning('High')
549
- },
550
- {
551
- metric: 'CPU User Time',
552
- current: cpuUserMs + "ms",
553
- limit: '-',
554
- status: output.success('OK')
555
- },
556
- {
557
- metric: 'Event Loop Latency',
558
- current: avgLatencyMs.toFixed(2) + "ms",
559
- limit: '10ms',
560
- status: avgLatencyMs < 10 ? output.success('OK') : output.warning('Slow')
561
- },
562
- {
563
- metric: 'HNSW Index',
564
- current: hnswEntries + " entries",
565
- limit: '-',
566
- status: hnswEntries > 0 ? output.success('Active') : output.dim('Empty')
567
- },
568
- {
569
- metric: 'Embedding Cache',
570
- current: cacheEntries + " entries",
571
- limit: '-',
572
- status: cacheEntries > 0 ? output.success('Active') : output.dim('Empty')
573
- },
574
- {
575
- metric: 'Process Uptime',
576
- current: Math.floor(uptime) + "s",
577
- limit: '-',
578
- status: output.success('Running')
579
- },
580
- ]
581
- });
582
- output.writeln();
583
- output.writeln(output.dim("Load Average: " + loadAvg.map(function (l) { return l.toFixed(2); }).join(', ')));
584
- output.writeln(output.dim("CPUs: " + os.cpus().length + " | Platform: " + os.platform() + " " + os.release()));
585
- return [2 /*return*/, { success: true }];
292
+ action: async (ctx) => {
293
+ const timeframe = ctx.flags.timeframe || '24h';
294
+ const format = ctx.flags.format || 'text';
295
+ output.writeln();
296
+ output.writeln(output.bold(`Performance Metrics (${timeframe})`));
297
+ output.writeln(output.dim(''.repeat(50)));
298
+ const os = await import('os');
299
+ const fs = await import('fs');
300
+ const path = await import('path');
301
+ // Real system metrics
302
+ const memUsage = process.memoryUsage();
303
+ const cpuUsage = process.cpuUsage();
304
+ const uptime = process.uptime();
305
+ const loadAvg = os.loadavg();
306
+ const freeMem = os.freemem();
307
+ const totalMem = os.totalmem();
308
+ // Calculate real metrics
309
+ const heapUsedMB = (memUsage.heapUsed / 1024 / 1024).toFixed(1);
310
+ const heapTotalMB = (memUsage.heapTotal / 1024 / 1024).toFixed(1);
311
+ const rssMB = (memUsage.rss / 1024 / 1024).toFixed(1);
312
+ const memPercent = ((1 - freeMem / totalMem) * 100).toFixed(1);
313
+ const cpuUserMs = (cpuUsage.user / 1000).toFixed(0);
314
+ const cpuSystemMs = (cpuUsage.system / 1000).toFixed(0);
315
+ // Try to get HNSW/cache stats from real data
316
+ let cacheHitRate = 'N/A';
317
+ let hnswEntries = 0;
318
+ try {
319
+ const { getHNSWStatus } = await import('../memory/memory-initializer.js');
320
+ const status = getHNSWStatus();
321
+ hnswEntries = status?.entryCount || 0;
322
+ }
323
+ catch { /* HNSW not initialized */ }
324
+ // Try to get real cache stats
325
+ let cacheEntries = 0;
326
+ try {
327
+ const cachePath = path.resolve('.cache/embeddings.db');
328
+ if (fs.existsSync(cachePath)) {
329
+ const stats = fs.statSync(cachePath);
330
+ cacheEntries = Math.floor(stats.size / 1600); // Approximate entries
586
331
  }
332
+ }
333
+ catch { /* no cache */ }
334
+ // Benchmark a quick operation to get real latency
335
+ let avgLatencyMs = 0;
336
+ try {
337
+ const times = [];
338
+ for (let i = 0; i < 10; i++) {
339
+ const start = performance.now();
340
+ await new Promise(r => setImmediate(r)); // Event loop turn
341
+ times.push(performance.now() - start);
342
+ }
343
+ avgLatencyMs = times.reduce((a, b) => a + b, 0) / times.length;
344
+ }
345
+ catch { /* timing failed */ }
346
+ // JSON/Prometheus output
347
+ if (format === 'json') {
348
+ const metrics = {
349
+ timestamp: new Date().toISOString(),
350
+ timeframe,
351
+ memory: {
352
+ heapUsed: memUsage.heapUsed,
353
+ heapTotal: memUsage.heapTotal,
354
+ rss: memUsage.rss,
355
+ external: memUsage.external,
356
+ systemPercent: parseFloat(memPercent),
357
+ },
358
+ cpu: {
359
+ user: cpuUsage.user,
360
+ system: cpuUsage.system,
361
+ loadAverage: loadAvg,
362
+ },
363
+ process: {
364
+ uptime,
365
+ pid: process.pid,
366
+ },
367
+ cache: {
368
+ entries: cacheEntries,
369
+ hnswEntries,
370
+ },
371
+ latency: {
372
+ avgMs: avgLatencyMs,
373
+ },
374
+ };
375
+ output.writeln(JSON.stringify(metrics, null, 2));
376
+ return { success: true };
377
+ }
378
+ if (format === 'prometheus') {
379
+ output.writeln(`# HELP claude_flow_heap_used_bytes Heap memory used`);
380
+ output.writeln(`claude_flow_heap_used_bytes ${memUsage.heapUsed}`);
381
+ output.writeln(`# HELP claude_flow_heap_total_bytes Total heap memory`);
382
+ output.writeln(`claude_flow_heap_total_bytes ${memUsage.heapTotal}`);
383
+ output.writeln(`# HELP claude_flow_rss_bytes Resident set size`);
384
+ output.writeln(`claude_flow_rss_bytes ${memUsage.rss}`);
385
+ output.writeln(`# HELP claude_flow_cpu_user_microseconds CPU user time`);
386
+ output.writeln(`claude_flow_cpu_user_microseconds ${cpuUsage.user}`);
387
+ output.writeln(`# HELP claude_flow_cpu_system_microseconds CPU system time`);
388
+ output.writeln(`claude_flow_cpu_system_microseconds ${cpuUsage.system}`);
389
+ output.writeln(`# HELP claude_flow_cache_entries Embedding cache entries`);
390
+ output.writeln(`claude_flow_cache_entries ${cacheEntries}`);
391
+ output.writeln(`# HELP claude_flow_hnsw_entries HNSW index entries`);
392
+ output.writeln(`claude_flow_hnsw_entries ${hnswEntries}`);
393
+ output.writeln(`# HELP claude_flow_uptime_seconds Process uptime`);
394
+ output.writeln(`claude_flow_uptime_seconds ${uptime}`);
395
+ return { success: true };
396
+ }
397
+ // Text table output with real values
398
+ output.printTable({
399
+ columns: [
400
+ { key: 'metric', header: 'Metric', width: 25 },
401
+ { key: 'current', header: 'Current', width: 15 },
402
+ { key: 'limit', header: 'Limit', width: 15 },
403
+ { key: 'status', header: 'Status', width: 12 },
404
+ ],
405
+ data: [
406
+ {
407
+ metric: 'Heap Memory',
408
+ current: `${heapUsedMB} MB`,
409
+ limit: `${heapTotalMB} MB`,
410
+ status: parseFloat(heapUsedMB) < parseFloat(heapTotalMB) * 0.8 ? output.success('OK') : output.warning('High'),
411
+ },
412
+ {
413
+ metric: 'RSS Memory',
414
+ current: `${rssMB} MB`,
415
+ limit: '-',
416
+ status: parseFloat(rssMB) < 500 ? output.success('OK') : output.warning('High'),
417
+ },
418
+ {
419
+ metric: 'System Memory',
420
+ current: `${memPercent}%`,
421
+ limit: '100%',
422
+ status: parseFloat(memPercent) < 80 ? output.success('OK') : output.warning('High'),
423
+ },
424
+ {
425
+ metric: 'CPU User Time',
426
+ current: `${cpuUserMs}ms`,
427
+ limit: '-',
428
+ status: output.success('OK'),
429
+ },
430
+ {
431
+ metric: 'Event Loop Latency',
432
+ current: `${avgLatencyMs.toFixed(2)}ms`,
433
+ limit: '10ms',
434
+ status: avgLatencyMs < 10 ? output.success('OK') : output.warning('Slow'),
435
+ },
436
+ {
437
+ metric: 'HNSW Index',
438
+ current: `${hnswEntries} entries`,
439
+ limit: '-',
440
+ status: hnswEntries > 0 ? output.success('Active') : output.dim('Empty'),
441
+ },
442
+ {
443
+ metric: 'Embedding Cache',
444
+ current: `${cacheEntries} entries`,
445
+ limit: '-',
446
+ status: cacheEntries > 0 ? output.success('Active') : output.dim('Empty'),
447
+ },
448
+ {
449
+ metric: 'Process Uptime',
450
+ current: `${Math.floor(uptime)}s`,
451
+ limit: '-',
452
+ status: output.success('Running'),
453
+ },
454
+ ],
587
455
  });
588
- }); }
456
+ output.writeln();
457
+ output.writeln(output.dim(`Load Average: ${loadAvg.map(l => l.toFixed(2)).join(', ')}`));
458
+ output.writeln(output.dim(`CPUs: ${os.cpus().length} | Platform: ${os.platform()} ${os.release()}`));
459
+ return { success: true };
460
+ },
589
461
  };
590
462
  // Optimize subcommand
591
- var optimizeCommand = {
463
+ const optimizeCommand = {
592
464
  name: 'optimize',
593
465
  description: 'Run performance optimization recommendations',
594
466
  options: [
595
- { name: 'target', short: 't', type: 'string', description: 'Target: memory, cpu, latency, all', "default": 'all' },
467
+ { name: 'target', short: 't', type: 'string', description: 'Target: memory, cpu, latency, all', default: 'all' },
596
468
  { name: 'apply', short: 'a', type: 'boolean', description: 'Apply recommended optimizations' },
597
469
  { name: 'dry-run', short: 'd', type: 'boolean', description: 'Show changes without applying' },
598
470
  ],
@@ -600,91 +472,75 @@ var optimizeCommand = {
600
472
  { command: 'claude-flow performance optimize -t memory', description: 'Optimize memory usage' },
601
473
  { command: 'claude-flow performance optimize --apply', description: 'Apply all optimizations' },
602
474
  ],
603
- action: function (ctx) { return __awaiter(void 0, void 0, Promise, function () {
604
- var target, spinner;
605
- return __generator(this, function (_a) {
606
- switch (_a.label) {
607
- case 0:
608
- target = ctx.flags.target || 'all';
609
- output.writeln();
610
- output.writeln(output.bold('Performance Optimization'));
611
- output.writeln(output.dim(''.repeat(50)));
612
- spinner = output.createSpinner({ text: 'Analyzing performance...', spinner: 'dots' });
613
- spinner.start();
614
- return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 800); })];
615
- case 1:
616
- _a.sent();
617
- spinner.succeed('Analysis complete');
618
- output.writeln();
619
- output.writeln(output.bold('Recommendations:'));
620
- output.writeln();
621
- output.printTable({
622
- columns: [
623
- { key: 'priority', header: 'Priority', width: 10 },
624
- { key: 'area', header: 'Area', width: 15 },
625
- { key: 'recommendation', header: 'Recommendation', width: 40 },
626
- { key: 'impact', header: 'Impact', width: 15 },
627
- ],
628
- data: [
629
- { priority: output.error('P0'), area: 'Memory', recommendation: 'Enable HNSW index quantization', impact: '+50% reduction' },
630
- { priority: output.warning('P1'), area: 'CPU', recommendation: 'Enable WASM SIMD acceleration', impact: '+4x speedup' },
631
- { priority: output.warning('P1'), area: 'Latency', recommendation: 'Enable Flash Attention', impact: '+2.49x speedup' },
632
- { priority: output.info('P2'), area: 'Cache', recommendation: 'Increase pattern cache size', impact: '+15% hit rate' },
633
- { priority: output.info('P2'), area: 'Network', recommendation: 'Enable request batching', impact: '-30% latency' },
634
- ]
635
- });
636
- return [2 /*return*/, { success: true }];
637
- }
475
+ action: async (ctx) => {
476
+ const target = ctx.flags.target || 'all';
477
+ output.writeln();
478
+ output.writeln(output.bold('Performance Optimization'));
479
+ output.writeln(output.dim('─'.repeat(50)));
480
+ const spinner = output.createSpinner({ text: 'Analyzing performance...', spinner: 'dots' });
481
+ spinner.start();
482
+ await new Promise(r => setTimeout(r, 800));
483
+ spinner.succeed('Analysis complete');
484
+ output.writeln();
485
+ output.writeln(output.bold('Recommendations:'));
486
+ output.writeln();
487
+ output.printTable({
488
+ columns: [
489
+ { key: 'priority', header: 'Priority', width: 10 },
490
+ { key: 'area', header: 'Area', width: 15 },
491
+ { key: 'recommendation', header: 'Recommendation', width: 40 },
492
+ { key: 'impact', header: 'Impact', width: 15 },
493
+ ],
494
+ data: [
495
+ { priority: output.error('P0'), area: 'Memory', recommendation: 'Enable HNSW index quantization', impact: '+50% reduction' },
496
+ { priority: output.warning('P1'), area: 'CPU', recommendation: 'Enable WASM SIMD acceleration', impact: '+4x speedup' },
497
+ { priority: output.warning('P1'), area: 'Latency', recommendation: 'Enable Flash Attention', impact: '+2.49x speedup' },
498
+ { priority: output.info('P2'), area: 'Cache', recommendation: 'Increase pattern cache size', impact: '+15% hit rate' },
499
+ { priority: output.info('P2'), area: 'Network', recommendation: 'Enable request batching', impact: '-30% latency' },
500
+ ],
638
501
  });
639
- }); }
502
+ return { success: true };
503
+ },
640
504
  };
641
505
  // Bottleneck subcommand
642
- var bottleneckCommand = {
506
+ const bottleneckCommand = {
643
507
  name: 'bottleneck',
644
508
  description: 'Identify performance bottlenecks',
645
509
  options: [
646
510
  { name: 'component', short: 'c', type: 'string', description: 'Component to analyze' },
647
- { name: 'depth', short: 'd', type: 'string', description: 'Analysis depth: quick, full', "default": 'quick' },
511
+ { name: 'depth', short: 'd', type: 'string', description: 'Analysis depth: quick, full', default: 'quick' },
648
512
  ],
649
513
  examples: [
650
514
  { command: 'claude-flow performance bottleneck', description: 'Find bottlenecks' },
651
515
  { command: 'claude-flow performance bottleneck -d full', description: 'Full analysis' },
652
516
  ],
653
- action: function (ctx) { return __awaiter(void 0, void 0, Promise, function () {
654
- var spinner;
655
- return __generator(this, function (_a) {
656
- switch (_a.label) {
657
- case 0:
658
- output.writeln();
659
- output.writeln(output.bold('Bottleneck Analysis'));
660
- output.writeln(output.dim(''.repeat(50)));
661
- spinner = output.createSpinner({ text: 'Analyzing system...', spinner: 'dots' });
662
- spinner.start();
663
- return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
664
- case 1:
665
- _a.sent();
666
- spinner.succeed('Analysis complete');
667
- output.writeln();
668
- output.printTable({
669
- columns: [
670
- { key: 'component', header: 'Component', width: 20 },
671
- { key: 'bottleneck', header: 'Bottleneck', width: 25 },
672
- { key: 'severity', header: 'Severity', width: 12 },
673
- { key: 'solution', header: 'Solution', width: 30 },
674
- ],
675
- data: [
676
- { component: 'Vector Search', bottleneck: 'Linear scan O(n)', severity: output.error('High'), solution: 'Enable HNSW indexing' },
677
- { component: 'Neural Inference', bottleneck: 'Sequential attention', severity: output.warning('Medium'), solution: 'Enable Flash Attention' },
678
- { component: 'Memory Store', bottleneck: 'Lock contention', severity: output.info('Low'), solution: 'Use sharded storage' },
679
- ]
680
- });
681
- return [2 /*return*/, { success: true }];
682
- }
517
+ action: async (ctx) => {
518
+ output.writeln();
519
+ output.writeln(output.bold('Bottleneck Analysis'));
520
+ output.writeln(output.dim('─'.repeat(50)));
521
+ const spinner = output.createSpinner({ text: 'Analyzing system...', spinner: 'dots' });
522
+ spinner.start();
523
+ await new Promise(r => setTimeout(r, 600));
524
+ spinner.succeed('Analysis complete');
525
+ output.writeln();
526
+ output.printTable({
527
+ columns: [
528
+ { key: 'component', header: 'Component', width: 20 },
529
+ { key: 'bottleneck', header: 'Bottleneck', width: 25 },
530
+ { key: 'severity', header: 'Severity', width: 12 },
531
+ { key: 'solution', header: 'Solution', width: 30 },
532
+ ],
533
+ data: [
534
+ { component: 'Vector Search', bottleneck: 'Linear scan O(n)', severity: output.error('High'), solution: 'Enable HNSW indexing' },
535
+ { component: 'Neural Inference', bottleneck: 'Sequential attention', severity: output.warning('Medium'), solution: 'Enable Flash Attention' },
536
+ { component: 'Memory Store', bottleneck: 'Lock contention', severity: output.info('Low'), solution: 'Use sharded storage' },
537
+ ],
683
538
  });
684
- }); }
539
+ return { success: true };
540
+ },
685
541
  };
686
542
  // Main performance command
687
- export var performanceCommand = {
543
+ export const performanceCommand = {
688
544
  name: 'performance',
689
545
  description: 'Performance profiling, benchmarking, optimization, metrics',
690
546
  aliases: ['perf'],
@@ -694,32 +550,30 @@ export var performanceCommand = {
694
550
  { command: 'claude-flow performance profile', description: 'Profile application' },
695
551
  { command: 'claude-flow perf metrics', description: 'View metrics (alias)' },
696
552
  ],
697
- action: function () { return __awaiter(void 0, void 0, Promise, function () {
698
- return __generator(this, function (_a) {
699
- output.writeln();
700
- output.writeln(output.bold('RuFlo Performance Suite'));
701
- output.writeln(output.dim('Advanced performance profiling and optimization'));
702
- output.writeln();
703
- output.writeln('Subcommands:');
704
- output.printList([
705
- 'benchmark - Run performance benchmarks (WASM, neural, search)',
706
- 'profile - Profile CPU, memory, I/O usage',
707
- 'metrics - View and export performance metrics',
708
- 'optimize - Get optimization recommendations',
709
- 'bottleneck - Identify performance bottlenecks',
710
- ]);
711
- output.writeln();
712
- output.writeln('Performance Targets:');
713
- output.printList([
714
- 'HNSW Search: 150x-12,500x faster than brute force',
715
- 'Flash Attention: 2.49x-7.47x speedup',
716
- 'Memory: 50-75% reduction with quantization',
717
- ]);
718
- output.writeln();
719
- output.writeln(output.dim('Created with ❤️ by ruv.io'));
720
- return [2 /*return*/, { success: true }];
721
- });
722
- }); }
553
+ action: async () => {
554
+ output.writeln();
555
+ output.writeln(output.bold('RuFlo Performance Suite'));
556
+ output.writeln(output.dim('Advanced performance profiling and optimization'));
557
+ output.writeln();
558
+ output.writeln('Subcommands:');
559
+ output.printList([
560
+ 'benchmark - Run performance benchmarks (WASM, neural, search)',
561
+ 'profile - Profile CPU, memory, I/O usage',
562
+ 'metrics - View and export performance metrics',
563
+ 'optimize - Get optimization recommendations',
564
+ 'bottleneck - Identify performance bottlenecks',
565
+ ]);
566
+ output.writeln();
567
+ output.writeln('Performance Targets:');
568
+ output.printList([
569
+ 'HNSW Search: 150x-12,500x faster than brute force',
570
+ 'Flash Attention: 2.49x-7.47x speedup',
571
+ 'Memory: 50-75% reduction with quantization',
572
+ ]);
573
+ output.writeln();
574
+ output.writeln(output.dim('Created with ❤️ by ruv.io'));
575
+ return { success: true };
576
+ },
723
577
  };
724
578
  export default performanceCommand;
725
579
  //# sourceMappingURL=performance.js.map