kynjal-cli 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (502) hide show
  1. package/dist/src/appliance/gguf-engine.d.ts +91 -0
  2. package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
  3. package/dist/src/appliance/gguf-engine.js +286 -525
  4. package/dist/src/appliance/gguf-engine.js.map +1 -1
  5. package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
  6. package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
  7. package/dist/src/appliance/ruvllm-bridge.js +203 -403
  8. package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
  9. package/dist/src/appliance/rvfa-builder.d.ts +44 -0
  10. package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
  11. package/dist/src/appliance/rvfa-builder.js +154 -208
  12. package/dist/src/appliance/rvfa-builder.js.map +1 -1
  13. package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
  14. package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
  15. package/dist/src/appliance/rvfa-distribution.js +260 -423
  16. package/dist/src/appliance/rvfa-distribution.js.map +1 -1
  17. package/dist/src/appliance/rvfa-format.d.ts +111 -0
  18. package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
  19. package/dist/src/appliance/rvfa-format.js +128 -200
  20. package/dist/src/appliance/rvfa-format.js.map +1 -1
  21. package/dist/src/appliance/rvfa-runner.d.ts +69 -0
  22. package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
  23. package/dist/src/appliance/rvfa-runner.js +168 -304
  24. package/dist/src/appliance/rvfa-runner.js.map +1 -1
  25. package/dist/src/appliance/rvfa-signing.d.ts +123 -0
  26. package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
  27. package/dist/src/appliance/rvfa-signing.js +173 -295
  28. package/dist/src/appliance/rvfa-signing.js.map +1 -1
  29. package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
  30. package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
  31. package/dist/src/benchmarks/pretrain/index.js +331 -542
  32. package/dist/src/benchmarks/pretrain/index.js.map +1 -1
  33. package/dist/src/commands/agent.js +574 -697
  34. package/dist/src/commands/agent.js.map +1 -1
  35. package/dist/src/commands/analyze.js +1218 -1548
  36. package/dist/src/commands/analyze.js.map +1 -1
  37. package/dist/src/commands/appliance-advanced.js +158 -267
  38. package/dist/src/commands/appliance-advanced.js.map +1 -1
  39. package/dist/src/commands/appliance.js +318 -493
  40. package/dist/src/commands/appliance.js.map +1 -1
  41. package/dist/src/commands/benchmark.js +372 -523
  42. package/dist/src/commands/benchmark.js.map +1 -1
  43. package/dist/src/commands/claims.js +274 -364
  44. package/dist/src/commands/claims.js.map +1 -1
  45. package/dist/src/commands/cleanup.js +113 -157
  46. package/dist/src/commands/cleanup.js.map +1 -1
  47. package/dist/src/commands/completions.js +477 -118
  48. package/dist/src/commands/completions.js.map +1 -1
  49. package/dist/src/commands/config.js +237 -303
  50. package/dist/src/commands/config.js.map +1 -1
  51. package/dist/src/commands/daemon.js +487 -596
  52. package/dist/src/commands/daemon.js.map +1 -1
  53. package/dist/src/commands/deployment.js +194 -275
  54. package/dist/src/commands/deployment.js.map +1 -1
  55. package/dist/src/commands/doctor.js +504 -686
  56. package/dist/src/commands/doctor.js.map +1 -1
  57. package/dist/src/commands/embeddings.js +1293 -1543
  58. package/dist/src/commands/embeddings.js.map +1 -1
  59. package/dist/src/commands/guidance.js +449 -596
  60. package/dist/src/commands/guidance.js.map +1 -1
  61. package/dist/src/commands/hive-mind.js +854 -938
  62. package/dist/src/commands/hive-mind.js.map +1 -1
  63. package/dist/src/commands/hooks.js +3112 -3519
  64. package/dist/src/commands/hooks.js.map +1 -1
  65. package/dist/src/commands/index.d.ts +115 -0
  66. package/dist/src/commands/index.d.ts.map +1 -0
  67. package/dist/src/commands/index.js +126 -308
  68. package/dist/src/commands/index.js.map +1 -1
  69. package/dist/src/commands/init.js +788 -940
  70. package/dist/src/commands/init.js.map +1 -1
  71. package/dist/src/commands/issues.js +383 -558
  72. package/dist/src/commands/issues.js.map +1 -1
  73. package/dist/src/commands/mcp.js +493 -605
  74. package/dist/src/commands/mcp.js.map +1 -1
  75. package/dist/src/commands/memory.js +833 -1026
  76. package/dist/src/commands/memory.js.map +1 -1
  77. package/dist/src/commands/migrate.js +282 -347
  78. package/dist/src/commands/migrate.js.map +1 -1
  79. package/dist/src/commands/neural.js +1289 -1563
  80. package/dist/src/commands/neural.js.map +1 -1
  81. package/dist/src/commands/performance.js +497 -643
  82. package/dist/src/commands/performance.js.map +1 -1
  83. package/dist/src/commands/plugins.js +668 -841
  84. package/dist/src/commands/plugins.js.map +1 -1
  85. package/dist/src/commands/process.js +392 -447
  86. package/dist/src/commands/process.js.map +1 -1
  87. package/dist/src/commands/progress.js +162 -256
  88. package/dist/src/commands/progress.js.map +1 -1
  89. package/dist/src/commands/providers.js +150 -220
  90. package/dist/src/commands/providers.js.map +1 -1
  91. package/dist/src/commands/route.js +520 -665
  92. package/dist/src/commands/route.js.map +1 -1
  93. package/dist/src/commands/ruvector/backup.js +505 -651
  94. package/dist/src/commands/ruvector/backup.js.map +1 -1
  95. package/dist/src/commands/ruvector/benchmark.js +349 -401
  96. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  97. package/dist/src/commands/ruvector/import.js +224 -266
  98. package/dist/src/commands/ruvector/import.js.map +1 -1
  99. package/dist/src/commands/ruvector/index.js +37 -75
  100. package/dist/src/commands/ruvector/index.js.map +1 -1
  101. package/dist/src/commands/ruvector/init.js +336 -359
  102. package/dist/src/commands/ruvector/init.js.map +1 -1
  103. package/dist/src/commands/ruvector/migrate.js +335 -322
  104. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  105. package/dist/src/commands/ruvector/optimize.js +375 -431
  106. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  107. package/dist/src/commands/ruvector/setup.js +703 -117
  108. package/dist/src/commands/ruvector/setup.js.map +1 -1
  109. package/dist/src/commands/ruvector/status.js +364 -419
  110. package/dist/src/commands/ruvector/status.js.map +1 -1
  111. package/dist/src/commands/security.js +485 -608
  112. package/dist/src/commands/security.js.map +1 -1
  113. package/dist/src/commands/session.js +504 -626
  114. package/dist/src/commands/session.js.map +1 -1
  115. package/dist/src/commands/start.js +267 -364
  116. package/dist/src/commands/start.js.map +1 -1
  117. package/dist/src/commands/status.js +380 -486
  118. package/dist/src/commands/status.js.map +1 -1
  119. package/dist/src/commands/swarm.js +408 -488
  120. package/dist/src/commands/swarm.js.map +1 -1
  121. package/dist/src/commands/task.js +423 -538
  122. package/dist/src/commands/task.js.map +1 -1
  123. package/dist/src/commands/transfer-store.js +322 -412
  124. package/dist/src/commands/transfer-store.js.map +1 -1
  125. package/dist/src/commands/update.js +196 -291
  126. package/dist/src/commands/update.js.map +1 -1
  127. package/dist/src/commands/workflow.js +386 -486
  128. package/dist/src/commands/workflow.js.map +1 -1
  129. package/dist/src/config-adapter.d.ts +15 -0
  130. package/dist/src/config-adapter.d.ts.map +1 -0
  131. package/dist/src/config-adapter.js +38 -39
  132. package/dist/src/config-adapter.js.map +1 -1
  133. package/dist/src/index.d.ts +77 -0
  134. package/dist/src/index.d.ts.map +1 -0
  135. package/dist/src/index.js +309 -411
  136. package/dist/src/index.js.map +1 -1
  137. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  138. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  139. package/dist/src/infrastructure/in-memory-repositories.js +246 -507
  140. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
  141. package/dist/src/init/claudemd-generator.d.ts +25 -0
  142. package/dist/src/init/claudemd-generator.d.ts.map +1 -0
  143. package/dist/src/init/claudemd-generator.js +368 -78
  144. package/dist/src/init/claudemd-generator.js.map +1 -1
  145. package/dist/src/init/executor.d.ts +41 -0
  146. package/dist/src/init/executor.d.ts.map +1 -0
  147. package/dist/src/init/executor.js +1307 -996
  148. package/dist/src/init/executor.js.map +1 -1
  149. package/dist/src/init/helpers-generator.d.ts +60 -0
  150. package/dist/src/init/helpers-generator.d.ts.map +1 -0
  151. package/dist/src/init/helpers-generator.js +657 -12
  152. package/dist/src/init/helpers-generator.js.map +1 -1
  153. package/dist/src/init/index.d.ts +1 -1
  154. package/dist/src/init/index.d.ts.map +1 -1
  155. package/dist/src/init/index.js +1 -1
  156. package/dist/src/init/index.js.map +1 -1
  157. package/dist/src/init/mcp-generator.js +33 -37
  158. package/dist/src/init/mcp-generator.js.map +1 -1
  159. package/dist/src/init/settings-generator.js +76 -77
  160. package/dist/src/init/settings-generator.js.map +1 -1
  161. package/dist/src/init/statusline-generator.js +801 -3
  162. package/dist/src/init/statusline-generator.js.map +1 -1
  163. package/dist/src/init/types.d.ts +1 -1
  164. package/dist/src/init/types.d.ts.map +1 -1
  165. package/dist/src/init/types.js +76 -59
  166. package/dist/src/init/types.js.map +1 -1
  167. package/dist/src/mcp-client.d.ts +92 -0
  168. package/dist/src/mcp-client.d.ts.map +1 -0
  169. package/dist/src/mcp-client.js +81 -125
  170. package/dist/src/mcp-client.js.map +1 -1
  171. package/dist/src/mcp-server.d.ts +161 -0
  172. package/dist/src/mcp-server.d.ts.map +1 -0
  173. package/dist/src/mcp-server.js +470 -757
  174. package/dist/src/mcp-server.js.map +1 -1
  175. package/dist/src/mcp-tools/agent-tools.js +391 -492
  176. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  177. package/dist/src/mcp-tools/agentdb-tools.js +332 -533
  178. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  179. package/dist/src/mcp-tools/analyze-tools.js +172 -236
  180. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  181. package/dist/src/mcp-tools/auto-install.d.ts +83 -0
  182. package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
  183. package/dist/src/mcp-tools/auto-install.js +80 -142
  184. package/dist/src/mcp-tools/auto-install.js.map +1 -1
  185. package/dist/src/mcp-tools/browser-tools.js +252 -375
  186. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  187. package/dist/src/mcp-tools/claims-tools.js +473 -565
  188. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  189. package/dist/src/mcp-tools/config-tools.js +197 -272
  190. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  191. package/dist/src/mcp-tools/coordination-tools.js +500 -572
  192. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  193. package/dist/src/mcp-tools/daa-tools.js +286 -364
  194. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  195. package/dist/src/mcp-tools/embeddings-tools.js +582 -693
  196. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  197. package/dist/src/mcp-tools/github-tools.js +260 -311
  198. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  199. package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
  200. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  201. package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
  202. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  203. package/dist/src/mcp-tools/memory-tools.js +350 -505
  204. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  205. package/dist/src/mcp-tools/neural-tools.js +315 -412
  206. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  207. package/dist/src/mcp-tools/performance-tools.js +420 -480
  208. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  209. package/dist/src/mcp-tools/progress-tools.js +204 -278
  210. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  211. package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
  212. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  213. package/dist/src/mcp-tools/security-tools.js +297 -429
  214. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  215. package/dist/src/mcp-tools/session-tools.js +185 -234
  216. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  217. package/dist/src/mcp-tools/swarm-tools.js +207 -260
  218. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  219. package/dist/src/mcp-tools/system-tools.js +276 -325
  220. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  221. package/dist/src/mcp-tools/task-tools.js +270 -336
  222. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  223. package/dist/src/mcp-tools/terminal-tools.js +148 -196
  224. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  225. package/dist/src/mcp-tools/transfer-tools.js +186 -333
  226. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  227. package/dist/src/mcp-tools/types.d.ts +31 -0
  228. package/dist/src/mcp-tools/types.d.ts.map +1 -0
  229. package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
  230. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  231. package/dist/src/mcp-tools/workflow-tools.js +405 -450
  232. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  233. package/dist/src/memory/ewc-consolidation.d.ts +295 -0
  234. package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
  235. package/dist/src/memory/ewc-consolidation.js +190 -303
  236. package/dist/src/memory/ewc-consolidation.js.map +1 -1
  237. package/dist/src/memory/intelligence.d.ts +338 -0
  238. package/dist/src/memory/intelligence.d.ts.map +1 -0
  239. package/dist/src/memory/intelligence.js +569 -794
  240. package/dist/src/memory/intelligence.js.map +1 -1
  241. package/dist/src/memory/memory-bridge.d.ts +407 -0
  242. package/dist/src/memory/memory-bridge.d.ts.map +1 -0
  243. package/dist/src/memory/memory-bridge.js +1170 -1640
  244. package/dist/src/memory/memory-bridge.js.map +1 -1
  245. package/dist/src/memory/memory-initializer.d.ts +412 -0
  246. package/dist/src/memory/memory-initializer.d.ts.map +1 -0
  247. package/dist/src/memory/memory-initializer.js +1836 -1851
  248. package/dist/src/memory/memory-initializer.js.map +1 -1
  249. package/dist/src/memory/sona-optimizer.d.ts +227 -0
  250. package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
  251. package/dist/src/memory/sona-optimizer.js +199 -329
  252. package/dist/src/memory/sona-optimizer.js.map +1 -1
  253. package/dist/src/output.d.ts +2 -2
  254. package/dist/src/output.d.ts.map +1 -1
  255. package/dist/src/output.js +242 -272
  256. package/dist/src/output.js.map +1 -1
  257. package/dist/src/parser.d.ts +51 -0
  258. package/dist/src/parser.d.ts.map +1 -0
  259. package/dist/src/parser.js +140 -187
  260. package/dist/src/parser.js.map +1 -1
  261. package/dist/src/plugins/manager.d.ts +133 -0
  262. package/dist/src/plugins/manager.d.ts.map +1 -0
  263. package/dist/src/plugins/manager.js +285 -521
  264. package/dist/src/plugins/manager.js.map +1 -1
  265. package/dist/src/plugins/store/discovery.d.ts +88 -0
  266. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  267. package/dist/src/plugins/store/discovery.js +271 -358
  268. package/dist/src/plugins/store/discovery.js.map +1 -1
  269. package/dist/src/plugins/store/index.d.ts +76 -0
  270. package/dist/src/plugins/store/index.d.ts.map +1 -0
  271. package/dist/src/plugins/store/index.js +48 -105
  272. package/dist/src/plugins/store/index.js.map +1 -1
  273. package/dist/src/plugins/store/search.d.ts +46 -0
  274. package/dist/src/plugins/store/search.d.ts.map +1 -0
  275. package/dist/src/plugins/store/search.js +69 -107
  276. package/dist/src/plugins/store/search.js.map +1 -1
  277. package/dist/src/plugins/store/types.d.ts +274 -0
  278. package/dist/src/plugins/store/types.d.ts.map +1 -0
  279. package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
  280. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
  281. package/dist/src/plugins/tests/standalone-test.js +172 -223
  282. package/dist/src/plugins/tests/standalone-test.js.map +1 -1
  283. package/dist/src/plugins/tests/test-plugin-store.js +190 -228
  284. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
  285. package/dist/src/production/circuit-breaker.d.ts +101 -0
  286. package/dist/src/production/circuit-breaker.d.ts.map +1 -0
  287. package/dist/src/production/circuit-breaker.js +62 -126
  288. package/dist/src/production/circuit-breaker.js.map +1 -1
  289. package/dist/src/production/error-handler.d.ts +92 -0
  290. package/dist/src/production/error-handler.d.ts.map +1 -0
  291. package/dist/src/production/error-handler.js +86 -156
  292. package/dist/src/production/error-handler.js.map +1 -1
  293. package/dist/src/production/monitoring.d.ts +161 -0
  294. package/dist/src/production/monitoring.d.ts.map +1 -0
  295. package/dist/src/production/monitoring.js +139 -220
  296. package/dist/src/production/monitoring.js.map +1 -1
  297. package/dist/src/production/rate-limiter.d.ts +80 -0
  298. package/dist/src/production/rate-limiter.d.ts.map +1 -0
  299. package/dist/src/production/rate-limiter.js +74 -93
  300. package/dist/src/production/rate-limiter.js.map +1 -1
  301. package/dist/src/production/retry.d.ts +48 -0
  302. package/dist/src/production/retry.d.ts.map +1 -0
  303. package/dist/src/production/retry.js +75 -167
  304. package/dist/src/production/retry.js.map +1 -1
  305. package/dist/src/prompt.d.ts +44 -0
  306. package/dist/src/prompt.d.ts.map +1 -0
  307. package/dist/src/prompt.js +436 -560
  308. package/dist/src/prompt.js.map +1 -1
  309. package/dist/src/runtime/headless.d.ts +60 -0
  310. package/dist/src/runtime/headless.d.ts.map +1 -0
  311. package/dist/src/runtime/headless.js +197 -286
  312. package/dist/src/runtime/headless.js.map +1 -1
  313. package/dist/src/ruvector/agent-wasm.d.ts +182 -0
  314. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
  315. package/dist/src/ruvector/agent-wasm.js +156 -351
  316. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  317. package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
  318. package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
  319. package/dist/src/ruvector/ast-analyzer.js +145 -232
  320. package/dist/src/ruvector/ast-analyzer.js.map +1 -1
  321. package/dist/src/ruvector/coverage-router.d.ts +160 -0
  322. package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
  323. package/dist/src/ruvector/coverage-router.js +287 -419
  324. package/dist/src/ruvector/coverage-router.js.map +1 -1
  325. package/dist/src/ruvector/coverage-tools.js +56 -101
  326. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  327. package/dist/src/ruvector/diff-classifier.d.ts +175 -0
  328. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
  329. package/dist/src/ruvector/diff-classifier.js +324 -451
  330. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  331. package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
  332. package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
  333. package/dist/src/ruvector/enhanced-model-router.js +260 -336
  334. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  335. package/dist/src/ruvector/flash-attention.d.ts +195 -0
  336. package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
  337. package/dist/src/ruvector/flash-attention.js +223 -254
  338. package/dist/src/ruvector/flash-attention.js.map +1 -1
  339. package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
  340. package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
  341. package/dist/src/ruvector/graph-analyzer.js +486 -680
  342. package/dist/src/ruvector/graph-analyzer.js.map +1 -1
  343. package/dist/src/ruvector/index.d.ts +40 -0
  344. package/dist/src/ruvector/index.d.ts.map +1 -0
  345. package/dist/src/ruvector/index.js +36 -106
  346. package/dist/src/ruvector/index.js.map +1 -1
  347. package/dist/src/ruvector/lora-adapter.d.ts +218 -0
  348. package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
  349. package/dist/src/ruvector/lora-adapter.js +155 -248
  350. package/dist/src/ruvector/lora-adapter.js.map +1 -1
  351. package/dist/src/ruvector/model-router.d.ts +220 -0
  352. package/dist/src/ruvector/model-router.d.ts.map +1 -0
  353. package/dist/src/ruvector/model-router.js +175 -248
  354. package/dist/src/ruvector/model-router.js.map +1 -1
  355. package/dist/src/ruvector/moe-router.d.ts +206 -0
  356. package/dist/src/ruvector/moe-router.d.ts.map +1 -0
  357. package/dist/src/ruvector/moe-router.js +228 -286
  358. package/dist/src/ruvector/moe-router.js.map +1 -1
  359. package/dist/src/ruvector/q-learning-router.d.ts +211 -0
  360. package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
  361. package/dist/src/ruvector/q-learning-router.js +257 -338
  362. package/dist/src/ruvector/q-learning-router.js.map +1 -1
  363. package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
  364. package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
  365. package/dist/src/ruvector/ruvllm-wasm.js +270 -434
  366. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
  367. package/dist/src/ruvector/semantic-router.d.ts +77 -0
  368. package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
  369. package/dist/src/ruvector/semantic-router.js +60 -67
  370. package/dist/src/ruvector/semantic-router.js.map +1 -1
  371. package/dist/src/ruvector/vector-db.d.ts +69 -0
  372. package/dist/src/ruvector/vector-db.d.ts.map +1 -0
  373. package/dist/src/ruvector/vector-db.js +119 -205
  374. package/dist/src/ruvector/vector-db.js.map +1 -1
  375. package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  376. package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
  377. package/dist/src/services/agentic-flow-bridge.js +32 -105
  378. package/dist/src/services/agentic-flow-bridge.js.map +1 -1
  379. package/dist/src/services/claim-service.d.ts +204 -0
  380. package/dist/src/services/claim-service.d.ts.map +1 -0
  381. package/dist/src/services/claim-service.js +615 -940
  382. package/dist/src/services/claim-service.js.map +1 -1
  383. package/dist/src/services/container-worker-pool.d.ts +197 -0
  384. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  385. package/dist/src/services/container-worker-pool.js +398 -666
  386. package/dist/src/services/container-worker-pool.js.map +1 -1
  387. package/dist/src/services/headless-worker-executor.d.ts +304 -0
  388. package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
  389. package/dist/src/services/headless-worker-executor.js +441 -467
  390. package/dist/src/services/headless-worker-executor.js.map +1 -1
  391. package/dist/src/services/index.d.ts +4 -4
  392. package/dist/src/services/index.d.ts.map +1 -1
  393. package/dist/src/services/index.js +4 -4
  394. package/dist/src/services/index.js.map +1 -1
  395. package/dist/src/services/registry-api.d.ts +58 -0
  396. package/dist/src/services/registry-api.d.ts.map +1 -0
  397. package/dist/src/services/registry-api.js +92 -200
  398. package/dist/src/services/registry-api.js.map +1 -1
  399. package/dist/src/services/ruvector-training.d.ts +222 -0
  400. package/dist/src/services/ruvector-training.d.ts.map +1 -0
  401. package/dist/src/services/ruvector-training.js +257 -337
  402. package/dist/src/services/ruvector-training.js.map +1 -1
  403. package/dist/src/services/worker-daemon.d.ts +228 -0
  404. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  405. package/dist/src/services/worker-daemon.js +591 -849
  406. package/dist/src/services/worker-daemon.js.map +1 -1
  407. package/dist/src/services/worker-queue.d.ts +194 -0
  408. package/dist/src/services/worker-queue.d.ts.map +1 -0
  409. package/dist/src/services/worker-queue.js +331 -548
  410. package/dist/src/services/worker-queue.js.map +1 -1
  411. package/dist/src/suggest.d.ts +53 -0
  412. package/dist/src/suggest.d.ts.map +1 -0
  413. package/dist/src/suggest.js +45 -55
  414. package/dist/src/suggest.js.map +1 -1
  415. package/dist/src/transfer/anonymization/index.js +29 -37
  416. package/dist/src/transfer/anonymization/index.js.map +1 -1
  417. package/dist/src/transfer/deploy-seraphine.js +128 -155
  418. package/dist/src/transfer/deploy-seraphine.js.map +1 -1
  419. package/dist/src/transfer/export.d.ts +25 -0
  420. package/dist/src/transfer/export.d.ts.map +1 -0
  421. package/dist/src/transfer/export.js +84 -142
  422. package/dist/src/transfer/export.js.map +1 -1
  423. package/dist/src/transfer/index.d.ts +1 -1
  424. package/dist/src/transfer/index.d.ts.map +1 -1
  425. package/dist/src/transfer/index.js +0 -2
  426. package/dist/src/transfer/index.js.map +1 -1
  427. package/dist/src/transfer/ipfs/client.d.ts +109 -0
  428. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  429. package/dist/src/transfer/ipfs/client.js +187 -337
  430. package/dist/src/transfer/ipfs/client.js.map +1 -1
  431. package/dist/src/transfer/ipfs/upload.d.ts +95 -0
  432. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  433. package/dist/src/transfer/ipfs/upload.js +288 -434
  434. package/dist/src/transfer/ipfs/upload.js.map +1 -1
  435. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  436. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  437. package/dist/src/transfer/models/seraphine.js +55 -55
  438. package/dist/src/transfer/models/seraphine.js.map +1 -1
  439. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  440. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  441. package/dist/src/transfer/serialization/cfp.js +30 -31
  442. package/dist/src/transfer/serialization/cfp.js.map +1 -1
  443. package/dist/src/transfer/storage/gcs.d.ts +82 -0
  444. package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
  445. package/dist/src/transfer/storage/gcs.js +165 -232
  446. package/dist/src/transfer/storage/gcs.js.map +1 -1
  447. package/dist/src/transfer/store/discovery.d.ts +84 -0
  448. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  449. package/dist/src/transfer/store/discovery.js +239 -349
  450. package/dist/src/transfer/store/discovery.js.map +1 -1
  451. package/dist/src/transfer/store/download.d.ts +70 -0
  452. package/dist/src/transfer/store/download.d.ts.map +1 -0
  453. package/dist/src/transfer/store/download.js +243 -365
  454. package/dist/src/transfer/store/download.js.map +1 -1
  455. package/dist/src/transfer/store/index.d.ts +84 -0
  456. package/dist/src/transfer/store/index.d.ts.map +1 -0
  457. package/dist/src/transfer/store/index.js +63 -130
  458. package/dist/src/transfer/store/index.js.map +1 -1
  459. package/dist/src/transfer/store/publish.d.ts +76 -0
  460. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  461. package/dist/src/transfer/store/publish.js +184 -258
  462. package/dist/src/transfer/store/publish.js.map +1 -1
  463. package/dist/src/transfer/store/registry.js +50 -72
  464. package/dist/src/transfer/store/registry.js.map +1 -1
  465. package/dist/src/transfer/store/search.d.ts +54 -0
  466. package/dist/src/transfer/store/search.d.ts.map +1 -0
  467. package/dist/src/transfer/store/search.js +64 -96
  468. package/dist/src/transfer/store/search.js.map +1 -1
  469. package/dist/src/transfer/store/tests/standalone-test.js +174 -231
  470. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
  471. package/dist/src/transfer/test-seraphine.js +95 -130
  472. package/dist/src/transfer/test-seraphine.js.map +1 -1
  473. package/dist/src/transfer/tests/test-store.js +194 -239
  474. package/dist/src/transfer/tests/test-store.js.map +1 -1
  475. package/dist/src/transfer/types.d.ts +245 -0
  476. package/dist/src/transfer/types.d.ts.map +1 -0
  477. package/dist/src/types.d.ts +198 -0
  478. package/dist/src/types.d.ts.map +1 -0
  479. package/dist/src/types.js +26 -55
  480. package/dist/src/types.js.map +1 -1
  481. package/dist/src/update/checker.d.ts +34 -0
  482. package/dist/src/update/checker.d.ts.map +1 -0
  483. package/dist/src/update/checker.js +106 -183
  484. package/dist/src/update/checker.js.map +1 -1
  485. package/dist/src/update/executor.d.ts +32 -0
  486. package/dist/src/update/executor.d.ts.map +1 -0
  487. package/dist/src/update/executor.js +135 -198
  488. package/dist/src/update/executor.js.map +1 -1
  489. package/dist/src/update/index.d.ts +33 -0
  490. package/dist/src/update/index.d.ts.map +1 -0
  491. package/dist/src/update/index.js +38 -85
  492. package/dist/src/update/index.js.map +1 -1
  493. package/dist/src/update/rate-limiter.d.ts +20 -0
  494. package/dist/src/update/rate-limiter.d.ts.map +1 -0
  495. package/dist/src/update/rate-limiter.js +19 -31
  496. package/dist/src/update/rate-limiter.js.map +1 -1
  497. package/dist/src/update/validator.d.ts +17 -0
  498. package/dist/src/update/validator.d.ts.map +1 -0
  499. package/dist/src/update/validator.js +38 -64
  500. package/dist/src/update/validator.js.map +1 -1
  501. package/dist/tsconfig.tsbuildinfo +1 -1
  502. package/package.json +1 -1
@@ -1,253 +1,174 @@
1
1
  /**
2
2
  * Diff Classifier for Change Analysis
3
3
  */
4
- var __assign = (this && this.__assign) || function () {
5
- __assign = Object.assign || function(t) {
6
- for (var s, i = 1, n = arguments.length; i < n; i++) {
7
- s = arguments[i];
8
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
9
- t[p] = s[p];
10
- }
11
- return t;
12
- };
13
- return __assign.apply(this, arguments);
14
- };
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- var __generator = (this && this.__generator) || function (thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (_) try {
31
- 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;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- };
51
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
52
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
53
- if (ar || !(i in from)) {
54
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
55
- ar[i] = from[i];
56
- }
57
- }
58
- return to.concat(ar || Array.prototype.slice.call(from));
59
- };
60
- var DEFAULT_CONFIG = {
4
+ const DEFAULT_CONFIG = {
61
5
  maxDiffSize: 10000,
62
6
  classifyByImpact: true,
63
7
  detectRefactoring: true,
64
- minConfidence: 0.5
8
+ minConfidence: 0.5,
65
9
  };
66
- var CLASSIFICATION_PATTERNS = {
10
+ const CLASSIFICATION_PATTERNS = {
67
11
  feature: [/^feat/, /add.*feature/, /implement/, /new.*functionality/i],
68
12
  bugfix: [/^fix/, /bug/, /patch/, /resolve.*issue/i, /hotfix/i],
69
13
  refactor: [/^refactor/, /restructure/, /reorganize/, /cleanup/i, /rename/i],
70
14
  docs: [/^docs?/, /documentation/, /readme/i, /comment/i, /\.md$/i],
71
15
  test: [/^test/, /spec/, /\.test\.[jt]sx?$/, /\.spec\.[jt]sx?$/, /__tests__/],
72
16
  config: [/^config/, /\.config\./, /package\.json/, /tsconfig/, /\.env/],
73
- style: [/^style/, /format/, /lint/, /prettier/, /eslint/]
17
+ style: [/^style/, /format/, /lint/, /prettier/, /eslint/],
74
18
  };
75
- var IMPACT_KEYWORDS = {
19
+ const IMPACT_KEYWORDS = {
76
20
  security: 3, auth: 3, payment: 3, database: 2, api: 2, core: 2,
77
- util: 1, helper: 1, test: 0, mock: 0, fixture: 0
21
+ util: 1, helper: 1, test: 0, mock: 0, fixture: 0,
78
22
  };
79
- var DiffClassifier = /** @class */ (function () {
80
- function DiffClassifier(config) {
81
- if (config === void 0) { config = {}; }
82
- this.ruvectorEngine = null;
83
- this.useNative = false;
84
- this.classificationCache = new Map();
85
- this.config = __assign(__assign({}, DEFAULT_CONFIG), config);
86
- }
87
- DiffClassifier.prototype.initialize = function () {
88
- var _a, _b;
89
- return __awaiter(this, void 0, Promise, function () {
90
- var ruvector, _c;
91
- return __generator(this, function (_d) {
92
- switch (_d.label) {
93
- case 0:
94
- _d.trys.push([0, 2, , 3]);
95
- return [4 /*yield*/, import('@ruvector/diff')["catch"](function () { return null; })];
96
- case 1:
97
- ruvector = _d.sent();
98
- if (ruvector) {
99
- this.ruvectorEngine = (_b = (_a = ruvector).createDiffClassifier) === null || _b === void 0 ? void 0 : _b.call(_a, this.config);
100
- this.useNative = !!this.ruvectorEngine;
101
- }
102
- return [3 /*break*/, 3];
103
- case 2:
104
- _c = _d.sent();
105
- this.useNative = false;
106
- return [3 /*break*/, 3];
107
- case 3: return [2 /*return*/];
108
- }
109
- });
110
- });
111
- };
112
- DiffClassifier.prototype.parseDiff = function (diffContent) {
113
- var files = [];
114
- var fileBlocks = diffContent.split(/^diff --git/m).filter(Boolean);
115
- for (var _i = 0, fileBlocks_1 = fileBlocks; _i < fileBlocks_1.length; _i++) {
116
- var block = fileBlocks_1[_i];
117
- var pathMatch = block.match(/a\/(.+?)\s+b\/(.+)/);
23
+ export class DiffClassifier {
24
+ config;
25
+ ruvectorEngine = null;
26
+ useNative = false;
27
+ classificationCache = new Map();
28
+ constructor(config = {}) {
29
+ this.config = { ...DEFAULT_CONFIG, ...config };
30
+ }
31
+ async initialize() {
32
+ try {
33
+ // @ruvector/diff is optional - gracefully fallback if not installed
34
+ const ruvector = await import('@ruvector/diff').catch(() => null);
35
+ if (ruvector) {
36
+ this.ruvectorEngine = ruvector.createDiffClassifier?.(this.config);
37
+ this.useNative = !!this.ruvectorEngine;
38
+ }
39
+ }
40
+ catch {
41
+ this.useNative = false;
42
+ }
43
+ }
44
+ parseDiff(diffContent) {
45
+ const files = [];
46
+ const fileBlocks = diffContent.split(/^diff --git/m).filter(Boolean);
47
+ for (const block of fileBlocks) {
48
+ const pathMatch = block.match(/a\/(.+?)\s+b\/(.+)/);
118
49
  if (!pathMatch)
119
50
  continue;
120
- var path = pathMatch[2];
121
- var hunks = this.parseHunks(block);
122
- var additions = hunks.reduce(function (sum, h) { return sum + h.changes.filter(function (c) { return c.type === 'add'; }).length; }, 0);
123
- var deletions = hunks.reduce(function (sum, h) { return sum + h.changes.filter(function (c) { return c.type === 'remove'; }).length; }, 0);
124
- var classification = this.classifyFile(path, hunks);
125
- files.push({ path: path, hunks: hunks, additions: additions, deletions: deletions, classification: classification });
51
+ const path = pathMatch[2];
52
+ const hunks = this.parseHunks(block);
53
+ const additions = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type === 'add').length, 0);
54
+ const deletions = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type === 'remove').length, 0);
55
+ const classification = this.classifyFile(path, hunks);
56
+ files.push({ path, hunks, additions, deletions, classification });
126
57
  }
127
58
  return files;
128
- };
129
- DiffClassifier.prototype.classify = function (files) {
130
- var overall = this.computeOverallClassification(files);
131
- var stats = {
132
- totalAdditions: files.reduce(function (sum, f) { return sum + f.additions; }, 0),
133
- totalDeletions: files.reduce(function (sum, f) { return sum + f.deletions; }, 0),
59
+ }
60
+ classify(files) {
61
+ const overall = this.computeOverallClassification(files);
62
+ const stats = {
63
+ totalAdditions: files.reduce((sum, f) => sum + f.additions, 0),
64
+ totalDeletions: files.reduce((sum, f) => sum + f.deletions, 0),
134
65
  filesChanged: files.length,
135
- avgConfidence: files.length > 0 ? files.reduce(function (sum, f) { return sum + f.classification.confidence; }, 0) / files.length : 0
66
+ avgConfidence: files.length > 0 ? files.reduce((sum, f) => sum + f.classification.confidence, 0) / files.length : 0,
136
67
  };
137
- return { files: files, overall: overall, stats: stats, timestamp: Date.now() };
138
- };
139
- DiffClassifier.prototype.classifyCommitMessage = function (message) {
140
- var lowerMessage = message.toLowerCase();
141
- for (var _i = 0, _a = Object.entries(CLASSIFICATION_PATTERNS); _i < _a.length; _i++) {
142
- var _b = _a[_i], type = _b[0], patterns = _b[1];
143
- for (var _c = 0, patterns_1 = patterns; _c < patterns_1.length; _c++) {
144
- var pattern = patterns_1[_c];
68
+ return { files, overall, stats, timestamp: Date.now() };
69
+ }
70
+ classifyCommitMessage(message) {
71
+ const lowerMessage = message.toLowerCase();
72
+ for (const [type, patterns] of Object.entries(CLASSIFICATION_PATTERNS)) {
73
+ for (const pattern of patterns) {
145
74
  if (pattern.test(lowerMessage))
146
75
  return type;
147
76
  }
148
77
  }
149
78
  return 'unknown';
150
- };
151
- DiffClassifier.prototype.getStats = function () {
79
+ }
80
+ getStats() {
152
81
  return { useNative: this.useNative, cacheSize: this.classificationCache.size };
153
- };
154
- DiffClassifier.prototype.clearCache = function () { this.classificationCache.clear(); };
155
- DiffClassifier.prototype.parseHunks = function (block) {
156
- var hunks = [];
157
- var hunkMatches = block.matchAll(/@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@([^\n]*)\n([\s\S]*?)(?=@@|$)/g);
158
- for (var _i = 0, hunkMatches_1 = hunkMatches; _i < hunkMatches_1.length; _i++) {
159
- var match = hunkMatches_1[_i];
160
- var oldStart = parseInt(match[1], 10);
161
- var oldLines = parseInt(match[2] || '1', 10);
162
- var newStart = parseInt(match[3], 10);
163
- var newLines = parseInt(match[4] || '1', 10);
164
- var content = match[6] || '';
165
- var changes = this.parseChanges(content, newStart);
166
- hunks.push({ oldStart: oldStart, oldLines: oldLines, newStart: newStart, newLines: newLines, content: content, changes: changes });
82
+ }
83
+ clearCache() { this.classificationCache.clear(); }
84
+ parseHunks(block) {
85
+ const hunks = [];
86
+ const hunkMatches = block.matchAll(/@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@([^\n]*)\n([\s\S]*?)(?=@@|$)/g);
87
+ for (const match of hunkMatches) {
88
+ const oldStart = parseInt(match[1], 10);
89
+ const oldLines = parseInt(match[2] || '1', 10);
90
+ const newStart = parseInt(match[3], 10);
91
+ const newLines = parseInt(match[4] || '1', 10);
92
+ const content = match[6] || '';
93
+ const changes = this.parseChanges(content, newStart);
94
+ hunks.push({ oldStart, oldLines, newStart, newLines, content, changes });
167
95
  }
168
96
  return hunks;
169
- };
170
- DiffClassifier.prototype.parseChanges = function (content, startLine) {
171
- var changes = [];
172
- var lines = content.split('\n');
173
- var lineNumber = startLine;
174
- for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
175
- var line = lines_1[_i];
97
+ }
98
+ parseChanges(content, startLine) {
99
+ const changes = [];
100
+ const lines = content.split('\n');
101
+ let lineNumber = startLine;
102
+ for (const line of lines) {
176
103
  if (line.startsWith('+')) {
177
- changes.push({ type: 'add', lineNumber: lineNumber, content: line.substring(1) });
104
+ changes.push({ type: 'add', lineNumber, content: line.substring(1) });
178
105
  lineNumber++;
179
106
  }
180
107
  else if (line.startsWith('-')) {
181
108
  changes.push({ type: 'remove', lineNumber: -1, content: line.substring(1) });
182
109
  }
183
110
  else if (line.startsWith(' ') || line === '') {
184
- changes.push({ type: 'context', lineNumber: lineNumber, content: line.substring(1) || '' });
111
+ changes.push({ type: 'context', lineNumber, content: line.substring(1) || '' });
185
112
  lineNumber++;
186
113
  }
187
114
  }
188
115
  return changes;
189
- };
190
- DiffClassifier.prototype.classifyFile = function (path, hunks) {
191
- var cacheKey = this.getCacheKey(path, hunks);
192
- var cached = this.classificationCache.get(cacheKey);
116
+ }
117
+ classifyFile(path, hunks) {
118
+ const cacheKey = this.getCacheKey(path, hunks);
119
+ const cached = this.classificationCache.get(cacheKey);
193
120
  if (cached)
194
121
  return cached;
195
- var primary = this.determinePrimaryClassification(path, hunks);
196
- var secondary = this.determineSecondaryClassifications(path, hunks, primary);
197
- var confidence = this.calculateConfidence(path, hunks, primary);
198
- var impactLevel = this.determineImpactLevel(path, hunks);
199
- var suggestedReviewers = this.suggestReviewers(path, primary, impactLevel);
200
- var testingStrategy = this.determineTestingStrategy(path, primary, impactLevel);
201
- var riskFactors = this.identifyRiskFactors(path, hunks, impactLevel);
202
- var classification = { primary: primary, secondary: secondary, confidence: confidence, impactLevel: impactLevel, suggestedReviewers: suggestedReviewers, testingStrategy: testingStrategy, riskFactors: riskFactors };
122
+ const primary = this.determinePrimaryClassification(path, hunks);
123
+ const secondary = this.determineSecondaryClassifications(path, hunks, primary);
124
+ const confidence = this.calculateConfidence(path, hunks, primary);
125
+ const impactLevel = this.determineImpactLevel(path, hunks);
126
+ const suggestedReviewers = this.suggestReviewers(path, primary, impactLevel);
127
+ const testingStrategy = this.determineTestingStrategy(path, primary, impactLevel);
128
+ const riskFactors = this.identifyRiskFactors(path, hunks, impactLevel);
129
+ const classification = { primary, secondary, confidence, impactLevel, suggestedReviewers, testingStrategy, riskFactors };
203
130
  this.classificationCache.set(cacheKey, classification);
204
131
  return classification;
205
- };
206
- DiffClassifier.prototype.getCacheKey = function (path, hunks) {
207
- var hunkSummary = hunks.map(function (h) { return h.oldStart + ':' + h.newStart; }).join(',');
132
+ }
133
+ getCacheKey(path, hunks) {
134
+ const hunkSummary = hunks.map(h => h.oldStart + ':' + h.newStart).join(',');
208
135
  return path + ':' + hunkSummary;
209
- };
210
- DiffClassifier.prototype.determinePrimaryClassification = function (path, hunks) {
211
- for (var _i = 0, _a = Object.entries(CLASSIFICATION_PATTERNS); _i < _a.length; _i++) {
212
- var _b = _a[_i], type = _b[0], patterns = _b[1];
213
- for (var _c = 0, patterns_2 = patterns; _c < patterns_2.length; _c++) {
214
- var pattern = patterns_2[_c];
136
+ }
137
+ determinePrimaryClassification(path, hunks) {
138
+ for (const [type, patterns] of Object.entries(CLASSIFICATION_PATTERNS)) {
139
+ for (const pattern of patterns) {
215
140
  if (pattern.test(path))
216
141
  return type;
217
142
  }
218
143
  }
219
- var allContent = hunks.flatMap(function (h) { return h.changes.map(function (c) { return c.content; }); }).join('\n').toLowerCase();
220
- if (/function|class|interface|type\s+\w+/.test(allContent) && hunks.some(function (h) { return h.changes.filter(function (c) { return c.type === 'add'; }).length > 10; }))
144
+ const allContent = hunks.flatMap(h => h.changes.map(c => c.content)).join('\n').toLowerCase();
145
+ if (/function|class|interface|type\s+\w+/.test(allContent) && hunks.some(h => h.changes.filter(c => c.type === 'add').length > 10))
221
146
  return 'feature';
222
147
  if (/fix|bug|issue|error|exception/.test(allContent))
223
148
  return 'bugfix';
224
149
  if (this.config.detectRefactoring && this.isRefactoring(hunks))
225
150
  return 'refactor';
226
151
  return 'unknown';
227
- };
228
- DiffClassifier.prototype.isRefactoring = function (hunks) {
229
- var totalAdds = 0, totalRemoves = 0;
230
- for (var _i = 0, hunks_1 = hunks; _i < hunks_1.length; _i++) {
231
- var hunk = hunks_1[_i];
232
- for (var _a = 0, _b = hunk.changes; _a < _b.length; _a++) {
233
- var change = _b[_a];
152
+ }
153
+ isRefactoring(hunks) {
154
+ let totalAdds = 0, totalRemoves = 0;
155
+ for (const hunk of hunks) {
156
+ for (const change of hunk.changes) {
234
157
  if (change.type === 'add')
235
158
  totalAdds++;
236
159
  else if (change.type === 'remove')
237
160
  totalRemoves++;
238
161
  }
239
162
  }
240
- var ratio = totalAdds > 0 ? totalRemoves / totalAdds : 0;
163
+ const ratio = totalAdds > 0 ? totalRemoves / totalAdds : 0;
241
164
  return ratio > 0.7 && ratio < 1.4 && totalAdds > 5;
242
- };
243
- DiffClassifier.prototype.determineSecondaryClassifications = function (path, hunks, primary) {
244
- var secondary = [];
245
- for (var _i = 0, _a = Object.entries(CLASSIFICATION_PATTERNS); _i < _a.length; _i++) {
246
- var _b = _a[_i], type = _b[0], patterns = _b[1];
165
+ }
166
+ determineSecondaryClassifications(path, hunks, primary) {
167
+ const secondary = [];
168
+ for (const [type, patterns] of Object.entries(CLASSIFICATION_PATTERNS)) {
247
169
  if (type === primary)
248
170
  continue;
249
- for (var _c = 0, patterns_3 = patterns; _c < patterns_3.length; _c++) {
250
- var pattern = patterns_3[_c];
171
+ for (const pattern of patterns) {
251
172
  if (pattern.test(path)) {
252
173
  secondary.push(type);
253
174
  break;
@@ -255,20 +176,18 @@ var DiffClassifier = /** @class */ (function () {
255
176
  }
256
177
  }
257
178
  return secondary.slice(0, 3);
258
- };
259
- DiffClassifier.prototype.calculateConfidence = function (path, hunks, primary) {
260
- var confidence = 0.5;
261
- for (var _i = 0, _a = Object.values(CLASSIFICATION_PATTERNS); _i < _a.length; _i++) {
262
- var patterns = _a[_i];
263
- for (var _b = 0, patterns_4 = patterns; _b < patterns_4.length; _b++) {
264
- var pattern = patterns_4[_b];
179
+ }
180
+ calculateConfidence(path, hunks, primary) {
181
+ let confidence = 0.5;
182
+ for (const patterns of Object.values(CLASSIFICATION_PATTERNS)) {
183
+ for (const pattern of patterns) {
265
184
  if (pattern.test(path)) {
266
185
  confidence += 0.2;
267
186
  break;
268
187
  }
269
188
  }
270
189
  }
271
- var totalChanges = hunks.reduce(function (sum, h) { return sum + h.changes.length; }, 0);
190
+ const totalChanges = hunks.reduce((sum, h) => sum + h.changes.length, 0);
272
191
  if (totalChanges > 10)
273
192
  confidence += 0.1;
274
193
  if (totalChanges > 50)
@@ -276,16 +195,15 @@ var DiffClassifier = /** @class */ (function () {
276
195
  if (primary !== 'unknown')
277
196
  confidence += 0.1;
278
197
  return Math.min(1, confidence);
279
- };
280
- DiffClassifier.prototype.determineImpactLevel = function (path, hunks) {
281
- var score = 0;
282
- var lowerPath = path.toLowerCase();
283
- for (var _i = 0, _a = Object.entries(IMPACT_KEYWORDS); _i < _a.length; _i++) {
284
- var _b = _a[_i], keyword = _b[0], weight = _b[1];
198
+ }
199
+ determineImpactLevel(path, hunks) {
200
+ let score = 0;
201
+ const lowerPath = path.toLowerCase();
202
+ for (const [keyword, weight] of Object.entries(IMPACT_KEYWORDS)) {
285
203
  if (lowerPath.includes(keyword))
286
204
  score = Math.max(score, weight);
287
205
  }
288
- var totalChanges = hunks.reduce(function (sum, h) { return sum + h.changes.filter(function (c) { return c.type !== 'context'; }).length; }, 0);
206
+ const totalChanges = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type !== 'context').length, 0);
289
207
  if (totalChanges > 100)
290
208
  score = Math.max(score, 2);
291
209
  if (totalChanges > 300)
@@ -297,21 +215,21 @@ var DiffClassifier = /** @class */ (function () {
297
215
  if (score >= 1)
298
216
  return 'medium';
299
217
  return 'low';
300
- };
301
- DiffClassifier.prototype.suggestReviewers = function (path, primary, impact) {
302
- var reviewers = [];
303
- var typeReviewers = { feature: ['tech-lead', 'product-owner'], bugfix: ['qa-engineer', 'developer'], refactor: ['senior-developer', 'architect'], docs: ['tech-writer', 'developer'], test: ['qa-engineer', 'developer'], config: ['devops', 'tech-lead'], style: ['developer'], unknown: ['developer'] };
304
- reviewers.push.apply(reviewers, (typeReviewers[primary] || typeReviewers.unknown));
218
+ }
219
+ suggestReviewers(path, primary, impact) {
220
+ const reviewers = [];
221
+ const typeReviewers = { feature: ['tech-lead', 'product-owner'], bugfix: ['qa-engineer', 'developer'], refactor: ['senior-developer', 'architect'], docs: ['tech-writer', 'developer'], test: ['qa-engineer', 'developer'], config: ['devops', 'tech-lead'], style: ['developer'], unknown: ['developer'] };
222
+ reviewers.push(...(typeReviewers[primary] || typeReviewers.unknown));
305
223
  if (impact === 'critical' || impact === 'high')
306
224
  reviewers.push('security-reviewer');
307
225
  if (/security|auth/.test(path))
308
226
  reviewers.push('security-team');
309
227
  if (/database|migration/.test(path))
310
228
  reviewers.push('dba');
311
- return __spreadArray([], new Set(reviewers), true).slice(0, 4);
312
- };
313
- DiffClassifier.prototype.determineTestingStrategy = function (path, primary, impact) {
314
- var strategies = [];
229
+ return [...new Set(reviewers)].slice(0, 4);
230
+ }
231
+ determineTestingStrategy(path, primary, impact) {
232
+ const strategies = [];
315
233
  if (primary !== 'test')
316
234
  strategies.push('unit-tests');
317
235
  if (primary === 'feature')
@@ -325,10 +243,10 @@ var DiffClassifier = /** @class */ (function () {
325
243
  if (/security|auth|crypto/.test(path))
326
244
  strategies.push('security-audit');
327
245
  return strategies.slice(0, 5);
328
- };
329
- DiffClassifier.prototype.identifyRiskFactors = function (path, hunks, impact) {
330
- var risks = [];
331
- var totalChanges = hunks.reduce(function (sum, h) { return sum + h.changes.length; }, 0);
246
+ }
247
+ identifyRiskFactors(path, hunks, impact) {
248
+ const risks = [];
249
+ const totalChanges = hunks.reduce((sum, h) => sum + h.changes.length, 0);
332
250
  if (totalChanges > 200)
333
251
  risks.push('Large change set - increased review time needed');
334
252
  if (impact === 'critical')
@@ -341,59 +259,49 @@ var DiffClassifier = /** @class */ (function () {
341
259
  risks.push('Database changes - ensure backup strategy');
342
260
  if (/config|env/.test(path))
343
261
  risks.push('Configuration changes - verify all environments');
344
- var allContent = hunks.flatMap(function (h) { return h.changes.map(function (c) { return c.content; }); }).join('\n');
262
+ const allContent = hunks.flatMap(h => h.changes.map(c => c.content)).join('\n');
345
263
  if (/TODO|FIXME|HACK/.test(allContent))
346
264
  risks.push('Contains TODO/FIXME comments');
347
265
  if (/password|secret|key|token/i.test(allContent))
348
266
  risks.push('Potential secrets in code');
349
267
  return risks.slice(0, 5);
350
- };
351
- DiffClassifier.prototype.computeOverallClassification = function (files) {
268
+ }
269
+ computeOverallClassification(files) {
352
270
  if (files.length === 0)
353
271
  return { primary: 'unknown', secondary: [], confidence: 0, impactLevel: 'low', suggestedReviewers: [], testingStrategy: [], riskFactors: [] };
354
- var primaryCounts = {};
355
- for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
356
- var file = files_1[_i];
357
- var p = file.classification.primary;
272
+ const primaryCounts = {};
273
+ for (const file of files) {
274
+ const p = file.classification.primary;
358
275
  primaryCounts[p] = (primaryCounts[p] || 0) + 1;
359
276
  }
360
- var primary = 'unknown';
361
- var maxCount = 0;
362
- for (var _a = 0, _b = Object.entries(primaryCounts); _a < _b.length; _a++) {
363
- var _c = _b[_a], type = _c[0], count = _c[1];
277
+ let primary = 'unknown';
278
+ let maxCount = 0;
279
+ for (const [type, count] of Object.entries(primaryCounts)) {
364
280
  if (count > maxCount) {
365
281
  maxCount = count;
366
282
  primary = type;
367
283
  }
368
284
  }
369
- var secondaryCounts = {};
370
- for (var _d = 0, files_2 = files; _d < files_2.length; _d++) {
371
- var file = files_2[_d];
372
- for (var _e = 0, _f = file.classification.secondary; _e < _f.length; _e++) {
373
- var s = _f[_e];
285
+ const secondaryCounts = {};
286
+ for (const file of files) {
287
+ for (const s of file.classification.secondary) {
374
288
  secondaryCounts[s] = (secondaryCounts[s] || 0) + 1;
375
289
  }
376
290
  }
377
- var secondary = Object.entries(secondaryCounts).sort(function (a, b) { return b[1] - a[1]; }).slice(0, 3).map(function (_a) {
378
- var type = _a[0];
379
- return type;
380
- });
381
- var confidence = files.reduce(function (sum, f) { return sum + f.classification.confidence; }, 0) / files.length;
382
- var impactOrder = ['low', 'medium', 'high', 'critical'];
383
- var impactLevel = 'low';
384
- for (var _g = 0, files_3 = files; _g < files_3.length; _g++) {
385
- var file = files_3[_g];
291
+ const secondary = Object.entries(secondaryCounts).sort((a, b) => b[1] - a[1]).slice(0, 3).map(([type]) => type);
292
+ const confidence = files.reduce((sum, f) => sum + f.classification.confidence, 0) / files.length;
293
+ const impactOrder = ['low', 'medium', 'high', 'critical'];
294
+ let impactLevel = 'low';
295
+ for (const file of files) {
386
296
  if (impactOrder.indexOf(file.classification.impactLevel) > impactOrder.indexOf(impactLevel))
387
297
  impactLevel = file.classification.impactLevel;
388
298
  }
389
- var reviewers = __spreadArray([], new Set(files.flatMap(function (f) { return f.classification.suggestedReviewers; })), true).slice(0, 5);
390
- var testingStrategy = __spreadArray([], new Set(files.flatMap(function (f) { return f.classification.testingStrategy; })), true).slice(0, 5);
391
- var riskFactors = __spreadArray([], new Set(files.flatMap(function (f) { return f.classification.riskFactors; })), true).slice(0, 5);
392
- return { primary: primary, secondary: secondary, confidence: confidence, impactLevel: impactLevel, suggestedReviewers: reviewers, testingStrategy: testingStrategy, riskFactors: riskFactors };
393
- };
394
- return DiffClassifier;
395
- }());
396
- export { DiffClassifier };
299
+ const reviewers = [...new Set(files.flatMap(f => f.classification.suggestedReviewers))].slice(0, 5);
300
+ const testingStrategy = [...new Set(files.flatMap(f => f.classification.testingStrategy))].slice(0, 5);
301
+ const riskFactors = [...new Set(files.flatMap(f => f.classification.riskFactors))].slice(0, 5);
302
+ return { primary, secondary, confidence, impactLevel, suggestedReviewers: reviewers, testingStrategy, riskFactors };
303
+ }
304
+ }
397
305
  export function createDiffClassifier(config) {
398
306
  return new DiffClassifier(config);
399
307
  }
@@ -401,8 +309,8 @@ export function createDiffClassifier(config) {
401
309
  // Optimized Git Diff Functions
402
310
  // ============================================================================
403
311
  // Cache for diff results (TTL-based)
404
- var diffCache = new Map();
405
- var CACHE_TTL_MS = 5000; // 5 seconds - short TTL since diffs change frequently
312
+ const diffCache = new Map();
313
+ const CACHE_TTL_MS = 5000; // 5 seconds - short TTL since diffs change frequently
406
314
  /**
407
315
  * Validate git ref to prevent command injection
408
316
  * Only allows safe characters: alphanumeric, -, _, /, ., ~, ^
@@ -410,73 +318,70 @@ var CACHE_TTL_MS = 5000; // 5 seconds - short TTL since diffs change frequently
410
318
  function validateGitRef(ref) {
411
319
  // Block shell metacharacters and dangerous patterns
412
320
  if (!/^[a-zA-Z0-9_\-./~^@]+$/.test(ref)) {
413
- throw new Error("Invalid git ref: contains unsafe characters");
321
+ throw new Error(`Invalid git ref: contains unsafe characters`);
414
322
  }
415
323
  // Block multiple dots (path traversal)
416
324
  if (ref.includes('..') && !ref.match(/^[a-zA-Z0-9_\-]+\.\.\.?[a-zA-Z0-9_\-]+$/)) {
417
325
  if (!/^\w+\.\.[.\w]+$/.test(ref)) {
418
- throw new Error("Invalid git ref: suspicious pattern");
326
+ throw new Error(`Invalid git ref: suspicious pattern`);
419
327
  }
420
328
  }
421
329
  // Max length check
422
330
  if (ref.length > 256) {
423
- throw new Error("Invalid git ref: too long");
331
+ throw new Error(`Invalid git ref: too long`);
424
332
  }
425
333
  }
426
334
  /**
427
335
  * Get git diff statistics using SINGLE combined command (optimized)
428
336
  * Replaces two separate git commands with one
429
337
  */
430
- export function getGitDiffNumstat(ref) {
431
- if (ref === void 0) { ref = 'HEAD'; }
338
+ export function getGitDiffNumstat(ref = 'HEAD') {
432
339
  // SECURITY: Validate git ref to prevent command injection
433
340
  validateGitRef(ref);
434
341
  // Check cache first
435
- var cacheKey = "numstat:" + ref;
436
- var cached = diffCache.get(cacheKey);
342
+ const cacheKey = `numstat:${ref}`;
343
+ const cached = diffCache.get(cacheKey);
437
344
  if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
438
345
  return cached.files;
439
346
  }
440
- var execFileSync = require('child_process').execFileSync;
347
+ const { execFileSync } = require('child_process');
441
348
  try {
442
349
  // SECURITY: Use execFileSync with args array instead of shell string
443
350
  // This prevents command injection via the ref parameter
444
- var numstatOutput = execFileSync('git', [
351
+ const numstatOutput = execFileSync('git', [
445
352
  'diff', '--numstat', '--diff-filter=ACDMRTUXB', ref
446
353
  ], { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
447
- var statusOutput = execFileSync('git', [
354
+ const statusOutput = execFileSync('git', [
448
355
  'diff', '--name-status', ref
449
356
  ], { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
450
- var output = numstatOutput + '---STATUS---' + statusOutput;
451
- var _a = output.split('---STATUS---'), numstatPart = _a[0], statusPart = _a[1];
357
+ const output = numstatOutput + '---STATUS---' + statusOutput;
358
+ const [numstatPart, statusPart] = output.split('---STATUS---');
452
359
  // Parse status (usually smaller, parse first)
453
- var statusMap = new Map();
360
+ const statusMap = new Map();
454
361
  if (statusPart) {
455
- for (var _i = 0, _b = statusPart.trim().split('\n'); _i < _b.length; _i++) {
456
- var line = _b[_i];
362
+ for (const line of statusPart.trim().split('\n')) {
457
363
  if (!line)
458
364
  continue;
459
- var _c = line.split('\t'), status = _c[0], pathParts = _c.slice(1);
460
- var path = pathParts[pathParts.length - 1] || pathParts[0];
365
+ const [status, ...pathParts] = line.split('\t');
366
+ const path = pathParts[pathParts.length - 1] || pathParts[0];
461
367
  if (path)
462
368
  statusMap.set(path, status.charAt(0));
463
369
  }
464
370
  }
465
371
  // Parse numstat
466
- var files = [];
372
+ const files = [];
467
373
  if (numstatPart) {
468
- for (var _d = 0, _e = numstatPart.trim().split('\n'); _d < _e.length; _d++) {
469
- var line = _e[_d];
374
+ for (const line of numstatPart.trim().split('\n')) {
470
375
  if (!line)
471
376
  continue;
472
- var _f = line.split('\t'), addStr = _f[0], delStr = _f[1], path = _f[2];
377
+ const [addStr, delStr, path] = line.split('\t');
473
378
  if (!path)
474
379
  continue;
475
- var additions = addStr === '-' ? 0 : parseInt(addStr, 10) || 0;
476
- var deletions = delStr === '-' ? 0 : parseInt(delStr, 10) || 0;
477
- var binary = addStr === '-' && delStr === '-';
478
- var statusChar = statusMap.get(path) || 'M';
479
- var status = 'modified';
380
+ const additions = addStr === '-' ? 0 : parseInt(addStr, 10) || 0;
381
+ const deletions = delStr === '-' ? 0 : parseInt(delStr, 10) || 0;
382
+ const binary = addStr === '-' && delStr === '-';
383
+ const statusChar = statusMap.get(path) || 'M';
384
+ let status = 'modified';
480
385
  switch (statusChar) {
481
386
  case 'A':
482
387
  status = 'added';
@@ -489,102 +394,87 @@ export function getGitDiffNumstat(ref) {
489
394
  break;
490
395
  default: status = 'modified';
491
396
  }
492
- files.push({ path: path, status: status, additions: additions, deletions: deletions, hunks: 1, binary: binary });
397
+ files.push({ path, status, additions, deletions, hunks: 1, binary });
493
398
  }
494
399
  }
495
400
  // Cache the result
496
- diffCache.set(cacheKey, { files: files, timestamp: Date.now() });
401
+ diffCache.set(cacheKey, { files, timestamp: Date.now() });
497
402
  return files;
498
403
  }
499
- catch (_g) {
404
+ catch {
500
405
  return [];
501
406
  }
502
407
  }
503
408
  /**
504
409
  * Async version of getGitDiffNumstat for non-blocking operation
505
410
  */
506
- export function getGitDiffNumstatAsync(ref) {
507
- if (ref === void 0) { ref = 'HEAD'; }
508
- return __awaiter(this, void 0, Promise, function () {
509
- var cacheKey, cached, execFile, promisify, execFileAsync, numstatOutput, statusOutput, stdout, _a, numstatPart, statusPart, statusMap, _i, _b, line, _c, status, pathParts, path, files, _d, _e, line, _f, addStr, delStr, path, additions, deletions, binary, statusChar, status, _g;
510
- return __generator(this, function (_h) {
511
- switch (_h.label) {
512
- case 0:
513
- // SECURITY: Validate git ref to prevent command injection
514
- validateGitRef(ref);
515
- cacheKey = "numstat:" + ref;
516
- cached = diffCache.get(cacheKey);
517
- if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
518
- return [2 /*return*/, cached.files];
519
- }
520
- execFile = require('child_process').execFile;
521
- promisify = require('util').promisify;
522
- execFileAsync = promisify(execFile);
523
- _h.label = 1;
524
- case 1:
525
- _h.trys.push([1, 4, , 5]);
526
- return [4 /*yield*/, execFileAsync('git', [
527
- 'diff', '--numstat', '--diff-filter=ACDMRTUXB', ref
528
- ], { maxBuffer: 10 * 1024 * 1024 })];
529
- case 2:
530
- numstatOutput = (_h.sent()).stdout;
531
- return [4 /*yield*/, execFileAsync('git', [
532
- 'diff', '--name-status', ref
533
- ], { maxBuffer: 10 * 1024 * 1024 })];
534
- case 3:
535
- statusOutput = (_h.sent()).stdout;
536
- stdout = numstatOutput + '---STATUS---' + statusOutput;
537
- _a = stdout.split('---STATUS---'), numstatPart = _a[0], statusPart = _a[1];
538
- statusMap = new Map();
539
- if (statusPart) {
540
- for (_i = 0, _b = statusPart.trim().split('\n'); _i < _b.length; _i++) {
541
- line = _b[_i];
542
- if (!line)
543
- continue;
544
- _c = line.split('\t'), status = _c[0], pathParts = _c.slice(1);
545
- path = pathParts[pathParts.length - 1] || pathParts[0];
546
- if (path)
547
- statusMap.set(path, status.charAt(0));
548
- }
549
- }
550
- files = [];
551
- if (numstatPart) {
552
- for (_d = 0, _e = numstatPart.trim().split('\n'); _d < _e.length; _d++) {
553
- line = _e[_d];
554
- if (!line)
555
- continue;
556
- _f = line.split('\t'), addStr = _f[0], delStr = _f[1], path = _f[2];
557
- if (!path)
558
- continue;
559
- additions = addStr === '-' ? 0 : parseInt(addStr, 10) || 0;
560
- deletions = delStr === '-' ? 0 : parseInt(delStr, 10) || 0;
561
- binary = addStr === '-' && delStr === '-';
562
- statusChar = statusMap.get(path) || 'M';
563
- status = 'modified';
564
- switch (statusChar) {
565
- case 'A':
566
- status = 'added';
567
- break;
568
- case 'D':
569
- status = 'deleted';
570
- break;
571
- case 'R':
572
- status = 'renamed';
573
- break;
574
- default: status = 'modified';
575
- }
576
- files.push({ path: path, status: status, additions: additions, deletions: deletions, hunks: 1, binary: binary });
577
- }
578
- }
579
- diffCache.set(cacheKey, { files: files, timestamp: Date.now() });
580
- return [2 /*return*/, files];
581
- case 4:
582
- _g = _h.sent();
583
- return [2 /*return*/, []];
584
- case 5: return [2 /*return*/];
411
+ export async function getGitDiffNumstatAsync(ref = 'HEAD') {
412
+ // SECURITY: Validate git ref to prevent command injection
413
+ validateGitRef(ref);
414
+ // Check cache first
415
+ const cacheKey = `numstat:${ref}`;
416
+ const cached = diffCache.get(cacheKey);
417
+ if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
418
+ return cached.files;
419
+ }
420
+ const { execFile } = require('child_process');
421
+ const { promisify } = require('util');
422
+ const execFileAsync = promisify(execFile);
423
+ try {
424
+ // SECURITY: Use execFile with args array instead of shell string
425
+ const { stdout: numstatOutput } = await execFileAsync('git', [
426
+ 'diff', '--numstat', '--diff-filter=ACDMRTUXB', ref
427
+ ], { maxBuffer: 10 * 1024 * 1024 });
428
+ const { stdout: statusOutput } = await execFileAsync('git', [
429
+ 'diff', '--name-status', ref
430
+ ], { maxBuffer: 10 * 1024 * 1024 });
431
+ const stdout = numstatOutput + '---STATUS---' + statusOutput;
432
+ const [numstatPart, statusPart] = stdout.split('---STATUS---');
433
+ const statusMap = new Map();
434
+ if (statusPart) {
435
+ for (const line of statusPart.trim().split('\n')) {
436
+ if (!line)
437
+ continue;
438
+ const [status, ...pathParts] = line.split('\t');
439
+ const path = pathParts[pathParts.length - 1] || pathParts[0];
440
+ if (path)
441
+ statusMap.set(path, status.charAt(0));
442
+ }
443
+ }
444
+ const files = [];
445
+ if (numstatPart) {
446
+ for (const line of numstatPart.trim().split('\n')) {
447
+ if (!line)
448
+ continue;
449
+ const [addStr, delStr, path] = line.split('\t');
450
+ if (!path)
451
+ continue;
452
+ const additions = addStr === '-' ? 0 : parseInt(addStr, 10) || 0;
453
+ const deletions = delStr === '-' ? 0 : parseInt(delStr, 10) || 0;
454
+ const binary = addStr === '-' && delStr === '-';
455
+ const statusChar = statusMap.get(path) || 'M';
456
+ let status = 'modified';
457
+ switch (statusChar) {
458
+ case 'A':
459
+ status = 'added';
460
+ break;
461
+ case 'D':
462
+ status = 'deleted';
463
+ break;
464
+ case 'R':
465
+ status = 'renamed';
466
+ break;
467
+ default: status = 'modified';
468
+ }
469
+ files.push({ path, status, additions, deletions, hunks: 1, binary });
585
470
  }
586
- });
587
- });
471
+ }
472
+ diffCache.set(cacheKey, { files, timestamp: Date.now() });
473
+ return files;
474
+ }
475
+ catch {
476
+ return [];
477
+ }
588
478
  }
589
479
  /**
590
480
  * Clear the diff cache (call when git state changes)
@@ -596,10 +486,10 @@ export function clearDiffCache() {
596
486
  * Assess risk for a single file
597
487
  */
598
488
  export function assessFileRisk(file) {
599
- var reasons = [];
600
- var score = 0;
489
+ const reasons = [];
490
+ let score = 0;
601
491
  // Size-based risk
602
- var totalChanges = file.additions + file.deletions;
492
+ const totalChanges = file.additions + file.deletions;
603
493
  if (totalChanges > 300) {
604
494
  score += 30;
605
495
  reasons.push('Large change size (>300 lines)');
@@ -609,7 +499,7 @@ export function assessFileRisk(file) {
609
499
  reasons.push('Medium change size (>100 lines)');
610
500
  }
611
501
  // Path-based risk
612
- var lowerPath = file.path.toLowerCase();
502
+ const lowerPath = file.path.toLowerCase();
613
503
  if (/security|auth|crypto|password/.test(lowerPath)) {
614
504
  score += 40;
615
505
  reasons.push('Security-sensitive file');
@@ -640,40 +530,39 @@ export function assessFileRisk(file) {
640
530
  score += 5;
641
531
  reasons.push('Binary file');
642
532
  }
643
- var risk = 'low';
533
+ let risk = 'low';
644
534
  if (score >= 60)
645
535
  risk = 'critical';
646
536
  else if (score >= 40)
647
537
  risk = 'high';
648
538
  else if (score >= 20)
649
539
  risk = 'medium';
650
- return { file: file.path, risk: risk, score: Math.min(100, score), reasons: reasons };
540
+ return { file: file.path, risk, score: Math.min(100, score), reasons };
651
541
  }
652
542
  /**
653
543
  * Assess overall risk from files and file risks
654
544
  */
655
545
  export function assessOverallRisk(files, fileRisks) {
656
- var breakdown = { low: 0, medium: 0, high: 0, critical: 0 };
657
- var totalScore = 0;
658
- for (var _i = 0, fileRisks_1 = fileRisks; _i < fileRisks_1.length; _i++) {
659
- var fr = fileRisks_1[_i];
546
+ const breakdown = { low: 0, medium: 0, high: 0, critical: 0 };
547
+ let totalScore = 0;
548
+ for (const fr of fileRisks) {
660
549
  breakdown[fr.risk]++;
661
550
  totalScore += fr.score;
662
551
  }
663
- var avgScore = fileRisks.length > 0 ? totalScore / fileRisks.length : 0;
552
+ const avgScore = fileRisks.length > 0 ? totalScore / fileRisks.length : 0;
664
553
  // Weight more heavily towards high/critical files
665
- var weightedScore = avgScore + (breakdown.critical * 15) + (breakdown.high * 10);
666
- var overall = 'low';
554
+ const weightedScore = avgScore + (breakdown.critical * 15) + (breakdown.high * 10);
555
+ let overall = 'low';
667
556
  if (weightedScore >= 60 || breakdown.critical > 0)
668
557
  overall = 'critical';
669
558
  else if (weightedScore >= 40 || breakdown.high > 1)
670
559
  overall = 'high';
671
560
  else if (weightedScore >= 20 || breakdown.medium > 2)
672
561
  overall = 'medium';
673
- return { overall: overall, score: Math.min(100, Math.round(weightedScore)), breakdown: breakdown };
562
+ return { overall, score: Math.min(100, Math.round(weightedScore)), breakdown };
674
563
  }
675
564
  // Singleton classifier instance for reuse
676
- var classifierInstance = null;
565
+ let classifierInstance = null;
677
566
  function getClassifier() {
678
567
  if (!classifierInstance) {
679
568
  classifierInstance = new DiffClassifier();
@@ -684,24 +573,23 @@ function getClassifier() {
684
573
  * Classify a diff based on files (uses singleton classifier)
685
574
  */
686
575
  export function classifyDiff(files) {
687
- var classifier = getClassifier();
688
- var fileDiffs = files.map(function (f) { return ({
576
+ const classifier = getClassifier();
577
+ const fileDiffs = files.map(f => ({
689
578
  path: f.path,
690
579
  hunks: [],
691
580
  additions: f.additions,
692
581
  deletions: f.deletions,
693
- classification: classifier['classifyFile'](f.path, [])
694
- }); });
582
+ classification: classifier['classifyFile'](f.path, []),
583
+ }));
695
584
  return classifier['computeOverallClassification'](fileDiffs);
696
585
  }
697
586
  /**
698
587
  * Suggest reviewers based on files and risks
699
588
  */
700
589
  export function suggestReviewers(files, fileRisks) {
701
- var reviewers = new Set();
702
- for (var _i = 0, files_4 = files; _i < files_4.length; _i++) {
703
- var file = files_4[_i];
704
- var lowerPath = file.path.toLowerCase();
590
+ const reviewers = new Set();
591
+ for (const file of files) {
592
+ const lowerPath = file.path.toLowerCase();
705
593
  if (/security|auth|crypto/.test(lowerPath))
706
594
  reviewers.add('security-team');
707
595
  if (/database|migration/.test(lowerPath))
@@ -718,7 +606,7 @@ export function suggestReviewers(files, fileRisks) {
718
606
  reviewers.add('backend-lead');
719
607
  }
720
608
  // Add based on risk
721
- var hasHighRisk = fileRisks.some(function (fr) { return fr.risk === 'high' || fr.risk === 'critical'; });
609
+ const hasHighRisk = fileRisks.some(fr => fr.risk === 'high' || fr.risk === 'critical');
722
610
  if (hasHighRisk) {
723
611
  reviewers.add('tech-lead');
724
612
  reviewers.add('senior-developer');
@@ -730,88 +618,73 @@ export function suggestReviewers(files, fileRisks) {
730
618
  return Array.from(reviewers).slice(0, 5);
731
619
  }
732
620
  // Analysis result cache
733
- var analysisCache = new Map();
734
- var ANALYSIS_CACHE_TTL_MS = 3000; // 3 seconds
621
+ const analysisCache = new Map();
622
+ const ANALYSIS_CACHE_TTL_MS = 3000; // 3 seconds
735
623
  /**
736
624
  * Analyze a diff with full analysis (optimized with caching)
737
625
  */
738
- export function analyzeDiff(options) {
739
- return __awaiter(this, void 0, Promise, function () {
740
- var ref, cached, files, fileRisks, _a, risk, classification, recommendedReviewers, totalAdditions, totalDeletions, result;
741
- return __generator(this, function (_b) {
742
- switch (_b.label) {
743
- case 0:
744
- ref = options.ref || 'HEAD';
745
- // Check analysis cache (unless skipCache is true)
746
- if (!options.skipCache) {
747
- cached = analysisCache.get(ref);
748
- if (cached && Date.now() - cached.timestamp < ANALYSIS_CACHE_TTL_MS) {
749
- return [2 /*return*/, cached.result];
750
- }
751
- }
752
- return [4 /*yield*/, getGitDiffNumstatAsync(ref)];
753
- case 1:
754
- files = _b.sent();
755
- if (!(files.length > 20)) return [3 /*break*/, 3];
756
- return [4 /*yield*/, Promise.all(files.map(function (f) { return Promise.resolve(assessFileRisk(f)); }))];
757
- case 2:
758
- _a = _b.sent();
759
- return [3 /*break*/, 4];
760
- case 3:
761
- _a = files.map(assessFileRisk);
762
- _b.label = 4;
763
- case 4:
764
- fileRisks = _a;
765
- risk = assessOverallRisk(files, fileRisks);
766
- classification = classifyDiff(files);
767
- recommendedReviewers = suggestReviewers(files, fileRisks);
768
- totalAdditions = files.reduce(function (sum, f) { return sum + f.additions; }, 0);
769
- totalDeletions = files.reduce(function (sum, f) { return sum + f.deletions; }, 0);
770
- result = {
771
- ref: ref,
772
- timestamp: Date.now(),
773
- files: files,
774
- risk: risk,
775
- classification: classification,
776
- summary: files.length + " files changed (+" + totalAdditions + "/-" + totalDeletions + "), " + risk.overall + " risk",
777
- fileRisks: fileRisks,
778
- recommendedReviewers: recommendedReviewers
779
- };
780
- // Cache the result
781
- analysisCache.set(ref, { result: result, timestamp: Date.now() });
782
- return [2 /*return*/, result];
783
- }
784
- });
785
- });
626
+ export async function analyzeDiff(options) {
627
+ const ref = options.ref || 'HEAD';
628
+ // Check analysis cache (unless skipCache is true)
629
+ if (!options.skipCache) {
630
+ const cached = analysisCache.get(ref);
631
+ if (cached && Date.now() - cached.timestamp < ANALYSIS_CACHE_TTL_MS) {
632
+ return cached.result;
633
+ }
634
+ }
635
+ // Use async git diff for non-blocking operation
636
+ const files = await getGitDiffNumstatAsync(ref);
637
+ // Parallel file risk assessment for large diffs
638
+ const fileRisks = files.length > 20
639
+ ? await Promise.all(files.map(f => Promise.resolve(assessFileRisk(f))))
640
+ : files.map(assessFileRisk);
641
+ const risk = assessOverallRisk(files, fileRisks);
642
+ const classification = classifyDiff(files);
643
+ const recommendedReviewers = suggestReviewers(files, fileRisks);
644
+ const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0);
645
+ const totalDeletions = files.reduce((sum, f) => sum + f.deletions, 0);
646
+ const result = {
647
+ ref,
648
+ timestamp: Date.now(),
649
+ files,
650
+ risk,
651
+ classification,
652
+ summary: `${files.length} files changed (+${totalAdditions}/-${totalDeletions}), ${risk.overall} risk`,
653
+ fileRisks,
654
+ recommendedReviewers,
655
+ };
656
+ // Cache the result
657
+ analysisCache.set(ref, { result, timestamp: Date.now() });
658
+ return result;
786
659
  }
787
660
  /**
788
661
  * Synchronous version of analyzeDiff for backward compatibility
789
662
  */
790
663
  export function analyzeDiffSync(options) {
791
- var ref = options.ref || 'HEAD';
664
+ const ref = options.ref || 'HEAD';
792
665
  // Check analysis cache
793
- var cached = analysisCache.get(ref);
666
+ const cached = analysisCache.get(ref);
794
667
  if (cached && Date.now() - cached.timestamp < ANALYSIS_CACHE_TTL_MS) {
795
668
  return cached.result;
796
669
  }
797
- var files = getGitDiffNumstat(ref);
798
- var fileRisks = files.map(assessFileRisk);
799
- var risk = assessOverallRisk(files, fileRisks);
800
- var classification = classifyDiff(files);
801
- var recommendedReviewers = suggestReviewers(files, fileRisks);
802
- var totalAdditions = files.reduce(function (sum, f) { return sum + f.additions; }, 0);
803
- var totalDeletions = files.reduce(function (sum, f) { return sum + f.deletions; }, 0);
804
- var result = {
805
- ref: ref,
670
+ const files = getGitDiffNumstat(ref);
671
+ const fileRisks = files.map(assessFileRisk);
672
+ const risk = assessOverallRisk(files, fileRisks);
673
+ const classification = classifyDiff(files);
674
+ const recommendedReviewers = suggestReviewers(files, fileRisks);
675
+ const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0);
676
+ const totalDeletions = files.reduce((sum, f) => sum + f.deletions, 0);
677
+ const result = {
678
+ ref,
806
679
  timestamp: Date.now(),
807
- files: files,
808
- risk: risk,
809
- classification: classification,
810
- summary: files.length + " files changed (+" + totalAdditions + "/-" + totalDeletions + "), " + risk.overall + " risk",
811
- fileRisks: fileRisks,
812
- recommendedReviewers: recommendedReviewers
680
+ files,
681
+ risk,
682
+ classification,
683
+ summary: `${files.length} files changed (+${totalAdditions}/-${totalDeletions}), ${risk.overall} risk`,
684
+ fileRisks,
685
+ recommendedReviewers,
813
686
  };
814
- analysisCache.set(ref, { result: result, timestamp: Date.now() });
687
+ analysisCache.set(ref, { result, timestamp: Date.now() });
815
688
  return result;
816
689
  }
817
690
  /**
@@ -820,6 +693,6 @@ export function analyzeDiffSync(options) {
820
693
  export function clearAllDiffCaches() {
821
694
  diffCache.clear();
822
695
  analysisCache.clear();
823
- classifierInstance === null || classifierInstance === void 0 ? void 0 : classifierInstance.clearCache();
696
+ classifierInstance?.clearCache();
824
697
  }
825
698
  //# sourceMappingURL=diff-classifier.js.map