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 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/ast/python/queries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,oEAG1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,8DAGvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,8EAKxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mJAO3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,uGAK1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,+EAI5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,wJAMxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,owBAgCjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;CASV,CAAC"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Python Tree-sitter Queries
3
+ *
4
+ * S-expression queries for extracting Python code elements.
5
+ * Tree-sitter uses a query language similar to Lisp S-expressions.
6
+ */
7
+ /**
8
+ * Query to find all function definitions (including async)
9
+ * Captures:
10
+ * - @function: the function_definition node
11
+ * - @name: the function name
12
+ */
13
+ export const FUNCTION_QUERY = `
14
+ (function_definition
15
+ name: (identifier) @name) @function
16
+ `;
17
+ /**
18
+ * Query to find all class definitions
19
+ * Captures:
20
+ * - @class: the class_definition node
21
+ * - @name: the class name
22
+ */
23
+ export const CLASS_QUERY = `
24
+ (class_definition
25
+ name: (identifier) @name) @class
26
+ `;
27
+ /**
28
+ * Query to find all import statements
29
+ * Captures:
30
+ * - @import: the import statement node
31
+ */
32
+ export const IMPORT_QUERY = `
33
+ [
34
+ (import_statement) @import
35
+ (import_from_statement) @import
36
+ ]
37
+ `;
38
+ /**
39
+ * Query to find all decorated definitions
40
+ * Captures:
41
+ * - @decorator: the decorator node
42
+ * - @definition: the decorated definition (function or class)
43
+ */
44
+ export const DECORATED_QUERY = `
45
+ (decorated_definition
46
+ (decorator) @decorator
47
+ definition: [
48
+ (function_definition) @function
49
+ (class_definition) @class
50
+ ])
51
+ `;
52
+ /**
53
+ * Query to find all assignments at module level (variables)
54
+ * Captures:
55
+ * - @variable: the assignment node
56
+ * - @name: the variable name
57
+ */
58
+ export const VARIABLE_QUERY = `
59
+ (module
60
+ (expression_statement
61
+ (assignment
62
+ left: (identifier) @name) @variable))
63
+ `;
64
+ /**
65
+ * Query to find all type aliases (using TypeAlias or simple assignment with type annotation)
66
+ * Captures:
67
+ * - @type_alias: the type alias definition
68
+ */
69
+ export const TYPE_ALIAS_QUERY = `
70
+ (module
71
+ (type_alias_statement
72
+ name: (type) @name) @type_alias)
73
+ `;
74
+ /**
75
+ * Query to find class methods
76
+ * Captures:
77
+ * - @method: the function_definition node inside a class
78
+ * - @name: the method name
79
+ * - @class_name: the parent class name
80
+ */
81
+ export const METHOD_QUERY = `
82
+ (class_definition
83
+ name: (identifier) @class_name
84
+ body: (block
85
+ (function_definition
86
+ name: (identifier) @method_name) @method))
87
+ `;
88
+ /**
89
+ * Combined query for all top-level definitions
90
+ * This is more efficient than running multiple queries
91
+ */
92
+ export const ALL_DEFINITIONS_QUERY = `
93
+ ; Functions at module level
94
+ (module
95
+ (function_definition
96
+ name: (identifier) @func_name) @function)
97
+
98
+ ; Decorated functions at module level
99
+ (module
100
+ (decorated_definition
101
+ (function_definition
102
+ name: (identifier) @decorated_func_name) @decorated_function))
103
+
104
+ ; Classes at module level
105
+ (module
106
+ (class_definition
107
+ name: (identifier) @class_name) @class)
108
+
109
+ ; Decorated classes at module level
110
+ (module
111
+ (decorated_definition
112
+ (class_definition
113
+ name: (identifier) @decorated_class_name) @decorated_class))
114
+
115
+ ; Import statements
116
+ (import_statement) @import
117
+ (import_from_statement) @import_from
118
+
119
+ ; Module-level variables
120
+ (module
121
+ (expression_statement
122
+ (assignment
123
+ left: (identifier) @var_name) @variable))
124
+ `;
125
+ /**
126
+ * Query patterns as a single object for easy access
127
+ */
128
+ export const QUERIES = {
129
+ function: FUNCTION_QUERY,
130
+ class: CLASS_QUERY,
131
+ import: IMPORT_QUERY,
132
+ decorated: DECORATED_QUERY,
133
+ variable: VARIABLE_QUERY,
134
+ typeAlias: TYPE_ALIAS_QUERY,
135
+ method: METHOD_QUERY,
136
+ all: ALL_DEFINITIONS_QUERY,
137
+ };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Python Parser Utilities
3
+ *
4
+ * Helper functions for converting Tree-sitter nodes to CodeElements
5
+ * and extracting Python-specific constructs.
6
+ */
7
+ import type Parser from "web-tree-sitter";
8
+ type Node = Parser.SyntaxNode;
9
+ import type { CodeElement, ElementType } from "../types.js";
10
+ /**
11
+ * Get line number from a Tree-sitter node (1-indexed)
12
+ */
13
+ export declare function getLineNumber(node: Node): number;
14
+ /**
15
+ * Get end line number from a Tree-sitter node (1-indexed)
16
+ */
17
+ export declare function getEndLineNumber(node: Node): number;
18
+ /**
19
+ * Extract docstring from a function or class body
20
+ * Returns the docstring content without the quotes
21
+ */
22
+ export declare function extractDocstring(bodyNode: Node | null): string | undefined;
23
+ /**
24
+ * Get function signature from a function_definition node
25
+ */
26
+ export declare function getFunctionSignature(node: Node, isAsync: boolean): string;
27
+ /**
28
+ * Get class signature from a class_definition node
29
+ */
30
+ export declare function getClassSignature(node: Node): string;
31
+ /**
32
+ * Check if a function is async
33
+ */
34
+ export declare function isAsyncFunction(node: Node): boolean;
35
+ /**
36
+ * Check if a definition has decorators that indicate it's exported
37
+ * (e.g., @property, @staticmethod, @classmethod)
38
+ */
39
+ export declare function getDecorators(node: Node): string[];
40
+ /**
41
+ * Create a CodeElement from a Tree-sitter node
42
+ */
43
+ export declare function createCodeElement(type: ElementType, name: string, node: Node, options?: {
44
+ signature?: string;
45
+ documentation?: string;
46
+ isAsync?: boolean;
47
+ isExported?: boolean;
48
+ parent?: string;
49
+ }): CodeElement;
50
+ /**
51
+ * Get the body node of a function or class
52
+ */
53
+ export declare function getBodyNode(node: Node): Node | null;
54
+ /**
55
+ * Extract import name from an import statement
56
+ */
57
+ export declare function getImportName(node: Node): string;
58
+ /**
59
+ * Get the full import statement text
60
+ */
61
+ export declare function getImportSignature(node: Node): string;
62
+ export {};
63
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ast/python/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,KAAK,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAwB1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAWzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAWnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAalD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,WAAW,CAYb;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAEnD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CA+BhD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAErD"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Python Parser Utilities
3
+ *
4
+ * Helper functions for converting Tree-sitter nodes to CodeElements
5
+ * and extracting Python-specific constructs.
6
+ */
7
+ /**
8
+ * Get line number from a Tree-sitter node (1-indexed)
9
+ */
10
+ export function getLineNumber(node) {
11
+ return node.startPosition.row + 1;
12
+ }
13
+ /**
14
+ * Get end line number from a Tree-sitter node (1-indexed)
15
+ */
16
+ export function getEndLineNumber(node) {
17
+ return node.endPosition.row + 1;
18
+ }
19
+ /**
20
+ * Extract docstring from a function or class body
21
+ * Returns the docstring content without the quotes
22
+ */
23
+ export function extractDocstring(bodyNode) {
24
+ if (!bodyNode)
25
+ return undefined;
26
+ // Look for the first expression_statement containing a string
27
+ for (const child of bodyNode.children) {
28
+ if (child.type === "expression_statement") {
29
+ const stringNode = child.firstChild;
30
+ if (stringNode && (stringNode.type === "string" || stringNode.type === "concatenated_string")) {
31
+ const text = stringNode.text;
32
+ // Remove triple quotes and clean up
33
+ if (text.startsWith('"""') || text.startsWith("'''")) {
34
+ return text.slice(3, -3).trim();
35
+ }
36
+ // Single quoted strings (less common for docstrings)
37
+ if (text.startsWith('"') || text.startsWith("'")) {
38
+ return text.slice(1, -1).trim();
39
+ }
40
+ }
41
+ }
42
+ // Only check the first statement
43
+ break;
44
+ }
45
+ return undefined;
46
+ }
47
+ /**
48
+ * Get function signature from a function_definition node
49
+ */
50
+ export function getFunctionSignature(node, isAsync) {
51
+ const nameNode = node.childForFieldName("name");
52
+ const paramsNode = node.childForFieldName("parameters");
53
+ const returnType = node.childForFieldName("return_type");
54
+ const name = nameNode?.text ?? "unknown";
55
+ const params = paramsNode?.text ?? "()";
56
+ const asyncPrefix = isAsync ? "async " : "";
57
+ const returnAnnotation = returnType ? ` -> ${returnType.text}` : "";
58
+ return `${asyncPrefix}def ${name}${params}${returnAnnotation}`;
59
+ }
60
+ /**
61
+ * Get class signature from a class_definition node
62
+ */
63
+ export function getClassSignature(node) {
64
+ const nameNode = node.childForFieldName("name");
65
+ const superclassNode = node.childForFieldName("superclasses");
66
+ const name = nameNode?.text ?? "unknown";
67
+ const superclasses = superclassNode ? `(${superclassNode.text})` : "";
68
+ return `class ${name}${superclasses}`;
69
+ }
70
+ /**
71
+ * Check if a function is async
72
+ */
73
+ export function isAsyncFunction(node) {
74
+ // In tree-sitter-python, async functions have type "function_definition"
75
+ // with an "async" modifier in their parent or the first child is "async" keyword
76
+ const firstChild = node.firstChild;
77
+ if (firstChild && firstChild.type === "async") {
78
+ return true;
79
+ }
80
+ // Check if there's an "async" keyword before "def"
81
+ const prevSibling = node.previousSibling;
82
+ return prevSibling?.type === "async" || false;
83
+ }
84
+ /**
85
+ * Check if a definition has decorators that indicate it's exported
86
+ * (e.g., @property, @staticmethod, @classmethod)
87
+ */
88
+ export function getDecorators(node) {
89
+ const decorators = [];
90
+ let current = node.previousSibling;
91
+ while (current && current.type === "decorator") {
92
+ const nameNode = current.firstNamedChild;
93
+ if (nameNode) {
94
+ decorators.unshift(nameNode.text);
95
+ }
96
+ current = current.previousSibling;
97
+ }
98
+ return decorators;
99
+ }
100
+ /**
101
+ * Create a CodeElement from a Tree-sitter node
102
+ */
103
+ export function createCodeElement(type, name, node, options) {
104
+ return {
105
+ type,
106
+ name,
107
+ startLine: getLineNumber(node),
108
+ endLine: getEndLineNumber(node),
109
+ signature: options?.signature,
110
+ documentation: options?.documentation,
111
+ isAsync: options?.isAsync,
112
+ isExported: options?.isExported,
113
+ parent: options?.parent,
114
+ };
115
+ }
116
+ /**
117
+ * Get the body node of a function or class
118
+ */
119
+ export function getBodyNode(node) {
120
+ return node.childForFieldName("body");
121
+ }
122
+ /**
123
+ * Extract import name from an import statement
124
+ */
125
+ export function getImportName(node) {
126
+ // For "import x" -> return "x"
127
+ // For "from x import y" -> return "y"
128
+ // For "import x as y" -> return "y"
129
+ if (node.type === "import_statement") {
130
+ const nameNode = node.firstNamedChild;
131
+ if (nameNode?.type === "dotted_name") {
132
+ return nameNode.text.split(".").pop() ?? nameNode.text;
133
+ }
134
+ if (nameNode?.type === "aliased_import") {
135
+ const alias = nameNode.childForFieldName("alias");
136
+ return alias?.text ?? nameNode.firstNamedChild?.text ?? "";
137
+ }
138
+ return nameNode?.text ?? "";
139
+ }
140
+ if (node.type === "import_from_statement") {
141
+ // Get the imported names
142
+ for (const child of node.namedChildren) {
143
+ if (child.type === "dotted_name" && child.previousSibling?.type !== "from") {
144
+ return child.text.split(".").pop() ?? child.text;
145
+ }
146
+ if (child.type === "aliased_import") {
147
+ const alias = child.childForFieldName("alias");
148
+ return alias?.text ?? child.firstNamedChild?.text ?? "";
149
+ }
150
+ }
151
+ }
152
+ return node.text.split(/\s+/).pop() ?? "";
153
+ }
154
+ /**
155
+ * Get the full import statement text
156
+ */
157
+ export function getImportSignature(node) {
158
+ return node.text.split("\n")[0] ?? node.text;
159
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Quick Scan - Regex-based fast scanning for top-level declarations
3
+ *
4
+ * Provides 90% faster parsing for skeleton mode by using regex
5
+ * instead of full AST parsing. Trade-off: no endLine, no signatures.
6
+ */
7
+ import type { SupportedLanguage, FileStructure } from "./types.js";
8
+ interface QuickElement {
9
+ name: string;
10
+ line: number;
11
+ exported: boolean;
12
+ isAsync?: boolean;
13
+ }
14
+ interface QuickScanResult {
15
+ functions: QuickElement[];
16
+ classes: QuickElement[];
17
+ interfaces: QuickElement[];
18
+ types: QuickElement[];
19
+ variables: QuickElement[];
20
+ imports: string[];
21
+ }
22
+ /**
23
+ * Quick scan TypeScript/JavaScript content
24
+ */
25
+ export declare function quickScanTypeScript(content: string): QuickScanResult;
26
+ /**
27
+ * Quick scan Python content
28
+ */
29
+ export declare function quickScanPython(content: string): QuickScanResult;
30
+ /**
31
+ * Quick scan Go content
32
+ */
33
+ export declare function quickScanGo(content: string): QuickScanResult;
34
+ export declare function convertToFileStructure(scan: QuickScanResult, language: SupportedLanguage, totalLines: number): FileStructure;
35
+ /**
36
+ * Quick scan content based on language
37
+ */
38
+ export declare function quickScan(content: string, language: SupportedLanguage): FileStructure;
39
+ export {};
40
+ //# sourceMappingURL=quick-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quick-scan.d.ts","sourceRoot":"","sources":["../../src/ast/quick-scan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAe,MAAM,YAAY,CAAC;AAEhF,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAwCD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAgFpE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CA2DhE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAkD5D;AAgBD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,EAAE,MAAM,GACjB,aAAa,CAiBf;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,GAC1B,aAAa,CA6Bf"}
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Quick Scan - Regex-based fast scanning for top-level declarations
3
+ *
4
+ * Provides 90% faster parsing for skeleton mode by using regex
5
+ * instead of full AST parsing. Trade-off: no endLine, no signatures.
6
+ */
7
+ // TypeScript/JavaScript patterns
8
+ const TS_PATTERNS = {
9
+ // export async function foo(
10
+ function: /^\s*(export\s+)?(async\s+)?function\s+(\w+)/,
11
+ // export class Foo
12
+ class: /^\s*(export\s+)?class\s+(\w+)/,
13
+ // export interface Foo
14
+ interface: /^\s*(export\s+)?interface\s+(\w+)/,
15
+ // export type Foo
16
+ type: /^\s*(export\s+)?type\s+(\w+)/,
17
+ // export const foo = or export const foo:
18
+ constExport: /^\s*export\s+const\s+(\w+)\s*[=:]/,
19
+ // import ... from or import "
20
+ import: /^\s*import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+)?["']([^"']+)["']/,
21
+ };
22
+ // Python patterns
23
+ const PY_PATTERNS = {
24
+ // def foo(
25
+ function: /^def\s+(\w+)\s*\(/,
26
+ // async def foo(
27
+ asyncFunction: /^async\s+def\s+(\w+)\s*\(/,
28
+ // class Foo:
29
+ class: /^class\s+(\w+)/,
30
+ // from x import y or import x
31
+ import: /^(?:from\s+(\S+)\s+import|import\s+(\S+))/,
32
+ };
33
+ // Go patterns
34
+ const GO_PATTERNS = {
35
+ // func Foo( or func (r *Receiver) Foo(
36
+ function: /^func\s+(?:\([^)]*\)\s+)?(\w+)\s*\(/,
37
+ // type Foo struct/interface
38
+ type: /^type\s+(\w+)\s+(?:struct|interface)/,
39
+ // import "x" or import ( multiline )
40
+ import: /^import\s+(?:\(\s*)?["']?([^"'\s)]+)/,
41
+ };
42
+ /**
43
+ * Quick scan TypeScript/JavaScript content
44
+ */
45
+ export function quickScanTypeScript(content) {
46
+ const lines = content.split("\n");
47
+ const result = {
48
+ functions: [],
49
+ classes: [],
50
+ interfaces: [],
51
+ types: [],
52
+ variables: [],
53
+ imports: [],
54
+ };
55
+ for (let i = 0; i < lines.length; i++) {
56
+ const line = lines[i];
57
+ if (!line)
58
+ continue;
59
+ const lineNum = i + 1; // 1-indexed
60
+ // Functions
61
+ const fnMatch = line.match(TS_PATTERNS.function);
62
+ if (fnMatch?.[3]) {
63
+ result.functions.push({
64
+ name: fnMatch[3],
65
+ line: lineNum,
66
+ exported: !!fnMatch[1],
67
+ isAsync: !!fnMatch[2],
68
+ });
69
+ continue;
70
+ }
71
+ // Classes
72
+ const classMatch = line.match(TS_PATTERNS.class);
73
+ if (classMatch?.[2]) {
74
+ result.classes.push({
75
+ name: classMatch[2],
76
+ line: lineNum,
77
+ exported: !!classMatch[1],
78
+ });
79
+ continue;
80
+ }
81
+ // Interfaces
82
+ const ifaceMatch = line.match(TS_PATTERNS.interface);
83
+ if (ifaceMatch?.[2]) {
84
+ result.interfaces.push({
85
+ name: ifaceMatch[2],
86
+ line: lineNum,
87
+ exported: !!ifaceMatch[1],
88
+ });
89
+ continue;
90
+ }
91
+ // Types
92
+ const typeMatch = line.match(TS_PATTERNS.type);
93
+ if (typeMatch?.[2]) {
94
+ result.types.push({
95
+ name: typeMatch[2],
96
+ line: lineNum,
97
+ exported: !!typeMatch[1],
98
+ });
99
+ continue;
100
+ }
101
+ // Exported const
102
+ const constMatch = line.match(TS_PATTERNS.constExport);
103
+ if (constMatch?.[1]) {
104
+ result.variables.push({
105
+ name: constMatch[1],
106
+ line: lineNum,
107
+ exported: true,
108
+ });
109
+ continue;
110
+ }
111
+ // Imports
112
+ const importMatch = line.match(TS_PATTERNS.import);
113
+ if (importMatch?.[1]) {
114
+ result.imports.push(importMatch[1]);
115
+ }
116
+ }
117
+ return result;
118
+ }
119
+ /**
120
+ * Quick scan Python content
121
+ */
122
+ export function quickScanPython(content) {
123
+ const lines = content.split("\n");
124
+ const result = {
125
+ functions: [],
126
+ classes: [],
127
+ interfaces: [],
128
+ types: [],
129
+ variables: [],
130
+ imports: [],
131
+ };
132
+ for (let i = 0; i < lines.length; i++) {
133
+ const line = lines[i];
134
+ if (!line)
135
+ continue;
136
+ const lineNum = i + 1;
137
+ // Async functions
138
+ const asyncMatch = line.match(PY_PATTERNS.asyncFunction);
139
+ if (asyncMatch?.[1]) {
140
+ result.functions.push({
141
+ name: asyncMatch[1],
142
+ line: lineNum,
143
+ exported: true, // Python doesn't have export keyword
144
+ isAsync: true,
145
+ });
146
+ continue;
147
+ }
148
+ // Functions
149
+ const fnMatch = line.match(PY_PATTERNS.function);
150
+ if (fnMatch?.[1]) {
151
+ result.functions.push({
152
+ name: fnMatch[1],
153
+ line: lineNum,
154
+ exported: true,
155
+ });
156
+ continue;
157
+ }
158
+ // Classes
159
+ const classMatch = line.match(PY_PATTERNS.class);
160
+ if (classMatch?.[1]) {
161
+ result.classes.push({
162
+ name: classMatch[1],
163
+ line: lineNum,
164
+ exported: true,
165
+ });
166
+ continue;
167
+ }
168
+ // Imports
169
+ const importMatch = line.match(PY_PATTERNS.import);
170
+ const importName = importMatch?.[1] || importMatch?.[2];
171
+ if (importName) {
172
+ result.imports.push(importName);
173
+ }
174
+ }
175
+ return result;
176
+ }
177
+ /**
178
+ * Quick scan Go content
179
+ */
180
+ export function quickScanGo(content) {
181
+ const lines = content.split("\n");
182
+ const result = {
183
+ functions: [],
184
+ classes: [],
185
+ interfaces: [],
186
+ types: [],
187
+ variables: [],
188
+ imports: [],
189
+ };
190
+ for (let i = 0; i < lines.length; i++) {
191
+ const line = lines[i];
192
+ if (!line)
193
+ continue;
194
+ const lineNum = i + 1;
195
+ // Functions
196
+ const fnMatch = line.match(GO_PATTERNS.function);
197
+ const fnName = fnMatch?.[1];
198
+ if (fnName && fnName.length > 0) {
199
+ const firstChar = fnName[0];
200
+ result.functions.push({
201
+ name: fnName,
202
+ line: lineNum,
203
+ exported: firstChar === firstChar.toUpperCase(), // Go: uppercase = exported
204
+ });
205
+ continue;
206
+ }
207
+ // Types (struct/interface)
208
+ const typeMatch = line.match(GO_PATTERNS.type);
209
+ const typeName = typeMatch?.[1];
210
+ if (typeName && typeName.length > 0) {
211
+ const firstChar = typeName[0];
212
+ result.types.push({
213
+ name: typeName,
214
+ line: lineNum,
215
+ exported: firstChar === firstChar.toUpperCase(),
216
+ });
217
+ continue;
218
+ }
219
+ // Imports
220
+ const importMatch = line.match(GO_PATTERNS.import);
221
+ if (importMatch?.[1]) {
222
+ result.imports.push(importMatch[1]);
223
+ }
224
+ }
225
+ return result;
226
+ }
227
+ /**
228
+ * Convert QuickScanResult to FileStructure
229
+ */
230
+ function toCodeElement(el, type) {
231
+ return {
232
+ type: type,
233
+ name: el.name,
234
+ startLine: el.line,
235
+ endLine: el.line, // Quick mode: no endLine
236
+ isExported: el.exported,
237
+ isAsync: el.isAsync,
238
+ };
239
+ }
240
+ export function convertToFileStructure(scan, language, totalLines) {
241
+ return {
242
+ language,
243
+ totalLines,
244
+ functions: scan.functions.map((f) => toCodeElement(f, "function")),
245
+ classes: scan.classes.map((c) => toCodeElement(c, "class")),
246
+ interfaces: scan.interfaces.map((i) => toCodeElement(i, "interface")),
247
+ types: scan.types.map((t) => toCodeElement(t, "type")),
248
+ variables: scan.variables.map((v) => toCodeElement(v, "variable")),
249
+ imports: scan.imports.map((name) => ({
250
+ type: "import",
251
+ name,
252
+ startLine: 0,
253
+ endLine: 0,
254
+ })),
255
+ exports: [], // Not tracked in quick mode
256
+ };
257
+ }
258
+ /**
259
+ * Quick scan content based on language
260
+ */
261
+ export function quickScan(content, language) {
262
+ const totalLines = content.split("\n").length;
263
+ let scanResult;
264
+ switch (language) {
265
+ case "typescript":
266
+ case "javascript":
267
+ scanResult = quickScanTypeScript(content);
268
+ break;
269
+ case "python":
270
+ scanResult = quickScanPython(content);
271
+ break;
272
+ case "go":
273
+ scanResult = quickScanGo(content);
274
+ break;
275
+ default:
276
+ // Fallback: empty structure for unsupported languages
277
+ scanResult = {
278
+ functions: [],
279
+ classes: [],
280
+ interfaces: [],
281
+ types: [],
282
+ variables: [],
283
+ imports: [],
284
+ };
285
+ }
286
+ return convertToFileStructure(scanResult, language, totalLines);
287
+ }