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,127 @@
1
+ import { execSync } from "child_process";
2
+ import { existsSync } from "fs";
3
+ import { detectInstalledIDEs, readJSONFile, isCtxOptConfigured, success, warn, error, log, COLORS, getPackageVersion, } from "./utils.js";
4
+ function checkNodeVersion() {
5
+ try {
6
+ const version = process.version;
7
+ const major = parseInt(version.slice(1).split(".")[0] ?? "0", 10);
8
+ if (major >= 18) {
9
+ return {
10
+ name: "Node.js version",
11
+ status: "pass",
12
+ message: `${version} (>= 18 required)`,
13
+ };
14
+ }
15
+ else {
16
+ return {
17
+ name: "Node.js version",
18
+ status: "fail",
19
+ message: `${version} (>= 18 required, please upgrade)`,
20
+ };
21
+ }
22
+ }
23
+ catch {
24
+ return {
25
+ name: "Node.js version",
26
+ status: "fail",
27
+ message: "Unable to determine Node.js version",
28
+ };
29
+ }
30
+ }
31
+ function checkPackageInstallation() {
32
+ try {
33
+ // Check if ctxopt-mcp is in PATH
34
+ const which = process.platform === "win32" ? "where" : "which";
35
+ execSync(`${which} ctxopt-mcp`, { stdio: "pipe" });
36
+ return {
37
+ name: "Package installation",
38
+ status: "pass",
39
+ message: `@ctxopt/mcp-server v${getPackageVersion()} installed globally`,
40
+ };
41
+ }
42
+ catch {
43
+ return {
44
+ name: "Package installation",
45
+ status: "warn",
46
+ message: "ctxopt-mcp not found in PATH (may be running via npx)",
47
+ };
48
+ }
49
+ }
50
+ function checkIDEConfigurations() {
51
+ const results = [];
52
+ const ideConfigs = detectInstalledIDEs();
53
+ for (const [ide, config] of Object.entries(ideConfigs)) {
54
+ if (!config.detected) {
55
+ results.push({
56
+ name: `${config.name} configuration`,
57
+ status: "warn",
58
+ message: "IDE not detected",
59
+ });
60
+ continue;
61
+ }
62
+ const configFile = readJSONFile(config.configPath);
63
+ if (!existsSync(config.configPath)) {
64
+ results.push({
65
+ name: `${config.name} configuration`,
66
+ status: "warn",
67
+ message: `Config file not found at ${config.configPath}`,
68
+ });
69
+ continue;
70
+ }
71
+ if (isCtxOptConfigured(configFile)) {
72
+ results.push({
73
+ name: `${config.name} configuration`,
74
+ status: "pass",
75
+ message: `CtxOpt configured in ${config.configPath}`,
76
+ });
77
+ }
78
+ else {
79
+ results.push({
80
+ name: `${config.name} configuration`,
81
+ status: "fail",
82
+ message: `CtxOpt not configured. Run 'ctxopt-mcp setup --${ide}'`,
83
+ });
84
+ }
85
+ }
86
+ return results;
87
+ }
88
+ export async function doctor() {
89
+ log(`\n${COLORS.bright}${COLORS.cyan}CtxOpt MCP Server Doctor${COLORS.reset}\n`);
90
+ log(`Running diagnostic checks...\n`);
91
+ const checks = [
92
+ checkNodeVersion(),
93
+ checkPackageInstallation(),
94
+ ...checkIDEConfigurations(),
95
+ ];
96
+ let passCount = 0;
97
+ let warnCount = 0;
98
+ let failCount = 0;
99
+ for (const check of checks) {
100
+ switch (check.status) {
101
+ case "pass":
102
+ success(`${check.name}: ${check.message}`);
103
+ passCount++;
104
+ break;
105
+ case "warn":
106
+ warn(`${check.name}: ${check.message}`);
107
+ warnCount++;
108
+ break;
109
+ case "fail":
110
+ error(`${check.name}: ${check.message}`);
111
+ failCount++;
112
+ break;
113
+ }
114
+ }
115
+ log("\n" + "─".repeat(50));
116
+ if (failCount === 0 && warnCount === 0) {
117
+ success(`All ${passCount} checks passed! CtxOpt is ready to use.`);
118
+ }
119
+ else if (failCount === 0) {
120
+ warn(`${passCount} passed, ${warnCount} warnings. CtxOpt should work but may have limited functionality.`);
121
+ }
122
+ else {
123
+ error(`${passCount} passed, ${warnCount} warnings, ${failCount} failed.`);
124
+ log(`\nRun ${COLORS.cyan}ctxopt-mcp setup${COLORS.reset} to fix configuration issues.`);
125
+ }
126
+ log("");
127
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * CtxOpt Hooks Installation Module
3
+ *
4
+ * Installs Claude Code hooks that suggest MCP tool usage:
5
+ * - PreToolUse: Suggests smart_file_read for code files (non-blocking for Edit compatibility)
6
+ * - PostToolUse: Reminds to use auto_optimize for large Bash outputs
7
+ * - UserPromptSubmit: Injects MCP tool reminders
8
+ */
9
+ export interface InstallHooksOptions {
10
+ projectDir?: string;
11
+ force?: boolean;
12
+ }
13
+ export declare function installHooks(options?: InstallHooksOptions): Promise<boolean>;
14
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/cli/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+JH,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqGtF"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * CtxOpt Hooks Installation Module
3
+ *
4
+ * Installs Claude Code hooks that suggest MCP tool usage:
5
+ * - PreToolUse: Suggests smart_file_read for code files (non-blocking for Edit compatibility)
6
+ * - PostToolUse: Reminds to use auto_optimize for large Bash outputs
7
+ * - UserPromptSubmit: Injects MCP tool reminders
8
+ */
9
+ import { existsSync, mkdirSync, writeFileSync, chmodSync } from "fs";
10
+ import { join } from "path";
11
+ import { success, warn, info, error, log, COLORS, readJSONFile, writeJSONFile } from "./utils.js";
12
+ // ============================================================================
13
+ // Hook Script Templates
14
+ // ============================================================================
15
+ const PRE_READ_CHECK_SCRIPT = `#!/bin/bash
16
+ # CtxOpt - PreToolUse Hook for Read
17
+ # Suggests smart_file_read for code files (non-blocking to allow Edit to work)
18
+
19
+ INPUT=$(cat)
20
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
21
+ BASENAME=$(basename "$FILE_PATH")
22
+
23
+ # Skip suggestion for configuration files
24
+ if echo "$BASENAME" | grep -qiE "^(CLAUDE|README|CHANGELOG|LICENSE)"; then
25
+ exit 0
26
+ fi
27
+ if echo "$BASENAME" | grep -qiE "\\.(md|json|yaml|yml|toml|ini|config)$"; then
28
+ exit 0
29
+ fi
30
+ if echo "$BASENAME" | grep -qiE "^(Dockerfile|Makefile|\\.gitignore|\\.env|\\.prettierrc|\\.eslintrc)"; then
31
+ exit 0
32
+ fi
33
+
34
+ # Suggest smart_file_read for source code files (non-blocking)
35
+ if echo "$FILE_PATH" | grep -qE "\\.(ts|tsx|js|jsx|py|go|rs|java|cpp|c|h|hpp)$"; then
36
+ # Use systemMessage to suggest without blocking (allows Edit to work)
37
+ cat << EOF
38
+ {"systemMessage": "TIP: Consider using mcp__ctxopt__smart_file_read for '\$BASENAME' to save 50-70% tokens. Example: mcp__ctxopt__smart_file_read filePath=\\"\$FILE_PATH\\" target={\\"type\\":\\"function\\",\\"name\\":\\"myFunc\\"}"}
39
+ EOF
40
+ exit 0
41
+ fi
42
+
43
+ # Allow everything else
44
+ exit 0
45
+ `;
46
+ const POST_BASH_REMIND_SCRIPT = `#!/bin/bash
47
+ # CtxOpt - PostToolUse Hook for Bash
48
+ # Reminds to use MCP tools for large outputs
49
+
50
+ INPUT=$(cat)
51
+ TOOL_RESPONSE=$(echo "$INPUT" | jq -r '.tool_response // empty')
52
+ RESPONSE_SIZE=\${#TOOL_RESPONSE}
53
+
54
+ # Threshold: 5000 chars ~ 1250 tokens
55
+ THRESHOLD=5000
56
+
57
+ # Skip if output is small
58
+ if [ "$RESPONSE_SIZE" -lt "$THRESHOLD" ]; then
59
+ exit 0
60
+ fi
61
+
62
+ # Detect content type and suggest appropriate tool
63
+ if echo "$TOOL_RESPONSE" | grep -qiE "(error TS|warning TS|error\\[E|npm ERR|ERROR in|failed|FAILED)"; then
64
+ echo '{"systemMessage": "TIP: Large build output detected. Use mcp__ctxopt__auto_optimize to compress errors (95%+ reduction)."}'
65
+ exit 0
66
+ fi
67
+
68
+ if echo "$TOOL_RESPONSE" | grep -qiE "(\\[INFO\\]|\\[ERROR\\]|\\[WARN\\]|\\[DEBUG\\]|[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2})"; then
69
+ echo '{"systemMessage": "TIP: Large log output detected. Use mcp__ctxopt__summarize_logs to compress (80-90% reduction)."}'
70
+ exit 0
71
+ fi
72
+
73
+ # Generic large output
74
+ echo '{"systemMessage": "TIP: Large output ('$RESPONSE_SIZE' chars). Consider using mcp__ctxopt__auto_optimize for compression (40-60% reduction)."}'
75
+ exit 0
76
+ `;
77
+ const PROMPT_INJECT_SCRIPT = `#!/bin/bash
78
+ # CtxOpt - UserPromptSubmit Hook
79
+ # Injects MCP tool reminders at the start of each prompt
80
+
81
+ cat << 'EOF'
82
+ <user-prompt-submit-hook>
83
+ CTXOPT REMINDER: Use MCP tools for token optimization:
84
+ - Code files: mcp__ctxopt__smart_file_read (50-70% savings vs Read)
85
+ - Build/test output: mcp__ctxopt__auto_optimize
86
+ - Session stats: mcp__ctxopt__session_stats
87
+ </user-prompt-submit-hook>
88
+ EOF
89
+ exit 0
90
+ `;
91
+ function createHooksConfig() {
92
+ return {
93
+ hooks: {
94
+ UserPromptSubmit: [
95
+ {
96
+ matcher: "",
97
+ hooks: [
98
+ {
99
+ type: "command",
100
+ command: '"$CLAUDE_PROJECT_DIR/.claude/hooks/prompt-inject.sh"',
101
+ timeout: 2,
102
+ },
103
+ ],
104
+ },
105
+ ],
106
+ PreToolUse: [
107
+ {
108
+ matcher: "Read",
109
+ hooks: [
110
+ {
111
+ type: "command",
112
+ command: '"$CLAUDE_PROJECT_DIR/.claude/hooks/pre-read-check.sh"',
113
+ timeout: 2,
114
+ },
115
+ ],
116
+ },
117
+ ],
118
+ PostToolUse: [
119
+ {
120
+ matcher: "Bash",
121
+ hooks: [
122
+ {
123
+ type: "command",
124
+ command: '"$CLAUDE_PROJECT_DIR/.claude/hooks/post-bash-remind.sh"',
125
+ timeout: 5,
126
+ },
127
+ ],
128
+ },
129
+ ],
130
+ },
131
+ };
132
+ }
133
+ export async function installHooks(options = {}) {
134
+ const projectDir = options.projectDir || process.cwd();
135
+ const force = options.force || false;
136
+ log(`\n${COLORS.bright}Installing CtxOpt hooks...${COLORS.reset}\n`);
137
+ // Check for jq dependency
138
+ info("Checking dependencies...");
139
+ const jqCheck = checkJqInstalled();
140
+ if (!jqCheck) {
141
+ warn("jq is not installed. Hooks require jq for JSON parsing.");
142
+ log(`\nInstall jq:`);
143
+ log(` ${COLORS.dim}macOS:${COLORS.reset} brew install jq`);
144
+ log(` ${COLORS.dim}Ubuntu:${COLORS.reset} sudo apt install jq`);
145
+ log(` ${COLORS.dim}Windows:${COLORS.reset} choco install jq`);
146
+ log("");
147
+ }
148
+ // Create directories
149
+ const claudeDir = join(projectDir, ".claude");
150
+ const hooksDir = join(claudeDir, "hooks");
151
+ if (!existsSync(claudeDir)) {
152
+ mkdirSync(claudeDir, { recursive: true });
153
+ info(`Created ${COLORS.dim}.claude/${COLORS.reset}`);
154
+ }
155
+ if (!existsSync(hooksDir)) {
156
+ mkdirSync(hooksDir, { recursive: true });
157
+ info(`Created ${COLORS.dim}.claude/hooks/${COLORS.reset}`);
158
+ }
159
+ // Write hook scripts
160
+ const hookFiles = {
161
+ "pre-read-check.sh": PRE_READ_CHECK_SCRIPT,
162
+ "post-bash-remind.sh": POST_BASH_REMIND_SCRIPT,
163
+ "prompt-inject.sh": PROMPT_INJECT_SCRIPT,
164
+ };
165
+ let scriptsWritten = 0;
166
+ for (const [filename, content] of Object.entries(hookFiles)) {
167
+ const filepath = join(hooksDir, filename);
168
+ if (existsSync(filepath) && !force) {
169
+ warn(`Skipped ${filename} (already exists, use --force to overwrite)`);
170
+ continue;
171
+ }
172
+ writeFileSync(filepath, content, "utf-8");
173
+ chmodSync(filepath, 0o755); // Make executable
174
+ success(`Created ${COLORS.dim}.claude/hooks/${COLORS.reset}${filename}`);
175
+ scriptsWritten++;
176
+ }
177
+ // Update settings.local.json
178
+ const settingsPath = join(claudeDir, "settings.local.json");
179
+ let settingsUpdated = false;
180
+ try {
181
+ let existingSettings = {};
182
+ if (existsSync(settingsPath)) {
183
+ existingSettings = (await readJSONFile(settingsPath)) || {};
184
+ }
185
+ const hooksConfig = createHooksConfig();
186
+ // Merge hooks config with existing settings
187
+ const newSettings = {
188
+ ...existingSettings,
189
+ hooks: {
190
+ ...(existingSettings.hooks || {}),
191
+ ...hooksConfig.hooks,
192
+ },
193
+ };
194
+ await writeJSONFile(settingsPath, newSettings);
195
+ success(`Updated ${COLORS.dim}.claude/${COLORS.reset}settings.local.json`);
196
+ settingsUpdated = true;
197
+ }
198
+ catch (err) {
199
+ error(`Failed to update settings.local.json: ${err}`);
200
+ }
201
+ // Summary
202
+ log("\n" + "─".repeat(50));
203
+ if (scriptsWritten > 0 || settingsUpdated) {
204
+ success("Hooks installed successfully!");
205
+ log(`\n${COLORS.dim}What the hooks do:${COLORS.reset}`);
206
+ log(` • ${COLORS.yellow}PreToolUse[Read]${COLORS.reset} Suggests smart_file_read for code files`);
207
+ log(` • ${COLORS.yellow}PostToolUse[Bash]${COLORS.reset} Suggests compression for large outputs`);
208
+ log(` • ${COLORS.yellow}UserPromptSubmit${COLORS.reset} Reminds to use MCP tools`);
209
+ log(`\n${COLORS.dim}Token savings:${COLORS.reset}`);
210
+ log(` • smart_file_read: 50-70% reduction vs Read`);
211
+ log(` • auto_optimize: 95%+ reduction on build errors`);
212
+ log(` • summarize_logs: 80-90% reduction on logs\n`);
213
+ return true;
214
+ }
215
+ else {
216
+ warn("No changes made. Use --force to overwrite existing files.");
217
+ return false;
218
+ }
219
+ }
220
+ function checkJqInstalled() {
221
+ try {
222
+ const { execSync } = require("child_process");
223
+ execSync("jq --version", { stdio: "ignore" });
224
+ return true;
225
+ }
226
+ catch {
227
+ return false;
228
+ }
229
+ }
@@ -0,0 +1,5 @@
1
+ export { setup, parseSetupArgs, type SetupOptions } from "./setup.js";
2
+ export { doctor } from "./doctor.js";
3
+ export { installHooks, type InstallHooksOptions } from "./hooks.js";
4
+ export * from "./utils.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACpE,cAAc,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { setup, parseSetupArgs } from "./setup.js";
2
+ export { doctor } from "./doctor.js";
3
+ export { installHooks } from "./hooks.js";
4
+ export * from "./utils.js";
@@ -0,0 +1,10 @@
1
+ export interface SetupOptions {
2
+ claude?: boolean;
3
+ cursor?: boolean;
4
+ windsurf?: boolean;
5
+ force?: boolean;
6
+ hooks?: boolean;
7
+ }
8
+ export declare function setup(options?: SetupOptions): Promise<void>;
9
+ export declare function parseSetupArgs(args: string[]): SetupOptions;
10
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAyBD,wBAAsB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4ErE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,CAyB3D"}
@@ -0,0 +1,117 @@
1
+ import { detectInstalledIDEs, readJSONFile, writeJSONFile, getMCPServerConfig, isCtxOptConfigured, success, warn, error, info, log, COLORS, } from "./utils.js";
2
+ import { installHooks } from "./hooks.js";
3
+ function configureIDE(ide, config, force) {
4
+ log(`\nConfiguring ${COLORS.bright}${config.name}${COLORS.reset}...`);
5
+ const existingConfig = readJSONFile(config.configPath) || {};
6
+ if (isCtxOptConfigured(existingConfig) && !force) {
7
+ warn(`CtxOpt already configured in ${config.name}. Use --force to overwrite.`);
8
+ return true;
9
+ }
10
+ const mcpServers = existingConfig.mcpServers || {};
11
+ mcpServers.ctxopt = getMCPServerConfig();
12
+ existingConfig.mcpServers = mcpServers;
13
+ if (writeJSONFile(config.configPath, existingConfig)) {
14
+ success(`Configured ${config.name} at ${config.configPath}`);
15
+ return true;
16
+ }
17
+ else {
18
+ error(`Failed to write config to ${config.configPath}`);
19
+ return false;
20
+ }
21
+ }
22
+ export async function setup(options = {}) {
23
+ log(`\n${COLORS.bright}${COLORS.cyan}CtxOpt MCP Server Setup${COLORS.reset}\n`);
24
+ const ideConfigs = detectInstalledIDEs();
25
+ const specificIDEs = options.claude || options.cursor || options.windsurf;
26
+ const hooksOnly = options.hooks && !specificIDEs;
27
+ // If --hooks only (no IDE specified), just install hooks
28
+ if (hooksOnly) {
29
+ await installHooks({ force: options.force });
30
+ return;
31
+ }
32
+ const idesToConfigure = [];
33
+ if (specificIDEs) {
34
+ if (options.claude)
35
+ idesToConfigure.push("claude");
36
+ if (options.cursor)
37
+ idesToConfigure.push("cursor");
38
+ if (options.windsurf)
39
+ idesToConfigure.push("windsurf");
40
+ }
41
+ else {
42
+ // Auto-detect installed IDEs
43
+ for (const [ide, config] of Object.entries(ideConfigs)) {
44
+ if (config.detected) {
45
+ idesToConfigure.push(ide);
46
+ }
47
+ }
48
+ }
49
+ if (idesToConfigure.length === 0 && !options.hooks) {
50
+ warn("No supported IDEs detected.");
51
+ log("\nSupported IDEs:");
52
+ log(" • Claude Code");
53
+ log(" • Cursor");
54
+ log(" • Windsurf");
55
+ log("\nYou can manually configure by running:");
56
+ log(" ctxopt-mcp setup --claude");
57
+ log(" ctxopt-mcp setup --cursor");
58
+ log(" ctxopt-mcp setup --windsurf");
59
+ return;
60
+ }
61
+ if (idesToConfigure.length > 0) {
62
+ info(`Detected IDEs: ${idesToConfigure.map((ide) => ideConfigs[ide].name).join(", ")}`);
63
+ let successCount = 0;
64
+ let failCount = 0;
65
+ for (const ide of idesToConfigure) {
66
+ const result = configureIDE(ide, ideConfigs[ide], options.force || false);
67
+ if (result) {
68
+ successCount++;
69
+ }
70
+ else {
71
+ failCount++;
72
+ }
73
+ }
74
+ log("\n" + "─".repeat(50));
75
+ if (successCount > 0 && failCount === 0) {
76
+ success(`Setup complete! Configured ${successCount} IDE(s).`);
77
+ }
78
+ else if (successCount > 0) {
79
+ warn(`Partially complete. ${successCount} succeeded, ${failCount} failed.`);
80
+ }
81
+ else {
82
+ error("Setup failed. No IDEs were configured.");
83
+ }
84
+ }
85
+ // Install hooks if requested
86
+ if (options.hooks) {
87
+ await installHooks({ force: options.force });
88
+ }
89
+ log(`\n${COLORS.dim}Next steps:${COLORS.reset}`);
90
+ log(" 1. Restart your IDE to load the MCP server");
91
+ log(" 2. Run 'ctxopt-mcp doctor' to verify the installation");
92
+ log(` 3. Visit ${COLORS.cyan}https://ctxopt.dev/docs${COLORS.reset} for documentation\n`);
93
+ }
94
+ export function parseSetupArgs(args) {
95
+ const options = {};
96
+ for (const arg of args) {
97
+ switch (arg) {
98
+ case "--claude":
99
+ options.claude = true;
100
+ break;
101
+ case "--cursor":
102
+ options.cursor = true;
103
+ break;
104
+ case "--windsurf":
105
+ options.windsurf = true;
106
+ break;
107
+ case "--force":
108
+ case "-f":
109
+ options.force = true;
110
+ break;
111
+ case "--hooks":
112
+ options.hooks = true;
113
+ break;
114
+ }
115
+ }
116
+ return options;
117
+ }
@@ -0,0 +1,30 @@
1
+ export type IDE = "claude" | "cursor" | "windsurf";
2
+ export interface IDEConfig {
3
+ name: string;
4
+ configPath: string;
5
+ configKey: string;
6
+ detected: boolean;
7
+ }
8
+ export declare const COLORS: {
9
+ reset: string;
10
+ bright: string;
11
+ dim: string;
12
+ green: string;
13
+ yellow: string;
14
+ blue: string;
15
+ red: string;
16
+ cyan: string;
17
+ };
18
+ export declare function log(message: string): void;
19
+ export declare function success(message: string): void;
20
+ export declare function warn(message: string): void;
21
+ export declare function error(message: string): void;
22
+ export declare function info(message: string): void;
23
+ export declare function getIDEConfigPaths(): Record<IDE, IDEConfig>;
24
+ export declare function detectInstalledIDEs(): Record<IDE, IDEConfig>;
25
+ export declare function readJSONFile(path: string): Record<string, unknown> | null;
26
+ export declare function writeJSONFile(path: string, data: Record<string, unknown>): boolean;
27
+ export declare function getMCPServerConfig(): Record<string, unknown>;
28
+ export declare function isCtxOptConfigured(config: Record<string, unknown> | null): boolean;
29
+ export declare function getPackageVersion(): string;
30
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,MAAM;;;;;;;;;CASlB,CAAC;AAEF,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAgC1D;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAS5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUzE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAWlF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM5D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAIlF;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C"}
@@ -0,0 +1,116 @@
1
+ import { homedir, platform } from "os";
2
+ import { join } from "path";
3
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
4
+ export const COLORS = {
5
+ reset: "\x1b[0m",
6
+ bright: "\x1b[1m",
7
+ dim: "\x1b[2m",
8
+ green: "\x1b[32m",
9
+ yellow: "\x1b[33m",
10
+ blue: "\x1b[34m",
11
+ red: "\x1b[31m",
12
+ cyan: "\x1b[36m",
13
+ };
14
+ export function log(message) {
15
+ console.log(message);
16
+ }
17
+ export function success(message) {
18
+ console.log(`${COLORS.green}✓${COLORS.reset} ${message}`);
19
+ }
20
+ export function warn(message) {
21
+ console.log(`${COLORS.yellow}⚠${COLORS.reset} ${message}`);
22
+ }
23
+ export function error(message) {
24
+ console.log(`${COLORS.red}✗${COLORS.reset} ${message}`);
25
+ }
26
+ export function info(message) {
27
+ console.log(`${COLORS.blue}ℹ${COLORS.reset} ${message}`);
28
+ }
29
+ export function getIDEConfigPaths() {
30
+ const home = homedir();
31
+ const isWindows = platform() === "win32";
32
+ return {
33
+ claude: {
34
+ name: "Claude Code",
35
+ configPath: isWindows
36
+ ? join(home, "AppData", "Roaming", "claude", "settings.json")
37
+ : join(home, ".claude", "settings.json"),
38
+ configKey: "mcpServers",
39
+ detected: false,
40
+ },
41
+ cursor: {
42
+ name: "Cursor",
43
+ configPath: isWindows
44
+ ? join(home, "AppData", "Roaming", "Cursor", "User", "globalStorage", "cursor.mcp", "mcp.json")
45
+ : platform() === "darwin"
46
+ ? join(home, "Library", "Application Support", "Cursor", "User", "globalStorage", "cursor.mcp", "mcp.json")
47
+ : join(home, ".config", "Cursor", "User", "globalStorage", "cursor.mcp", "mcp.json"),
48
+ configKey: "mcpServers",
49
+ detected: false,
50
+ },
51
+ windsurf: {
52
+ name: "Windsurf",
53
+ configPath: isWindows
54
+ ? join(home, "AppData", "Roaming", "windsurf", "settings.json")
55
+ : join(home, ".windsurf", "settings.json"),
56
+ configKey: "mcpServers",
57
+ detected: false,
58
+ },
59
+ };
60
+ }
61
+ export function detectInstalledIDEs() {
62
+ const configs = getIDEConfigPaths();
63
+ for (const [key, config] of Object.entries(configs)) {
64
+ const configDir = join(config.configPath, "..");
65
+ config.detected = existsSync(configDir);
66
+ }
67
+ return configs;
68
+ }
69
+ export function readJSONFile(path) {
70
+ try {
71
+ if (!existsSync(path)) {
72
+ return null;
73
+ }
74
+ const content = readFileSync(path, "utf-8");
75
+ return JSON.parse(content);
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ export function writeJSONFile(path, data) {
82
+ try {
83
+ const dir = join(path, "..");
84
+ if (!existsSync(dir)) {
85
+ mkdirSync(dir, { recursive: true });
86
+ }
87
+ writeFileSync(path, JSON.stringify(data, null, 2) + "\n");
88
+ return true;
89
+ }
90
+ catch {
91
+ return false;
92
+ }
93
+ }
94
+ export function getMCPServerConfig() {
95
+ return {
96
+ command: "ctxopt-mcp",
97
+ args: ["serve"],
98
+ env: {},
99
+ };
100
+ }
101
+ export function isCtxOptConfigured(config) {
102
+ if (!config)
103
+ return false;
104
+ const mcpServers = config.mcpServers;
105
+ return mcpServers?.ctxopt !== undefined;
106
+ }
107
+ export function getPackageVersion() {
108
+ try {
109
+ const pkgPath = join(import.meta.dirname, "..", "..", "package.json");
110
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
111
+ return pkg.version || "0.1.0";
112
+ }
113
+ catch {
114
+ return "0.1.0";
115
+ }
116
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Config Compressor
3
+ *
4
+ * Specialized compressor for configuration files (JSON, YAML-like).
5
+ * Summarizes nested objects and arrays while preserving structure.
6
+ */
7
+ import type { Compressor } from "./types.js";
8
+ export declare const configCompressor: Compressor;
9
+ //# sourceMappingURL=config.d.ts.map