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,289 @@
1
+ /**
2
+ * Conversation Memory Tool
3
+ *
4
+ * Manages long conversation context with decision extraction
5
+ * and context restoration capabilities.
6
+ */
7
+ import { z } from "zod";
8
+ import { compressConversationWithMemory, extractDecisions, extractCodeReferences, restoreContext, } from "../compressors/conversation.js";
9
+ import { getSessionTracker } from "../analytics/session-tracker.js";
10
+ import { getOutputConfig } from "../config/output-config.js";
11
+ import { serializeResultToToon, } from "../utils/toon-serializer.js";
12
+ // Global memory storage for session persistence
13
+ let sessionMemory = null;
14
+ export const conversationMemorySchema = {
15
+ type: "object",
16
+ properties: {
17
+ action: {
18
+ type: "string",
19
+ enum: ["compress", "restore", "get_memory", "clear", "extract_decisions"],
20
+ description: "Action to perform",
21
+ },
22
+ messages: {
23
+ type: "array",
24
+ items: {
25
+ type: "object",
26
+ properties: {
27
+ role: { type: "string", enum: ["user", "assistant", "system"] },
28
+ content: { type: "string" },
29
+ },
30
+ required: ["role", "content"],
31
+ },
32
+ description: "Conversation messages (for compress action)",
33
+ },
34
+ strategy: {
35
+ type: "string",
36
+ enum: ["rolling-summary", "key-extraction", "hybrid"],
37
+ description: "Compression strategy (default: hybrid)",
38
+ },
39
+ maxTokens: {
40
+ type: "number",
41
+ description: "Maximum tokens for output (default: 10000)",
42
+ },
43
+ preserveLastN: {
44
+ type: "number",
45
+ description: "Number of recent messages to preserve (default: 2)",
46
+ },
47
+ includeSummary: {
48
+ type: "boolean",
49
+ description: "Include summary in restored context (default: true)",
50
+ },
51
+ includeDecisions: {
52
+ type: "boolean",
53
+ description: "Include decisions in restored context (default: true)",
54
+ },
55
+ includeCodeRefs: {
56
+ type: "boolean",
57
+ description: "Include code references in restored context (default: true)",
58
+ },
59
+ recentMessages: {
60
+ type: "number",
61
+ description: "Number of recent messages to include in restoration (default: 3)",
62
+ },
63
+ },
64
+ required: ["action"],
65
+ };
66
+ const messageSchema = z.object({
67
+ role: z.enum(["user", "assistant", "system"]),
68
+ content: z.string(),
69
+ });
70
+ const inputSchema = z.object({
71
+ action: z.enum(["compress", "restore", "get_memory", "clear", "extract_decisions"]),
72
+ messages: z.array(messageSchema).optional(),
73
+ strategy: z
74
+ .enum(["rolling-summary", "key-extraction", "hybrid"])
75
+ .optional()
76
+ .default("hybrid"),
77
+ maxTokens: z.number().optional().default(10000),
78
+ preserveLastN: z.number().optional().default(2),
79
+ includeSummary: z.boolean().optional().default(true),
80
+ includeDecisions: z.boolean().optional().default(true),
81
+ includeCodeRefs: z.boolean().optional().default(true),
82
+ recentMessages: z.number().optional().default(3),
83
+ });
84
+ /**
85
+ * Format memory summary for display
86
+ */
87
+ function formatMemorySummary(memory) {
88
+ const parts = [];
89
+ parts.push("[Memory Summary]");
90
+ parts.push(`Summary: ${memory.summary}`);
91
+ parts.push(`Decisions: ${memory.decisions.length}`);
92
+ parts.push(`Code References: ${memory.codeReferences.length}`);
93
+ parts.push(`Messages: ${memory.compressedHistory.length}`);
94
+ parts.push(`Last Updated: ${new Date(memory.lastUpdated).toISOString()}`);
95
+ if (memory.decisions.length > 0) {
96
+ parts.push("");
97
+ parts.push("[Recent Decisions]");
98
+ for (const d of memory.decisions.slice(-5)) {
99
+ parts.push(`- ${d.decision}`);
100
+ }
101
+ }
102
+ if (memory.codeReferences.length > 0) {
103
+ parts.push("");
104
+ parts.push("[Code References]");
105
+ const created = memory.codeReferences.filter((r) => r.action === "created");
106
+ const modified = memory.codeReferences.filter((r) => r.action === "modified");
107
+ if (created.length > 0) {
108
+ parts.push(`Created: ${created.map((r) => r.file).slice(0, 5).join(", ")}`);
109
+ }
110
+ if (modified.length > 0) {
111
+ parts.push(`Modified: ${modified.map((r) => r.file).slice(0, 5).join(", ")}`);
112
+ }
113
+ }
114
+ return parts.join("\n");
115
+ }
116
+ /**
117
+ * Format output based on config
118
+ */
119
+ function formatOutput(result, name) {
120
+ const config = getOutputConfig();
121
+ if (config.mode === "toon" || config.useToon) {
122
+ const schema = { name };
123
+ return serializeResultToToon(result, schema, {
124
+ verbosity: config.verbosity,
125
+ includeStats: config.includeStats,
126
+ });
127
+ }
128
+ if (typeof result === "string") {
129
+ return result;
130
+ }
131
+ return JSON.stringify(result, null, 2);
132
+ }
133
+ /**
134
+ * Execute conversation memory tool
135
+ */
136
+ async function executeConversationMemory(args) {
137
+ const input = inputSchema.parse(args);
138
+ switch (input.action) {
139
+ case "compress": {
140
+ if (!input.messages || input.messages.length === 0) {
141
+ return {
142
+ content: [
143
+ {
144
+ type: "text",
145
+ text: "Error: messages array required for compress action",
146
+ },
147
+ ],
148
+ };
149
+ }
150
+ const messages = input.messages;
151
+ const result = compressConversationWithMemory(messages, {
152
+ strategy: input.strategy,
153
+ maxTokens: input.maxTokens,
154
+ preserveSystem: true,
155
+ preserveLastN: input.preserveLastN,
156
+ });
157
+ // Store in session memory
158
+ sessionMemory = result.memory;
159
+ // Track usage
160
+ const tokensSaved = result.stats.originalTokens - result.stats.compressedTokens;
161
+ getSessionTracker().recordInvocation("conversation_memory", result.stats.originalTokens, result.stats.compressedTokens, tokensSaved, 0);
162
+ const output = [
163
+ `[Compressed] ${result.stats.originalTokens}→${result.stats.compressedTokens} tokens (-${Math.round((1 - result.stats.compressedTokens / result.stats.originalTokens) * 100)}%)`,
164
+ `Decisions: ${result.stats.decisionsExtracted}, Code Refs: ${result.stats.codeRefsFound}`,
165
+ "",
166
+ result.context,
167
+ ].join("\n");
168
+ return {
169
+ content: [{ type: "text", text: output }],
170
+ };
171
+ }
172
+ case "restore": {
173
+ if (!sessionMemory) {
174
+ return {
175
+ content: [
176
+ {
177
+ type: "text",
178
+ text: "No memory stored. Use compress action first.",
179
+ },
180
+ ],
181
+ };
182
+ }
183
+ const context = restoreContext(sessionMemory, {
184
+ includeSummary: input.includeSummary,
185
+ includeDecisions: input.includeDecisions,
186
+ includeCodeRefs: input.includeCodeRefs,
187
+ recentMessages: input.recentMessages,
188
+ });
189
+ return {
190
+ content: [{ type: "text", text: context }],
191
+ };
192
+ }
193
+ case "get_memory": {
194
+ if (!sessionMemory) {
195
+ return {
196
+ content: [
197
+ {
198
+ type: "text",
199
+ text: "No memory stored. Use compress action first.",
200
+ },
201
+ ],
202
+ };
203
+ }
204
+ const output = formatMemorySummary(sessionMemory);
205
+ return {
206
+ content: [{ type: "text", text: output }],
207
+ };
208
+ }
209
+ case "clear": {
210
+ sessionMemory = null;
211
+ return {
212
+ content: [
213
+ {
214
+ type: "text",
215
+ text: "Memory cleared.",
216
+ },
217
+ ],
218
+ };
219
+ }
220
+ case "extract_decisions": {
221
+ if (!input.messages || input.messages.length === 0) {
222
+ return {
223
+ content: [
224
+ {
225
+ type: "text",
226
+ text: "Error: messages array required for extract_decisions action",
227
+ },
228
+ ],
229
+ };
230
+ }
231
+ const messages = input.messages;
232
+ const decisions = extractDecisions(messages);
233
+ const codeRefs = extractCodeReferences(messages);
234
+ const parts = [];
235
+ parts.push(`[Extracted] ${decisions.length} decisions, ${codeRefs.length} code references`);
236
+ parts.push("");
237
+ if (decisions.length > 0) {
238
+ parts.push("[Decisions]");
239
+ for (const d of decisions) {
240
+ parts.push(`- ${d.decision}`);
241
+ }
242
+ parts.push("");
243
+ }
244
+ if (codeRefs.length > 0) {
245
+ parts.push("[Code References]");
246
+ const byAction = new Map();
247
+ for (const ref of codeRefs) {
248
+ if (!byAction.has(ref.action)) {
249
+ byAction.set(ref.action, []);
250
+ }
251
+ byAction.get(ref.action).push(ref.file);
252
+ }
253
+ for (const [action, files] of byAction) {
254
+ parts.push(`${action}: ${files.join(", ")}`);
255
+ }
256
+ }
257
+ return {
258
+ content: [{ type: "text", text: parts.join("\n") }],
259
+ };
260
+ }
261
+ default:
262
+ return {
263
+ content: [
264
+ {
265
+ type: "text",
266
+ text: `Unknown action: ${input.action}`,
267
+ },
268
+ ],
269
+ };
270
+ }
271
+ }
272
+ export const conversationMemoryTool = {
273
+ name: "conversation_memory",
274
+ description: "Manage long conversation context. Actions: compress (with decision extraction), restore, get_memory, clear, extract_decisions.",
275
+ inputSchema: conversationMemorySchema,
276
+ execute: executeConversationMemory,
277
+ };
278
+ /**
279
+ * Get current session memory (for SDK use)
280
+ */
281
+ export function getSessionMemory() {
282
+ return sessionMemory;
283
+ }
284
+ /**
285
+ * Set session memory (for SDK use)
286
+ */
287
+ export function setSessionMemory(memory) {
288
+ sessionMemory = memory;
289
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Deduplicate Errors Tool
3
+ *
4
+ * Detects and deduplicates repetitive errors in build/test outputs,
5
+ * keeping only unique occurrences with counters.
6
+ */
7
+ import type { ToolDefinition } from "./registry.js";
8
+ export declare const deduplicateErrorsSchema: {
9
+ type: "object";
10
+ properties: {
11
+ content: {
12
+ type: string;
13
+ };
14
+ threshold: {
15
+ type: string;
16
+ };
17
+ keepFirst: {
18
+ type: string;
19
+ };
20
+ };
21
+ required: string[];
22
+ };
23
+ export declare function executeDeduplicateErrors(args: unknown): Promise<{
24
+ content: Array<{
25
+ type: "text";
26
+ text: string;
27
+ }>;
28
+ }>;
29
+ export declare const deduplicateErrorsTool: ToolDefinition;
30
+ //# sourceMappingURL=deduplicate-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicate-errors.d.ts","sourceRoot":"","sources":["../../src/tools/deduplicate-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AASpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;CAQnC,CAAC;AASF,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAgD7D;AAED,eAAO,MAAM,qBAAqB,EAAE,cAMnC,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Deduplicate Errors Tool
3
+ *
4
+ * Detects and deduplicates repetitive errors in build/test outputs,
5
+ * keeping only unique occurrences with counters.
6
+ */
7
+ import { z } from "zod";
8
+ import { groupBySignature, formatGroups, calculateStats, } from "../utils/signature-grouper.js";
9
+ // Minimal schema - errorPattern rarely used
10
+ export const deduplicateErrorsSchema = {
11
+ type: "object",
12
+ properties: {
13
+ content: { type: "string" },
14
+ threshold: { type: "number" },
15
+ keepFirst: { type: "number" },
16
+ },
17
+ required: ["content"],
18
+ };
19
+ const inputSchema = z.object({
20
+ content: z.string(),
21
+ threshold: z.number().min(1).optional().default(2),
22
+ keepFirst: z.number().min(0).optional().default(1),
23
+ errorPattern: z.string().optional(),
24
+ });
25
+ export async function executeDeduplicateErrors(args) {
26
+ const { content, threshold, keepFirst, errorPattern } = inputSchema.parse(args);
27
+ // Parse custom pattern if provided
28
+ let customPattern;
29
+ if (errorPattern) {
30
+ try {
31
+ customPattern = new RegExp(errorPattern, "gm");
32
+ }
33
+ catch {
34
+ return {
35
+ content: [
36
+ {
37
+ type: "text",
38
+ text: `**Error:** Invalid regex pattern: ${errorPattern}`,
39
+ },
40
+ ],
41
+ };
42
+ }
43
+ }
44
+ // Split content into lines
45
+ const lines = content.split("\n");
46
+ // Group by signature
47
+ const options = {
48
+ threshold,
49
+ keepFirst,
50
+ customPattern,
51
+ };
52
+ const result = groupBySignature(lines, options);
53
+ const stats = calculateStats(result);
54
+ if (result.groups.size === 0) {
55
+ return {
56
+ content: [{ type: "text", text: "No errors detected." }],
57
+ };
58
+ }
59
+ // Formatted groups
60
+ const formattedGroups = formatGroups(result, "markdown", options);
61
+ // Minimal header
62
+ const header = `[dedup] ${stats.uniqueErrors} patterns, ${stats.totalDuplicates} duplicates removed (-${stats.reductionPercent}%)`;
63
+ return {
64
+ content: [{ type: "text", text: `${header}\n${formattedGroups}` }],
65
+ };
66
+ }
67
+ export const deduplicateErrorsTool = {
68
+ name: "deduplicate_errors",
69
+ description: "Group repeated errors. Shows unique patterns with count and affected files.",
70
+ inputSchema: deduplicateErrorsSchema,
71
+ execute: executeDeduplicateErrors,
72
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Detect Retry Loop Tool
3
+ *
4
+ * Analyzes command history to detect retry loops - patterns where
5
+ * the same command is being executed repeatedly, often indicating
6
+ * an unresolved build/test failure.
7
+ */
8
+ import type { ToolDefinition } from "./registry.js";
9
+ export declare const detectRetryLoopSchema: {
10
+ type: "object";
11
+ properties: {
12
+ commands: {
13
+ type: string;
14
+ items: {
15
+ type: string;
16
+ };
17
+ description: string;
18
+ };
19
+ errors: {
20
+ type: string;
21
+ items: {
22
+ type: string;
23
+ };
24
+ description: string;
25
+ };
26
+ threshold: {
27
+ type: string;
28
+ description: string;
29
+ };
30
+ };
31
+ required: string[];
32
+ };
33
+ export declare function executeDetectRetryLoop(args: unknown): Promise<{
34
+ content: Array<{
35
+ type: "text";
36
+ text: string;
37
+ }>;
38
+ }>;
39
+ export declare const detectRetryLoopTool: ToolDefinition;
40
+ //# sourceMappingURL=detect-retry-loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-retry-loop.d.ts","sourceRoot":"","sources":["../../src/tools/detect-retry-loop.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQpD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;CAmBjC,CAAC;AA0KF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA2C7D;AAED,eAAO,MAAM,mBAAmB,EAAE,cAMjC,CAAC"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Detect Retry Loop Tool
3
+ *
4
+ * Analyzes command history to detect retry loops - patterns where
5
+ * the same command is being executed repeatedly, often indicating
6
+ * an unresolved build/test failure.
7
+ */
8
+ import { z } from "zod";
9
+ import { normalizeCommand, getBaseCommand, areCommandsSimilar, } from "../utils/command-normalizer.js";
10
+ export const detectRetryLoopSchema = {
11
+ type: "object",
12
+ properties: {
13
+ commands: {
14
+ type: "array",
15
+ items: { type: "string" },
16
+ description: "Recent command history (most recent last)",
17
+ },
18
+ errors: {
19
+ type: "array",
20
+ items: { type: "string" },
21
+ description: "Optional: error outputs associated with commands",
22
+ },
23
+ threshold: {
24
+ type: "number",
25
+ description: "Minimum repetitions to consider a loop (default: 3)",
26
+ },
27
+ },
28
+ required: ["commands"],
29
+ };
30
+ const inputSchema = z.object({
31
+ commands: z.array(z.string()).min(1),
32
+ errors: z.array(z.string()).optional(),
33
+ threshold: z.number().min(2).optional().default(3),
34
+ });
35
+ /**
36
+ * Analyze commands to find retry patterns
37
+ */
38
+ function analyzeRetryPatterns(commands, threshold) {
39
+ const groups = new Map();
40
+ for (const cmd of commands) {
41
+ const normalized = normalizeCommand(cmd);
42
+ const existing = groups.get(normalized) || [];
43
+ existing.push(cmd);
44
+ groups.set(normalized, existing);
45
+ }
46
+ let maxRepetitions = 0;
47
+ let mostRepeated = null;
48
+ for (const [normalized, cmds] of groups.entries()) {
49
+ if (cmds.length > maxRepetitions) {
50
+ maxRepetitions = cmds.length;
51
+ mostRepeated = normalized;
52
+ }
53
+ }
54
+ return { groups, maxRepetitions, mostRepeated };
55
+ }
56
+ /**
57
+ * Count consecutive runs of similar commands at the end of history
58
+ */
59
+ function countConsecutiveRuns(commands) {
60
+ if (commands.length === 0)
61
+ return 0;
62
+ const lastCmd = commands[commands.length - 1];
63
+ let count = 1;
64
+ for (let i = commands.length - 2; i >= 0; i--) {
65
+ if (areCommandsSimilar(commands[i], lastCmd)) {
66
+ count++;
67
+ }
68
+ else {
69
+ break;
70
+ }
71
+ }
72
+ return count;
73
+ }
74
+ /**
75
+ * Detect the type of command (build, test, lint, etc.)
76
+ */
77
+ function detectCommandType(cmd) {
78
+ const lower = cmd.toLowerCase();
79
+ if (/\btest\b|vitest|jest|mocha|ava/.test(lower))
80
+ return "test";
81
+ if (/\bbuild\b|compile|tsc\b/.test(lower))
82
+ return "build";
83
+ if (/\blint\b|eslint|prettier/.test(lower))
84
+ return "lint";
85
+ if (/\bcheck\b|type-check/.test(lower))
86
+ return "typecheck";
87
+ if (/\bformat\b/.test(lower))
88
+ return "format";
89
+ if (/cargo\s+(build|test|check)/.test(lower))
90
+ return lower.includes("test") ? "test" : "build";
91
+ if (/go\s+(build|test)/.test(lower))
92
+ return lower.includes("test") ? "test" : "build";
93
+ return "command";
94
+ }
95
+ /**
96
+ * Generate suggestions based on the loop type and errors
97
+ */
98
+ function generateSuggestions(loopType, baseCommand, errors) {
99
+ const suggestions = [];
100
+ // Common suggestions based on loop type
101
+ switch (loopType) {
102
+ case "build":
103
+ suggestions.push("Check the specific error message for the root cause");
104
+ suggestions.push("Try `git stash` to test with a clean working state");
105
+ suggestions.push("Look for circular dependencies or missing imports");
106
+ break;
107
+ case "test":
108
+ suggestions.push("Run a single failing test to isolate the issue");
109
+ suggestions.push("Check if tests depend on external state or services");
110
+ suggestions.push("Review test fixtures and mock data");
111
+ break;
112
+ case "lint":
113
+ suggestions.push("Run with --fix flag to auto-correct issues");
114
+ suggestions.push("Check if rules are conflicting with each other");
115
+ suggestions.push("Consider disabling the problematic rule temporarily");
116
+ break;
117
+ case "typecheck":
118
+ suggestions.push("Check for missing type definitions (@types/*)");
119
+ suggestions.push("Look for incorrect generic type usage");
120
+ suggestions.push("Review recent changes to shared type files");
121
+ break;
122
+ }
123
+ // Error-based suggestions
124
+ if (errors && errors.length > 0) {
125
+ const errorText = errors.join("\n").toLowerCase();
126
+ if (errorText.includes("cannot find module") || errorText.includes("module not found")) {
127
+ suggestions.unshift("Run `npm install` or `bun install` to install missing dependencies");
128
+ }
129
+ if (errorText.includes("enoent") || errorText.includes("no such file")) {
130
+ suggestions.unshift("Check if referenced files exist and paths are correct");
131
+ }
132
+ if (errorText.includes("permission denied") || errorText.includes("eacces")) {
133
+ suggestions.unshift("Check file permissions or run with appropriate privileges");
134
+ }
135
+ if (errorText.includes("out of memory") || errorText.includes("heap")) {
136
+ suggestions.unshift("Increase Node.js memory limit with --max-old-space-size");
137
+ }
138
+ if (errorText.includes("timeout") || errorText.includes("timed out")) {
139
+ suggestions.unshift("Check for infinite loops or long-running operations");
140
+ }
141
+ }
142
+ // General suggestion
143
+ suggestions.push("Consider using `deduplicate_errors` to group similar errors");
144
+ return [...new Set(suggestions)].slice(0, 5);
145
+ }
146
+ /**
147
+ * Format the analysis result
148
+ */
149
+ function formatResult(result) {
150
+ const parts = [];
151
+ if (result.isLoop) {
152
+ parts.push("## Retry Loop Detected\n");
153
+ parts.push(`**Command**: \`${result.baseCommand}\``);
154
+ parts.push(`**Type**: ${result.loopType}`);
155
+ parts.push(`**Total runs**: ${result.repetitions}`);
156
+ parts.push(`**Consecutive runs**: ${result.consecutiveRuns}`);
157
+ parts.push("");
158
+ parts.push("### Suggestions\n");
159
+ result.suggestions.forEach((s, i) => {
160
+ parts.push(`${i + 1}. ${s}`);
161
+ });
162
+ }
163
+ else {
164
+ parts.push("## No Retry Loop Detected\n");
165
+ parts.push(result.analysis);
166
+ }
167
+ return parts.join("\n");
168
+ }
169
+ export async function executeDetectRetryLoop(args) {
170
+ const { commands, errors, threshold } = inputSchema.parse(args);
171
+ // Analyze patterns
172
+ const { maxRepetitions, mostRepeated } = analyzeRetryPatterns(commands, threshold);
173
+ const consecutiveRuns = countConsecutiveRuns(commands);
174
+ // Determine if this is a retry loop
175
+ const isLoop = maxRepetitions >= threshold || consecutiveRuns >= threshold;
176
+ let result;
177
+ if (isLoop && mostRepeated) {
178
+ const loopType = detectCommandType(mostRepeated);
179
+ const baseCommand = getBaseCommand(mostRepeated);
180
+ const suggestions = generateSuggestions(loopType, baseCommand, errors);
181
+ result = {
182
+ isLoop: true,
183
+ loopType,
184
+ baseCommand: mostRepeated,
185
+ repetitions: maxRepetitions,
186
+ consecutiveRuns,
187
+ suggestions,
188
+ analysis: `Detected ${maxRepetitions} runs of similar ${loopType} command`,
189
+ };
190
+ }
191
+ else {
192
+ result = {
193
+ isLoop: false,
194
+ loopType: null,
195
+ baseCommand: null,
196
+ repetitions: maxRepetitions,
197
+ consecutiveRuns,
198
+ suggestions: [],
199
+ analysis: `No retry loop detected. Max command repetitions: ${maxRepetitions}, Consecutive: ${consecutiveRuns}`,
200
+ };
201
+ }
202
+ const output = formatResult(result);
203
+ return {
204
+ content: [{ type: "text", text: output }],
205
+ };
206
+ }
207
+ export const detectRetryLoopTool = {
208
+ name: "detect_retry_loop",
209
+ description: "Detect retry loops in command history. Identifies when build/test commands are being repeatedly executed without success, and suggests alternative approaches.",
210
+ inputSchema: detectRetryLoopSchema,
211
+ execute: executeDetectRetryLoop,
212
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Diff Compress Tool
3
+ *
4
+ * Compress git diff output to reduce tokens while preserving essential changes.
5
+ * Supports three strategies: hunks-only, summary, and semantic.
6
+ */
7
+ import type { ToolDefinition } from "./registry.js";
8
+ /**
9
+ * JSON Schema for MCP tool registration
10
+ */
11
+ export declare const diffCompressSchema: {
12
+ type: "object";
13
+ properties: {
14
+ diff: {
15
+ type: string;
16
+ };
17
+ strategy: {
18
+ enum: string[];
19
+ };
20
+ maxTokens: {
21
+ type: string;
22
+ };
23
+ };
24
+ required: string[];
25
+ };
26
+ /**
27
+ * Execute diff compression
28
+ */
29
+ export declare function executeDiffCompress(args: unknown): Promise<{
30
+ content: Array<{
31
+ type: "text";
32
+ text: string;
33
+ }>;
34
+ isError?: boolean;
35
+ }>;
36
+ /**
37
+ * Tool definition for MCP registration
38
+ */
39
+ export declare const diffCompressTool: ToolDefinition;
40
+ //# sourceMappingURL=diff-compress.d.ts.map