distill-mcp 0.6.0-beta

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 (440) hide show
  1. package/bin/cli.js +133 -0
  2. package/dist/analytics/session-tracker.d.ts +74 -0
  3. package/dist/analytics/session-tracker.d.ts.map +1 -0
  4. package/dist/analytics/session-tracker.js +123 -0
  5. package/dist/ast/benchmark.test.d.ts +7 -0
  6. package/dist/ast/benchmark.test.d.ts.map +1 -0
  7. package/dist/ast/benchmark.test.js +175 -0
  8. package/dist/ast/go/index.d.ts +9 -0
  9. package/dist/ast/go/index.d.ts.map +1 -0
  10. package/dist/ast/go/index.js +8 -0
  11. package/dist/ast/go/parser.d.ts +31 -0
  12. package/dist/ast/go/parser.d.ts.map +1 -0
  13. package/dist/ast/go/parser.js +428 -0
  14. package/dist/ast/go/parser.test.d.ts +5 -0
  15. package/dist/ast/go/parser.test.d.ts.map +1 -0
  16. package/dist/ast/go/parser.test.js +241 -0
  17. package/dist/ast/go/queries.d.ts +51 -0
  18. package/dist/ast/go/queries.d.ts.map +1 -0
  19. package/dist/ast/go/queries.js +114 -0
  20. package/dist/ast/go/utils.d.ts +66 -0
  21. package/dist/ast/go/utils.d.ts.map +1 -0
  22. package/dist/ast/go/utils.js +140 -0
  23. package/dist/ast/index.d.ts +39 -0
  24. package/dist/ast/index.d.ts.map +1 -0
  25. package/dist/ast/index.js +245 -0
  26. package/dist/ast/php/index.d.ts +9 -0
  27. package/dist/ast/php/index.d.ts.map +1 -0
  28. package/dist/ast/php/index.js +8 -0
  29. package/dist/ast/php/parser.d.ts +31 -0
  30. package/dist/ast/php/parser.d.ts.map +1 -0
  31. package/dist/ast/php/parser.js +388 -0
  32. package/dist/ast/php/parser.test.d.ts +5 -0
  33. package/dist/ast/php/parser.test.d.ts.map +1 -0
  34. package/dist/ast/php/parser.test.js +328 -0
  35. package/dist/ast/php/queries.d.ts +61 -0
  36. package/dist/ast/php/queries.d.ts.map +1 -0
  37. package/dist/ast/php/queries.js +117 -0
  38. package/dist/ast/php/utils.d.ts +83 -0
  39. package/dist/ast/php/utils.d.ts.map +1 -0
  40. package/dist/ast/php/utils.js +246 -0
  41. package/dist/ast/python/index.d.ts +9 -0
  42. package/dist/ast/python/index.d.ts.map +1 -0
  43. package/dist/ast/python/index.js +8 -0
  44. package/dist/ast/python/parser.d.ts +32 -0
  45. package/dist/ast/python/parser.d.ts.map +1 -0
  46. package/dist/ast/python/parser.js +422 -0
  47. package/dist/ast/python/parser.test.d.ts +5 -0
  48. package/dist/ast/python/parser.test.d.ts.map +1 -0
  49. package/dist/ast/python/parser.test.js +186 -0
  50. package/dist/ast/python/queries.d.ts +73 -0
  51. package/dist/ast/python/queries.d.ts.map +1 -0
  52. package/dist/ast/python/queries.js +137 -0
  53. package/dist/ast/python/utils.d.ts +63 -0
  54. package/dist/ast/python/utils.d.ts.map +1 -0
  55. package/dist/ast/python/utils.js +159 -0
  56. package/dist/ast/quick-scan.d.ts +40 -0
  57. package/dist/ast/quick-scan.d.ts.map +1 -0
  58. package/dist/ast/quick-scan.js +287 -0
  59. package/dist/ast/rust/index.d.ts +9 -0
  60. package/dist/ast/rust/index.d.ts.map +1 -0
  61. package/dist/ast/rust/index.js +8 -0
  62. package/dist/ast/rust/parser.d.ts +31 -0
  63. package/dist/ast/rust/parser.d.ts.map +1 -0
  64. package/dist/ast/rust/parser.js +416 -0
  65. package/dist/ast/rust/parser.test.d.ts +5 -0
  66. package/dist/ast/rust/parser.test.d.ts.map +1 -0
  67. package/dist/ast/rust/parser.test.js +329 -0
  68. package/dist/ast/rust/queries.d.ts +66 -0
  69. package/dist/ast/rust/queries.d.ts.map +1 -0
  70. package/dist/ast/rust/queries.js +132 -0
  71. package/dist/ast/rust/utils.d.ts +91 -0
  72. package/dist/ast/rust/utils.d.ts.map +1 -0
  73. package/dist/ast/rust/utils.js +254 -0
  74. package/dist/ast/swift/index.d.ts +10 -0
  75. package/dist/ast/swift/index.d.ts.map +1 -0
  76. package/dist/ast/swift/index.js +8 -0
  77. package/dist/ast/swift/parser.d.ts +31 -0
  78. package/dist/ast/swift/parser.d.ts.map +1 -0
  79. package/dist/ast/swift/parser.js +554 -0
  80. package/dist/ast/swift/parser.test.d.ts +5 -0
  81. package/dist/ast/swift/parser.test.d.ts.map +1 -0
  82. package/dist/ast/swift/parser.test.js +398 -0
  83. package/dist/ast/swift/queries.d.ts +71 -0
  84. package/dist/ast/swift/queries.d.ts.map +1 -0
  85. package/dist/ast/swift/queries.js +137 -0
  86. package/dist/ast/swift/utils.d.ts +94 -0
  87. package/dist/ast/swift/utils.d.ts.map +1 -0
  88. package/dist/ast/swift/utils.js +411 -0
  89. package/dist/ast/types.d.ts +96 -0
  90. package/dist/ast/types.d.ts.map +1 -0
  91. package/dist/ast/types.js +21 -0
  92. package/dist/ast/typescript.d.ts +24 -0
  93. package/dist/ast/typescript.d.ts.map +1 -0
  94. package/dist/ast/typescript.js +357 -0
  95. package/dist/cache/file-hash.d.ts +33 -0
  96. package/dist/cache/file-hash.d.ts.map +1 -0
  97. package/dist/cache/file-hash.js +59 -0
  98. package/dist/cache/index.d.ts +9 -0
  99. package/dist/cache/index.d.ts.map +1 -0
  100. package/dist/cache/index.js +8 -0
  101. package/dist/cache/smart-cache.d.ts +68 -0
  102. package/dist/cache/smart-cache.d.ts.map +1 -0
  103. package/dist/cache/smart-cache.js +266 -0
  104. package/dist/cache/types.d.ts +102 -0
  105. package/dist/cache/types.d.ts.map +1 -0
  106. package/dist/cache/types.js +6 -0
  107. package/dist/cli/analyze.d.ts +43 -0
  108. package/dist/cli/analyze.d.ts.map +1 -0
  109. package/dist/cli/analyze.js +250 -0
  110. package/dist/cli/doctor.d.ts +2 -0
  111. package/dist/cli/doctor.d.ts.map +1 -0
  112. package/dist/cli/doctor.js +127 -0
  113. package/dist/cli/hooks.d.ts +14 -0
  114. package/dist/cli/hooks.d.ts.map +1 -0
  115. package/dist/cli/hooks.js +229 -0
  116. package/dist/cli/index.d.ts +5 -0
  117. package/dist/cli/index.d.ts.map +1 -0
  118. package/dist/cli/index.js +4 -0
  119. package/dist/cli/setup.d.ts +10 -0
  120. package/dist/cli/setup.d.ts.map +1 -0
  121. package/dist/cli/setup.js +117 -0
  122. package/dist/cli/utils.d.ts +30 -0
  123. package/dist/cli/utils.d.ts.map +1 -0
  124. package/dist/cli/utils.js +116 -0
  125. package/dist/compressors/config.d.ts +9 -0
  126. package/dist/compressors/config.d.ts.map +1 -0
  127. package/dist/compressors/config.js +183 -0
  128. package/dist/compressors/conversation.d.ts +109 -0
  129. package/dist/compressors/conversation.d.ts.map +1 -0
  130. package/dist/compressors/conversation.js +404 -0
  131. package/dist/compressors/diff.d.ts +35 -0
  132. package/dist/compressors/diff.d.ts.map +1 -0
  133. package/dist/compressors/diff.js +389 -0
  134. package/dist/compressors/generic.d.ts +9 -0
  135. package/dist/compressors/generic.d.ts.map +1 -0
  136. package/dist/compressors/generic.js +188 -0
  137. package/dist/compressors/index.d.ts +31 -0
  138. package/dist/compressors/index.d.ts.map +1 -0
  139. package/dist/compressors/index.js +82 -0
  140. package/dist/compressors/logs.d.ts +9 -0
  141. package/dist/compressors/logs.d.ts.map +1 -0
  142. package/dist/compressors/logs.js +245 -0
  143. package/dist/compressors/multifile.d.ts +106 -0
  144. package/dist/compressors/multifile.d.ts.map +1 -0
  145. package/dist/compressors/multifile.js +498 -0
  146. package/dist/compressors/semantic.d.ts +33 -0
  147. package/dist/compressors/semantic.d.ts.map +1 -0
  148. package/dist/compressors/semantic.js +233 -0
  149. package/dist/compressors/stacktrace.d.ts +9 -0
  150. package/dist/compressors/stacktrace.d.ts.map +1 -0
  151. package/dist/compressors/stacktrace.js +259 -0
  152. package/dist/compressors/types.d.ts +146 -0
  153. package/dist/compressors/types.d.ts.map +1 -0
  154. package/dist/compressors/types.js +6 -0
  155. package/dist/config/output-config.d.ts +56 -0
  156. package/dist/config/output-config.d.ts.map +1 -0
  157. package/dist/config/output-config.js +78 -0
  158. package/dist/index.d.ts +21 -0
  159. package/dist/index.d.ts.map +1 -0
  160. package/dist/index.js +27 -0
  161. package/dist/middleware/chain.d.ts +49 -0
  162. package/dist/middleware/chain.d.ts.map +1 -0
  163. package/dist/middleware/chain.js +126 -0
  164. package/dist/middleware/index.d.ts +4 -0
  165. package/dist/middleware/index.d.ts.map +1 -0
  166. package/dist/middleware/index.js +3 -0
  167. package/dist/middleware/logging.d.ts +8 -0
  168. package/dist/middleware/logging.d.ts.map +1 -0
  169. package/dist/middleware/logging.js +71 -0
  170. package/dist/middleware/types.d.ts +58 -0
  171. package/dist/middleware/types.d.ts.map +1 -0
  172. package/dist/middleware/types.js +7 -0
  173. package/dist/parsers/eslint.d.ts +8 -0
  174. package/dist/parsers/eslint.d.ts.map +1 -0
  175. package/dist/parsers/eslint.js +132 -0
  176. package/dist/parsers/generic.d.ts +8 -0
  177. package/dist/parsers/generic.d.ts.map +1 -0
  178. package/dist/parsers/generic.js +234 -0
  179. package/dist/parsers/index.d.ts +34 -0
  180. package/dist/parsers/index.d.ts.map +1 -0
  181. package/dist/parsers/index.js +216 -0
  182. package/dist/parsers/types.d.ts +84 -0
  183. package/dist/parsers/types.d.ts.map +1 -0
  184. package/dist/parsers/types.js +6 -0
  185. package/dist/parsers/typescript.d.ts +8 -0
  186. package/dist/parsers/typescript.d.ts.map +1 -0
  187. package/dist/parsers/typescript.js +107 -0
  188. package/dist/pipelines/definitions.d.ts +50 -0
  189. package/dist/pipelines/definitions.d.ts.map +1 -0
  190. package/dist/pipelines/definitions.js +206 -0
  191. package/dist/sandbox/executor.d.ts +12 -0
  192. package/dist/sandbox/executor.d.ts.map +1 -0
  193. package/dist/sandbox/executor.js +191 -0
  194. package/dist/sandbox/index.d.ts +11 -0
  195. package/dist/sandbox/index.d.ts.map +1 -0
  196. package/dist/sandbox/index.js +9 -0
  197. package/dist/sandbox/sandbox.test.d.ts +7 -0
  198. package/dist/sandbox/sandbox.test.d.ts.map +1 -0
  199. package/dist/sandbox/sandbox.test.js +202 -0
  200. package/dist/sandbox/sdk/analyze.d.ts +36 -0
  201. package/dist/sandbox/sdk/analyze.d.ts.map +1 -0
  202. package/dist/sandbox/sdk/analyze.js +413 -0
  203. package/dist/sandbox/sdk/analyze.test.d.ts +7 -0
  204. package/dist/sandbox/sdk/analyze.test.d.ts.map +1 -0
  205. package/dist/sandbox/sdk/analyze.test.js +191 -0
  206. package/dist/sandbox/sdk/code.d.ts +20 -0
  207. package/dist/sandbox/sdk/code.d.ts.map +1 -0
  208. package/dist/sandbox/sdk/code.js +104 -0
  209. package/dist/sandbox/sdk/compress.d.ts +23 -0
  210. package/dist/sandbox/sdk/compress.d.ts.map +1 -0
  211. package/dist/sandbox/sdk/compress.js +107 -0
  212. package/dist/sandbox/sdk/conversation.d.ts +148 -0
  213. package/dist/sandbox/sdk/conversation.d.ts.map +1 -0
  214. package/dist/sandbox/sdk/conversation.js +177 -0
  215. package/dist/sandbox/sdk/files.d.ts +29 -0
  216. package/dist/sandbox/sdk/files.d.ts.map +1 -0
  217. package/dist/sandbox/sdk/files.js +41 -0
  218. package/dist/sandbox/sdk/git.d.ts +37 -0
  219. package/dist/sandbox/sdk/git.d.ts.map +1 -0
  220. package/dist/sandbox/sdk/git.js +313 -0
  221. package/dist/sandbox/sdk/git.test.d.ts +8 -0
  222. package/dist/sandbox/sdk/git.test.d.ts.map +1 -0
  223. package/dist/sandbox/sdk/git.test.js +160 -0
  224. package/dist/sandbox/sdk/index.d.ts +16 -0
  225. package/dist/sandbox/sdk/index.d.ts.map +1 -0
  226. package/dist/sandbox/sdk/index.js +15 -0
  227. package/dist/sandbox/sdk/multifile.d.ts +63 -0
  228. package/dist/sandbox/sdk/multifile.d.ts.map +1 -0
  229. package/dist/sandbox/sdk/multifile.js +130 -0
  230. package/dist/sandbox/sdk/pipeline.d.ts +16 -0
  231. package/dist/sandbox/sdk/pipeline.d.ts.map +1 -0
  232. package/dist/sandbox/sdk/pipeline.js +454 -0
  233. package/dist/sandbox/sdk/pipeline.test.d.ts +7 -0
  234. package/dist/sandbox/sdk/pipeline.test.d.ts.map +1 -0
  235. package/dist/sandbox/sdk/pipeline.test.js +197 -0
  236. package/dist/sandbox/sdk/search.d.ts +36 -0
  237. package/dist/sandbox/sdk/search.d.ts.map +1 -0
  238. package/dist/sandbox/sdk/search.js +338 -0
  239. package/dist/sandbox/sdk/search.test.d.ts +7 -0
  240. package/dist/sandbox/sdk/search.test.d.ts.map +1 -0
  241. package/dist/sandbox/sdk/search.test.js +183 -0
  242. package/dist/sandbox/sdk/utils.d.ts +18 -0
  243. package/dist/sandbox/sdk/utils.d.ts.map +1 -0
  244. package/dist/sandbox/sdk/utils.js +24 -0
  245. package/dist/sandbox/security/code-analyzer.d.ts +15 -0
  246. package/dist/sandbox/security/code-analyzer.d.ts.map +1 -0
  247. package/dist/sandbox/security/code-analyzer.js +87 -0
  248. package/dist/sandbox/security/index.d.ts +6 -0
  249. package/dist/sandbox/security/index.d.ts.map +1 -0
  250. package/dist/sandbox/security/index.js +5 -0
  251. package/dist/sandbox/security/path-validator.d.ts +23 -0
  252. package/dist/sandbox/security/path-validator.d.ts.map +1 -0
  253. package/dist/sandbox/security/path-validator.js +113 -0
  254. package/dist/sandbox/types.d.ts +577 -0
  255. package/dist/sandbox/types.d.ts.map +1 -0
  256. package/dist/sandbox/types.js +14 -0
  257. package/dist/server.d.ts +36 -0
  258. package/dist/server.d.ts.map +1 -0
  259. package/dist/server.js +133 -0
  260. package/dist/summarizers/build-logs.d.ts +11 -0
  261. package/dist/summarizers/build-logs.d.ts.map +1 -0
  262. package/dist/summarizers/build-logs.js +234 -0
  263. package/dist/summarizers/generic.d.ts +11 -0
  264. package/dist/summarizers/generic.d.ts.map +1 -0
  265. package/dist/summarizers/generic.js +93 -0
  266. package/dist/summarizers/index.d.ts +20 -0
  267. package/dist/summarizers/index.d.ts.map +1 -0
  268. package/dist/summarizers/index.js +43 -0
  269. package/dist/summarizers/server-logs.d.ts +11 -0
  270. package/dist/summarizers/server-logs.d.ts.map +1 -0
  271. package/dist/summarizers/server-logs.js +215 -0
  272. package/dist/summarizers/test-logs.d.ts +11 -0
  273. package/dist/summarizers/test-logs.d.ts.map +1 -0
  274. package/dist/summarizers/test-logs.js +258 -0
  275. package/dist/summarizers/types.d.ts +146 -0
  276. package/dist/summarizers/types.d.ts.map +1 -0
  277. package/dist/summarizers/types.js +21 -0
  278. package/dist/tools/analyze-build-output.d.ts +30 -0
  279. package/dist/tools/analyze-build-output.d.ts.map +1 -0
  280. package/dist/tools/analyze-build-output.js +45 -0
  281. package/dist/tools/analyze-context.d.ts +23 -0
  282. package/dist/tools/analyze-context.d.ts.map +1 -0
  283. package/dist/tools/analyze-context.js +78 -0
  284. package/dist/tools/auto-optimize.d.ts +9 -0
  285. package/dist/tools/auto-optimize.d.ts.map +1 -0
  286. package/dist/tools/auto-optimize.js +191 -0
  287. package/dist/tools/code-execute.d.ts +9 -0
  288. package/dist/tools/code-execute.d.ts.map +1 -0
  289. package/dist/tools/code-execute.js +84 -0
  290. package/dist/tools/code-skeleton.d.ts +33 -0
  291. package/dist/tools/code-skeleton.d.ts.map +1 -0
  292. package/dist/tools/code-skeleton.js +206 -0
  293. package/dist/tools/compress-context.d.ts +33 -0
  294. package/dist/tools/compress-context.d.ts.map +1 -0
  295. package/dist/tools/compress-context.js +64 -0
  296. package/dist/tools/context-budget.d.ts +43 -0
  297. package/dist/tools/context-budget.d.ts.map +1 -0
  298. package/dist/tools/context-budget.js +260 -0
  299. package/dist/tools/context-budget.test.d.ts +5 -0
  300. package/dist/tools/context-budget.test.d.ts.map +1 -0
  301. package/dist/tools/context-budget.test.js +219 -0
  302. package/dist/tools/conversation-compress.d.ts +46 -0
  303. package/dist/tools/conversation-compress.d.ts.map +1 -0
  304. package/dist/tools/conversation-compress.js +78 -0
  305. package/dist/tools/conversation-memory.d.ts +75 -0
  306. package/dist/tools/conversation-memory.d.ts.map +1 -0
  307. package/dist/tools/conversation-memory.js +289 -0
  308. package/dist/tools/deduplicate-errors.d.ts +30 -0
  309. package/dist/tools/deduplicate-errors.d.ts.map +1 -0
  310. package/dist/tools/deduplicate-errors.js +72 -0
  311. package/dist/tools/detect-retry-loop.d.ts +40 -0
  312. package/dist/tools/detect-retry-loop.d.ts.map +1 -0
  313. package/dist/tools/detect-retry-loop.js +212 -0
  314. package/dist/tools/diff-compress.d.ts +40 -0
  315. package/dist/tools/diff-compress.d.ts.map +1 -0
  316. package/dist/tools/diff-compress.js +94 -0
  317. package/dist/tools/discover-tools.d.ts +11 -0
  318. package/dist/tools/discover-tools.d.ts.map +1 -0
  319. package/dist/tools/discover-tools.js +163 -0
  320. package/dist/tools/dynamic-loader.d.ts +131 -0
  321. package/dist/tools/dynamic-loader.d.ts.map +1 -0
  322. package/dist/tools/dynamic-loader.js +378 -0
  323. package/dist/tools/dynamic-loader.test.d.ts +10 -0
  324. package/dist/tools/dynamic-loader.test.d.ts.map +1 -0
  325. package/dist/tools/dynamic-loader.test.js +164 -0
  326. package/dist/tools/lazy-mcp.d.ts +31 -0
  327. package/dist/tools/lazy-mcp.d.ts.map +1 -0
  328. package/dist/tools/lazy-mcp.js +151 -0
  329. package/dist/tools/lazy-mcp.test.d.ts +10 -0
  330. package/dist/tools/lazy-mcp.test.d.ts.map +1 -0
  331. package/dist/tools/lazy-mcp.test.js +172 -0
  332. package/dist/tools/multifile-compress.d.ts +36 -0
  333. package/dist/tools/multifile-compress.d.ts.map +1 -0
  334. package/dist/tools/multifile-compress.js +223 -0
  335. package/dist/tools/optimization-tips.d.ts +18 -0
  336. package/dist/tools/optimization-tips.d.ts.map +1 -0
  337. package/dist/tools/optimization-tips.js +133 -0
  338. package/dist/tools/registry.d.ts +70 -0
  339. package/dist/tools/registry.d.ts.map +1 -0
  340. package/dist/tools/registry.js +169 -0
  341. package/dist/tools/semantic-compress.d.ts +39 -0
  342. package/dist/tools/semantic-compress.d.ts.map +1 -0
  343. package/dist/tools/semantic-compress.js +113 -0
  344. package/dist/tools/semantic-compress.test.d.ts +5 -0
  345. package/dist/tools/semantic-compress.test.d.ts.map +1 -0
  346. package/dist/tools/semantic-compress.test.js +182 -0
  347. package/dist/tools/session-stats.d.ts +34 -0
  348. package/dist/tools/session-stats.d.ts.map +1 -0
  349. package/dist/tools/session-stats.js +194 -0
  350. package/dist/tools/set-output-config.d.ts +38 -0
  351. package/dist/tools/set-output-config.d.ts.map +1 -0
  352. package/dist/tools/set-output-config.js +122 -0
  353. package/dist/tools/smart-cache-tool.d.ts +38 -0
  354. package/dist/tools/smart-cache-tool.d.ts.map +1 -0
  355. package/dist/tools/smart-cache-tool.js +224 -0
  356. package/dist/tools/smart-file-read.d.ts +52 -0
  357. package/dist/tools/smart-file-read.d.ts.map +1 -0
  358. package/dist/tools/smart-file-read.js +481 -0
  359. package/dist/tools/smart-pipeline.d.ts +40 -0
  360. package/dist/tools/smart-pipeline.d.ts.map +1 -0
  361. package/dist/tools/smart-pipeline.js +295 -0
  362. package/dist/tools/summarize-logs.d.ts +36 -0
  363. package/dist/tools/summarize-logs.d.ts.map +1 -0
  364. package/dist/tools/summarize-logs.js +184 -0
  365. package/dist/tools/token-budget.test.d.ts +11 -0
  366. package/dist/tools/token-budget.test.d.ts.map +1 -0
  367. package/dist/tools/token-budget.test.js +275 -0
  368. package/dist/utils/bm25.d.ts +86 -0
  369. package/dist/utils/bm25.d.ts.map +1 -0
  370. package/dist/utils/bm25.js +153 -0
  371. package/dist/utils/bm25.test.d.ts +5 -0
  372. package/dist/utils/bm25.test.d.ts.map +1 -0
  373. package/dist/utils/bm25.test.js +156 -0
  374. package/dist/utils/command-normalizer.d.ts +39 -0
  375. package/dist/utils/command-normalizer.d.ts.map +1 -0
  376. package/dist/utils/command-normalizer.js +90 -0
  377. package/dist/utils/content-detector.d.ts +27 -0
  378. package/dist/utils/content-detector.d.ts.map +1 -0
  379. package/dist/utils/content-detector.js +127 -0
  380. package/dist/utils/embeddings.d.ts +54 -0
  381. package/dist/utils/embeddings.d.ts.map +1 -0
  382. package/dist/utils/embeddings.js +97 -0
  383. package/dist/utils/embeddings.test.d.ts +8 -0
  384. package/dist/utils/embeddings.test.d.ts.map +1 -0
  385. package/dist/utils/embeddings.test.js +96 -0
  386. package/dist/utils/error-normalizer.d.ts +39 -0
  387. package/dist/utils/error-normalizer.d.ts.map +1 -0
  388. package/dist/utils/error-normalizer.js +233 -0
  389. package/dist/utils/hybrid-search.d.ts +79 -0
  390. package/dist/utils/hybrid-search.d.ts.map +1 -0
  391. package/dist/utils/hybrid-search.js +146 -0
  392. package/dist/utils/hybrid-search.test.d.ts +5 -0
  393. package/dist/utils/hybrid-search.test.d.ts.map +1 -0
  394. package/dist/utils/hybrid-search.test.js +172 -0
  395. package/dist/utils/index.d.ts +13 -0
  396. package/dist/utils/index.d.ts.map +1 -0
  397. package/dist/utils/index.js +12 -0
  398. package/dist/utils/language-detector.d.ts +27 -0
  399. package/dist/utils/language-detector.d.ts.map +1 -0
  400. package/dist/utils/language-detector.js +94 -0
  401. package/dist/utils/log-parser.d.ts +46 -0
  402. package/dist/utils/log-parser.d.ts.map +1 -0
  403. package/dist/utils/log-parser.js +287 -0
  404. package/dist/utils/output-estimator.d.ts +54 -0
  405. package/dist/utils/output-estimator.d.ts.map +1 -0
  406. package/dist/utils/output-estimator.js +119 -0
  407. package/dist/utils/output-estimator.test.d.ts +5 -0
  408. package/dist/utils/output-estimator.test.d.ts.map +1 -0
  409. package/dist/utils/output-estimator.test.js +115 -0
  410. package/dist/utils/output-similarity.d.ts +48 -0
  411. package/dist/utils/output-similarity.d.ts.map +1 -0
  412. package/dist/utils/output-similarity.js +140 -0
  413. package/dist/utils/project-detector.d.ts +16 -0
  414. package/dist/utils/project-detector.d.ts.map +1 -0
  415. package/dist/utils/project-detector.js +119 -0
  416. package/dist/utils/segment-scorer.d.ts +99 -0
  417. package/dist/utils/segment-scorer.d.ts.map +1 -0
  418. package/dist/utils/segment-scorer.js +148 -0
  419. package/dist/utils/signature-grouper.d.ts +58 -0
  420. package/dist/utils/signature-grouper.d.ts.map +1 -0
  421. package/dist/utils/signature-grouper.js +185 -0
  422. package/dist/utils/tfidf.d.ts +45 -0
  423. package/dist/utils/tfidf.d.ts.map +1 -0
  424. package/dist/utils/tfidf.js +204 -0
  425. package/dist/utils/tfidf.test.d.ts +5 -0
  426. package/dist/utils/tfidf.test.d.ts.map +1 -0
  427. package/dist/utils/tfidf.test.js +115 -0
  428. package/dist/utils/token-counter.d.ts +35 -0
  429. package/dist/utils/token-counter.d.ts.map +1 -0
  430. package/dist/utils/token-counter.js +83 -0
  431. package/dist/utils/toon-serializer.d.ts +120 -0
  432. package/dist/utils/toon-serializer.d.ts.map +1 -0
  433. package/dist/utils/toon-serializer.js +472 -0
  434. package/dist/utils/toon-serializer.test.d.ts +7 -0
  435. package/dist/utils/toon-serializer.test.d.ts.map +1 -0
  436. package/dist/utils/toon-serializer.test.js +290 -0
  437. package/package.json +63 -0
  438. package/scripts/install.ps1 +133 -0
  439. package/scripts/install.sh +183 -0
  440. package/scripts/pre-commit-hook.sh +86 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Command Normalizer
3
+ *
4
+ * Normalizes shell commands for retry loop detection.
5
+ * Similar commands with different flags or file arguments
6
+ * are normalized to the same base command.
7
+ */
8
+ /**
9
+ * Normalize a shell command for comparison.
10
+ * Removes flags, specific file paths, and normalizes whitespace.
11
+ *
12
+ * @example
13
+ * normalizeCommand("npm run build --verbose") // "npm run build"
14
+ * normalizeCommand("bun test src/foo.test.ts") // "bun test"
15
+ * normalizeCommand("tsc --noEmit src/index.ts") // "tsc"
16
+ */
17
+ export declare function normalizeCommand(cmd: string): string;
18
+ /**
19
+ * Extract the base command (first word or first two words for npm/bun/yarn/pnpm)
20
+ *
21
+ * @example
22
+ * getBaseCommand("npm run build") // "npm run"
23
+ * getBaseCommand("bun test") // "bun test"
24
+ * getBaseCommand("tsc") // "tsc"
25
+ */
26
+ export declare function getBaseCommand(cmd: string): string;
27
+ /**
28
+ * Check if two commands are similar (same base operation)
29
+ */
30
+ export declare function areCommandsSimilar(cmd1: string, cmd2: string): boolean;
31
+ /**
32
+ * Common build/test commands that are often retried
33
+ */
34
+ export declare const COMMON_RETRY_COMMANDS: string[];
35
+ /**
36
+ * Check if a command is a common build/test command
37
+ */
38
+ export declare function isCommonRetryCommand(cmd: string): boolean;
39
+ //# sourceMappingURL=command-normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-normalizer.d.ts","sourceRoot":"","sources":["../../src/utils/command-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBpD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,UAwBjC,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGzD"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Command Normalizer
3
+ *
4
+ * Normalizes shell commands for retry loop detection.
5
+ * Similar commands with different flags or file arguments
6
+ * are normalized to the same base command.
7
+ */
8
+ /**
9
+ * Normalize a shell command for comparison.
10
+ * Removes flags, specific file paths, and normalizes whitespace.
11
+ *
12
+ * @example
13
+ * normalizeCommand("npm run build --verbose") // "npm run build"
14
+ * normalizeCommand("bun test src/foo.test.ts") // "bun test"
15
+ * normalizeCommand("tsc --noEmit src/index.ts") // "tsc"
16
+ */
17
+ export function normalizeCommand(cmd) {
18
+ return (cmd
19
+ // Remove long flags with values (--flag=value or --flag value)
20
+ .replace(/--\w+(?:=\S+)?/g, "")
21
+ // Remove short flags (-v, -f, etc.)
22
+ .replace(/\s-\w+/g, "")
23
+ // Remove specific file paths with extensions
24
+ .replace(/\s+\S+\.(ts|tsx|js|jsx|json|md|css|scss|html|vue|svelte)(?:\s|$)/g, " ")
25
+ // Remove quoted strings (often file paths or arguments)
26
+ .replace(/"[^"]*"|'[^']*'/g, "")
27
+ // Remove path-like arguments (containing /)
28
+ .replace(/\s+\S*\/\S+/g, "")
29
+ // Normalize multiple spaces to single space
30
+ .replace(/\s+/g, " ")
31
+ .trim());
32
+ }
33
+ /**
34
+ * Extract the base command (first word or first two words for npm/bun/yarn/pnpm)
35
+ *
36
+ * @example
37
+ * getBaseCommand("npm run build") // "npm run"
38
+ * getBaseCommand("bun test") // "bun test"
39
+ * getBaseCommand("tsc") // "tsc"
40
+ */
41
+ export function getBaseCommand(cmd) {
42
+ const parts = cmd.trim().split(/\s+/);
43
+ // Package manager commands keep their subcommand
44
+ const packageManagers = ["npm", "bun", "yarn", "pnpm", "npx", "bunx"];
45
+ if (packageManagers.includes(parts[0] ?? "")) {
46
+ return parts.slice(0, 2).join(" ");
47
+ }
48
+ return parts[0] ?? cmd;
49
+ }
50
+ /**
51
+ * Check if two commands are similar (same base operation)
52
+ */
53
+ export function areCommandsSimilar(cmd1, cmd2) {
54
+ return normalizeCommand(cmd1) === normalizeCommand(cmd2);
55
+ }
56
+ /**
57
+ * Common build/test commands that are often retried
58
+ */
59
+ export const COMMON_RETRY_COMMANDS = [
60
+ "npm run build",
61
+ "npm run test",
62
+ "npm run lint",
63
+ "npm run check",
64
+ "bun run build",
65
+ "bun run test",
66
+ "bun test",
67
+ "bun run lint",
68
+ "yarn build",
69
+ "yarn test",
70
+ "yarn lint",
71
+ "pnpm build",
72
+ "pnpm test",
73
+ "pnpm lint",
74
+ "tsc",
75
+ "eslint",
76
+ "prettier",
77
+ "vitest",
78
+ "jest",
79
+ "cargo build",
80
+ "cargo test",
81
+ "go build",
82
+ "go test",
83
+ ];
84
+ /**
85
+ * Check if a command is a common build/test command
86
+ */
87
+ export function isCommonRetryCommand(cmd) {
88
+ const normalized = normalizeCommand(cmd).toLowerCase();
89
+ return COMMON_RETRY_COMMANDS.some((common) => normalized.startsWith(common.toLowerCase()));
90
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Content Type Detector
3
+ *
4
+ * Auto-detects the type of content for optimal compression.
5
+ */
6
+ import type { ContentType } from "../compressors/types.js";
7
+ /**
8
+ * Check if content is valid JSON
9
+ */
10
+ export declare function isValidJSON(content: string): boolean;
11
+ /**
12
+ * Check if content looks like YAML
13
+ */
14
+ export declare function isLikelyYAML(content: string): boolean;
15
+ /**
16
+ * Check if content looks like code
17
+ */
18
+ export declare function isLikelyCode(content: string): boolean;
19
+ /**
20
+ * Detect the type of content
21
+ */
22
+ export declare function detectContentType(content: string): ContentType;
23
+ /**
24
+ * Get a human-readable description of the content type
25
+ */
26
+ export declare function getContentTypeDescription(type: ContentType): string;
27
+ //# sourceMappingURL=content-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-detector.d.ts","sourceRoot":"","sources":["../../src/utils/content-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAkB3D;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAarD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASrD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CA6D9D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAanE"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Content Type Detector
3
+ *
4
+ * Auto-detects the type of content for optimal compression.
5
+ */
6
+ // Log patterns
7
+ const LOG_LEVEL_PATTERN = /\[\s*(INFO|DEBUG|WARN|WARNING|ERROR|TRACE|FATAL)\s*\]/i;
8
+ const LOG_TIMESTAMP_PATTERN = /\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}/;
9
+ const LOG_COMMON_FORMATS = /^(\d{4}-\d{2}-\d{2}|\[\d{2}:\d{2}:\d{2}\]|[A-Z]{3,5}\s+\d{1,2})/m;
10
+ // Stack trace patterns
11
+ const ERROR_START_PATTERN = /^(Error|TypeError|ReferenceError|SyntaxError|RangeError|URIError|EvalError|AggregateError|Exception|Panic|panic):/m;
12
+ const STACK_FRAME_PATTERN = /^\s+at\s+/m;
13
+ const PYTHON_TRACEBACK = /^Traceback \(most recent call last\):/m;
14
+ const RUST_PANIC = /^thread '.*' panicked at/m;
15
+ const GO_PANIC = /^panic:/m;
16
+ // Config patterns
17
+ const JSON_START = /^\s*[\[{]/;
18
+ const YAML_PATTERN = /^[\w-]+:\s*(\n|.+)/m;
19
+ /**
20
+ * Check if content is valid JSON
21
+ */
22
+ export function isValidJSON(content) {
23
+ try {
24
+ JSON.parse(content);
25
+ return true;
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ /**
32
+ * Check if content looks like YAML
33
+ */
34
+ export function isLikelyYAML(content) {
35
+ const lines = content.trim().split("\n");
36
+ if (lines.length < 2)
37
+ return false;
38
+ // Check for YAML-like structure: key: value pairs
39
+ let yamlLikeLines = 0;
40
+ for (const line of lines.slice(0, 10)) {
41
+ if (/^\s*[\w-]+:\s*.+$/.test(line) || /^\s*-\s+/.test(line)) {
42
+ yamlLikeLines++;
43
+ }
44
+ }
45
+ return yamlLikeLines >= 3;
46
+ }
47
+ /**
48
+ * Check if content looks like code
49
+ */
50
+ export function isLikelyCode(content) {
51
+ const codeIndicators = [
52
+ /^(import|export|const|let|var|function|class|interface|type)\s+/m,
53
+ /^(def|class|import|from|if|for|while|try|except)\s+/m,
54
+ /^(fn|struct|impl|use|mod|pub|let|mut)\s+/m,
55
+ /^(func|package|import|type|struct|interface)\s+/m,
56
+ ];
57
+ return codeIndicators.some((pattern) => pattern.test(content));
58
+ }
59
+ /**
60
+ * Detect the type of content
61
+ */
62
+ export function detectContentType(content) {
63
+ // Empty or very short content
64
+ if (!content || content.trim().length < 10) {
65
+ return "generic";
66
+ }
67
+ // Stack trace detection (check first as it's most specific)
68
+ if (ERROR_START_PATTERN.test(content) &&
69
+ (STACK_FRAME_PATTERN.test(content) || content.includes(" at "))) {
70
+ return "stacktrace";
71
+ }
72
+ // Python traceback
73
+ if (PYTHON_TRACEBACK.test(content)) {
74
+ return "stacktrace";
75
+ }
76
+ // Rust/Go panic
77
+ if (RUST_PANIC.test(content) || GO_PANIC.test(content)) {
78
+ return "stacktrace";
79
+ }
80
+ // Log detection
81
+ if (LOG_LEVEL_PATTERN.test(content) || LOG_TIMESTAMP_PATTERN.test(content)) {
82
+ // Count log-like lines
83
+ const lines = content.split("\n");
84
+ const logLines = lines.filter((line) => LOG_LEVEL_PATTERN.test(line) || LOG_TIMESTAMP_PATTERN.test(line));
85
+ if (logLines.length >= lines.length * 0.3) {
86
+ return "logs";
87
+ }
88
+ }
89
+ // Common log formats
90
+ if (LOG_COMMON_FORMATS.test(content)) {
91
+ const lines = content.split("\n");
92
+ const matchingLines = lines.filter((line) => LOG_COMMON_FORMATS.test(line));
93
+ if (matchingLines.length >= lines.length * 0.5) {
94
+ return "logs";
95
+ }
96
+ }
97
+ // Config detection (JSON)
98
+ if (JSON_START.test(content.trim()) && isValidJSON(content)) {
99
+ return "config";
100
+ }
101
+ // Config detection (YAML-like)
102
+ if (YAML_PATTERN.test(content) && isLikelyYAML(content)) {
103
+ return "config";
104
+ }
105
+ // Code detection
106
+ if (isLikelyCode(content)) {
107
+ return "code";
108
+ }
109
+ return "generic";
110
+ }
111
+ /**
112
+ * Get a human-readable description of the content type
113
+ */
114
+ export function getContentTypeDescription(type) {
115
+ switch (type) {
116
+ case "logs":
117
+ return "Application logs";
118
+ case "stacktrace":
119
+ return "Stack trace / Error dump";
120
+ case "config":
121
+ return "Configuration file (JSON/YAML)";
122
+ case "code":
123
+ return "Source code";
124
+ case "generic":
125
+ return "Generic text content";
126
+ }
127
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Embeddings Utilities using Transformers.js
3
+ *
4
+ * Provides local embedding computation using the all-MiniLM-L6-v2 model.
5
+ * Model is loaded lazily on first use to avoid startup overhead.
6
+ */
7
+ type EmbeddingPipeline = (text: string, options?: Record<string, unknown>) => Promise<{
8
+ data: Float32Array;
9
+ }>;
10
+ /**
11
+ * Get or initialize the embedding pipeline (lazy loaded)
12
+ *
13
+ * The model is downloaded and cached on first use (~23MB quantized).
14
+ * Subsequent calls return the cached pipeline instantly.
15
+ */
16
+ export declare function getEmbeddingPipeline(): Promise<EmbeddingPipeline>;
17
+ /**
18
+ * Compute embedding for a single text
19
+ *
20
+ * @param text - Text to embed
21
+ * @returns 384-dimensional normalized embedding vector
22
+ */
23
+ export declare function computeEmbedding(text: string): Promise<number[]>;
24
+ /**
25
+ * Compute embeddings for multiple texts
26
+ *
27
+ * @param texts - Array of texts to embed
28
+ * @returns Array of 384-dimensional normalized embedding vectors
29
+ */
30
+ export declare function computeEmbeddings(texts: string[]): Promise<number[][]>;
31
+ /**
32
+ * Cosine similarity between two normalized vectors
33
+ *
34
+ * Since vectors are normalized, dot product equals cosine similarity.
35
+ *
36
+ * @param a - First embedding vector
37
+ * @param b - Second embedding vector
38
+ * @returns Similarity score between -1 and 1 (higher = more similar)
39
+ */
40
+ export declare function cosineSimilarity(a: number[], b: number[]): number;
41
+ /**
42
+ * Check if embeddings pipeline is ready (model loaded)
43
+ */
44
+ export declare function isEmbeddingsReady(): boolean;
45
+ /**
46
+ * Get embedding dimension for the current model
47
+ */
48
+ export declare function getEmbeddingDimension(): number;
49
+ /**
50
+ * Reset the embedding pipeline (for testing)
51
+ */
52
+ export declare function resetEmbeddingPipeline(): void;
53
+ export {};
54
+ //# sourceMappingURL=embeddings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../src/utils/embeddings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,KAAK,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AAM9G;;;;;GAKG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAiBvE;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAItE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAU5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAOjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Embeddings Utilities using Transformers.js
3
+ *
4
+ * Provides local embedding computation using the all-MiniLM-L6-v2 model.
5
+ * Model is loaded lazily on first use to avoid startup overhead.
6
+ */
7
+ const MODEL_ID = "Xenova/all-MiniLM-L6-v2";
8
+ const EMBEDDING_DIM = 384;
9
+ // Lazy-loaded pipeline singleton
10
+ let extractor = null;
11
+ let loadingPromise = null;
12
+ /**
13
+ * Get or initialize the embedding pipeline (lazy loaded)
14
+ *
15
+ * The model is downloaded and cached on first use (~23MB quantized).
16
+ * Subsequent calls return the cached pipeline instantly.
17
+ */
18
+ export async function getEmbeddingPipeline() {
19
+ if (extractor)
20
+ return extractor;
21
+ if (!loadingPromise) {
22
+ loadingPromise = (async () => {
23
+ // Dynamic import to avoid type complexity at module level
24
+ const { pipeline } = await import("@huggingface/transformers");
25
+ const pipe = await pipeline("feature-extraction", MODEL_ID, {
26
+ dtype: "q8",
27
+ });
28
+ // Cast to our simplified type
29
+ return pipe;
30
+ })();
31
+ }
32
+ extractor = await loadingPromise;
33
+ return extractor;
34
+ }
35
+ /**
36
+ * Compute embedding for a single text
37
+ *
38
+ * @param text - Text to embed
39
+ * @returns 384-dimensional normalized embedding vector
40
+ */
41
+ export async function computeEmbedding(text) {
42
+ const pipe = await getEmbeddingPipeline();
43
+ const output = await pipe(text, { pooling: "mean", normalize: true });
44
+ return Array.from(output.data);
45
+ }
46
+ /**
47
+ * Compute embeddings for multiple texts
48
+ *
49
+ * @param texts - Array of texts to embed
50
+ * @returns Array of 384-dimensional normalized embedding vectors
51
+ */
52
+ export async function computeEmbeddings(texts) {
53
+ const pipe = await getEmbeddingPipeline();
54
+ const results = [];
55
+ for (const text of texts) {
56
+ const output = await pipe(text, { pooling: "mean", normalize: true });
57
+ results.push(Array.from(output.data));
58
+ }
59
+ return results;
60
+ }
61
+ /**
62
+ * Cosine similarity between two normalized vectors
63
+ *
64
+ * Since vectors are normalized, dot product equals cosine similarity.
65
+ *
66
+ * @param a - First embedding vector
67
+ * @param b - Second embedding vector
68
+ * @returns Similarity score between -1 and 1 (higher = more similar)
69
+ */
70
+ export function cosineSimilarity(a, b) {
71
+ if (a.length !== b.length)
72
+ return 0;
73
+ let dot = 0;
74
+ for (let i = 0; i < a.length; i++) {
75
+ dot += (a[i] ?? 0) * (b[i] ?? 0);
76
+ }
77
+ return dot;
78
+ }
79
+ /**
80
+ * Check if embeddings pipeline is ready (model loaded)
81
+ */
82
+ export function isEmbeddingsReady() {
83
+ return extractor !== null;
84
+ }
85
+ /**
86
+ * Get embedding dimension for the current model
87
+ */
88
+ export function getEmbeddingDimension() {
89
+ return EMBEDDING_DIM;
90
+ }
91
+ /**
92
+ * Reset the embedding pipeline (for testing)
93
+ */
94
+ export function resetEmbeddingPipeline() {
95
+ extractor = null;
96
+ loadingPromise = null;
97
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Embeddings Utilities Tests
3
+ *
4
+ * Note: These tests use the actual model for integration testing.
5
+ * The model is downloaded once and cached.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=embeddings.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeddings.test.d.ts","sourceRoot":"","sources":["../../src/utils/embeddings.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Embeddings Utilities Tests
3
+ *
4
+ * Note: These tests use the actual model for integration testing.
5
+ * The model is downloaded once and cached.
6
+ */
7
+ import { describe, it, expect } from "vitest";
8
+ import { computeEmbedding, computeEmbeddings, cosineSimilarity, getEmbeddingDimension, isEmbeddingsReady, } from "./embeddings.js";
9
+ describe("Embeddings utilities", () => {
10
+ describe("cosineSimilarity", () => {
11
+ it("should return 1 for identical normalized vectors", () => {
12
+ const v = [0.5, 0.5, 0.5, 0.5];
13
+ const norm = Math.sqrt(v.reduce((sum, x) => sum + x * x, 0));
14
+ const normalized = v.map((x) => x / norm);
15
+ expect(cosineSimilarity(normalized, normalized)).toBeCloseTo(1, 5);
16
+ });
17
+ it("should return 0 for orthogonal vectors", () => {
18
+ const a = [1, 0, 0, 0];
19
+ const b = [0, 1, 0, 0];
20
+ expect(cosineSimilarity(a, b)).toBe(0);
21
+ });
22
+ it("should return -1 for opposite vectors", () => {
23
+ const a = [1, 0, 0, 0];
24
+ const b = [-1, 0, 0, 0];
25
+ expect(cosineSimilarity(a, b)).toBe(-1);
26
+ });
27
+ it("should return 0 for vectors of different lengths", () => {
28
+ const a = [1, 0, 0];
29
+ const b = [1, 0, 0, 0];
30
+ expect(cosineSimilarity(a, b)).toBe(0);
31
+ });
32
+ it("should handle empty vectors", () => {
33
+ expect(cosineSimilarity([], [])).toBe(0);
34
+ });
35
+ it("should compute similarity for arbitrary vectors", () => {
36
+ // Two similar vectors (normalized)
37
+ const a = [0.6, 0.8, 0, 0];
38
+ const b = [0.8, 0.6, 0, 0];
39
+ const similarity = cosineSimilarity(a, b);
40
+ // 0.6*0.8 + 0.8*0.6 = 0.48 + 0.48 = 0.96
41
+ expect(similarity).toBeCloseTo(0.96, 5);
42
+ });
43
+ });
44
+ describe("getEmbeddingDimension", () => {
45
+ it("should return 384 for all-MiniLM-L6-v2", () => {
46
+ expect(getEmbeddingDimension()).toBe(384);
47
+ });
48
+ });
49
+ describe("isEmbeddingsReady", () => {
50
+ it("should return false before model is loaded", () => {
51
+ // Note: This might be true if other tests loaded the model
52
+ // We just verify it returns a boolean
53
+ expect(typeof isEmbeddingsReady()).toBe("boolean");
54
+ });
55
+ });
56
+ // Integration tests - these download the model on first run
57
+ describe("computeEmbedding (integration)", () => {
58
+ // Skip these tests in CI or if model download is slow
59
+ const skipIntegration = process.env.SKIP_EMBEDDING_TESTS === "true";
60
+ it.skipIf(skipIntegration)("should compute embedding with correct dimensions", async () => {
61
+ const embedding = await computeEmbedding("Hello world");
62
+ expect(embedding).toHaveLength(384);
63
+ }, 60000); // 60s timeout for model download
64
+ it.skipIf(skipIntegration)("should return normalized vectors", async () => {
65
+ const embedding = await computeEmbedding("Test text");
66
+ // Check that the vector is normalized (magnitude ≈ 1)
67
+ const magnitude = Math.sqrt(embedding.reduce((sum, x) => sum + x * x, 0));
68
+ expect(magnitude).toBeCloseTo(1, 3);
69
+ }, 60000);
70
+ it.skipIf(skipIntegration)("should produce similar embeddings for similar texts", async () => {
71
+ const emb1 = await computeEmbedding("compress log output");
72
+ const emb2 = await computeEmbedding("shrink log files");
73
+ const emb3 = await computeEmbedding("unrelated banana smoothie recipe");
74
+ const sim12 = cosineSimilarity(emb1, emb2);
75
+ const sim13 = cosineSimilarity(emb1, emb3);
76
+ // Similar texts should have higher similarity
77
+ expect(sim12).toBeGreaterThan(sim13);
78
+ expect(sim12).toBeGreaterThan(0.5);
79
+ }, 60000);
80
+ });
81
+ describe("computeEmbeddings (integration)", () => {
82
+ const skipIntegration = process.env.SKIP_EMBEDDING_TESTS === "true";
83
+ it.skipIf(skipIntegration)("should compute multiple embeddings", async () => {
84
+ const texts = ["Hello", "World", "Test"];
85
+ const embeddings = await computeEmbeddings(texts);
86
+ expect(embeddings).toHaveLength(3);
87
+ for (const emb of embeddings) {
88
+ expect(emb).toHaveLength(384);
89
+ }
90
+ }, 60000);
91
+ it.skipIf(skipIntegration)("should handle empty array", async () => {
92
+ const embeddings = await computeEmbeddings([]);
93
+ expect(embeddings).toHaveLength(0);
94
+ }, 60000);
95
+ });
96
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Error Normalizer
3
+ *
4
+ * Normalizes error lines to create consistent signatures for deduplication.
5
+ * Removes variable parts (file paths, line numbers, values) while preserving
6
+ * the error pattern.
7
+ */
8
+ export interface ErrorParts {
9
+ file?: string;
10
+ line?: number;
11
+ column?: number;
12
+ code?: string;
13
+ message: string;
14
+ raw: string;
15
+ }
16
+ /**
17
+ * Normalize an error line by replacing variable parts with placeholders.
18
+ * This creates a consistent signature for grouping similar errors.
19
+ */
20
+ export declare function normalizeErrorLine(line: string): string;
21
+ /**
22
+ * Extract structured parts from an error line.
23
+ * Returns null if the line doesn't match any known error pattern.
24
+ */
25
+ export declare function extractErrorParts(line: string): ErrorParts | null;
26
+ /**
27
+ * Check if a line is likely an error message
28
+ */
29
+ export declare function isLikelyError(line: string): boolean;
30
+ /**
31
+ * Create a signature from error parts for grouping.
32
+ * The signature represents the "type" of error, ignoring location.
33
+ */
34
+ export declare function createSignature(parts: ErrorParts): string;
35
+ /**
36
+ * Extract file location from error parts
37
+ */
38
+ export declare function formatLocation(parts: ErrorParts): string;
39
+ //# sourceMappingURL=error-normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-normalizer.d.ts","sourceRoot":"","sources":["../../src/utils/error-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4BvD;AA0HD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAoBjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAqBnD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAYzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAWxD"}