@ltm-alpha/alpha-cs 1.6.0

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 (1107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +972 -0
  3. package/dist/bin/command-supervision.d.ts +49 -0
  4. package/dist/bin/command-supervision.d.ts.map +1 -0
  5. package/dist/bin/command-supervision.js +95 -0
  6. package/dist/bin/command-supervision.js.map +1 -0
  7. package/dist/bin/fatal-handler.d.ts +20 -0
  8. package/dist/bin/fatal-handler.d.ts.map +1 -0
  9. package/dist/bin/fatal-handler.js +118 -0
  10. package/dist/bin/fatal-handler.js.map +1 -0
  11. package/dist/bin/ltm-alpha-cs.d.ts +27 -0
  12. package/dist/bin/ltm-alpha-cs.d.ts.map +1 -0
  13. package/dist/bin/ltm-alpha-cs.js +2643 -0
  14. package/dist/bin/ltm-alpha-cs.js.map +1 -0
  15. package/dist/bin/node-version-check.d.ts +37 -0
  16. package/dist/bin/node-version-check.d.ts.map +1 -0
  17. package/dist/bin/node-version-check.js +79 -0
  18. package/dist/bin/node-version-check.js.map +1 -0
  19. package/dist/bin/uninstall.d.ts +14 -0
  20. package/dist/bin/uninstall.d.ts.map +1 -0
  21. package/dist/bin/uninstall.js +36 -0
  22. package/dist/bin/uninstall.js.map +1 -0
  23. package/dist/context/formatter.d.ts +36 -0
  24. package/dist/context/formatter.d.ts.map +1 -0
  25. package/dist/context/formatter.js +269 -0
  26. package/dist/context/formatter.js.map +1 -0
  27. package/dist/context/index.d.ts +131 -0
  28. package/dist/context/index.d.ts.map +1 -0
  29. package/dist/context/index.js +1378 -0
  30. package/dist/context/index.js.map +1 -0
  31. package/dist/context/markers.d.ts +19 -0
  32. package/dist/context/markers.d.ts.map +1 -0
  33. package/dist/context/markers.js +22 -0
  34. package/dist/context/markers.js.map +1 -0
  35. package/dist/db/index.d.ts +385 -0
  36. package/dist/db/index.d.ts.map +1 -0
  37. package/dist/db/index.js +902 -0
  38. package/dist/db/index.js.map +1 -0
  39. package/dist/db/migrations.d.ts +44 -0
  40. package/dist/db/migrations.d.ts.map +1 -0
  41. package/dist/db/migrations.js +236 -0
  42. package/dist/db/migrations.js.map +1 -0
  43. package/dist/db/queries.d.ts +1095 -0
  44. package/dist/db/queries.d.ts.map +1 -0
  45. package/dist/db/queries.js +3285 -0
  46. package/dist/db/queries.js.map +1 -0
  47. package/dist/db/schema.sql +207 -0
  48. package/dist/db/sqlite-adapter.d.ts +55 -0
  49. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  50. package/dist/db/sqlite-adapter.js +135 -0
  51. package/dist/db/sqlite-adapter.js.map +1 -0
  52. package/dist/db/wal-valve.d.ts +139 -0
  53. package/dist/db/wal-valve.d.ts.map +1 -0
  54. package/dist/db/wal-valve.js +333 -0
  55. package/dist/db/wal-valve.js.map +1 -0
  56. package/dist/directory.d.ts +232 -0
  57. package/dist/directory.d.ts.map +1 -0
  58. package/dist/directory.js +877 -0
  59. package/dist/directory.js.map +1 -0
  60. package/dist/errors.d.ts +150 -0
  61. package/dist/errors.d.ts.map +1 -0
  62. package/dist/errors.js +234 -0
  63. package/dist/errors.js.map +1 -0
  64. package/dist/extraction/astro-extractor.d.ts +79 -0
  65. package/dist/extraction/astro-extractor.d.ts.map +1 -0
  66. package/dist/extraction/astro-extractor.js +320 -0
  67. package/dist/extraction/astro-extractor.js.map +1 -0
  68. package/dist/extraction/cfml-extractor.d.ts +107 -0
  69. package/dist/extraction/cfml-extractor.d.ts.map +1 -0
  70. package/dist/extraction/cfml-extractor.js +505 -0
  71. package/dist/extraction/cfml-extractor.js.map +1 -0
  72. package/dist/extraction/dfm-extractor.d.ts +31 -0
  73. package/dist/extraction/dfm-extractor.d.ts.map +1 -0
  74. package/dist/extraction/dfm-extractor.js +151 -0
  75. package/dist/extraction/dfm-extractor.js.map +1 -0
  76. package/dist/extraction/extraction-version.d.ts +25 -0
  77. package/dist/extraction/extraction-version.d.ts.map +1 -0
  78. package/dist/extraction/extraction-version.js +28 -0
  79. package/dist/extraction/extraction-version.js.map +1 -0
  80. package/dist/extraction/function-ref.d.ts +118 -0
  81. package/dist/extraction/function-ref.d.ts.map +1 -0
  82. package/dist/extraction/function-ref.js +746 -0
  83. package/dist/extraction/function-ref.js.map +1 -0
  84. package/dist/extraction/generated-detection.d.ts +66 -0
  85. package/dist/extraction/generated-detection.d.ts.map +1 -0
  86. package/dist/extraction/generated-detection.js +248 -0
  87. package/dist/extraction/generated-detection.js.map +1 -0
  88. package/dist/extraction/grammars.d.ts +148 -0
  89. package/dist/extraction/grammars.d.ts.map +1 -0
  90. package/dist/extraction/grammars.js +743 -0
  91. package/dist/extraction/grammars.js.map +1 -0
  92. package/dist/extraction/index.d.ts +455 -0
  93. package/dist/extraction/index.d.ts.map +1 -0
  94. package/dist/extraction/index.js +3208 -0
  95. package/dist/extraction/index.js.map +1 -0
  96. package/dist/extraction/kernel/decode.d.ts +9 -0
  97. package/dist/extraction/kernel/decode.d.ts.map +1 -0
  98. package/dist/extraction/kernel/decode.js +162 -0
  99. package/dist/extraction/kernel/decode.js.map +1 -0
  100. package/dist/extraction/kernel/index.d.ts +64 -0
  101. package/dist/extraction/kernel/index.d.ts.map +1 -0
  102. package/dist/extraction/kernel/index.js +279 -0
  103. package/dist/extraction/kernel/index.js.map +1 -0
  104. package/dist/extraction/kernel/layout.d.ts +101 -0
  105. package/dist/extraction/kernel/layout.d.ts.map +1 -0
  106. package/dist/extraction/kernel/layout.js +104 -0
  107. package/dist/extraction/kernel/layout.js.map +1 -0
  108. package/dist/extraction/kernel/loader.d.ts +103 -0
  109. package/dist/extraction/kernel/loader.d.ts.map +1 -0
  110. package/dist/extraction/kernel/loader.js +146 -0
  111. package/dist/extraction/kernel/loader.js.map +1 -0
  112. package/dist/extraction/languages/arkts.d.ts +3 -0
  113. package/dist/extraction/languages/arkts.d.ts.map +1 -0
  114. package/dist/extraction/languages/arkts.js +127 -0
  115. package/dist/extraction/languages/arkts.js.map +1 -0
  116. package/dist/extraction/languages/c-cpp.d.ts +167 -0
  117. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  118. package/dist/extraction/languages/c-cpp.js +1850 -0
  119. package/dist/extraction/languages/c-cpp.js.map +1 -0
  120. package/dist/extraction/languages/cfquery.d.ts +12 -0
  121. package/dist/extraction/languages/cfquery.d.ts.map +1 -0
  122. package/dist/extraction/languages/cfquery.js +28 -0
  123. package/dist/extraction/languages/cfquery.js.map +1 -0
  124. package/dist/extraction/languages/cfscript.d.ts +3 -0
  125. package/dist/extraction/languages/cfscript.d.ts.map +1 -0
  126. package/dist/extraction/languages/cfscript.js +73 -0
  127. package/dist/extraction/languages/cfscript.js.map +1 -0
  128. package/dist/extraction/languages/cobol.d.ts +33 -0
  129. package/dist/extraction/languages/cobol.d.ts.map +1 -0
  130. package/dist/extraction/languages/cobol.js +499 -0
  131. package/dist/extraction/languages/cobol.js.map +1 -0
  132. package/dist/extraction/languages/csharp.d.ts +25 -0
  133. package/dist/extraction/languages/csharp.d.ts.map +1 -0
  134. package/dist/extraction/languages/csharp.js +175 -0
  135. package/dist/extraction/languages/csharp.js.map +1 -0
  136. package/dist/extraction/languages/dart.d.ts +3 -0
  137. package/dist/extraction/languages/dart.d.ts.map +1 -0
  138. package/dist/extraction/languages/dart.js +374 -0
  139. package/dist/extraction/languages/dart.js.map +1 -0
  140. package/dist/extraction/languages/erlang.d.ts +3 -0
  141. package/dist/extraction/languages/erlang.d.ts.map +1 -0
  142. package/dist/extraction/languages/erlang.js +386 -0
  143. package/dist/extraction/languages/erlang.js.map +1 -0
  144. package/dist/extraction/languages/go.d.ts +3 -0
  145. package/dist/extraction/languages/go.d.ts.map +1 -0
  146. package/dist/extraction/languages/go.js +111 -0
  147. package/dist/extraction/languages/go.js.map +1 -0
  148. package/dist/extraction/languages/index.d.ts +10 -0
  149. package/dist/extraction/languages/index.d.ts.map +1 -0
  150. package/dist/extraction/languages/index.js +71 -0
  151. package/dist/extraction/languages/index.js.map +1 -0
  152. package/dist/extraction/languages/java.d.ts +3 -0
  153. package/dist/extraction/languages/java.d.ts.map +1 -0
  154. package/dist/extraction/languages/java.js +315 -0
  155. package/dist/extraction/languages/java.js.map +1 -0
  156. package/dist/extraction/languages/javascript.d.ts +3 -0
  157. package/dist/extraction/languages/javascript.d.ts.map +1 -0
  158. package/dist/extraction/languages/javascript.js +106 -0
  159. package/dist/extraction/languages/javascript.js.map +1 -0
  160. package/dist/extraction/languages/kotlin.d.ts +3 -0
  161. package/dist/extraction/languages/kotlin.d.ts.map +1 -0
  162. package/dist/extraction/languages/kotlin.js +512 -0
  163. package/dist/extraction/languages/kotlin.js.map +1 -0
  164. package/dist/extraction/languages/lua.d.ts +3 -0
  165. package/dist/extraction/languages/lua.d.ts.map +1 -0
  166. package/dist/extraction/languages/lua.js +153 -0
  167. package/dist/extraction/languages/lua.js.map +1 -0
  168. package/dist/extraction/languages/luau.d.ts +3 -0
  169. package/dist/extraction/languages/luau.d.ts.map +1 -0
  170. package/dist/extraction/languages/luau.js +37 -0
  171. package/dist/extraction/languages/luau.js.map +1 -0
  172. package/dist/extraction/languages/nix.d.ts +3 -0
  173. package/dist/extraction/languages/nix.d.ts.map +1 -0
  174. package/dist/extraction/languages/nix.js +294 -0
  175. package/dist/extraction/languages/nix.js.map +1 -0
  176. package/dist/extraction/languages/objc.d.ts +3 -0
  177. package/dist/extraction/languages/objc.d.ts.map +1 -0
  178. package/dist/extraction/languages/objc.js +179 -0
  179. package/dist/extraction/languages/objc.js.map +1 -0
  180. package/dist/extraction/languages/pascal.d.ts +3 -0
  181. package/dist/extraction/languages/pascal.d.ts.map +1 -0
  182. package/dist/extraction/languages/pascal.js +77 -0
  183. package/dist/extraction/languages/pascal.js.map +1 -0
  184. package/dist/extraction/languages/php.d.ts +3 -0
  185. package/dist/extraction/languages/php.d.ts.map +1 -0
  186. package/dist/extraction/languages/php.js +196 -0
  187. package/dist/extraction/languages/php.js.map +1 -0
  188. package/dist/extraction/languages/python.d.ts +3 -0
  189. package/dist/extraction/languages/python.d.ts.map +1 -0
  190. package/dist/extraction/languages/python.js +56 -0
  191. package/dist/extraction/languages/python.js.map +1 -0
  192. package/dist/extraction/languages/r.d.ts +3 -0
  193. package/dist/extraction/languages/r.d.ts.map +1 -0
  194. package/dist/extraction/languages/r.js +314 -0
  195. package/dist/extraction/languages/r.js.map +1 -0
  196. package/dist/extraction/languages/ruby.d.ts +3 -0
  197. package/dist/extraction/languages/ruby.d.ts.map +1 -0
  198. package/dist/extraction/languages/ruby.js +149 -0
  199. package/dist/extraction/languages/ruby.js.map +1 -0
  200. package/dist/extraction/languages/rust.d.ts +23 -0
  201. package/dist/extraction/languages/rust.d.ts.map +1 -0
  202. package/dist/extraction/languages/rust.js +172 -0
  203. package/dist/extraction/languages/rust.js.map +1 -0
  204. package/dist/extraction/languages/scala.d.ts +3 -0
  205. package/dist/extraction/languages/scala.d.ts.map +1 -0
  206. package/dist/extraction/languages/scala.js +219 -0
  207. package/dist/extraction/languages/scala.js.map +1 -0
  208. package/dist/extraction/languages/solidity.d.ts +3 -0
  209. package/dist/extraction/languages/solidity.d.ts.map +1 -0
  210. package/dist/extraction/languages/solidity.js +293 -0
  211. package/dist/extraction/languages/solidity.js.map +1 -0
  212. package/dist/extraction/languages/swift.d.ts +3 -0
  213. package/dist/extraction/languages/swift.d.ts.map +1 -0
  214. package/dist/extraction/languages/swift.js +152 -0
  215. package/dist/extraction/languages/swift.js.map +1 -0
  216. package/dist/extraction/languages/terraform.d.ts +3 -0
  217. package/dist/extraction/languages/terraform.d.ts.map +1 -0
  218. package/dist/extraction/languages/terraform.js +641 -0
  219. package/dist/extraction/languages/terraform.js.map +1 -0
  220. package/dist/extraction/languages/typescript.d.ts +16 -0
  221. package/dist/extraction/languages/typescript.d.ts.map +1 -0
  222. package/dist/extraction/languages/typescript.js +174 -0
  223. package/dist/extraction/languages/typescript.js.map +1 -0
  224. package/dist/extraction/languages/vbnet.d.ts +11 -0
  225. package/dist/extraction/languages/vbnet.d.ts.map +1 -0
  226. package/dist/extraction/languages/vbnet.js +141 -0
  227. package/dist/extraction/languages/vbnet.js.map +1 -0
  228. package/dist/extraction/liquid-extractor.d.ts +59 -0
  229. package/dist/extraction/liquid-extractor.d.ts.map +1 -0
  230. package/dist/extraction/liquid-extractor.js +357 -0
  231. package/dist/extraction/liquid-extractor.js.map +1 -0
  232. package/dist/extraction/mybatis-extractor.d.ts +68 -0
  233. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  234. package/dist/extraction/mybatis-extractor.js +300 -0
  235. package/dist/extraction/mybatis-extractor.js.map +1 -0
  236. package/dist/extraction/parse-pool.d.ts +167 -0
  237. package/dist/extraction/parse-pool.d.ts.map +1 -0
  238. package/dist/extraction/parse-pool.js +421 -0
  239. package/dist/extraction/parse-pool.js.map +1 -0
  240. package/dist/extraction/parse-worker.d.ts +8 -0
  241. package/dist/extraction/parse-worker.d.ts.map +1 -0
  242. package/dist/extraction/parse-worker.js +138 -0
  243. package/dist/extraction/parse-worker.js.map +1 -0
  244. package/dist/extraction/razor-extractor.d.ts +42 -0
  245. package/dist/extraction/razor-extractor.d.ts.map +1 -0
  246. package/dist/extraction/razor-extractor.js +285 -0
  247. package/dist/extraction/razor-extractor.js.map +1 -0
  248. package/dist/extraction/store-worker.d.ts +24 -0
  249. package/dist/extraction/store-worker.d.ts.map +1 -0
  250. package/dist/extraction/store-worker.js +139 -0
  251. package/dist/extraction/store-worker.js.map +1 -0
  252. package/dist/extraction/store-writer.d.ts +63 -0
  253. package/dist/extraction/store-writer.d.ts.map +1 -0
  254. package/dist/extraction/store-writer.js +174 -0
  255. package/dist/extraction/store-writer.js.map +1 -0
  256. package/dist/extraction/svelte-extractor.d.ts +56 -0
  257. package/dist/extraction/svelte-extractor.d.ts.map +1 -0
  258. package/dist/extraction/svelte-extractor.js +275 -0
  259. package/dist/extraction/svelte-extractor.js.map +1 -0
  260. package/dist/extraction/syntax-tokens.d.ts +103 -0
  261. package/dist/extraction/syntax-tokens.d.ts.map +1 -0
  262. package/dist/extraction/syntax-tokens.js +381 -0
  263. package/dist/extraction/syntax-tokens.js.map +1 -0
  264. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  265. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  266. package/dist/extraction/tree-sitter-helpers.js +153 -0
  267. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  268. package/dist/extraction/tree-sitter-types.d.ts +279 -0
  269. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  270. package/dist/extraction/tree-sitter-types.js +10 -0
  271. package/dist/extraction/tree-sitter-types.js.map +1 -0
  272. package/dist/extraction/tree-sitter.d.ts +766 -0
  273. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  274. package/dist/extraction/tree-sitter.js +7138 -0
  275. package/dist/extraction/tree-sitter.js.map +1 -0
  276. package/dist/extraction/vue-extractor.d.ts +51 -0
  277. package/dist/extraction/vue-extractor.d.ts.map +1 -0
  278. package/dist/extraction/vue-extractor.js +254 -0
  279. package/dist/extraction/vue-extractor.js.map +1 -0
  280. package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  281. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  282. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  283. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  284. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  285. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  286. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  287. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  288. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  289. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  290. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  291. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  292. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  293. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  294. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  295. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  296. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  297. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  298. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  299. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  300. package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  301. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  302. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  303. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  304. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  305. package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  306. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  307. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  308. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  309. package/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  310. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  311. package/dist/extraction/wasm-runtime-flags.js +130 -0
  312. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  313. package/dist/graph/branch-guards.d.ts +248 -0
  314. package/dist/graph/branch-guards.d.ts.map +1 -0
  315. package/dist/graph/branch-guards.js +2231 -0
  316. package/dist/graph/branch-guards.js.map +1 -0
  317. package/dist/graph/dead-code.d.ts +251 -0
  318. package/dist/graph/dead-code.d.ts.map +1 -0
  319. package/dist/graph/dead-code.js +756 -0
  320. package/dist/graph/dead-code.js.map +1 -0
  321. package/dist/graph/dynamic-boundary-report.d.ts +121 -0
  322. package/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  323. package/dist/graph/dynamic-boundary-report.js +283 -0
  324. package/dist/graph/dynamic-boundary-report.js.map +1 -0
  325. package/dist/graph/index.d.ts +12 -0
  326. package/dist/graph/index.d.ts.map +1 -0
  327. package/dist/graph/index.js +28 -0
  328. package/dist/graph/index.js.map +1 -0
  329. package/dist/graph/named-symbol-flow.d.ts +125 -0
  330. package/dist/graph/named-symbol-flow.d.ts.map +1 -0
  331. package/dist/graph/named-symbol-flow.js +552 -0
  332. package/dist/graph/named-symbol-flow.js.map +1 -0
  333. package/dist/graph/queries.d.ts +106 -0
  334. package/dist/graph/queries.d.ts.map +1 -0
  335. package/dist/graph/queries.js +341 -0
  336. package/dist/graph/queries.js.map +1 -0
  337. package/dist/graph/symbol-lookup.d.ts +83 -0
  338. package/dist/graph/symbol-lookup.d.ts.map +1 -0
  339. package/dist/graph/symbol-lookup.js +181 -0
  340. package/dist/graph/symbol-lookup.js.map +1 -0
  341. package/dist/graph/traversal.d.ts +127 -0
  342. package/dist/graph/traversal.d.ts.map +1 -0
  343. package/dist/graph/traversal.js +599 -0
  344. package/dist/graph/traversal.js.map +1 -0
  345. package/dist/graph/type-hierarchy.d.ts +155 -0
  346. package/dist/graph/type-hierarchy.d.ts.map +1 -0
  347. package/dist/graph/type-hierarchy.js +382 -0
  348. package/dist/graph/type-hierarchy.js.map +1 -0
  349. package/dist/index.d.ts +874 -0
  350. package/dist/index.d.ts.map +1 -0
  351. package/dist/index.js +2005 -0
  352. package/dist/index.js.map +1 -0
  353. package/dist/installer/config-writer.d.ts +28 -0
  354. package/dist/installer/config-writer.d.ts.map +1 -0
  355. package/dist/installer/config-writer.js +91 -0
  356. package/dist/installer/config-writer.js.map +1 -0
  357. package/dist/installer/index.d.ts +143 -0
  358. package/dist/installer/index.d.ts.map +1 -0
  359. package/dist/installer/index.js +621 -0
  360. package/dist/installer/index.js.map +1 -0
  361. package/dist/installer/instructions-template.d.ts +41 -0
  362. package/dist/installer/instructions-template.d.ts.map +1 -0
  363. package/dist/installer/instructions-template.js +53 -0
  364. package/dist/installer/instructions-template.js.map +1 -0
  365. package/dist/installer/targets/antigravity.d.ts +57 -0
  366. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  367. package/dist/installer/targets/antigravity.js +308 -0
  368. package/dist/installer/targets/antigravity.js.map +1 -0
  369. package/dist/installer/targets/claude.d.ts +65 -0
  370. package/dist/installer/targets/claude.d.ts.map +1 -0
  371. package/dist/installer/targets/claude.js +514 -0
  372. package/dist/installer/targets/claude.js.map +1 -0
  373. package/dist/installer/targets/codex.d.ts +33 -0
  374. package/dist/installer/targets/codex.d.ts.map +1 -0
  375. package/dist/installer/targets/codex.js +212 -0
  376. package/dist/installer/targets/codex.js.map +1 -0
  377. package/dist/installer/targets/copilot-cli.d.ts +32 -0
  378. package/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  379. package/dist/installer/targets/copilot-cli.js +215 -0
  380. package/dist/installer/targets/copilot-cli.js.map +1 -0
  381. package/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  382. package/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  383. package/dist/installer/targets/copilot-jetbrains.js +238 -0
  384. package/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  385. package/dist/installer/targets/copilot-vscode.d.ts +47 -0
  386. package/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  387. package/dist/installer/targets/copilot-vscode.js +219 -0
  388. package/dist/installer/targets/copilot-vscode.js.map +1 -0
  389. package/dist/installer/targets/cursor.d.ts +35 -0
  390. package/dist/installer/targets/cursor.d.ts.map +1 -0
  391. package/dist/installer/targets/cursor.js +254 -0
  392. package/dist/installer/targets/cursor.js.map +1 -0
  393. package/dist/installer/targets/gemini.d.ts +26 -0
  394. package/dist/installer/targets/gemini.d.ts.map +1 -0
  395. package/dist/installer/targets/gemini.js +165 -0
  396. package/dist/installer/targets/gemini.js.map +1 -0
  397. package/dist/installer/targets/hermes.d.ts +18 -0
  398. package/dist/installer/targets/hermes.d.ts.map +1 -0
  399. package/dist/installer/targets/hermes.js +359 -0
  400. package/dist/installer/targets/hermes.js.map +1 -0
  401. package/dist/installer/targets/kiro.d.ts +27 -0
  402. package/dist/installer/targets/kiro.d.ts.map +1 -0
  403. package/dist/installer/targets/kiro.js +178 -0
  404. package/dist/installer/targets/kiro.js.map +1 -0
  405. package/dist/installer/targets/opencode.d.ts +49 -0
  406. package/dist/installer/targets/opencode.d.ts.map +1 -0
  407. package/dist/installer/targets/opencode.js +339 -0
  408. package/dist/installer/targets/opencode.js.map +1 -0
  409. package/dist/installer/targets/registry.d.ts +35 -0
  410. package/dist/installer/targets/registry.d.ts.map +1 -0
  411. package/dist/installer/targets/registry.js +97 -0
  412. package/dist/installer/targets/registry.js.map +1 -0
  413. package/dist/installer/targets/shared.d.ts +101 -0
  414. package/dist/installer/targets/shared.d.ts.map +1 -0
  415. package/dist/installer/targets/shared.js +264 -0
  416. package/dist/installer/targets/shared.js.map +1 -0
  417. package/dist/installer/targets/toml.d.ts +53 -0
  418. package/dist/installer/targets/toml.d.ts.map +1 -0
  419. package/dist/installer/targets/toml.js +226 -0
  420. package/dist/installer/targets/toml.js.map +1 -0
  421. package/dist/installer/targets/types.d.ts +108 -0
  422. package/dist/installer/targets/types.d.ts.map +1 -0
  423. package/dist/installer/targets/types.js +16 -0
  424. package/dist/installer/targets/types.js.map +1 -0
  425. package/dist/mcp/daemon-manager.d.ts +42 -0
  426. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  427. package/dist/mcp/daemon-manager.js +141 -0
  428. package/dist/mcp/daemon-manager.js.map +1 -0
  429. package/dist/mcp/daemon-paths.d.ts +81 -0
  430. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  431. package/dist/mcp/daemon-paths.js +228 -0
  432. package/dist/mcp/daemon-paths.js.map +1 -0
  433. package/dist/mcp/daemon-registry.d.ts +57 -0
  434. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  435. package/dist/mcp/daemon-registry.js +323 -0
  436. package/dist/mcp/daemon-registry.js.map +1 -0
  437. package/dist/mcp/daemon.d.ts +294 -0
  438. package/dist/mcp/daemon.d.ts.map +1 -0
  439. package/dist/mcp/daemon.js +897 -0
  440. package/dist/mcp/daemon.js.map +1 -0
  441. package/dist/mcp/dynamic-boundaries.d.ts +32 -0
  442. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  443. package/dist/mcp/dynamic-boundaries.js +323 -0
  444. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  445. package/dist/mcp/early-ppid.d.ts +26 -0
  446. package/dist/mcp/early-ppid.d.ts.map +1 -0
  447. package/dist/mcp/early-ppid.js +29 -0
  448. package/dist/mcp/early-ppid.js.map +1 -0
  449. package/dist/mcp/engine.d.ts +133 -0
  450. package/dist/mcp/engine.d.ts.map +1 -0
  451. package/dist/mcp/engine.js +421 -0
  452. package/dist/mcp/engine.js.map +1 -0
  453. package/dist/mcp/explore-dedup.d.ts +140 -0
  454. package/dist/mcp/explore-dedup.d.ts.map +1 -0
  455. package/dist/mcp/explore-dedup.js +239 -0
  456. package/dist/mcp/explore-dedup.js.map +1 -0
  457. package/dist/mcp/explore-diagnostics.d.ts +289 -0
  458. package/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  459. package/dist/mcp/explore-diagnostics.js +558 -0
  460. package/dist/mcp/explore-diagnostics.js.map +1 -0
  461. package/dist/mcp/explore-session-state.d.ts +217 -0
  462. package/dist/mcp/explore-session-state.d.ts.map +1 -0
  463. package/dist/mcp/explore-session-state.js +322 -0
  464. package/dist/mcp/explore-session-state.js.map +1 -0
  465. package/dist/mcp/index.d.ts +139 -0
  466. package/dist/mcp/index.d.ts.map +1 -0
  467. package/dist/mcp/index.js +636 -0
  468. package/dist/mcp/index.js.map +1 -0
  469. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  470. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  471. package/dist/mcp/liveness-watchdog.js +269 -0
  472. package/dist/mcp/liveness-watchdog.js.map +1 -0
  473. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  474. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  475. package/dist/mcp/ppid-watchdog.js +64 -0
  476. package/dist/mcp/ppid-watchdog.js.map +1 -0
  477. package/dist/mcp/proxy.d.ts +87 -0
  478. package/dist/mcp/proxy.d.ts.map +1 -0
  479. package/dist/mcp/proxy.js +672 -0
  480. package/dist/mcp/proxy.js.map +1 -0
  481. package/dist/mcp/query-pool.d.ts +108 -0
  482. package/dist/mcp/query-pool.d.ts.map +1 -0
  483. package/dist/mcp/query-pool.js +315 -0
  484. package/dist/mcp/query-pool.js.map +1 -0
  485. package/dist/mcp/query-worker.d.ts +24 -0
  486. package/dist/mcp/query-worker.d.ts.map +1 -0
  487. package/dist/mcp/query-worker.js +87 -0
  488. package/dist/mcp/query-worker.js.map +1 -0
  489. package/dist/mcp/server-instructions.d.ts +34 -0
  490. package/dist/mcp/server-instructions.d.ts.map +1 -0
  491. package/dist/mcp/server-instructions.js +113 -0
  492. package/dist/mcp/server-instructions.js.map +1 -0
  493. package/dist/mcp/session.d.ts +109 -0
  494. package/dist/mcp/session.d.ts.map +1 -0
  495. package/dist/mcp/session.js +380 -0
  496. package/dist/mcp/session.js.map +1 -0
  497. package/dist/mcp/startup-handshake.d.ts +44 -0
  498. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  499. package/dist/mcp/startup-handshake.js +73 -0
  500. package/dist/mcp/startup-handshake.js.map +1 -0
  501. package/dist/mcp/stdin-teardown.d.ts +27 -0
  502. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  503. package/dist/mcp/stdin-teardown.js +49 -0
  504. package/dist/mcp/stdin-teardown.js.map +1 -0
  505. package/dist/mcp/tools.d.ts +936 -0
  506. package/dist/mcp/tools.d.ts.map +1 -0
  507. package/dist/mcp/tools.js +6611 -0
  508. package/dist/mcp/tools.js.map +1 -0
  509. package/dist/mcp/transport.d.ts +188 -0
  510. package/dist/mcp/transport.d.ts.map +1 -0
  511. package/dist/mcp/transport.js +377 -0
  512. package/dist/mcp/transport.js.map +1 -0
  513. package/dist/mcp/version.d.ts +19 -0
  514. package/dist/mcp/version.d.ts.map +1 -0
  515. package/dist/mcp/version.js +71 -0
  516. package/dist/mcp/version.js.map +1 -0
  517. package/dist/mcp/writer-lock.d.ts +47 -0
  518. package/dist/mcp/writer-lock.d.ts.map +1 -0
  519. package/dist/mcp/writer-lock.js +218 -0
  520. package/dist/mcp/writer-lock.js.map +1 -0
  521. package/dist/project-config.d.ts +117 -0
  522. package/dist/project-config.d.ts.map +1 -0
  523. package/dist/project-config.js +409 -0
  524. package/dist/project-config.js.map +1 -0
  525. package/dist/resolution/alias-binding.d.ts +56 -0
  526. package/dist/resolution/alias-binding.d.ts.map +1 -0
  527. package/dist/resolution/alias-binding.js +118 -0
  528. package/dist/resolution/alias-binding.js.map +1 -0
  529. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  530. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  531. package/dist/resolution/c-fnptr-synthesizer.js +1506 -0
  532. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  533. package/dist/resolution/callback-synthesizer.d.ts +78 -0
  534. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  535. package/dist/resolution/callback-synthesizer.js +4105 -0
  536. package/dist/resolution/callback-synthesizer.js.map +1 -0
  537. package/dist/resolution/cooperative-yield.d.ts +40 -0
  538. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  539. package/dist/resolution/cooperative-yield.js +44 -0
  540. package/dist/resolution/cooperative-yield.js.map +1 -0
  541. package/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  542. package/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  543. package/dist/resolution/expo-router-synthesizer.js +189 -0
  544. package/dist/resolution/expo-router-synthesizer.js.map +1 -0
  545. package/dist/resolution/frameworks/astro.d.ts +9 -0
  546. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  547. package/dist/resolution/frameworks/astro.js +169 -0
  548. package/dist/resolution/frameworks/astro.js.map +1 -0
  549. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  550. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  551. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  552. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  553. package/dist/resolution/frameworks/cics.d.ts +20 -0
  554. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  555. package/dist/resolution/frameworks/cics.js +90 -0
  556. package/dist/resolution/frameworks/cics.js.map +1 -0
  557. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  558. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  559. package/dist/resolution/frameworks/csharp.js +335 -0
  560. package/dist/resolution/frameworks/csharp.js.map +1 -0
  561. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  562. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  563. package/dist/resolution/frameworks/drupal.js +367 -0
  564. package/dist/resolution/frameworks/drupal.js.map +1 -0
  565. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  566. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  567. package/dist/resolution/frameworks/expo-modules.js +148 -0
  568. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  569. package/dist/resolution/frameworks/expo-router.d.ts +189 -0
  570. package/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  571. package/dist/resolution/frameworks/expo-router.js +785 -0
  572. package/dist/resolution/frameworks/expo-router.js.map +1 -0
  573. package/dist/resolution/frameworks/express.d.ts +8 -0
  574. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  575. package/dist/resolution/frameworks/express.js +540 -0
  576. package/dist/resolution/frameworks/express.js.map +1 -0
  577. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  578. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  579. package/dist/resolution/frameworks/fabric.js +354 -0
  580. package/dist/resolution/frameworks/fabric.js.map +1 -0
  581. package/dist/resolution/frameworks/go.d.ts +8 -0
  582. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  583. package/dist/resolution/frameworks/go.js +184 -0
  584. package/dist/resolution/frameworks/go.js.map +1 -0
  585. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  586. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  587. package/dist/resolution/frameworks/goframe.js +112 -0
  588. package/dist/resolution/frameworks/goframe.js.map +1 -0
  589. package/dist/resolution/frameworks/index.d.ts +55 -0
  590. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  591. package/dist/resolution/frameworks/index.js +203 -0
  592. package/dist/resolution/frameworks/index.js.map +1 -0
  593. package/dist/resolution/frameworks/java.d.ts +8 -0
  594. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  595. package/dist/resolution/frameworks/java.js +539 -0
  596. package/dist/resolution/frameworks/java.js.map +1 -0
  597. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  598. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  599. package/dist/resolution/frameworks/laravel.js +257 -0
  600. package/dist/resolution/frameworks/laravel.js.map +1 -0
  601. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  602. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  603. package/dist/resolution/frameworks/nestjs.js +690 -0
  604. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  605. package/dist/resolution/frameworks/nextjs.d.ts +76 -0
  606. package/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  607. package/dist/resolution/frameworks/nextjs.js +328 -0
  608. package/dist/resolution/frameworks/nextjs.js.map +1 -0
  609. package/dist/resolution/frameworks/object-literal.d.ts +32 -0
  610. package/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  611. package/dist/resolution/frameworks/object-literal.js +139 -0
  612. package/dist/resolution/frameworks/object-literal.js.map +1 -0
  613. package/dist/resolution/frameworks/package-deps.d.ts +14 -0
  614. package/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  615. package/dist/resolution/frameworks/package-deps.js +78 -0
  616. package/dist/resolution/frameworks/package-deps.js.map +1 -0
  617. package/dist/resolution/frameworks/play.d.ts +19 -0
  618. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  619. package/dist/resolution/frameworks/play.js +111 -0
  620. package/dist/resolution/frameworks/play.js.map +1 -0
  621. package/dist/resolution/frameworks/python.d.ts +10 -0
  622. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  623. package/dist/resolution/frameworks/python.js +566 -0
  624. package/dist/resolution/frameworks/python.js.map +1 -0
  625. package/dist/resolution/frameworks/react-native.d.ts +29 -0
  626. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  627. package/dist/resolution/frameworks/react-native.js +549 -0
  628. package/dist/resolution/frameworks/react-native.js.map +1 -0
  629. package/dist/resolution/frameworks/react-router.d.ts +46 -0
  630. package/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  631. package/dist/resolution/frameworks/react-router.js +187 -0
  632. package/dist/resolution/frameworks/react-router.js.map +1 -0
  633. package/dist/resolution/frameworks/react.d.ts +9 -0
  634. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  635. package/dist/resolution/frameworks/react.js +257 -0
  636. package/dist/resolution/frameworks/react.js.map +1 -0
  637. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  638. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  639. package/dist/resolution/frameworks/ruby.js +302 -0
  640. package/dist/resolution/frameworks/ruby.js.map +1 -0
  641. package/dist/resolution/frameworks/rust.d.ts +8 -0
  642. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  643. package/dist/resolution/frameworks/rust.js +304 -0
  644. package/dist/resolution/frameworks/rust.js.map +1 -0
  645. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  646. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  647. package/dist/resolution/frameworks/svelte.js +258 -0
  648. package/dist/resolution/frameworks/svelte.js.map +1 -0
  649. package/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  650. package/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  651. package/dist/resolution/frameworks/sveltekit-router.js +156 -0
  652. package/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  653. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  654. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  655. package/dist/resolution/frameworks/swift-objc.js +252 -0
  656. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  657. package/dist/resolution/frameworks/swift.d.ts +10 -0
  658. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  659. package/dist/resolution/frameworks/swift.js +410 -0
  660. package/dist/resolution/frameworks/swift.js.map +1 -0
  661. package/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  662. package/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  663. package/dist/resolution/frameworks/tanstack-router.js +437 -0
  664. package/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  665. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  666. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  667. package/dist/resolution/frameworks/terraform.js +277 -0
  668. package/dist/resolution/frameworks/terraform.js.map +1 -0
  669. package/dist/resolution/frameworks/vue-router.d.ts +82 -0
  670. package/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  671. package/dist/resolution/frameworks/vue-router.js +377 -0
  672. package/dist/resolution/frameworks/vue-router.js.map +1 -0
  673. package/dist/resolution/frameworks/vue.d.ts +9 -0
  674. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  675. package/dist/resolution/frameworks/vue.js +303 -0
  676. package/dist/resolution/frameworks/vue.js.map +1 -0
  677. package/dist/resolution/go-module.d.ts +26 -0
  678. package/dist/resolution/go-module.d.ts.map +1 -0
  679. package/dist/resolution/go-module.js +78 -0
  680. package/dist/resolution/go-module.js.map +1 -0
  681. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  682. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  683. package/dist/resolution/goframe-synthesizer.js +163 -0
  684. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  685. package/dist/resolution/import-resolver.d.ts +122 -0
  686. package/dist/resolution/import-resolver.d.ts.map +1 -0
  687. package/dist/resolution/import-resolver.js +2490 -0
  688. package/dist/resolution/import-resolver.js.map +1 -0
  689. package/dist/resolution/index.d.ts +402 -0
  690. package/dist/resolution/index.d.ts.map +1 -0
  691. package/dist/resolution/index.js +2581 -0
  692. package/dist/resolution/index.js.map +1 -0
  693. package/dist/resolution/js-builtins.d.ts +11 -0
  694. package/dist/resolution/js-builtins.d.ts.map +1 -0
  695. package/dist/resolution/js-builtins.js +23 -0
  696. package/dist/resolution/js-builtins.js.map +1 -0
  697. package/dist/resolution/lru-cache.d.ts +24 -0
  698. package/dist/resolution/lru-cache.d.ts.map +1 -0
  699. package/dist/resolution/lru-cache.js +62 -0
  700. package/dist/resolution/lru-cache.js.map +1 -0
  701. package/dist/resolution/memory-budget.d.ts +48 -0
  702. package/dist/resolution/memory-budget.d.ts.map +1 -0
  703. package/dist/resolution/memory-budget.js +162 -0
  704. package/dist/resolution/memory-budget.js.map +1 -0
  705. package/dist/resolution/name-matcher.d.ts +196 -0
  706. package/dist/resolution/name-matcher.d.ts.map +1 -0
  707. package/dist/resolution/name-matcher.js +3484 -0
  708. package/dist/resolution/name-matcher.js.map +1 -0
  709. package/dist/resolution/next-router-synthesizer.d.ts +27 -0
  710. package/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  711. package/dist/resolution/next-router-synthesizer.js +113 -0
  712. package/dist/resolution/next-router-synthesizer.js.map +1 -0
  713. package/dist/resolution/path-aliases.d.ts +70 -0
  714. package/dist/resolution/path-aliases.d.ts.map +1 -0
  715. package/dist/resolution/path-aliases.js +346 -0
  716. package/dist/resolution/path-aliases.js.map +1 -0
  717. package/dist/resolution/react-router-synthesizer.d.ts +33 -0
  718. package/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  719. package/dist/resolution/react-router-synthesizer.js +126 -0
  720. package/dist/resolution/react-router-synthesizer.js.map +1 -0
  721. package/dist/resolution/resolver-pool.d.ts +106 -0
  722. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  723. package/dist/resolution/resolver-pool.js +344 -0
  724. package/dist/resolution/resolver-pool.js.map +1 -0
  725. package/dist/resolution/resolver-worker.d.ts +17 -0
  726. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  727. package/dist/resolution/resolver-worker.js +141 -0
  728. package/dist/resolution/resolver-worker.js.map +1 -0
  729. package/dist/resolution/strip-comments.d.ts +33 -0
  730. package/dist/resolution/strip-comments.d.ts.map +1 -0
  731. package/dist/resolution/strip-comments.js +550 -0
  732. package/dist/resolution/strip-comments.js.map +1 -0
  733. package/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  734. package/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  735. package/dist/resolution/sveltekit-synthesizer.js +173 -0
  736. package/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  737. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  738. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  739. package/dist/resolution/swift-objc-bridge.js +256 -0
  740. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  741. package/dist/resolution/synth-utils.d.ts +26 -0
  742. package/dist/resolution/synth-utils.d.ts.map +1 -0
  743. package/dist/resolution/synth-utils.js +75 -0
  744. package/dist/resolution/synth-utils.js.map +1 -0
  745. package/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  746. package/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  747. package/dist/resolution/tanstack-router-synthesizer.js +114 -0
  748. package/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  749. package/dist/resolution/tier-synthesizer.d.ts +48 -0
  750. package/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  751. package/dist/resolution/tier-synthesizer.js +907 -0
  752. package/dist/resolution/tier-synthesizer.js.map +1 -0
  753. package/dist/resolution/types.d.ts +323 -0
  754. package/dist/resolution/types.d.ts.map +1 -0
  755. package/dist/resolution/types.js +58 -0
  756. package/dist/resolution/types.js.map +1 -0
  757. package/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  758. package/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  759. package/dist/resolution/vue-router-synthesizer.js +115 -0
  760. package/dist/resolution/vue-router-synthesizer.js.map +1 -0
  761. package/dist/resolution/workspace-packages.d.ts +58 -0
  762. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  763. package/dist/resolution/workspace-packages.js +346 -0
  764. package/dist/resolution/workspace-packages.js.map +1 -0
  765. package/dist/search/identifier-segments.d.ts +70 -0
  766. package/dist/search/identifier-segments.d.ts.map +1 -0
  767. package/dist/search/identifier-segments.js +205 -0
  768. package/dist/search/identifier-segments.js.map +1 -0
  769. package/dist/search/query-parser.d.ts +57 -0
  770. package/dist/search/query-parser.d.ts.map +1 -0
  771. package/dist/search/query-parser.js +177 -0
  772. package/dist/search/query-parser.js.map +1 -0
  773. package/dist/search/query-paths.d.ts +57 -0
  774. package/dist/search/query-paths.d.ts.map +1 -0
  775. package/dist/search/query-paths.js +298 -0
  776. package/dist/search/query-paths.js.map +1 -0
  777. package/dist/search/query-utils.d.ts +102 -0
  778. package/dist/search/query-utils.d.ts.map +1 -0
  779. package/dist/search/query-utils.js +487 -0
  780. package/dist/search/query-utils.js.map +1 -0
  781. package/dist/sync/git-hooks.d.ts +45 -0
  782. package/dist/sync/git-hooks.d.ts.map +1 -0
  783. package/dist/sync/git-hooks.js +227 -0
  784. package/dist/sync/git-hooks.js.map +1 -0
  785. package/dist/sync/index.d.ts +19 -0
  786. package/dist/sync/index.d.ts.map +1 -0
  787. package/dist/sync/index.js +35 -0
  788. package/dist/sync/index.js.map +1 -0
  789. package/dist/sync/watch-policy.d.ts +48 -0
  790. package/dist/sync/watch-policy.d.ts.map +1 -0
  791. package/dist/sync/watch-policy.js +124 -0
  792. package/dist/sync/watch-policy.js.map +1 -0
  793. package/dist/sync/watcher.d.ts +402 -0
  794. package/dist/sync/watcher.d.ts.map +1 -0
  795. package/dist/sync/watcher.js +978 -0
  796. package/dist/sync/watcher.js.map +1 -0
  797. package/dist/sync/worktree.d.ts +63 -0
  798. package/dist/sync/worktree.d.ts.map +1 -0
  799. package/dist/sync/worktree.js +182 -0
  800. package/dist/sync/worktree.js.map +1 -0
  801. package/dist/telemetry/index.d.ts +145 -0
  802. package/dist/telemetry/index.d.ts.map +1 -0
  803. package/dist/telemetry/index.js +592 -0
  804. package/dist/telemetry/index.js.map +1 -0
  805. package/dist/types.d.ts +473 -0
  806. package/dist/types.d.ts.map +1 -0
  807. package/dist/types.js +118 -0
  808. package/dist/types.js.map +1 -0
  809. package/dist/ui/color.d.ts +21 -0
  810. package/dist/ui/color.d.ts.map +1 -0
  811. package/dist/ui/color.js +42 -0
  812. package/dist/ui/color.js.map +1 -0
  813. package/dist/ui/glyphs.d.ts +67 -0
  814. package/dist/ui/glyphs.d.ts.map +1 -0
  815. package/dist/ui/glyphs.js +125 -0
  816. package/dist/ui/glyphs.js.map +1 -0
  817. package/dist/ui/shimmer-progress.d.ts +11 -0
  818. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  819. package/dist/ui/shimmer-progress.js +164 -0
  820. package/dist/ui/shimmer-progress.js.map +1 -0
  821. package/dist/ui/shimmer-worker.d.ts +2 -0
  822. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  823. package/dist/ui/shimmer-worker.js +126 -0
  824. package/dist/ui/shimmer-worker.js.map +1 -0
  825. package/dist/ui/types.d.ts +15 -0
  826. package/dist/ui/types.d.ts.map +1 -0
  827. package/dist/ui/types.js +3 -0
  828. package/dist/ui/types.js.map +1 -0
  829. package/dist/ui-server/api/deadcode.d.ts +84 -0
  830. package/dist/ui-server/api/deadcode.d.ts.map +1 -0
  831. package/dist/ui-server/api/deadcode.js +136 -0
  832. package/dist/ui-server/api/deadcode.js.map +1 -0
  833. package/dist/ui-server/api/effects.d.ts +87 -0
  834. package/dist/ui-server/api/effects.d.ts.map +1 -0
  835. package/dist/ui-server/api/effects.js +499 -0
  836. package/dist/ui-server/api/effects.js.map +1 -0
  837. package/dist/ui-server/api/entrypoints.d.ts +86 -0
  838. package/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  839. package/dist/ui-server/api/entrypoints.js +279 -0
  840. package/dist/ui-server/api/entrypoints.js.map +1 -0
  841. package/dist/ui-server/api/events.d.ts +183 -0
  842. package/dist/ui-server/api/events.d.ts.map +1 -0
  843. package/dist/ui-server/api/events.js +430 -0
  844. package/dist/ui-server/api/events.js.map +1 -0
  845. package/dist/ui-server/api/file.d.ts +66 -0
  846. package/dist/ui-server/api/file.d.ts.map +1 -0
  847. package/dist/ui-server/api/file.js +235 -0
  848. package/dist/ui-server/api/file.js.map +1 -0
  849. package/dist/ui-server/api/filecode.d.ts +126 -0
  850. package/dist/ui-server/api/filecode.d.ts.map +1 -0
  851. package/dist/ui-server/api/filecode.js +205 -0
  852. package/dist/ui-server/api/filecode.js.map +1 -0
  853. package/dist/ui-server/api/flow.d.ts +226 -0
  854. package/dist/ui-server/api/flow.d.ts.map +1 -0
  855. package/dist/ui-server/api/flow.js +611 -0
  856. package/dist/ui-server/api/flow.js.map +1 -0
  857. package/dist/ui-server/api/hierarchy.d.ts +81 -0
  858. package/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  859. package/dist/ui-server/api/hierarchy.js +92 -0
  860. package/dist/ui-server/api/hierarchy.js.map +1 -0
  861. package/dist/ui-server/api/index.d.ts +90 -0
  862. package/dist/ui-server/api/index.d.ts.map +1 -0
  863. package/dist/ui-server/api/index.js +332 -0
  864. package/dist/ui-server/api/index.js.map +1 -0
  865. package/dist/ui-server/api/map.d.ts +238 -0
  866. package/dist/ui-server/api/map.d.ts.map +1 -0
  867. package/dist/ui-server/api/map.js +681 -0
  868. package/dist/ui-server/api/map.js.map +1 -0
  869. package/dist/ui-server/api/node.d.ts +81 -0
  870. package/dist/ui-server/api/node.d.ts.map +1 -0
  871. package/dist/ui-server/api/node.js +388 -0
  872. package/dist/ui-server/api/node.js.map +1 -0
  873. package/dist/ui-server/api/nodes.d.ts +25 -0
  874. package/dist/ui-server/api/nodes.d.ts.map +1 -0
  875. package/dist/ui-server/api/nodes.js +45 -0
  876. package/dist/ui-server/api/nodes.js.map +1 -0
  877. package/dist/ui-server/api/program.d.ts +139 -0
  878. package/dist/ui-server/api/program.d.ts.map +1 -0
  879. package/dist/ui-server/api/program.js +315 -0
  880. package/dist/ui-server/api/program.js.map +1 -0
  881. package/dist/ui-server/api/respond.d.ts +76 -0
  882. package/dist/ui-server/api/respond.d.ts.map +1 -0
  883. package/dist/ui-server/api/respond.js +186 -0
  884. package/dist/ui-server/api/respond.js.map +1 -0
  885. package/dist/ui-server/api/route-roots.d.ts +39 -0
  886. package/dist/ui-server/api/route-roots.d.ts.map +1 -0
  887. package/dist/ui-server/api/route-roots.js +96 -0
  888. package/dist/ui-server/api/route-roots.js.map +1 -0
  889. package/dist/ui-server/api/routes.d.ts +59 -0
  890. package/dist/ui-server/api/routes.d.ts.map +1 -0
  891. package/dist/ui-server/api/routes.js +112 -0
  892. package/dist/ui-server/api/routes.js.map +1 -0
  893. package/dist/ui-server/api/screens.d.ts +117 -0
  894. package/dist/ui-server/api/screens.d.ts.map +1 -0
  895. package/dist/ui-server/api/screens.js +611 -0
  896. package/dist/ui-server/api/screens.js.map +1 -0
  897. package/dist/ui-server/api/search.d.ts +29 -0
  898. package/dist/ui-server/api/search.d.ts.map +1 -0
  899. package/dist/ui-server/api/search.js +232 -0
  900. package/dist/ui-server/api/search.js.map +1 -0
  901. package/dist/ui-server/api/session.d.ts +52 -0
  902. package/dist/ui-server/api/session.d.ts.map +1 -0
  903. package/dist/ui-server/api/session.js +199 -0
  904. package/dist/ui-server/api/session.js.map +1 -0
  905. package/dist/ui-server/api/source.d.ts +200 -0
  906. package/dist/ui-server/api/source.d.ts.map +1 -0
  907. package/dist/ui-server/api/source.js +419 -0
  908. package/dist/ui-server/api/source.js.map +1 -0
  909. package/dist/ui-server/api/stats.d.ts +27 -0
  910. package/dist/ui-server/api/stats.d.ts.map +1 -0
  911. package/dist/ui-server/api/stats.js +164 -0
  912. package/dist/ui-server/api/stats.js.map +1 -0
  913. package/dist/ui-server/api/steps.d.ts +274 -0
  914. package/dist/ui-server/api/steps.d.ts.map +1 -0
  915. package/dist/ui-server/api/steps.js +1446 -0
  916. package/dist/ui-server/api/steps.js.map +1 -0
  917. package/dist/ui-server/api/trail-store.d.ts +142 -0
  918. package/dist/ui-server/api/trail-store.d.ts.map +1 -0
  919. package/dist/ui-server/api/trail-store.js +323 -0
  920. package/dist/ui-server/api/trail-store.js.map +1 -0
  921. package/dist/ui-server/api/trails.d.ts +163 -0
  922. package/dist/ui-server/api/trails.d.ts.map +1 -0
  923. package/dist/ui-server/api/trails.js +369 -0
  924. package/dist/ui-server/api/trails.js.map +1 -0
  925. package/dist/ui-server/api/when.d.ts +125 -0
  926. package/dist/ui-server/api/when.d.ts.map +1 -0
  927. package/dist/ui-server/api/when.js +251 -0
  928. package/dist/ui-server/api/when.js.map +1 -0
  929. package/dist/ui-server/api/wire.d.ts +179 -0
  930. package/dist/ui-server/api/wire.d.ts.map +1 -0
  931. package/dist/ui-server/api/wire.js +231 -0
  932. package/dist/ui-server/api/wire.js.map +1 -0
  933. package/dist/ui-server/assets.d.ts +40 -0
  934. package/dist/ui-server/assets.d.ts.map +1 -0
  935. package/dist/ui-server/assets.js +110 -0
  936. package/dist/ui-server/assets.js.map +1 -0
  937. package/dist/ui-server/constants.d.ts +32 -0
  938. package/dist/ui-server/constants.d.ts.map +1 -0
  939. package/dist/ui-server/constants.js +35 -0
  940. package/dist/ui-server/constants.js.map +1 -0
  941. package/dist/ui-server/highlight/index.d.ts +113 -0
  942. package/dist/ui-server/highlight/index.d.ts.map +1 -0
  943. package/dist/ui-server/highlight/index.js +307 -0
  944. package/dist/ui-server/highlight/index.js.map +1 -0
  945. package/dist/ui-server/highlight/languages.d.ts +36 -0
  946. package/dist/ui-server/highlight/languages.d.ts.map +1 -0
  947. package/dist/ui-server/highlight/languages.js +50 -0
  948. package/dist/ui-server/highlight/languages.js.map +1 -0
  949. package/dist/ui-server/index.d.ts +92 -0
  950. package/dist/ui-server/index.d.ts.map +1 -0
  951. package/dist/ui-server/index.js +399 -0
  952. package/dist/ui-server/index.js.map +1 -0
  953. package/dist/ui-server/open-browser.d.ts +31 -0
  954. package/dist/ui-server/open-browser.d.ts.map +1 -0
  955. package/dist/ui-server/open-browser.js +79 -0
  956. package/dist/ui-server/open-browser.js.map +1 -0
  957. package/dist/ui-server/security.d.ts +127 -0
  958. package/dist/ui-server/security.d.ts.map +1 -0
  959. package/dist/ui-server/security.js +332 -0
  960. package/dist/ui-server/security.js.map +1 -0
  961. package/dist/ui-server/static.d.ts +45 -0
  962. package/dist/ui-server/static.d.ts.map +1 -0
  963. package/dist/ui-server/static.js +165 -0
  964. package/dist/ui-server/static.js.map +1 -0
  965. package/dist/upgrade/index.d.ts +164 -0
  966. package/dist/upgrade/index.d.ts.map +1 -0
  967. package/dist/upgrade/index.js +649 -0
  968. package/dist/upgrade/index.js.map +1 -0
  969. package/dist/upgrade/remove-binary.d.ts +87 -0
  970. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  971. package/dist/upgrade/remove-binary.js +289 -0
  972. package/dist/upgrade/remove-binary.js.map +1 -0
  973. package/dist/upgrade/update-check.d.ts +92 -0
  974. package/dist/upgrade/update-check.d.ts.map +1 -0
  975. package/dist/upgrade/update-check.js +258 -0
  976. package/dist/upgrade/update-check.js.map +1 -0
  977. package/dist/utils.d.ts +238 -0
  978. package/dist/utils.d.ts.map +1 -0
  979. package/dist/utils.js +601 -0
  980. package/dist/utils.js.map +1 -0
  981. package/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  982. package/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  983. package/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  984. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  985. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  986. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  987. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  988. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  989. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  990. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  991. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  992. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  993. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  994. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  995. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  996. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  997. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  998. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  999. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  1000. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  1001. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  1002. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  1003. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  1004. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  1005. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  1006. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  1007. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  1008. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  1009. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  1010. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  1011. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  1012. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  1013. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  1014. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  1015. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  1016. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  1017. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  1018. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  1019. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  1020. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  1021. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  1022. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  1023. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  1024. package/dist/viewer/assets/index-2LG7iXtP.js +97 -0
  1025. package/dist/viewer/assets/index-AtMBttuU.css +1 -0
  1026. package/dist/viewer/index.html +16 -0
  1027. package/package.json +69 -0
  1028. package/scripts/add-lang/bench.sh +60 -0
  1029. package/scripts/add-lang/check-grammar.mjs +75 -0
  1030. package/scripts/add-lang/dump-ast.mjs +103 -0
  1031. package/scripts/add-lang/verify-extraction.mjs +70 -0
  1032. package/scripts/agent-eval/ab-adoption.sh +91 -0
  1033. package/scripts/agent-eval/ab-hook.sh +86 -0
  1034. package/scripts/agent-eval/ab-impl.sh +78 -0
  1035. package/scripts/agent-eval/ab-new-vs-baseline.sh +161 -0
  1036. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  1037. package/scripts/agent-eval/allocation-fixtures.json +344 -0
  1038. package/scripts/agent-eval/arms-F.sh +21 -0
  1039. package/scripts/agent-eval/arms-matrix.sh +37 -0
  1040. package/scripts/agent-eval/audit.sh +68 -0
  1041. package/scripts/agent-eval/bench-readme.sh +48 -0
  1042. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  1043. package/scripts/agent-eval/block-read-hook.sh +19 -0
  1044. package/scripts/agent-eval/compare-arms.mjs +209 -0
  1045. package/scripts/agent-eval/diff-index-drift.mjs +102 -0
  1046. package/scripts/agent-eval/hook-settings.json +15 -0
  1047. package/scripts/agent-eval/itrun.sh +120 -0
  1048. package/scripts/agent-eval/no-cli-shim.sh +96 -0
  1049. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  1050. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  1051. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  1052. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  1053. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  1054. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  1055. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  1056. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  1057. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  1058. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  1059. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  1060. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  1061. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  1062. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  1063. package/scripts/agent-eval/offload-eval.md +76 -0
  1064. package/scripts/agent-eval/parse-arms.mjs +116 -0
  1065. package/scripts/agent-eval/parse-bench-readme.mjs +238 -0
  1066. package/scripts/agent-eval/parse-run.mjs +1401 -0
  1067. package/scripts/agent-eval/parse-session.mjs +130 -0
  1068. package/scripts/agent-eval/probe-allocation.mjs +335 -0
  1069. package/scripts/agent-eval/probe-context.mjs +21 -0
  1070. package/scripts/agent-eval/probe-decl-only.mjs +198 -0
  1071. package/scripts/agent-eval/probe-explore.mjs +40 -0
  1072. package/scripts/agent-eval/probe-factory-closure.mjs +147 -0
  1073. package/scripts/agent-eval/probe-file-spend.mjs +195 -0
  1074. package/scripts/agent-eval/probe-named-symbol.mjs +163 -0
  1075. package/scripts/agent-eval/probe-node.mjs +20 -0
  1076. package/scripts/agent-eval/probe-suite-envelope.mjs +124 -0
  1077. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  1078. package/scripts/agent-eval/probe-trace.mjs +20 -0
  1079. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  1080. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  1081. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  1082. package/scripts/agent-eval/run-agent.sh +34 -0
  1083. package/scripts/agent-eval/run-all.sh +149 -0
  1084. package/scripts/agent-eval/run-arms.sh +56 -0
  1085. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  1086. package/scripts/benchmarks/measure-index.cjs +128 -0
  1087. package/scripts/benchmarks/observe-index.py +91 -0
  1088. package/scripts/build-bundle.sh +154 -0
  1089. package/scripts/build-kernel.sh +87 -0
  1090. package/scripts/check-ui-build.mjs +157 -0
  1091. package/scripts/check-ui-package.mjs +192 -0
  1092. package/scripts/clean-remaining.mjs +243 -0
  1093. package/scripts/count-codegraph.mjs +26 -0
  1094. package/scripts/deep-clean.mjs +66 -0
  1095. package/scripts/dump-graph.mjs +57 -0
  1096. package/scripts/extract-release-notes.mjs +130 -0
  1097. package/scripts/final-codegraph-cleanup.mjs +57 -0
  1098. package/scripts/go-rebrand.mjs +114 -0
  1099. package/scripts/kernel-parity.mjs +283 -0
  1100. package/scripts/local-install.sh +41 -0
  1101. package/scripts/npm-sdk.js +75 -0
  1102. package/scripts/npm-shim.js +279 -0
  1103. package/scripts/pack-npm.sh +123 -0
  1104. package/scripts/prepare-release.mjs +270 -0
  1105. package/scripts/rebrand.mjs +129 -0
  1106. package/scripts/sync-ui-version.mjs +47 -0
  1107. package/scripts/try-repo.sh +112 -0
@@ -0,0 +1,2643 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Alpha Code Sense CLI (deprecated alias)
5
+ *
6
+ * Command-line interface for Alpha Code Sense code intelligence.
7
+ *
8
+ * Usage:
9
+ * codegraph Run interactive installer (when no args)
10
+ * codegraph install Run interactive installer
11
+ * ltm-alpha-cs uninstall Remove Alpha Code Sense from your agents
12
+ * codegraph init [path] Initialize Alpha Code Sense in a project
13
+ * codegraph uninit [path] Remove Alpha Code Sense from a project
14
+ * codegraph index [path] Index all files in the project
15
+ * codegraph sync [path] Sync changes since last index
16
+ * ltm-alpha-cs status [path] Show index status
17
+ * codegraph query <search> Search for symbols
18
+ * codegraph files [options] Show project file structure
19
+ * codegraph context <task> Build context for a task
20
+ * codegraph callers <symbol> Find what calls a function/method
21
+ * codegraph callees <symbol> Find what a function/method calls
22
+ * codegraph impact <symbol> Analyze what code is affected by changing a symbol
23
+ * codegraph affected [files] Find test files affected by changes
24
+ * codegraph ui [path] Open the browser viewer for an indexed project (alias: web)
25
+ * ltm-alpha-cs upgrade [version] Update Alpha Code Sense to the latest release
26
+ */
27
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ var desc = Object.getOwnPropertyDescriptor(m, k);
30
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
+ desc = { enumerable: true, get: function() { return m[k]; } };
32
+ }
33
+ Object.defineProperty(o, k2, desc);
34
+ }) : (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ o[k2] = m[k];
37
+ }));
38
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
39
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
40
+ }) : function(o, v) {
41
+ o["default"] = v;
42
+ });
43
+ var __importStar = (this && this.__importStar) || (function () {
44
+ var ownKeys = function(o) {
45
+ ownKeys = Object.getOwnPropertyNames || function (o) {
46
+ var ar = [];
47
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
48
+ return ar;
49
+ };
50
+ return ownKeys(o);
51
+ };
52
+ return function (mod) {
53
+ if (mod && mod.__esModule) return mod;
54
+ var result = {};
55
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
56
+ __setModuleDefault(result, mod);
57
+ return result;
58
+ };
59
+ })();
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ // FIRST import, before anything else loads: capture process.ppid while our
62
+ // launcher is (almost certainly) still alive. A launcher killed mid-startup
63
+ // otherwise blinds the PPID watchdog forever (#1185) — see early-ppid.ts.
64
+ require("../mcp/early-ppid");
65
+ // Persist V8 compile artifacts across runs (Node ≥22.8). Every invocation —
66
+ // and every worker thread, which re-requires the whole extraction module
67
+ // graph — skips recompiling unchanged sources. Worth hundreds of ms of
68
+ // worker-boot latency per bulk index; harmless no-op when unavailable.
69
+ try {
70
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
71
+ require('node:module').enableCompileCache?.();
72
+ }
73
+ catch { /* cache is best-effort */ }
74
+ const commander_1 = require("commander");
75
+ const path = __importStar(require("path"));
76
+ const fs = __importStar(require("fs"));
77
+ const directory_1 = require("../directory");
78
+ const identifier_segments_1 = require("../search/identifier-segments");
79
+ const worktree_1 = require("../sync/worktree");
80
+ const shimmer_progress_1 = require("../ui/shimmer-progress");
81
+ const glyphs_1 = require("../ui/glyphs");
82
+ const color_1 = require("../ui/color");
83
+ const node_version_check_1 = require("./node-version-check");
84
+ const fatal_handler_1 = require("./fatal-handler");
85
+ const wasm_runtime_flags_1 = require("../extraction/wasm-runtime-flags");
86
+ const command_supervision_1 = require("./command-supervision");
87
+ const extraction_version_1 = require("../extraction/extraction-version");
88
+ const telemetry_1 = require("../telemetry");
89
+ // Value import, but dependency-free by design so `--help` text can name the
90
+ // default port without dragging node:http into every other subcommand; the
91
+ // server itself is loaded lazily inside the `ui` action. See ui-server/constants.
92
+ const constants_1 = require("../ui-server/constants");
93
+ const symbol_lookup_1 = require("../graph/symbol-lookup");
94
+ const query_utils_1 = require("../search/query-utils");
95
+ // Decided once, before `--color`/`--no-color` are stripped from argv below
96
+ // (#1281). Piped/redirected stdout, NO_COLOR, or --no-color -> plain output.
97
+ const COLORS_ENABLED = (0, color_1.ansiColorsEnabled)();
98
+ // Lazy-load heavy modules (Alpha Code Sense, runInstaller) to keep CLI startup fast.
99
+ async function loadAlphaCodeSense() {
100
+ try {
101
+ return await Promise.resolve().then(() => __importStar(require('../index')));
102
+ }
103
+ catch (err) {
104
+ const msg = err instanceof Error ? err.message : String(err);
105
+ const [red, reset] = COLORS_ENABLED ? ['\x1b[31m', '\x1b[0m'] : ['', ''];
106
+ console.error(`${red}${(0, glyphs_1.getGlyphs)().err}${reset} Failed to load Alpha Code Sense modules.`);
107
+ console.error(`\n Node: ${process.version} Platform: ${process.platform} ${process.arch}`);
108
+ console.error(`\n Error: ${msg}`);
109
+ console.error('\n Try reinstalling with: npm install -g @ltm/alpha-cs\n');
110
+ process.exit(1);
111
+ }
112
+ }
113
+ // Dynamic import helper — tsc compiles import() to require() in CJS mode,
114
+ // which fails for ESM-only packages. This bypasses the transformation.
115
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
116
+ const importESM = new Function('specifier', 'return import(specifier)');
117
+ // Block Alpha Code Sense on Node.js 25.x — V8's turboshaft WASM JIT has a Zone
118
+ // allocator bug that reliably crashes when compiling tree-sitter
119
+ // grammars (see #54, #81, #140). The previous behaviour was a soft
120
+ // console.warn that scrolls off-screen before the OOM crash 30 seconds
121
+ // later, leading to a steady stream of "what is this OOM" reports.
122
+ // Hard-exit before any WASM work; allow override via env var for users
123
+ // who patched V8 themselves or want to test a future fix.
124
+ const nodeVersion = process.versions.node;
125
+ const nodeMajor = parseInt(nodeVersion.split('.')[0] ?? '0', 10);
126
+ if (nodeMajor >= 25) {
127
+ process.stderr.write((0, node_version_check_1.buildNode25BlockBanner)(nodeVersion) + '\n');
128
+ if (!process.env.CODEGRAPH_ALLOW_UNSAFE_NODE) {
129
+ process.exit(1);
130
+ }
131
+ // Override active — banner shown for visibility, continuing.
132
+ }
133
+ // Enforce the supported Node floor. `engines` in package.json only *warns* on
134
+ // install (unless engine-strict), so hard-block here to actually keep users off
135
+ // unsupported versions. Mirrors the 25+ block above. See package.json `engines`.
136
+ if (nodeMajor < node_version_check_1.MIN_NODE_MAJOR) {
137
+ process.stderr.write((0, node_version_check_1.buildNodeTooOldBanner)(nodeVersion) + '\n');
138
+ if (!process.env.CODEGRAPH_ALLOW_UNSAFE_NODE) {
139
+ process.exit(1);
140
+ }
141
+ // Override active — banner shown for visibility, continuing.
142
+ }
143
+ // Re-exec with V8's `--liftoff-only` if it isn't already set, so tree-sitter's
144
+ // large WASM grammars never hit the turboshaft Zone OOM (`Fatal process out of
145
+ // memory: Zone`) on Node >= 22. No-op under the bundled launcher, which already
146
+ // passes the flag. Must run before any grammar (in the parse worker, which
147
+ // inherits this process's flags) is compiled. See ../extraction/wasm-runtime-flags.
148
+ (0, wasm_runtime_flags_1.relaunchWithWasmRuntimeFlagsIfNeeded)(__filename);
149
+ // Last-resort fatal handlers: log a bounded line and exit non-zero. A fault
150
+ // that reaches here escaped every boundary, so the process is in an undefined
151
+ // state — keeping it alive is what let the detached MCP daemon orphan and pin a
152
+ // CPU core with no recovery (#799, #850). Installed before the command branch
153
+ // so it also covers a synchronous throw during startup. See ./fatal-handler.
154
+ (0, fatal_handler_1.installFatalHandlers)();
155
+ // Check if running with no arguments - run installer
156
+ if (process.argv.length === 2) {
157
+ Promise.resolve().then(() => __importStar(require('../installer'))).then(({ runInstaller }) => runInstaller()).catch((err) => {
158
+ console.error('Installation failed:', err instanceof Error ? err.message : String(err));
159
+ process.exit(1);
160
+ });
161
+ }
162
+ else {
163
+ // Normal CLI flow
164
+ main();
165
+ }
166
+ function main() {
167
+ const program = new commander_1.Command();
168
+ // Version from package.json
169
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8'));
170
+ // Make the version trivial to reach. commander's `.version()` (below) wires up
171
+ // `--version` and `-V`; intercept the spellings it can't — lowercase `-v` and
172
+ // single-dash `-version` — before any parsing. (commander's version short flag
173
+ // is the capital `-V`, and its parser rejects a multi-character single-dash
174
+ // flag.) The bare `codegraph version` subcommand is registered further down so
175
+ // the affordance also shows up in `codegraph --help`.
176
+ const firstArg = process.argv[2];
177
+ if (firstArg === '-v' || firstArg === '-version') {
178
+ console.log(packageJson.version);
179
+ return;
180
+ }
181
+ // =============================================================================
182
+ // ANSI Color Helpers (avoid chalk ESM issues)
183
+ // =============================================================================
184
+ // `--color` / `--no-color` are global and position-independent — they were
185
+ // already read by ansiColorsEnabled() at module load, so strip them before
186
+ // commander parses (a subcommand would otherwise reject the unknown flag).
187
+ process.argv = process.argv.filter((a) => a !== '--color' && a !== '--no-color');
188
+ const colors = COLORS_ENABLED
189
+ ? {
190
+ reset: '\x1b[0m',
191
+ bold: '\x1b[1m',
192
+ dim: '\x1b[2m',
193
+ red: '\x1b[31m',
194
+ green: '\x1b[32m',
195
+ yellow: '\x1b[33m',
196
+ blue: '\x1b[34m',
197
+ cyan: '\x1b[36m',
198
+ white: '\x1b[37m',
199
+ gray: '\x1b[90m',
200
+ }
201
+ : {
202
+ reset: '',
203
+ bold: '',
204
+ dim: '',
205
+ red: '',
206
+ green: '',
207
+ yellow: '',
208
+ blue: '',
209
+ cyan: '',
210
+ white: '',
211
+ gray: '',
212
+ };
213
+ const chalk = {
214
+ bold: (s) => `${colors.bold}${s}${colors.reset}`,
215
+ dim: (s) => `${colors.dim}${s}${colors.reset}`,
216
+ red: (s) => `${colors.red}${s}${colors.reset}`,
217
+ green: (s) => `${colors.green}${s}${colors.reset}`,
218
+ yellow: (s) => `${colors.yellow}${s}${colors.reset}`,
219
+ blue: (s) => `${colors.blue}${s}${colors.reset}`,
220
+ cyan: (s) => `${colors.cyan}${s}${colors.reset}`,
221
+ white: (s) => `${colors.white}${s}${colors.reset}`,
222
+ gray: (s) => `${colors.gray}${s}${colors.reset}`,
223
+ };
224
+ program
225
+ .name('codegraph')
226
+ .description('Code intelligence and knowledge graph for any codebase')
227
+ .version(packageJson.version)
228
+ // Parsed manually before commander runs (any argv position works); declared
229
+ // here so they show up in --help. NO_COLOR / FORCE_COLOR env vars are also
230
+ // honored, and piped output defaults to no color (#1281).
231
+ .option('--color', 'force ANSI colors even when stdout is not a TTY')
232
+ .option('--no-color', 'disable ANSI colors (NO_COLOR env is also honored)');
233
+ // Anonymous usage telemetry (see TELEMETRY.md): record the invoked subcommand
234
+ // NAME only — never arguments or paths. Counts buffer locally; network sends
235
+ // piggyback on commands that run long anyway (quick commands only append to
236
+ // the local buffer at exit, costing nothing).
237
+ // install/uninstall are absent on purpose: the installer flushes at its own
238
+ // end, AFTER its consent prompt — a flush here would fire the first-run
239
+ // notice before the user ever sees the toggle.
240
+ const TELEMETRY_FLUSH_COMMANDS = new Set(['init', 'uninit', 'index', 'sync', 'upgrade']);
241
+ program.hook('preAction', (_thisCommand, actionCommand) => {
242
+ try {
243
+ // The detached daemon re-invokes `serve --mcp` internally — not a user action.
244
+ if (process.env.CODEGRAPH_DAEMON_INTERNAL)
245
+ return;
246
+ const name = actionCommand.name();
247
+ if (name === 'telemetry')
248
+ return; // managing telemetry is not usage
249
+ (0, telemetry_1.getTelemetry)().recordUsage('cli_command', name, true);
250
+ if (TELEMETRY_FLUSH_COMMANDS.has(name))
251
+ (0, telemetry_1.getTelemetry)().maybeFlush();
252
+ }
253
+ catch {
254
+ /* telemetry must never break the CLI */
255
+ }
256
+ });
257
+ // =============================================================================
258
+ // Helper Functions
259
+ // =============================================================================
260
+ /**
261
+ * Resolve project path from argument or current directory
262
+ * Walks up parent directories to find nearest initialized Alpha Code Sense project
263
+ * (must have .alpha-cs/codegraph.db, not just .alpha-cs/lessons.db)
264
+ */
265
+ function resolveProjectPath(pathArg) {
266
+ const absolutePath = path.resolve(pathArg || process.cwd());
267
+ // If exact path is initialized (has codegraph.db), use it
268
+ if ((0, directory_1.isInitialized)(absolutePath)) {
269
+ return absolutePath;
270
+ }
271
+ // Walk up to find nearest parent with Alpha Code Sense initialized
272
+ // Note: findNearestAlphaCsRoot finds any .codegraph folder, but we need one with codegraph.db
273
+ let current = absolutePath;
274
+ const root = path.parse(current).root;
275
+ while (current !== root) {
276
+ const parent = path.dirname(current);
277
+ if (parent === current)
278
+ break;
279
+ current = parent;
280
+ if ((0, directory_1.isInitialized)(current)) {
281
+ return current;
282
+ }
283
+ }
284
+ // Not found - return original path (will fail later with helpful error)
285
+ return absolutePath;
286
+ }
287
+ /**
288
+ * Format a number with commas
289
+ */
290
+ function formatNumber(n) {
291
+ return n.toLocaleString();
292
+ }
293
+ /**
294
+ * Format duration in milliseconds to human readable
295
+ */
296
+ function formatDuration(ms) {
297
+ if (ms < 1000) {
298
+ return `${ms}ms`;
299
+ }
300
+ const seconds = ms / 1000;
301
+ if (seconds < 60) {
302
+ return `${seconds.toFixed(1)}s`;
303
+ }
304
+ const minutes = Math.floor(seconds / 60);
305
+ const remainingSeconds = seconds % 60;
306
+ return `${minutes}m ${remainingSeconds.toFixed(0)}s`;
307
+ }
308
+ // Shimmer progress renderer (runs in a worker thread for smooth animation)
309
+ // Imported at top of file from '../ui/shimmer-progress'
310
+ /**
311
+ * Create a plain-text progress callback for --verbose mode.
312
+ * No animations, no ANSI tricks — just timestamped lines to stdout.
313
+ */
314
+ function createVerboseProgress() {
315
+ let lastPhase = '';
316
+ let lastPct = -1;
317
+ const startTime = Date.now();
318
+ return (progress) => {
319
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
320
+ if (progress.phase !== lastPhase) {
321
+ lastPhase = progress.phase;
322
+ lastPct = -1;
323
+ console.log(`[${elapsed}s] Phase: ${progress.phase}`);
324
+ }
325
+ if (progress.total > 0) {
326
+ const pct = Math.floor((progress.current / progress.total) * 100);
327
+ // Log every 5% to keep output manageable
328
+ if (pct >= lastPct + 5 || progress.current === progress.total) {
329
+ lastPct = pct;
330
+ console.log(`[${elapsed}s] ${progress.current}/${progress.total} (${pct}%)${progress.currentFile ? ` ${(0, glyphs_1.getGlyphs)().dash} ${progress.currentFile}` : ''}`);
331
+ }
332
+ }
333
+ else if (progress.current > 0) {
334
+ // Scanning phase (no total yet) — log periodically
335
+ if (progress.current % 1000 === 0 || progress.current === 1) {
336
+ console.log(`[${elapsed}s] ${formatNumber(progress.current)} files found`);
337
+ }
338
+ }
339
+ };
340
+ }
341
+ /**
342
+ * Print success message
343
+ */
344
+ function success(message) {
345
+ console.log(chalk.green((0, glyphs_1.getGlyphs)().ok) + ' ' + message);
346
+ }
347
+ /**
348
+ * Print error message
349
+ */
350
+ function error(message) {
351
+ console.error(chalk.red((0, glyphs_1.getGlyphs)().err) + ' ' + message);
352
+ }
353
+ /**
354
+ * Print info message
355
+ */
356
+ function info(message) {
357
+ console.log(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' ' + message);
358
+ }
359
+ /**
360
+ * Print warning message
361
+ */
362
+ function warn(message) {
363
+ console.log(chalk.yellow((0, glyphs_1.getGlyphs)().warn) + ' ' + message);
364
+ }
365
+ /** "not found" (+ optional did-you-mean) when no exact symbol matches. */
366
+ function formatSymbolNotFound(symbol, fuzzyNames) {
367
+ const suggestions = [...new Set(fuzzyNames.filter((n) => n !== symbol))].slice(0, 3);
368
+ if (suggestions.length === 0)
369
+ return `Symbol "${symbol}" not found`;
370
+ return `Symbol "${symbol}" not found — did you mean: ${suggestions.join(', ')}?`;
371
+ }
372
+ /** Compact node shape retained by the CLI's existing JSON lists. */
373
+ function cliNode(node) {
374
+ return { name: node.name, kind: node.kind, filePath: node.filePath, startLine: node.startLine };
375
+ }
376
+ /** Attribute a group's edges to every overload of this definition. */
377
+ function cliDefinition(group) {
378
+ const head = group[0];
379
+ return {
380
+ definition: { ...cliNode(head), id: head.id, qualifiedName: head.qualifiedName, language: head.language },
381
+ roots: group.map((node) => node.id),
382
+ };
383
+ }
384
+ /**
385
+ * Print indexing results using clack log methods
386
+ */
387
+ function printIndexResult(clack, result, projectPath) {
388
+ const hasErrors = result.filesErrored > 0;
389
+ const parseWarnings = result.errors.filter((e) => e.code === 'parse_error' && e.severity === 'warning');
390
+ // Surface non-file-level failures (e.g. lock-acquisition failure
391
+ // when another indexer is running) before the file-count branches.
392
+ // Without this the CLI falls through to "No files found to index",
393
+ // which is actively misleading — the index DID run, it just couldn't
394
+ // get the lock.
395
+ //
396
+ // If success is false but no severity:'error' entry exists in
397
+ // `result.errors` (degenerate case — shouldn't happen in practice
398
+ // but worth guarding because the result shape is plumbed through
399
+ // multiple call sites), fall back to a generic message rather than
400
+ // continuing to the misleading "No files found" branch or throwing.
401
+ if (!result.success && !hasErrors && result.filesIndexed === 0) {
402
+ const generic = result.errors.find((e) => e.severity === 'error');
403
+ clack.log.error(generic?.message ?? `Indexing failed ${(0, glyphs_1.getGlyphs)().dash} no further details available`);
404
+ return;
405
+ }
406
+ if (result.filesIndexed > 0) {
407
+ if (hasErrors) {
408
+ clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files (${formatNumber(result.filesErrored)} could not be parsed)`);
409
+ }
410
+ else {
411
+ clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files`);
412
+ }
413
+ clack.log.info(`${formatNumber(result.nodesCreated)} nodes, ${formatNumber(result.edgesCreated)} edges in ${formatDuration(result.durationMs)}`);
414
+ // Warning-only parse failures keep indexing successful, but must be visible.
415
+ for (const warning of parseWarnings) {
416
+ clack.log.warn(warning.message);
417
+ }
418
+ // A PARTIAL index (files silently dropped mid-pipeline) must not pass
419
+ // as a clean run — it's the difference between "indexed the repo" and
420
+ // "indexed most of the repo, quietly". Only the completeness
421
+ // reconciliation warning; per-file extractor warnings stay in the
422
+ // error-code summary below.
423
+ for (const w of result.errors.filter((e) => e.code === 'index_partial')) {
424
+ clack.log.warn(w.message);
425
+ }
426
+ // Files salvaged from comment-stripped source after repeated parser
427
+ // failures are indexed but possibly incomplete — say so here, or the run
428
+ // reads as fully clean and the index quietly disagrees with a later
429
+ // re-parse of the same bytes (#1565).
430
+ const salvaged = result.errors.filter((e) => e.code === 'salvaged_stripped');
431
+ if (salvaged.length > 0) {
432
+ const sample = salvaged.slice(0, 3).map((e) => e.filePath).filter(Boolean).join(', ');
433
+ const more = salvaged.length > 3 ? ', ...' : '';
434
+ clack.log.warn(`${formatNumber(salvaged.length)} file(s) indexed from comment-stripped source after repeated parse failures ${(0, glyphs_1.getGlyphs)().dash} symbols may be incomplete (${sample}${more})`);
435
+ }
436
+ }
437
+ else if (hasErrors) {
438
+ clack.log.error(`Indexing failed ${(0, glyphs_1.getGlyphs)().dash} all ${formatNumber(result.filesErrored)} files had errors`);
439
+ }
440
+ else if (result.filesSkippedUnsupported) {
441
+ // A project Alpha Code Sense has no grammar for used to be indistinguishable from
442
+ // an empty one: same message, same `complete` state, same exit 0. Say which
443
+ // files were there and that the graph is empty on purpose, so nobody — and
444
+ // no agent trusting the graph — reads silence as "this code doesn't exist"
445
+ // (#1502).
446
+ const top = (result.topUnsupportedExtensions ?? [])
447
+ .map(e => `${e.ext} (${formatNumber(e.count)})`)
448
+ .join(', ');
449
+ clack.log.warn(`No supported source files found ${(0, glyphs_1.getGlyphs)().dash} ${formatNumber(result.filesSkippedUnsupported)} file(s) present, none in a language Alpha Code Sense indexes`
450
+ + (top ? `: ${top}` : ''));
451
+ clack.log.info('Alpha Code Sense is inactive for this workspace — searches will return nothing. Use your own file tools here.');
452
+ }
453
+ else {
454
+ clack.log.warn('No files found to index');
455
+ }
456
+ if (hasErrors) {
457
+ const errorsByCode = new Map();
458
+ for (const err of result.errors) {
459
+ if (err.severity === 'error') {
460
+ const code = err.code || 'unknown';
461
+ errorsByCode.set(code, (errorsByCode.get(code) || 0) + 1);
462
+ }
463
+ }
464
+ const codeLabels = {
465
+ parse_error: 'files failed to parse',
466
+ read_error: 'files could not be read',
467
+ size_exceeded: 'files exceeded size limit',
468
+ path_traversal: 'blocked paths',
469
+ unsupported_language: 'unsupported language',
470
+ parser_error: 'parser initialization failures',
471
+ };
472
+ const breakdown = Array.from(errorsByCode)
473
+ .map(([code, count]) => `${formatNumber(count)} ${codeLabels[code] || code}`)
474
+ .join('\n');
475
+ clack.note(breakdown, 'Error breakdown');
476
+ if (projectPath) {
477
+ writeErrorLog(projectPath, result.errors);
478
+ clack.log.info('See .alpha-cs/errors.log for details');
479
+ }
480
+ if (result.filesIndexed > 0) {
481
+ clack.log.info(`The index is fully usable ${(0, glyphs_1.getGlyphs)().dash} only the failed files are missing.`);
482
+ }
483
+ }
484
+ else if (projectPath) {
485
+ // No hard errors. Salvaged-file warnings still belong in the log — it
486
+ // carries the per-file detail behind the one-line summary above.
487
+ if (result.errors.some((e) => e.code === 'salvaged_stripped')) {
488
+ writeErrorLog(projectPath, result.errors);
489
+ clack.log.info('See .alpha-cs/errors.log for details');
490
+ }
491
+ else {
492
+ const logPath = path.join((0, directory_1.getAlphaCsDir)(projectPath), 'errors.log');
493
+ if (fs.existsSync(logPath)) {
494
+ fs.unlinkSync(logPath);
495
+ }
496
+ }
497
+ }
498
+ }
499
+ /**
500
+ * When an `init`/`index` produced an EMPTY graph and the reason is that the
501
+ * project's own `.gitignore` excludes nested git repositories — the "super-repo
502
+ * gitignores its child repos" layout (#1156), where `init` at the parent
503
+ * correctly indexes ~nothing while `init` inside each child works — name those
504
+ * repos and offer to index them. An interactive terminal gets a yes/no prompt
505
+ * that writes `includeIgnored` to codegraph.json and re-indexes; a
506
+ * non-interactive run just prints the one-line opt-in snippet. The caller gates
507
+ * this on `nodesCreated === 0`, so a project that DID index real content is
508
+ * never nagged about the gitignored reference clones it deliberately keeps out
509
+ * (#970, #1065). Best-effort throughout: detection never breaks the command.
510
+ */
511
+ async function offerIndexIgnoredRepos(clack, projectPath, reindex, opts) {
512
+ let repos;
513
+ try {
514
+ const { findUnindexedIgnoredRepos } = await Promise.resolve().then(() => __importStar(require('../extraction')));
515
+ repos = findUnindexedIgnoredRepos(projectPath);
516
+ }
517
+ catch {
518
+ return; // detection is advisory — never let it break the command
519
+ }
520
+ if (repos.length === 0)
521
+ return;
522
+ const { PROJECT_CONFIG_FILENAME } = await Promise.resolve().then(() => __importStar(require('../project-config')));
523
+ const isOne = repos.length === 1;
524
+ const SHOWN = 6;
525
+ const names = repos.slice(0, SHOWN).map((r) => r.replace(/\/$/, ''));
526
+ const extra = repos.length > SHOWN ? ` (+${formatNumber(repos.length - SHOWN)} more)` : '';
527
+ const snippet = `{ "includeIgnored": [${repos.map((p) => JSON.stringify(p)).join(', ')}] }`;
528
+ clack.log.warn(`Your .gitignore excludes ${isOne ? 'a nested git repository' : `${formatNumber(repos.length)} nested git repositories`} here, ` +
529
+ `so ${isOne ? 'it was' : 'they were'} not indexed: ${names.join(', ')}${extra}.`);
530
+ const manualHint = () => {
531
+ clack.log.info(`If ${isOne ? "it's" : "they're"} your code, add ${isOne ? 'it' : 'them'} to ${PROJECT_CONFIG_FILENAME} and re-index:`);
532
+ clack.log.info(` ${snippet}`);
533
+ };
534
+ if (!opts.interactive || !process.stdin.isTTY) {
535
+ manualHint();
536
+ return;
537
+ }
538
+ const yes = await clack.confirm({
539
+ message: `Index ${isOne ? 'it' : `these ${formatNumber(repos.length)}`} now? Adds ${isOne ? 'it' : 'them'} to ${PROJECT_CONFIG_FILENAME}.`,
540
+ initialValue: true,
541
+ });
542
+ if (clack.isCancel(yes) || !yes) {
543
+ manualHint();
544
+ return;
545
+ }
546
+ let added;
547
+ try {
548
+ const { addIncludeIgnoredPatterns } = await Promise.resolve().then(() => __importStar(require('../project-config')));
549
+ added = addIncludeIgnoredPatterns(projectPath, repos);
550
+ }
551
+ catch (err) {
552
+ clack.log.error(`Could not update ${PROJECT_CONFIG_FILENAME}: ${err instanceof Error ? err.message : String(err)}`);
553
+ manualHint();
554
+ return;
555
+ }
556
+ clack.log.success(`Added ${formatNumber(added)} ${added === 1 ? 'entry' : 'entries'} to ${PROJECT_CONFIG_FILENAME} ${(0, glyphs_1.getGlyphs)().dash} re-indexing…`);
557
+ const result = await reindex();
558
+ printIndexResult(clack, result, projectPath);
559
+ return result;
560
+ }
561
+ /**
562
+ * Write detailed error log to .alpha-cs/errors.log
563
+ */
564
+ function writeErrorLog(projectPath, errors) {
565
+ const cgDir = (0, directory_1.getAlphaCsDir)(projectPath);
566
+ if (!fs.existsSync(cgDir))
567
+ return;
568
+ const logPath = path.join(cgDir, 'errors.log');
569
+ // Group errors by file path
570
+ const errorsByFile = new Map();
571
+ const noFileErrors = [];
572
+ for (const err of errors) {
573
+ if (err.severity !== 'error')
574
+ continue;
575
+ if (err.filePath) {
576
+ let list = errorsByFile.get(err.filePath);
577
+ if (!list) {
578
+ list = [];
579
+ errorsByFile.set(err.filePath, list);
580
+ }
581
+ list.push({ message: err.message, code: err.code });
582
+ }
583
+ else {
584
+ noFileErrors.push({ message: err.message, code: err.code });
585
+ }
586
+ }
587
+ const lines = [
588
+ `Alpha Code Sense Error Log - ${new Date().toISOString()}`,
589
+ `${errorsByFile.size} files with errors`,
590
+ '',
591
+ ];
592
+ for (const [filePath, fileErrors] of errorsByFile) {
593
+ for (const err of fileErrors) {
594
+ lines.push(`${filePath}: ${err.message}`);
595
+ }
596
+ }
597
+ for (const err of noFileErrors) {
598
+ lines.push(err.message);
599
+ }
600
+ fs.writeFileSync(logPath, lines.join('\n') + '\n');
601
+ }
602
+ /**
603
+ * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush
604
+ * keeps init/index responsive (these commands just ran for seconds anyway)
605
+ * while delivering the event promptly.
606
+ */
607
+ async function recordIndexTelemetry(cg, result) {
608
+ (0, telemetry_1.recordIndexEvent)(cg, result);
609
+ await (0, telemetry_1.getTelemetry)().flushNow();
610
+ }
611
+ // =============================================================================
612
+ // Commands
613
+ // =============================================================================
614
+ /**
615
+ * The `init` flow — shared by `codegraph init` and `codegraph install --init`
616
+ * (#1578): refuse an unsafe root, create `.alpha-cs/`, build the initial
617
+ * index under supervision, then the post-index offers. `yes` makes every
618
+ * offer non-interactive (defaults only), so a container / CI bootstrap never
619
+ * blocks on a prompt. An unsafe root sets `process.exitCode = 1` and returns
620
+ * (no `--force` is implied by any caller); an index failure exits 1.
621
+ */
622
+ async function runInit(projectPath, options) {
623
+ const clack = await importESM('@clack/prompts');
624
+ clack.intro('Initializing Alpha Code Sense');
625
+ try {
626
+ // Refuse to index your home directory / a filesystem root — it pulls in
627
+ // caches, other projects, and your whole tree (a multi-GB index + watcher
628
+ // churn, and on pre-1.0 macOS a machine-crashing fd blowup, #845).
629
+ const unsafe = (0, directory_1.unsafeIndexRootReason)(projectPath);
630
+ if (unsafe && !options.force) {
631
+ clack.log.error(`Refusing to initialize in ${projectPath} — it looks like ${unsafe}.`);
632
+ clack.log.info('Run this inside a specific project directory, or pass --force if you really mean to index everything under it.');
633
+ clack.outro('');
634
+ process.exitCode = 1;
635
+ return;
636
+ }
637
+ if ((0, directory_1.isInitialized)(projectPath)) {
638
+ clack.log.warn(`Already initialized in ${projectPath}`);
639
+ clack.log.info('Use "codegraph index" to re-index or "codegraph sync" to update');
640
+ try {
641
+ const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
642
+ await offerWatchFallback(clack, projectPath, { yes: options.yes });
643
+ }
644
+ catch { /* non-fatal */ }
645
+ clack.outro('');
646
+ return;
647
+ }
648
+ const { default: AlphaCodeSense, getDatabasePath } = await loadAlphaCodeSense();
649
+ const cg = await AlphaCodeSense.init(projectPath, { index: false });
650
+ clack.log.success(`Initialized in ${projectPath}`);
651
+ // Indexing runs by default now. The legacy -i/--index flag is still
652
+ // accepted (so existing muscle memory and scripts don't break) but is a
653
+ // no-op — initializing always builds the initial index.
654
+ // Supervise the index: self-terminate if orphaned or wedged (#999).
655
+ // The DB + WAL paths let the liveness watchdog tell a slow store on
656
+ // degraded storage from a true wedge (#1231).
657
+ // A closure so we can re-run the exact same supervised, progress-rendered
658
+ // index if the user opts gitignored child repos in below (#1156).
659
+ const dbPath = getDatabasePath(projectPath);
660
+ const runIndex = async () => {
661
+ const supervision = (0, command_supervision_1.installCommandSupervision)('init', { progressPaths: [dbPath, `${dbPath}-wal`] });
662
+ try {
663
+ if (options.verbose) {
664
+ return await cg.indexAll({ onProgress: createVerboseProgress(), verbose: true });
665
+ }
666
+ process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
667
+ const progress = (0, shimmer_progress_1.createShimmerProgress)();
668
+ const r = await cg.indexAll({ onProgress: progress.onProgress });
669
+ await progress.stop();
670
+ return r;
671
+ }
672
+ finally {
673
+ supervision.stop();
674
+ }
675
+ };
676
+ const result = await runIndex();
677
+ printIndexResult(clack, result, projectPath);
678
+ await recordIndexTelemetry(cg, result);
679
+ // An empty graph at a git super-repo usually means `.gitignore` excludes
680
+ // the child repos that hold the code — surface them and offer to opt in
681
+ // rather than leaving the user with a silent 0-node "Done". (#1156)
682
+ // Under --yes the offer prints its one-line opt-in snippet instead of
683
+ // prompting (same as a non-TTY run).
684
+ if (result.nodesCreated === 0) {
685
+ await offerIndexIgnoredRepos(clack, projectPath, runIndex, { interactive: !options.yes });
686
+ }
687
+ try {
688
+ const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
689
+ await offerWatchFallback(clack, projectPath, { yes: options.yes });
690
+ }
691
+ catch { /* non-fatal */ }
692
+ clack.outro('Done');
693
+ cg.destroy();
694
+ }
695
+ catch (err) {
696
+ clack.log.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
697
+ process.exit(1);
698
+ }
699
+ }
700
+ /**
701
+ * codegraph init [path]
702
+ */
703
+ program
704
+ .command('init [path]')
705
+ .description('Initialize Alpha Code Sense in a project directory and build the initial index')
706
+ .option('-i, --index', 'Deprecated: indexing now runs by default; flag accepted for backward compatibility')
707
+ .option('-f, --force', 'Initialize even if the path looks like your home directory or a filesystem root')
708
+ .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
709
+ .option('-y, --yes', 'Non-interactive: skip every prompt and take the defaults (for scripts / CI / container bootstraps)')
710
+ .action(async (pathArg, options) => {
711
+ await runInit(path.resolve(pathArg || process.cwd()), options);
712
+ });
713
+ /**
714
+ * codegraph uninit [path]
715
+ */
716
+ program
717
+ .command('uninit [path]')
718
+ .description('Remove Alpha Code Sense from a project (deletes .alpha-cs/ directory)')
719
+ .option('-f, --force', 'Skip confirmation prompt')
720
+ .action(async (pathArg, options) => {
721
+ const projectPath = resolveProjectPath(pathArg);
722
+ try {
723
+ if (!(0, directory_1.isInitialized)(projectPath)) {
724
+ warn(`Alpha Code Sense is not initialized in ${projectPath}`);
725
+ return;
726
+ }
727
+ if (!options.force) {
728
+ // Confirm with user
729
+ const readline = await Promise.resolve().then(() => __importStar(require('readline')));
730
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
731
+ const answer = await new Promise((resolve) => {
732
+ rl.question(chalk.yellow(`${(0, glyphs_1.getGlyphs)().warn} This will permanently delete all Alpha Code Sense data. Continue? (y/N) `), resolve);
733
+ });
734
+ rl.close();
735
+ if (answer.toLowerCase() !== 'y') {
736
+ info('Cancelled');
737
+ return;
738
+ }
739
+ }
740
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
741
+ const cg = AlphaCodeSense.openSync(projectPath);
742
+ cg.uninitialize();
743
+ // Clean up any git sync hooks we installed (no-op if none / not a repo).
744
+ try {
745
+ const { removeGitSyncHook } = await Promise.resolve().then(() => __importStar(require('../sync/git-hooks')));
746
+ const removed = removeGitSyncHook(projectPath);
747
+ if (removed.installed.length > 0) {
748
+ info(`Removed git ${removed.installed.join(', ')} sync hook${removed.installed.length > 1 ? 's' : ''}`);
749
+ }
750
+ }
751
+ catch { /* non-fatal */ }
752
+ success(`Removed Alpha Code Sense from ${projectPath}`);
753
+ // Churn signal — and flush now, since after an uninit there may be no
754
+ // "next run" to deliver it.
755
+ try {
756
+ (0, telemetry_1.getTelemetry)().recordLifecycle('uninstall', {});
757
+ await (0, telemetry_1.getTelemetry)().flushNow();
758
+ }
759
+ catch { /* non-fatal */ }
760
+ }
761
+ catch (err) {
762
+ error(`Failed to uninitialize: ${err instanceof Error ? err.message : String(err)}`);
763
+ process.exit(1);
764
+ }
765
+ });
766
+ /**
767
+ * codegraph index [path]
768
+ */
769
+ program
770
+ .command('index [path]')
771
+ .description('Rebuild the full index from scratch (same result as a fresh init)')
772
+ .option('-f, --force', 'Index even if the path looks like your home directory or a filesystem root')
773
+ .option('-q, --quiet', 'Suppress progress output')
774
+ .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
775
+ .action(async (pathArg, options) => {
776
+ // An EXPLICIT path names the project to rebuild — it is never a hint to go
777
+ // looking for one. resolveProjectPath walks up to the nearest initialized
778
+ // ancestor, which is right for `codegraph query` run from a subdirectory,
779
+ // but for a full re-index it silently rebuilt the parent's graph under a
780
+ // normal "Done" when <path> had no index of its own (#1524). Only a bare
781
+ // `codegraph index` (cwd) may resolve upward.
782
+ const projectPath = pathArg ? path.resolve(pathArg) : resolveProjectPath();
783
+ try {
784
+ // Don't (re)index your home directory / a filesystem root (#845). --force
785
+ // doubles as the override.
786
+ const unsafe = (0, directory_1.unsafeIndexRootReason)(projectPath);
787
+ if (unsafe && !options.force) {
788
+ error(`Refusing to index ${projectPath} — it looks like ${unsafe}. Pass --force to override.`);
789
+ process.exit(1);
790
+ }
791
+ if (!(0, directory_1.isInitialized)(projectPath)) {
792
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
793
+ const ancestor = pathArg ? resolveProjectPath(pathArg) : projectPath;
794
+ if (ancestor !== projectPath) {
795
+ info(`The nearest initialized project is ${ancestor} — pass that path to rebuild it, or run "codegraph init" in ${projectPath} to index it on its own.`);
796
+ }
797
+ else {
798
+ info('Run "codegraph init" first');
799
+ }
800
+ process.exit(1);
801
+ }
802
+ const { default: AlphaCodeSense, getDatabasePath } = await loadAlphaCodeSense();
803
+ // `index` is a FULL re-index — identical to a fresh `init`. RECREATE the
804
+ // database from scratch (discard .alpha-cs/codegraph.db + its WAL) rather
805
+ // than opening the old graph and DELETE-ing every row. The clear-then-index
806
+ // approach reported "0 nodes" without the clear (#874); the recreate keeps
807
+ // that fixed AND avoids the failure mode where, on a large or pre-fix
808
+ // poisoned index, the per-row FTS delete churn wedged the main thread long
809
+ // enough to trip the liveness watchdog before scanning even began (#1067).
810
+ // recreate() hands back a fresh, empty instance — no clear() needed. For
811
+ // fast incremental updates use `sync`.
812
+ const cg = await AlphaCodeSense.recreate(projectPath);
813
+ // Supervise the indexer: self-terminate if orphaned (parent shim killed)
814
+ // or if the main thread wedges — neither was guarded on this path (#999).
815
+ // The DB + WAL paths let the liveness watchdog tell a slow store on
816
+ // degraded storage from a true wedge (#1231).
817
+ const dbPath = getDatabasePath(projectPath);
818
+ const supervision = (0, command_supervision_1.installCommandSupervision)('index', { progressPaths: [dbPath, `${dbPath}-wal`] });
819
+ try {
820
+ if (options.quiet) {
821
+ // Quiet mode: no UI, just run against the freshly-recreated graph.
822
+ const result = await cg.indexAll();
823
+ if (!result.success)
824
+ process.exit(1);
825
+ cg.destroy();
826
+ return;
827
+ }
828
+ const clack = await importESM('@clack/prompts');
829
+ clack.intro('Indexing project');
830
+ // A closure so a re-index (after opting gitignored child repos in, #1156)
831
+ // renders identically. Supervision already wraps the whole command.
832
+ const renderIndex = async () => {
833
+ if (options.verbose) {
834
+ return await cg.indexAll({ onProgress: createVerboseProgress(), verbose: true });
835
+ }
836
+ process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
837
+ const progress = (0, shimmer_progress_1.createShimmerProgress)();
838
+ const r = await cg.indexAll({ onProgress: progress.onProgress });
839
+ await progress.stop();
840
+ return r;
841
+ };
842
+ const result = await renderIndex();
843
+ printIndexResult(clack, result, projectPath);
844
+ await recordIndexTelemetry(cg, result);
845
+ // Empty graph at a git super-repo → likely `.gitignore`d child repos;
846
+ // name them and offer to opt in instead of a silent 0-node result (#1156).
847
+ let finalResult = result;
848
+ if (result.nodesCreated === 0) {
849
+ finalResult = (await offerIndexIgnoredRepos(clack, projectPath, renderIndex, { interactive: true })) ?? result;
850
+ }
851
+ if (!finalResult.success) {
852
+ process.exit(1);
853
+ }
854
+ clack.outro('Done');
855
+ cg.destroy();
856
+ }
857
+ finally {
858
+ supervision.stop();
859
+ }
860
+ }
861
+ catch (err) {
862
+ error(`Failed to index: ${err instanceof Error ? err.message : String(err)}`);
863
+ process.exit(1);
864
+ }
865
+ });
866
+ /**
867
+ * codegraph sync [path]
868
+ */
869
+ program
870
+ .command('sync [path]')
871
+ .description('Sync changes since last index')
872
+ .option('-q, --quiet', 'Suppress output (for git hooks)')
873
+ .action(async (pathArg, options) => {
874
+ const projectPath = resolveProjectPath(pathArg);
875
+ try {
876
+ if (!(0, directory_1.isInitialized)(projectPath)) {
877
+ if (!options.quiet) {
878
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
879
+ }
880
+ process.exit(1);
881
+ }
882
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
883
+ const cg = await AlphaCodeSense.open(projectPath);
884
+ if (options.quiet) {
885
+ await cg.sync();
886
+ cg.destroy();
887
+ return;
888
+ }
889
+ const clack = await importESM('@clack/prompts');
890
+ clack.intro('Syncing Alpha Code Sense');
891
+ process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
892
+ const progress = (0, shimmer_progress_1.createShimmerProgress)();
893
+ const result = await cg.sync({
894
+ onProgress: progress.onProgress,
895
+ });
896
+ await progress.stop();
897
+ const totalChanges = result.filesAdded + result.filesModified + result.filesRemoved;
898
+ if (totalChanges === 0) {
899
+ clack.log.info('Already up to date');
900
+ }
901
+ else {
902
+ clack.log.success(`Synced ${formatNumber(totalChanges)} changed files`);
903
+ const details = [];
904
+ if (result.filesAdded > 0)
905
+ details.push(`Added: ${result.filesAdded}`);
906
+ if (result.filesModified > 0)
907
+ details.push(`Modified: ${result.filesModified}`);
908
+ if (result.filesRemoved > 0)
909
+ details.push(`Removed: ${result.filesRemoved}`);
910
+ clack.log.info(`${details.join(', ')} ${(0, glyphs_1.getGlyphs)().dash} ${formatNumber(result.nodesUpdated)} nodes in ${formatDuration(result.durationMs)}`);
911
+ }
912
+ clack.outro('Done');
913
+ cg.destroy();
914
+ }
915
+ catch (err) {
916
+ if (!options.quiet) {
917
+ error(`Failed to sync: ${err instanceof Error ? err.message : String(err)}`);
918
+ }
919
+ process.exit(1);
920
+ }
921
+ });
922
+ /**
923
+ * ltm-alpha-cs status [path]
924
+ */
925
+ program
926
+ .command('status [path]')
927
+ .description('Show index status and statistics')
928
+ .option('-j, --json', 'Output as JSON')
929
+ .action(async (pathArg, options) => {
930
+ const projectPath = resolveProjectPath(pathArg);
931
+ // The directory the user actually ran from, before walking up to the index
932
+ // root. Used to detect when the resolved index lives in a different git
933
+ // working tree (e.g. a nested worktree borrowing the main checkout's index).
934
+ const startPath = path.resolve(pathArg || process.cwd());
935
+ const worktreeMismatch = (0, worktree_1.detectWorktreeIndexMismatch)(startPath, projectPath);
936
+ try {
937
+ if (!(0, directory_1.isInitialized)(projectPath)) {
938
+ if (options.json) {
939
+ console.log(JSON.stringify({
940
+ initialized: false,
941
+ version: packageJson.version,
942
+ projectPath,
943
+ indexPath: (0, directory_1.getAlphaCsDir)(projectPath),
944
+ lastIndexed: null,
945
+ }));
946
+ return;
947
+ }
948
+ console.log(chalk.bold('\nCodeGraph Status\n'));
949
+ info(`Project: ${projectPath}`);
950
+ warn('Not initialized');
951
+ info('Run "codegraph init" to initialize');
952
+ return;
953
+ }
954
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
955
+ const cg = await AlphaCodeSense.open(projectPath);
956
+ const stats = cg.getStats();
957
+ const changes = cg.getChangedFiles();
958
+ const backend = cg.getBackend();
959
+ const journalMode = cg.getJournalMode();
960
+ const buildInfo = cg.getIndexBuildInfo();
961
+ const reindexRecommended = cg.isIndexStale();
962
+ const indexState = cg.getIndexState();
963
+ // Zero on a healthy index; non-zero at rest means a resolution pass was
964
+ // interrupted, so some files' call edges are missing (#1187).
965
+ const pendingRefs = cg.getPendingReferenceCount();
966
+ // JSON output mode
967
+ if (options.json) {
968
+ const lastIndexedMs = cg.getLastIndexedAt();
969
+ console.log(JSON.stringify({
970
+ initialized: true,
971
+ version: packageJson.version,
972
+ projectPath,
973
+ indexPath: (0, directory_1.getAlphaCsDir)(projectPath),
974
+ lastIndexed: lastIndexedMs != null ? new Date(lastIndexedMs).toISOString() : null,
975
+ fileCount: stats.fileCount,
976
+ nodeCount: stats.nodeCount,
977
+ edgeCount: stats.edgeCount,
978
+ dbSizeBytes: stats.dbSizeBytes,
979
+ walSizeBytes: stats.walSizeBytes,
980
+ backend,
981
+ journalMode,
982
+ nodesByKind: stats.nodesByKind,
983
+ languages: Object.entries(stats.filesByLanguage).filter(([, count]) => count > 0).map(([lang]) => lang),
984
+ pendingChanges: {
985
+ added: changes.added.length,
986
+ modified: changes.modified.length,
987
+ removed: changes.removed.length,
988
+ },
989
+ worktreeMismatch: worktreeMismatch
990
+ ? { worktreeRoot: worktreeMismatch.worktreeRoot, indexRoot: worktreeMismatch.indexRoot }
991
+ : null,
992
+ index: {
993
+ builtWithVersion: buildInfo.version,
994
+ builtWithExtractionVersion: buildInfo.extractionVersion,
995
+ currentExtractionVersion: extraction_version_1.EXTRACTION_VERSION,
996
+ reindexRecommended,
997
+ // 'complete' | 'partial' (files silently dropped) | 'indexing'
998
+ // (a run was killed mid-index — the index is truncated) |
999
+ // 'failed' | null (predates the marker).
1000
+ state: indexState,
1001
+ // References awaiting resolution. Non-zero at rest means an
1002
+ // interrupted resolution pass left edges missing; the next
1003
+ // sync sweeps them (#1187).
1004
+ pendingRefs,
1005
+ },
1006
+ }));
1007
+ cg.destroy();
1008
+ return;
1009
+ }
1010
+ console.log(chalk.bold('\nCodeGraph Status\n'));
1011
+ // Project info
1012
+ console.log(chalk.cyan('Project:'), projectPath);
1013
+ if (worktreeMismatch) {
1014
+ warn((0, worktree_1.worktreeMismatchWarning)(worktreeMismatch));
1015
+ }
1016
+ if (indexState === 'indexing') {
1017
+ warn('The last index run never finished (killed mid-index?) — the index is truncated. Re-run "codegraph index".');
1018
+ }
1019
+ else if (indexState === 'partial') {
1020
+ warn('The last index run silently dropped files — the index is partial. Re-run "codegraph index".');
1021
+ }
1022
+ else if (indexState === 'failed') {
1023
+ warn('The last index run failed — results may be incomplete. Re-run "codegraph index".');
1024
+ }
1025
+ if (pendingRefs > 0) {
1026
+ warn(`${formatNumber(pendingRefs)} references from an interrupted run are awaiting resolution — some callers/impact edges are missing. Run "codegraph sync" to resolve them.`);
1027
+ }
1028
+ console.log();
1029
+ // Index stats
1030
+ console.log(chalk.bold('Index Statistics:'));
1031
+ console.log(` Files: ${formatNumber(stats.fileCount)}`);
1032
+ console.log(` Nodes: ${formatNumber(stats.nodeCount)}`);
1033
+ console.log(` Edges: ${formatNumber(stats.edgeCount)}`);
1034
+ console.log(` DB Size: ${(stats.dbSizeBytes / 1024 / 1024).toFixed(2)} MB`);
1035
+ // Surface the WAL sidecar (#1431): a WAL that dwarfs the DB at rest is
1036
+ // the killed-session leak — invisible before this line, it only showed
1037
+ // up as a mysteriously full disk. open() above already kicked off the
1038
+ // automatic heal for the oversized case.
1039
+ if (stats.walSizeBytes > 0) {
1040
+ const { WAL_HEAL_THRESHOLD_BYTES } = await Promise.resolve().then(() => __importStar(require('../db/index')));
1041
+ const oversized = stats.walSizeBytes > Math.max(WAL_HEAL_THRESHOLD_BYTES, stats.dbSizeBytes);
1042
+ const walLabel = `${(stats.walSizeBytes / 1024 / 1024).toFixed(2)} MB`;
1043
+ console.log(` WAL Size: ${oversized ? chalk.yellow(walLabel) : walLabel}`);
1044
+ if (oversized) {
1045
+ warn('The write-ahead log is larger than the database — killed sessions left it behind. It is reclaimed automatically on open; if it persists across runs, another live Alpha Code Sense process is holding it.');
1046
+ }
1047
+ }
1048
+ // Surface the active SQLite backend (node:sqlite — Node's built-in real
1049
+ // SQLite, full WAL + FTS5, no native build).
1050
+ const backendLabel = chalk.green(`node:sqlite ${(0, glyphs_1.getGlyphs)().dash} built-in (full WAL)`);
1051
+ console.log(` Backend: ${backendLabel}`);
1052
+ // Effective journal mode: 'wal' means concurrent reads never block on a
1053
+ // writer; anything else means they can ("database is locked"). node:sqlite
1054
+ // supports WAL everywhere, so a non-wal mode means the filesystem can't
1055
+ // (network mounts, WSL2 /mnt). See issue #238.
1056
+ const journalLabel = journalMode === 'wal'
1057
+ ? chalk.green('wal')
1058
+ : chalk.yellow(`${journalMode || 'unknown'} ${(0, glyphs_1.getGlyphs)().dash} WAL inactive; reads can block on writes`);
1059
+ console.log(` Journal: ${journalLabel}`);
1060
+ console.log();
1061
+ // Node breakdown
1062
+ console.log(chalk.bold('Nodes by Kind:'));
1063
+ const nodesByKind = Object.entries(stats.nodesByKind)
1064
+ .filter(([, count]) => count > 0)
1065
+ .sort((a, b) => b[1] - a[1]);
1066
+ for (const [kind, count] of nodesByKind) {
1067
+ console.log(` ${kind.padEnd(15)} ${formatNumber(count)}`);
1068
+ }
1069
+ console.log();
1070
+ // Language breakdown
1071
+ console.log(chalk.bold('Files by Language:'));
1072
+ const filesByLang = Object.entries(stats.filesByLanguage)
1073
+ .filter(([, count]) => count > 0)
1074
+ .sort((a, b) => b[1] - a[1]);
1075
+ for (const [lang, count] of filesByLang) {
1076
+ console.log(` ${lang.padEnd(15)} ${formatNumber(count)}`);
1077
+ }
1078
+ console.log();
1079
+ // Pending changes
1080
+ const totalChanges = changes.added.length + changes.modified.length + changes.removed.length;
1081
+ if (totalChanges > 0) {
1082
+ console.log(chalk.bold('Pending Changes:'));
1083
+ if (changes.added.length > 0) {
1084
+ console.log(` Added: ${changes.added.length} files`);
1085
+ }
1086
+ if (changes.modified.length > 0) {
1087
+ console.log(` Modified: ${changes.modified.length} files`);
1088
+ }
1089
+ if (changes.removed.length > 0) {
1090
+ console.log(` Removed: ${changes.removed.length} files`);
1091
+ }
1092
+ info('Run "codegraph sync" to update the index');
1093
+ }
1094
+ else {
1095
+ success('Index is up to date');
1096
+ }
1097
+ console.log();
1098
+ // Re-index hint: the index was built by an older engine than the one now
1099
+ // running, so a rebuild would add data a migration can't backfill.
1100
+ if (reindexRecommended) {
1101
+ const builtWith = buildInfo.version ? `v${buildInfo.version.replace(/^v/, '')}` : 'an earlier version';
1102
+ warn(`Index was built by ${builtWith}; re-index to pick up this engine's improvements.`);
1103
+ info('Run "codegraph index" (full rebuild) or "codegraph sync"');
1104
+ console.log();
1105
+ }
1106
+ cg.destroy();
1107
+ }
1108
+ catch (err) {
1109
+ error(`Failed to get status: ${err instanceof Error ? err.message : String(err)}`);
1110
+ process.exit(1);
1111
+ }
1112
+ });
1113
+ /**
1114
+ * codegraph query <search>
1115
+ */
1116
+ program
1117
+ .command('query <search>')
1118
+ .description('Search for symbols in the codebase')
1119
+ .option('-p, --path <path>', 'Project path')
1120
+ .option('-l, --limit <number>', 'Maximum results', '10')
1121
+ .option('-k, --kind <kind>', 'Filter by node kind (function, class, etc.)')
1122
+ .option('-j, --json', 'Output as JSON')
1123
+ .action(async (search, options) => {
1124
+ const projectPath = resolveProjectPath(options.path);
1125
+ try {
1126
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1127
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
1128
+ process.exit(1);
1129
+ }
1130
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
1131
+ const cg = await AlphaCodeSense.open(projectPath);
1132
+ const limit = parseInt(options.limit || '10', 10);
1133
+ const rawResults = cg.searchNodes(search, {
1134
+ // Fetch one extra row so the CLI can report a cut without changing the
1135
+ // long-standing bare-array contract of `query --json` (#1639).
1136
+ limit: limit + 1,
1137
+ kinds: options.kind ? [options.kind] : undefined,
1138
+ });
1139
+ // Mirror the MCP search down-rank so the CLI also surfaces the
1140
+ // hand-written implementation before protobuf/gRPC scaffolding
1141
+ // when both share a name. See extraction/generated-detection.ts.
1142
+ const isGen = cg.generatedFilePredicate(rawResults.map((r) => r.node.filePath));
1143
+ const rankedResults = [...rawResults].sort((a, b) => {
1144
+ const aGen = isGen(a.node.filePath) ? 1 : 0;
1145
+ const bGen = isGen(b.node.filePath) ? 1 : 0;
1146
+ return aGen - bGen;
1147
+ });
1148
+ const truncated = rankedResults.length > limit;
1149
+ const results = rankedResults.slice(0, limit);
1150
+ const truncationMessage = `Results truncated at ${limit}; pass --limit to widen.`;
1151
+ if (options.json) {
1152
+ console.log(JSON.stringify(results, null, 2));
1153
+ if (truncated)
1154
+ console.error(truncationMessage);
1155
+ }
1156
+ else {
1157
+ if (results.length === 0) {
1158
+ info(`No results found for "${search}"`);
1159
+ }
1160
+ else {
1161
+ console.log(chalk.bold(`\nSearch Results for "${search}":\n`));
1162
+ // Results arrive already ranked by relevance, so the order conveys
1163
+ // it. We don't print the raw score: it's an unbounded BM25/FTS value
1164
+ // (relative-ranking only), and the old `(score * 100)%` rendered it
1165
+ // as nonsensical percentages like "12042%" (#1045). The MCP search
1166
+ // tool likewise shows no score. Raw `score` stays in --json output.
1167
+ for (const result of results) {
1168
+ const node = result.node;
1169
+ const location = `${node.filePath}:${node.startLine}`;
1170
+ console.log(chalk.cyan(node.kind.padEnd(12)) +
1171
+ chalk.white(node.name));
1172
+ console.log(chalk.dim(` ${location}`));
1173
+ if (node.signature) {
1174
+ console.log(chalk.dim(` ${node.signature}`));
1175
+ }
1176
+ console.log();
1177
+ }
1178
+ if (truncated)
1179
+ console.log(chalk.dim(truncationMessage));
1180
+ }
1181
+ }
1182
+ cg.destroy();
1183
+ }
1184
+ catch (err) {
1185
+ error(`Search failed: ${err instanceof Error ? err.message : String(err)}`);
1186
+ process.exit(1);
1187
+ }
1188
+ });
1189
+ /**
1190
+ * codegraph explore <query...>
1191
+ *
1192
+ * The CLI face of the MCP codegraph_explore tool — same handler, same
1193
+ * output (source of the relevant symbols grouped by file + the call path
1194
+ * among them). Exists so agents WITHOUT the MCP tools — Task-tool
1195
+ * subagents (which don't inherit MCP tools, #704) and non-MCP harnesses —
1196
+ * can reach the graph through a plain shell command.
1197
+ */
1198
+ program
1199
+ .command('explore <query...>')
1200
+ .description('Explore an area: relevant symbols\' source + call paths in one shot (same output as the codegraph_explore MCP tool)')
1201
+ .option('-p, --path <path>', 'Project path')
1202
+ .option('--max-files <number>', 'Maximum number of files to include source from')
1203
+ .action(async (queryParts, options) => {
1204
+ const projectPath = resolveProjectPath(options.path);
1205
+ try {
1206
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1207
+ error(`Alpha Code Sense isn't available here — no .alpha-cs/ index exists in ${projectPath}. If you are an AI agent: continue with your usual tools; indexing is the user's decision, do not run it yourself. (The project owner can enable Alpha Code Sense with 'codegraph init'.)`);
1208
+ process.exit(1);
1209
+ }
1210
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
1211
+ const cg = await AlphaCodeSense.open(projectPath);
1212
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
1213
+ const handler = new ToolHandler(cg);
1214
+ const args = { query: queryParts.join(' ') };
1215
+ if (options.maxFiles)
1216
+ args.maxFiles = parseInt(options.maxFiles, 10);
1217
+ const result = await handler.execute('codegraph_explore', args);
1218
+ console.log(result.content[0]?.text ?? '');
1219
+ cg.destroy();
1220
+ if (result.isError)
1221
+ process.exit(1);
1222
+ }
1223
+ catch (err) {
1224
+ error(`Explore failed: ${err instanceof Error ? err.message : String(err)}`);
1225
+ process.exit(1);
1226
+ }
1227
+ });
1228
+ /**
1229
+ * codegraph context <task...>
1230
+ *
1231
+ * The CLI face of the public `buildContext` API (ContextBuilder): FTS entry
1232
+ * points + graph expansion + code blocks, formatted as markdown or JSON.
1233
+ * Advertised in the usage header since the first release but never actually
1234
+ * registered (#1611); external integrations (e.g. Memorix) invoke it as
1235
+ * `codegraph context --path <root> --format json --max-nodes 8 --no-code <task>`.
1236
+ */
1237
+ program
1238
+ .command('context <task...>')
1239
+ .description('Build context for a task: relevant symbols, relationships, and code blocks')
1240
+ .option('-p, --path <path>', 'Project path')
1241
+ .option('-f, --format <format>', 'Output format: markdown or json', 'markdown')
1242
+ .option('-n, --max-nodes <number>', 'Maximum number of symbols to include')
1243
+ .option('--no-code', 'Omit code blocks (structure only)')
1244
+ .action(async (taskParts, options) => {
1245
+ const projectPath = resolveProjectPath(options.path);
1246
+ const format = options.format ?? 'markdown';
1247
+ if (format !== 'markdown' && format !== 'json') {
1248
+ error(`Unknown format "${options.format}" — use "markdown" or "json".`);
1249
+ process.exit(1);
1250
+ }
1251
+ let maxNodes;
1252
+ if (options.maxNodes !== undefined) {
1253
+ maxNodes = parseInt(options.maxNodes, 10);
1254
+ if (Number.isNaN(maxNodes) || maxNodes < 1) {
1255
+ error(`--max-nodes expects a positive integer, got "${options.maxNodes}".`);
1256
+ process.exit(1);
1257
+ }
1258
+ }
1259
+ try {
1260
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1261
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
1262
+ process.exit(1);
1263
+ }
1264
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
1265
+ const cg = await AlphaCodeSense.open(projectPath);
1266
+ const result = await cg.buildContext(taskParts.join(' '), {
1267
+ format,
1268
+ includeCode: options.code !== false,
1269
+ ...(maxNodes !== undefined ? { maxNodes } : {}),
1270
+ });
1271
+ // Both supported formats return a formatted string; print it verbatim so
1272
+ // `--format json` stays machine-parseable on stdout (error()/warnings go
1273
+ // to stderr only).
1274
+ console.log(typeof result === 'string' ? result : JSON.stringify(result, null, 2));
1275
+ cg.destroy();
1276
+ }
1277
+ catch (err) {
1278
+ error(`Context build failed: ${err instanceof Error ? err.message : String(err)}`);
1279
+ process.exit(1);
1280
+ }
1281
+ });
1282
+ /**
1283
+ * codegraph prompt-hook (hidden)
1284
+ *
1285
+ * A Claude Code `UserPromptSubmit` hook entry point. Reads `{prompt, cwd}` JSON
1286
+ * on stdin; for a structural/flow/impact prompt it runs `codegraph_explore` on
1287
+ * the indexed project and prints the result to stdout, which Claude injects into
1288
+ * the agent's context — so the agent's reflex grep/read has nothing left to find
1289
+ * and reliably uses Alpha Code Sense (the adoption problem). Installed by the installer
1290
+ * into Claude's settings.json (opt-in, default-yes).
1291
+ *
1292
+ * LOAD-BEARING: this must NEVER break the user's prompt. Every failure path —
1293
+ * kill-switch, non-structural prompt, no index, engine error — exits 0 with no
1294
+ * output. The only effect is additive context when it can confidently provide it.
1295
+ */
1296
+ program
1297
+ .command('prompt-hook', { hidden: true })
1298
+ .description('Claude UserPromptSubmit hook: inject Alpha Code Sense context for structural prompts (reads {prompt,cwd} JSON on stdin)')
1299
+ .action(async () => {
1300
+ try {
1301
+ // Kill-switch: lets a user disable the nudge without uninstalling /
1302
+ // editing settings.json (CI, low-power machines, personal preference).
1303
+ if (process.env.ALPHA_CS_NO_PROMPT_HOOK === '1' || process.env.CODEGRAPH_PROMPT_HOOK === '0')
1304
+ return;
1305
+ if (process.stdin.isTTY)
1306
+ return; // invoked by hand, no piped payload
1307
+ const raw = await new Promise((resolve) => {
1308
+ let data = '';
1309
+ process.stdin.setEncoding('utf8');
1310
+ process.stdin.on('data', (c) => { data += c; });
1311
+ process.stdin.on('end', () => resolve(data));
1312
+ process.stdin.on('error', () => resolve(data));
1313
+ });
1314
+ let input = {};
1315
+ try {
1316
+ input = JSON.parse(raw);
1317
+ }
1318
+ catch {
1319
+ return;
1320
+ }
1321
+ const prompt = String(input.prompt || '');
1322
+ // Gate telemetry: how often each tier fires vs. no-ops — counter names
1323
+ // only, NEVER prompt content (see TELEMETRY.md). This is the data that
1324
+ // turns "is the gate any good" from vibes into a measured recall rate.
1325
+ const gate = (outcome) => {
1326
+ try {
1327
+ (0, telemetry_1.getTelemetry)().recordUsage('cli_command', `prompt-hook-gate-${outcome}`, true);
1328
+ }
1329
+ catch { /* never break the hook */ }
1330
+ };
1331
+ // Gate, tiered by confidence (#994, #1126):
1332
+ // HIGH — a structural keyword (any covered language), or a code-shaped
1333
+ // token verified in the index → full explore injection.
1334
+ // MEDIUM — no keyword/token, but prose words match indexed symbol-name
1335
+ // SEGMENTS ("state machine" → OrderStateMachine, in any
1336
+ // language): inject a short list of the matching symbols and
1337
+ // let the AGENT write the explore query — the graph-derived
1338
+ // tier, no vocabulary involved.
1339
+ // silent — nothing verified. Every other prompt ("fix this typo")
1340
+ // stays a zero-cost no-op.
1341
+ // Keywords fire on their own; a token or prose word is only a CANDIDATE
1342
+ // verified against the graph below, so a tech brand ("JavaScript") that
1343
+ // merely looks like code doesn't inject spurious context.
1344
+ const keyworded = (0, directory_1.hasStructuralKeyword)(prompt);
1345
+ const codeTokens = keyworded ? [] : (0, directory_1.extractCodeTokens)(prompt);
1346
+ const proseWords = keyworded ? [] : (0, identifier_segments_1.extractProseCandidates)(prompt);
1347
+ if (!keyworded && codeTokens.length === 0 && proseWords.length === 0) {
1348
+ gate('noop-shape');
1349
+ return;
1350
+ }
1351
+ // Decide what to inject, shaped by WHERE the index(es) are: the nearest
1352
+ // indexed ancestor of cwd, or — when cwd is an un-indexed workspace root
1353
+ // whose indexed project(s) live in sub-dirs (the monorepo case, #964) —
1354
+ // the sub-project the prompt points at, plus a `projectPath` nudge for any
1355
+ // others. Without the down-scan the hook injected nothing at a monorepo
1356
+ // root (it only walked up), so the validated adoption lever never fired
1357
+ // exactly where the agent most needs it.
1358
+ const plan = (0, directory_1.planFrontload)(String(input.cwd || process.cwd()), prompt);
1359
+ if (!plan.exploreRoot && plan.nudgeProjects.length === 0) {
1360
+ gate('noop-no-index');
1361
+ return;
1362
+ } // nothing reachable — the agent's normal tools apply
1363
+ // A "pass projectPath" line for indexed sub-projects we did NOT front-load.
1364
+ // Follow-up codegraph_explore calls against a sub-project (cwd isn't its
1365
+ // index root) need an explicit projectPath, so spell it out.
1366
+ const nudge = (projects, lead) => `${lead}\n${projects.map((p) => ` - projectPath: "${p}"`).join('\n')}\n`;
1367
+ if (plan.exploreRoot) {
1368
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
1369
+ const cg = await AlphaCodeSense.open(plan.exploreRoot);
1370
+ try {
1371
+ const others = plan.nudgeProjects.length
1372
+ ? `\n${nudge(plan.nudgeProjects, 'Other indexed projects in this workspace — pass projectPath to query them:')}`
1373
+ : '';
1374
+ // Tier decision against THIS index (issue #994 follow-up: candidates
1375
+ // must be real here — a brand name or prose about another domain
1376
+ // must not inject). Keyword-bearing prompts skip verification — the
1377
+ // keyword is signal enough.
1378
+ const tokenVerified = !keyworded && codeTokens.some((t) => cg.getNodesByName(t).length > 0);
1379
+ if (keyworded || tokenVerified) {
1380
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
1381
+ const handler = new ToolHandler(cg);
1382
+ const result = await handler.execute('codegraph_explore', { query: prompt });
1383
+ const text = result.content[0]?.text ?? '';
1384
+ if (!result.isError && text.trim()) {
1385
+ // Cap the injection so a large-repo explore can't flood the prompt.
1386
+ // Claude Code shows hook stdout inline only up to 10,000 characters;
1387
+ // above that it persists the output to a file and the model sees a
1388
+ // 2 KB preview (#1694). PROMPT_HOOK_INJECTION_MAX (9,000) leaves
1389
+ // room for the wrapper and the projectPath nudge lines below.
1390
+ const body = (0, directory_1.capPromptHookInjection)(text);
1391
+ // For a front-loaded SUB-project, a follow-up explore needs its path.
1392
+ const more = plan.viaSubScan
1393
+ ? `call codegraph_explore with projectPath: "${plan.exploreRoot}" for more`
1394
+ : 'call codegraph_explore for more';
1395
+ process.stdout.write(`<codegraph_context note="Structural context from Alpha Code Sense for this prompt — treat returned source as already read; ${more}.">\n${body}${others}\n</codegraph_context>\n`);
1396
+ gate(keyworded ? 'high-keyword' : 'high-token');
1397
+ }
1398
+ else {
1399
+ // A high-* outcome must mean context was actually delivered —
1400
+ // the funnel's noop-vs-high split is how gate recall is
1401
+ // measured (#1143). An explore error or empty result is a
1402
+ // delivery failure, not a gate success.
1403
+ gate(keyworded ? 'noop-explore-keyword' : 'noop-explore-token');
1404
+ }
1405
+ return;
1406
+ }
1407
+ // MEDIUM: prose words → symbol-name segments, co-occurrence/rarity
1408
+ // scored, each hit re-verified to exist (see getSegmentMatches). The
1409
+ // payload names the symbols but does NOT run explore — the agent owns
1410
+ // the query where the hook's confidence is only "these are related".
1411
+ //
1412
+ // A database indexed before the vocab table existed starts with it
1413
+ // EMPTY, and only sync() backfills it — which this hook never runs
1414
+ // (#1142). Heal it here: on a populated vocab this is one SELECT;
1415
+ // the actual backfill is a one-time batched pass whose cost the MCP
1416
+ // server's own catch-up sync usually pays first (it runs at every
1417
+ // session start). A distinct noop outcome keeps a dormant vocab
1418
+ // from polluting the noop-unverified recall signal.
1419
+ const vocabReady = await cg.healSegmentVocabIfEmpty().catch(() => false);
1420
+ if (!vocabReady) {
1421
+ gate('noop-vocab-empty');
1422
+ return;
1423
+ }
1424
+ const related = cg.getSegmentMatches(proseWords);
1425
+ if (related.length === 0) {
1426
+ gate('noop-unverified');
1427
+ return;
1428
+ }
1429
+ const lines = related
1430
+ .map((m) => ` - ${m.name} (${m.kind} — ${m.filePath}:${m.startLine})`)
1431
+ .join('\n');
1432
+ const exampleQuery = related.slice(0, 3).map((m) => m.name).join(' ');
1433
+ const projectHint = plan.viaSubScan ? ` with projectPath: "${plan.exploreRoot}"` : '';
1434
+ process.stdout.write(`<codegraph_context note="Alpha Code Sense found indexed symbols matching this prompt — query the graph before searching files.">\n` +
1435
+ `This project's Alpha Code Sense index contains symbols matching this request:\n${lines}\n` +
1436
+ `Call codegraph_explore ONCE${projectHint} with the relevant names in one query (e.g. "${exampleQuery}") ` +
1437
+ `to get their source, call paths, and blast radius — cheaper and more complete than Read/Grep.\n${others}` +
1438
+ `</codegraph_context>\n`);
1439
+ gate('medium-segment');
1440
+ }
1441
+ finally {
1442
+ cg.destroy();
1443
+ }
1444
+ }
1445
+ else {
1446
+ // Several indexed sub-projects, none a clear match — don't guess; tell
1447
+ // the agent they exist and how to query one.
1448
+ process.stdout.write(`<codegraph_context note="Alpha Code Sense is available for this workspace's indexed sub-projects — query one by passing projectPath to codegraph_explore.">\n` +
1449
+ nudge(plan.nudgeProjects, "This workspace's Alpha Code Sense indexes live in sub-projects. To use Alpha Code Sense, call codegraph_explore with the projectPath of the relevant one:") +
1450
+ `</codegraph_context>\n`);
1451
+ gate('nudge-projects');
1452
+ }
1453
+ }
1454
+ catch {
1455
+ // Degradable by contract: never surface an error to the prompt pipeline.
1456
+ }
1457
+ });
1458
+ /**
1459
+ * codegraph node [name]
1460
+ *
1461
+ * The CLI face of the MCP codegraph_node tool: one symbol's source +
1462
+ * caller/callee trail, or a whole file with line numbers + dependents
1463
+ * (Read-parity). Same subagent/non-MCP rationale as `explore`.
1464
+ *
1465
+ * `name` is OPTIONAL because `--file` (file-read mode) carries no symbol —
1466
+ * a required `<name>` made `codegraph node -f <file>` unreachable (#1044).
1467
+ */
1468
+ program
1469
+ .command('node [name]')
1470
+ .description('One symbol\'s source + caller/callee trail, or read a file with line numbers + dependents (same output as the codegraph_node MCP tool)')
1471
+ .option('-p, --path <path>', 'Project path')
1472
+ .option('-f, --file <file>', 'Treat as file mode (or disambiguate a symbol to this file)')
1473
+ .option('--offset <number>', 'File mode: 1-based start line')
1474
+ .option('--limit <number>', 'File mode: maximum lines')
1475
+ .option('--symbols-only', 'File mode: just the symbol map + dependents')
1476
+ .action(async (name, options) => {
1477
+ // Need a symbol (positional) OR a file (--file / a path-like positional).
1478
+ // With [name] optional, a bare `codegraph node` reaches here with neither
1479
+ // and must be told what to pass, rather than crashing downstream.
1480
+ if (!name && !options.file) {
1481
+ error("Pass a symbol name (e.g. 'codegraph node parseToken') or a file (e.g. 'codegraph node -f src/auth.ts', or 'codegraph node src/auth.ts').");
1482
+ process.exit(1);
1483
+ }
1484
+ const projectPath = resolveProjectPath(options.path);
1485
+ try {
1486
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1487
+ error(`Alpha Code Sense isn't available here — no .alpha-cs/ index exists in ${projectPath}. If you are an AI agent: continue with your usual tools; indexing is the user's decision, do not run it yourself. (The project owner can enable Alpha Code Sense with 'codegraph init'.)`);
1488
+ process.exit(1);
1489
+ }
1490
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
1491
+ const cg = await AlphaCodeSense.open(projectPath);
1492
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
1493
+ const handler = new ToolHandler(cg);
1494
+ // A name with a path separator is a file read; otherwise a symbol
1495
+ // (use --file for basename-only file reads or to pin an overload).
1496
+ // Both separators: Windows users type src\auth\session.ts. Symbols
1497
+ // never contain either ('/' isn't an identifier char anywhere we
1498
+ // index; C++ scope is '::', JS members '.').
1499
+ const args = {};
1500
+ if (options.file) {
1501
+ args.file = options.file;
1502
+ if (name && name !== options.file) {
1503
+ args.symbol = name;
1504
+ // Symbol mode pinned to a file is still symbol mode — the CLI
1505
+ // always wants the body, exactly like the bare-symbol branch
1506
+ // below. Omitting this printed location + trail with no source
1507
+ // (#1284).
1508
+ args.includeCode = true;
1509
+ }
1510
+ }
1511
+ else if (name && (name.includes('/') || name.includes('\\'))) {
1512
+ args.file = name.replace(/\\/g, '/');
1513
+ }
1514
+ else if (name) {
1515
+ args.symbol = name;
1516
+ args.includeCode = true;
1517
+ }
1518
+ if (options.offset)
1519
+ args.offset = parseInt(options.offset, 10);
1520
+ if (options.limit)
1521
+ args.limit = parseInt(options.limit, 10);
1522
+ if (options.symbolsOnly)
1523
+ args.symbolsOnly = true;
1524
+ const result = await handler.execute('codegraph_node', args);
1525
+ console.log(result.content[0]?.text ?? '');
1526
+ cg.destroy();
1527
+ if (result.isError)
1528
+ process.exit(1);
1529
+ }
1530
+ catch (err) {
1531
+ error(`Node lookup failed: ${err instanceof Error ? err.message : String(err)}`);
1532
+ process.exit(1);
1533
+ }
1534
+ });
1535
+ /**
1536
+ * codegraph files [path]
1537
+ */
1538
+ program
1539
+ .command('files')
1540
+ .description('Show project file structure from the index')
1541
+ .option('-p, --path <path>', 'Project path')
1542
+ .option('--filter <dir>', 'Filter to files under this directory')
1543
+ .option('--pattern <glob>', 'Filter files matching this glob pattern')
1544
+ .option('--format <format>', 'Output format (tree, flat, grouped)', 'tree')
1545
+ .option('--max-depth <number>', 'Maximum directory depth for tree format')
1546
+ .option('--no-metadata', 'Hide file metadata (language, symbol count)')
1547
+ .option('-j, --json', 'Output as JSON')
1548
+ .action(async (options) => {
1549
+ const projectPath = resolveProjectPath(options.path);
1550
+ try {
1551
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1552
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
1553
+ process.exit(1);
1554
+ }
1555
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
1556
+ const cg = await AlphaCodeSense.open(projectPath);
1557
+ let files = cg.getFiles();
1558
+ if (files.length === 0) {
1559
+ info('No files indexed. Run "codegraph index" first.');
1560
+ cg.destroy();
1561
+ return;
1562
+ }
1563
+ // Filter by path prefix
1564
+ if (options.filter) {
1565
+ const filter = options.filter;
1566
+ files = files.filter(f => f.path.startsWith(filter) || f.path.startsWith('./' + filter));
1567
+ }
1568
+ // Filter by glob pattern
1569
+ if (options.pattern) {
1570
+ const regex = globToRegex(options.pattern);
1571
+ files = files.filter(f => regex.test(f.path));
1572
+ }
1573
+ if (files.length === 0) {
1574
+ info('No files found matching the criteria.');
1575
+ cg.destroy();
1576
+ return;
1577
+ }
1578
+ // JSON output
1579
+ if (options.json) {
1580
+ const output = files.map(f => ({
1581
+ path: f.path,
1582
+ language: f.language,
1583
+ nodeCount: f.nodeCount,
1584
+ size: f.size,
1585
+ }));
1586
+ console.log(JSON.stringify(output, null, 2));
1587
+ cg.destroy();
1588
+ return;
1589
+ }
1590
+ const includeMetadata = options.metadata !== false;
1591
+ const format = options.format || 'tree';
1592
+ const maxDepth = options.maxDepth ? parseInt(options.maxDepth, 10) : undefined;
1593
+ // Format output
1594
+ switch (format) {
1595
+ case 'flat':
1596
+ console.log(chalk.bold(`\nFiles (${files.length}):\n`));
1597
+ for (const file of files.sort((a, b) => a.path.localeCompare(b.path))) {
1598
+ if (includeMetadata) {
1599
+ console.log(` ${file.path} ${chalk.dim(`(${file.language}, ${file.nodeCount} symbols)`)}`);
1600
+ }
1601
+ else {
1602
+ console.log(` ${file.path}`);
1603
+ }
1604
+ }
1605
+ break;
1606
+ case 'grouped':
1607
+ console.log(chalk.bold(`\nFiles by Language (${files.length} total):\n`));
1608
+ const byLang = new Map();
1609
+ for (const file of files) {
1610
+ const existing = byLang.get(file.language) || [];
1611
+ existing.push(file);
1612
+ byLang.set(file.language, existing);
1613
+ }
1614
+ const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
1615
+ for (const [lang, langFiles] of sortedLangs) {
1616
+ console.log(chalk.cyan(`${lang} (${langFiles.length}):`));
1617
+ for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
1618
+ if (includeMetadata) {
1619
+ console.log(` ${file.path} ${chalk.dim(`(${file.nodeCount} symbols)`)}`);
1620
+ }
1621
+ else {
1622
+ console.log(` ${file.path}`);
1623
+ }
1624
+ }
1625
+ console.log();
1626
+ }
1627
+ break;
1628
+ case 'tree':
1629
+ default:
1630
+ console.log(chalk.bold(`\nProject Structure (${files.length} files):\n`));
1631
+ printFileTree(files, includeMetadata, maxDepth, chalk);
1632
+ break;
1633
+ }
1634
+ console.log();
1635
+ cg.destroy();
1636
+ }
1637
+ catch (err) {
1638
+ error(`Failed to list files: ${err instanceof Error ? err.message : String(err)}`);
1639
+ process.exit(1);
1640
+ }
1641
+ });
1642
+ /**
1643
+ * Normalize a user-supplied file path to the project-relative, forward-slash
1644
+ * form Alpha Code Sense stores in the index. Accepts an absolute path, a `./`-prefixed
1645
+ * path, or Windows back-slashes; an empty string when the input is blank. Used
1646
+ * by `codegraph affected` so `./src/x.ts`, `/abs/repo/src/x.ts`, and
1647
+ * `src/x.ts` all match the same indexed file. (#825)
1648
+ */
1649
+ function normalizeIndexPath(filePath, projectPath) {
1650
+ let f = filePath.trim();
1651
+ if (!f)
1652
+ return '';
1653
+ if (path.isAbsolute(f))
1654
+ f = path.relative(projectPath, f);
1655
+ // Collapse `.`/`..` segments, then force forward slashes and drop a leading
1656
+ // `./` (path.normalize already strips it on POSIX; explicit for Windows).
1657
+ f = path.normalize(f).replace(/\\/g, '/').replace(/^\.\//, '');
1658
+ return f;
1659
+ }
1660
+ /**
1661
+ * Convert glob pattern to regex
1662
+ */
1663
+ function globToRegex(pattern) {
1664
+ const escaped = pattern
1665
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
1666
+ .replace(/\*\*/g, '{{GLOBSTAR}}')
1667
+ .replace(/\*/g, '[^/]*')
1668
+ .replace(/\?/g, '[^/]')
1669
+ .replace(/\{\{GLOBSTAR\}\}/g, '.*');
1670
+ return new RegExp(escaped);
1671
+ }
1672
+ /**
1673
+ * Print files as a tree
1674
+ */
1675
+ function printFileTree(files, includeMetadata, maxDepth, chalk) {
1676
+ const root = { name: '', children: new Map() };
1677
+ for (const file of files) {
1678
+ const parts = file.path.split('/');
1679
+ let current = root;
1680
+ for (let i = 0; i < parts.length; i++) {
1681
+ const part = parts[i];
1682
+ if (!part)
1683
+ continue;
1684
+ if (!current.children.has(part)) {
1685
+ current.children.set(part, { name: part, children: new Map() });
1686
+ }
1687
+ current = current.children.get(part);
1688
+ if (i === parts.length - 1) {
1689
+ current.file = { language: file.language, nodeCount: file.nodeCount };
1690
+ }
1691
+ }
1692
+ }
1693
+ const renderNode = (node, prefix, isLast, depth) => {
1694
+ if (maxDepth !== undefined && depth > maxDepth)
1695
+ return;
1696
+ const glyphs = (0, glyphs_1.getGlyphs)();
1697
+ const connector = isLast ? glyphs.treeLast : glyphs.treeBranch;
1698
+ const childPrefix = isLast ? ' ' : glyphs.treePipe;
1699
+ if (node.name) {
1700
+ let line = prefix + connector + node.name;
1701
+ if (node.file && includeMetadata) {
1702
+ line += chalk.dim(` (${node.file.language}, ${node.file.nodeCount} symbols)`);
1703
+ }
1704
+ console.log(line);
1705
+ }
1706
+ const children = [...node.children.values()];
1707
+ children.sort((a, b) => {
1708
+ const aIsDir = a.children.size > 0 && !a.file;
1709
+ const bIsDir = b.children.size > 0 && !b.file;
1710
+ if (aIsDir !== bIsDir)
1711
+ return aIsDir ? -1 : 1;
1712
+ return a.name.localeCompare(b.name);
1713
+ });
1714
+ for (let i = 0; i < children.length; i++) {
1715
+ const child = children[i];
1716
+ const nextPrefix = node.name ? prefix + childPrefix : prefix;
1717
+ renderNode(child, nextPrefix, i === children.length - 1, depth + 1);
1718
+ }
1719
+ };
1720
+ renderNode(root, '', true, 0);
1721
+ }
1722
+ /**
1723
+ * codegraph daemon — interactive manager for the background daemons. Arrow keys
1724
+ * to pick one (the current project's daemon floats to the top, auto-selected),
1725
+ * enter to stop it. Falls back to a plain list when output isn't a TTY.
1726
+ */
1727
+ program
1728
+ .command('daemon')
1729
+ .aliases(['daemons'])
1730
+ .description('Manage running Alpha Code Sense background daemons — pick one and press enter to stop it')
1731
+ .action(async () => {
1732
+ const { listVerifiedDaemons, stopDaemonAt, stopAllDaemons } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
1733
+ const { runDaemonPicker } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-manager')));
1734
+ const daemons = await listVerifiedDaemons();
1735
+ if (daemons.length === 0) {
1736
+ info('No Alpha Code Sense daemons running.');
1737
+ return;
1738
+ }
1739
+ // No TTY (piped / CI / non-interactive) — can't do arrow-key selection, so
1740
+ // just print what's running instead of crashing on a prompt with no input.
1741
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
1742
+ for (const d of daemons) {
1743
+ console.log(`pid ${d.pid} v${d.version} up ${formatDuration(Date.now() - d.startedAt)} ${d.root}`);
1744
+ }
1745
+ return;
1746
+ }
1747
+ // The current project's daemon floats to the top and is pre-selected.
1748
+ let cwdRoot = null;
1749
+ const found = (0, directory_1.findNearestAlphaCsRoot)(process.cwd());
1750
+ if (found) {
1751
+ try {
1752
+ cwdRoot = fs.realpathSync(found);
1753
+ }
1754
+ catch {
1755
+ cwdRoot = found;
1756
+ }
1757
+ }
1758
+ const clack = await importESM('@clack/prompts');
1759
+ clack.intro('Alpha Code Sense daemons');
1760
+ await runDaemonPicker({
1761
+ list: listVerifiedDaemons,
1762
+ stop: stopDaemonAt,
1763
+ stopAll: stopAllDaemons,
1764
+ cwdRoot,
1765
+ now: () => Date.now(),
1766
+ select: (opts) => clack.select(opts),
1767
+ isCancel: (v) => clack.isCancel(v),
1768
+ note: (m) => clack.log.success(m),
1769
+ done: (m) => clack.outro(m),
1770
+ });
1771
+ });
1772
+ /**
1773
+ * Print the "no index here" guidance.
1774
+ *
1775
+ * The viewer READS an index; it never builds one — indexing stays the user's
1776
+ * decision, exactly as it is for the MCP tools. So a missing index is normal
1777
+ * input, not a failure to apologize for: say what is missing, say the one
1778
+ * command that fixes it, and never print a stack trace.
1779
+ */
1780
+ function printNoIndexGuidance(projectPath) {
1781
+ error(`No Alpha Code Sense index found for ${projectPath}`);
1782
+ console.error('');
1783
+ // getGlyphs() (not a literal em dash): a legacy Windows console decodes raw
1784
+ // UTF-8 with its OEM codepage and renders one as mojibake (#168).
1785
+ console.error(` The viewer reads an index that already exists ${(0, glyphs_1.getGlyphs)().dash} it never creates one.`);
1786
+ console.error(' To index this project:');
1787
+ console.error('');
1788
+ console.error(` ${chalk.cyan('codegraph init')}`);
1789
+ console.error('');
1790
+ console.error(' Already indexed somewhere else? Point the viewer at it:');
1791
+ console.error('');
1792
+ console.error(` ${chalk.cyan('codegraph ui /path/to/indexed/project')}`);
1793
+ console.error('');
1794
+ }
1795
+ /**
1796
+ * codegraph ui [path] (alias: web)
1797
+ *
1798
+ * The browser reader: serves the built viewer (`dist/viewer/`) over loopback
1799
+ * and opens it. It opens the index for reading and never writes to it, never
1800
+ * indexes, and never changes a line of the project's code. The single thing it
1801
+ * writes is a trail the reader saved, as JSON under `.alpha-cs/ui/trails/`;
1802
+ * `--read-only` turns even that off.
1803
+ *
1804
+ * Deliberately absent from TELEMETRY_FLUSH_COMMANDS above: the command's own
1805
+ * banner tells the user nothing leaves their machine, so it must not be the
1806
+ * thing that triggers a telemetry send. The usage count still buffers locally
1807
+ * like every other quick command.
1808
+ */
1809
+ program
1810
+ .command('ui [path]')
1811
+ .alias('web')
1812
+ .description('Open the Alpha Code Sense viewer in your browser — read your indexed project as a graph')
1813
+ .option('--port <number>', `Port to listen on (default: ${constants_1.DEFAULT_UI_PORT}, or the next free one)`)
1814
+ .option('--no-open', 'Print the URL instead of opening a browser')
1815
+ .option('--read-only', 'Refuse every write — saved trails can be opened but not saved or deleted')
1816
+ .addHelpText('after', `
1817
+ Examples:
1818
+ $ codegraph ui Read the project you're standing in
1819
+ $ codegraph ui ~/code/my-app Read a specific indexed project
1820
+ $ codegraph ui --port 8080 Use one specific port (fails if it's taken)
1821
+ $ codegraph ui --no-open Just print the URL (headless boxes, SSH)
1822
+ $ codegraph web Same command under its alias
1823
+
1824
+ Pick a symbol and you see who calls it on the left, its source in the middle,
1825
+ and what it calls on the right at the height of the line that calls it. Search
1826
+ with / (or Cmd-K), click a file path for the file's outline and its imports.
1827
+
1828
+ Ask "how does execute reach getFile" (or "execute -> getFile") in the search
1829
+ box for the flow between two symbols: one card per hop, opened at the line that
1830
+ makes the next call, with dynamic-dispatch hops drawn dashed and named. The Map
1831
+ tab draws the whole project by module, with dependencies pointing down.
1832
+
1833
+ Never opened this codebase before? The Entry points tab lists the routes with
1834
+ the symbols that serve them, the files that run something when they load, the
1835
+ tests, and what the most code depends on — and starts a flow from any of them.
1836
+
1837
+ The page keeps up with the project while it is open: save a file and it says so
1838
+ within about a third of a second, and whatever is on screen re-reads the graph
1839
+ when something re-indexes it. It watches for that; it never polls.
1840
+
1841
+ Save a walk you want to keep: name the trail and it is written to
1842
+ .alpha-cs/ui/trails/ (already gitignored) as plain JSON, listed on the empty
1843
+ screen, and reopened at the symbol you left. Hops are remembered by name rather
1844
+ than by position, so a saved trail survives re-indexing and says which hop moved
1845
+ when one does. Pass --read-only to refuse every write.
1846
+
1847
+ The viewer listens on 127.0.0.1 only, so nothing on your network can reach it.
1848
+ It opens an index that already exists, never indexes, and never changes a line
1849
+ of your code — the one thing it writes is a trail you asked it to save.
1850
+ Requests from any other host are refused, and nothing is sent anywhere: no code,
1851
+ no paths, no analytics.
1852
+
1853
+ Without --port it takes ${constants_1.DEFAULT_UI_PORT}, or the next free port if that one is busy.
1854
+
1855
+ Set ${constants_1.BROWSER_ENV}=<command> to choose which browser opens, or
1856
+ ${constants_1.BROWSER_ENV}=none to never open one.
1857
+ `)
1858
+ .action(async (pathArg, options) => {
1859
+ // An explicit --port stays explicit: a scripted `--port 8080` that quietly
1860
+ // lands on 8081 is worse than one that says the port is busy. The default
1861
+ // port is the only one we're free to walk away from.
1862
+ let requestedPort;
1863
+ if (options.port !== undefined) {
1864
+ requestedPort = Number(options.port);
1865
+ if (!Number.isInteger(requestedPort) || requestedPort < 0 || requestedPort > 65535) {
1866
+ error(`--port must be a whole number between 0 and 65535 (got "${options.port}").`);
1867
+ process.exit(1);
1868
+ }
1869
+ }
1870
+ const projectPath = resolveProjectPath(pathArg);
1871
+ // Sensitive-directory refusal before anything opens: the same guard the MCP
1872
+ // entry points use, so `codegraph ui /etc` is turned away here rather than
1873
+ // becoming a browsable view of the system.
1874
+ const { validateProjectPath } = await Promise.resolve().then(() => __importStar(require('../utils')));
1875
+ const rootError = validateProjectPath(projectPath);
1876
+ if (rootError) {
1877
+ error(rootError);
1878
+ process.exit(1);
1879
+ }
1880
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1881
+ printNoIndexGuidance(projectPath);
1882
+ process.exit(1);
1883
+ }
1884
+ const { startUiServer, openBrowser, createGraphApi, ViewerMissingError } = await Promise.resolve().then(() => __importStar(require('../ui-server')));
1885
+ // The JSON API the viewer reads its screens from. It opens the index lazily
1886
+ // on the first request, so a slow first paint is the only cost of mounting
1887
+ // it here rather than after the browser connects.
1888
+ const readOnly = options.readOnly === true;
1889
+ const api = createGraphApi({
1890
+ projectRoot: projectPath,
1891
+ readOnly,
1892
+ readOnlyReason: readOnly
1893
+ ? 'This viewer was started with --read-only, so trails cannot be saved.'
1894
+ : undefined,
1895
+ });
1896
+ let handle;
1897
+ try {
1898
+ handle = await startUiServer({
1899
+ projectRoot: projectPath,
1900
+ port: requestedPort,
1901
+ portFallback: requestedPort === undefined,
1902
+ api: api.handler,
1903
+ });
1904
+ }
1905
+ catch (err) {
1906
+ api.close();
1907
+ // Both failure modes here (viewer assets missing, no port available) carry
1908
+ // their own remediation — print it plainly, never a stack trace.
1909
+ error(err instanceof ViewerMissingError || err instanceof Error ? err.message : String(err));
1910
+ process.exit(1);
1911
+ }
1912
+ console.log('');
1913
+ console.log(chalk.bold('Alpha Code Sense viewer'));
1914
+ console.log('');
1915
+ console.log(` ${chalk.dim('Reading')} ${projectPath}`);
1916
+ console.log(` ${chalk.dim('URL')} ${chalk.cyan(handle.url)}`);
1917
+ console.log(` ${chalk.dim('Access')} this machine only ${(0, glyphs_1.getGlyphs)().dash} ` +
1918
+ (readOnly
1919
+ ? 'read-only, nothing leaves your computer'
1920
+ : 'nothing leaves your computer; saved trails are the only thing written'));
1921
+ console.log('');
1922
+ const opened = options.open === false ? false : openBrowser(handle.url);
1923
+ console.log(opened
1924
+ ? chalk.dim(' Opening your browser... press Ctrl+C to stop.')
1925
+ : chalk.dim(' Open that URL in a browser. Press Ctrl+C to stop.'));
1926
+ console.log('');
1927
+ // The http server keeps the event loop alive on its own; these just make
1928
+ // Ctrl-C hang up live sockets instead of waiting on browser keep-alives.
1929
+ const shutdown = () => {
1930
+ // Release the SQLite handle before the socket: the process should never
1931
+ // exit with a live connection to the user's index.
1932
+ api.close();
1933
+ void handle.close().then(() => process.exit(0));
1934
+ };
1935
+ process.once('SIGINT', shutdown);
1936
+ process.once('SIGTERM', shutdown);
1937
+ });
1938
+ /**
1939
+ * codegraph serve
1940
+ */
1941
+ program
1942
+ // Hidden from `--help`: this is the stdio entry point an AI agent launches
1943
+ // for itself (the installer wires `args: ['serve','--mcp']` into every
1944
+ // agent's MCP config), not a command a human runs. It still works when
1945
+ // invoked — hiding only removes it from the listing. See the interactive-TTY
1946
+ // guard below, which explains this to anyone who runs it by hand.
1947
+ .command('serve', { hidden: true })
1948
+ .description('Start Alpha Code Sense as an MCP server for AI assistants')
1949
+ .option('-p, --path <path>', 'Project path (optional for MCP mode, uses rootUri from client)')
1950
+ .option('--mcp', 'Run as MCP server (stdio transport)')
1951
+ .option('--no-watch', 'Disable the file watcher (no auto-sync; useful on slow filesystems like WSL2 /mnt drives)')
1952
+ .action(async (options) => {
1953
+ const projectPath = options.path ? resolveProjectPath(options.path) : undefined;
1954
+ // Commander sets watch=false when --no-watch is passed. Route it through
1955
+ // the same env-var chokepoint the watcher and MCP server already honor.
1956
+ if (options.watch === false) {
1957
+ process.env.CODEGRAPH_NO_WATCH = '1';
1958
+ }
1959
+ try {
1960
+ if (options.mcp) {
1961
+ // `serve --mcp` is the stdio MCP server an AI agent launches for itself,
1962
+ // not a command to run by hand. A human in a terminal would otherwise
1963
+ // see it hang waiting for JSON-RPC on stdin, which reads as broken. If
1964
+ // stdin is an interactive TTY, explain instead of hanging. The agent's
1965
+ // pipe and the detached daemon both have a non-TTY stdin, so this only
1966
+ // ever fires for a person who typed it.
1967
+ if (process.stdin.isTTY && !process.env.CODEGRAPH_DAEMON_INTERNAL) {
1968
+ console.error(chalk.bold('\nCodeGraph MCP server\n'));
1969
+ console.error("This is the MCP server your AI agent (Claude Code, Cursor, Codex, opencode, …)");
1970
+ console.error("starts automatically — you don't run it yourself.");
1971
+ console.error(`\nIt's already wired up by ${chalk.cyan('codegraph install')}. To check on things:`);
1972
+ console.error(` ${chalk.cyan('ltm-alpha-cs status')} ${chalk.dim('— is this project indexed and healthy?')}`);
1973
+ console.error(` ${chalk.cyan('codegraph daemon')} ${chalk.dim('— list or stop background MCP servers')}`);
1974
+ console.error(chalk.dim('\n(Running it directly only does something when an MCP client drives it over stdin.)'));
1975
+ return;
1976
+ }
1977
+ // Start MCP server - it handles initialization lazily based on rootUri from client
1978
+ const { MCPServer } = await Promise.resolve().then(() => __importStar(require('../mcp/index')));
1979
+ const server = new MCPServer(projectPath);
1980
+ await server.start();
1981
+ // Server will run until terminated
1982
+ }
1983
+ else {
1984
+ // Default: show info about MCP mode.
1985
+ // Use stderr so stdout stays clean for any piped/stdio usage.
1986
+ console.error(chalk.bold('\nCodeGraph MCP Server\n'));
1987
+ console.error(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' Use --mcp flag to start the MCP server');
1988
+ console.error('\nTo use with Claude Code, add to your MCP configuration:');
1989
+ console.error(chalk.dim(`
1990
+ {
1991
+ "mcpServers": {
1992
+ "codegraph": {
1993
+ "command": "codegraph",
1994
+ "args": ["serve", "--mcp"]
1995
+ }
1996
+ }
1997
+ }
1998
+ `));
1999
+ console.error('Available tools:');
2000
+ console.error(chalk.cyan(' codegraph_explore') + ' - Primary: source of the relevant symbols for any question');
2001
+ console.error(chalk.cyan(' codegraph_search') + ' - Search for code symbols');
2002
+ console.error(chalk.cyan(' codegraph_callers') + ' - Find callers of a symbol');
2003
+ console.error(chalk.cyan(' codegraph_callees') + ' - Find what a symbol calls');
2004
+ console.error(chalk.cyan(' codegraph_impact') + ' - Analyze impact of changes');
2005
+ console.error(chalk.cyan(' codegraph_node') + ' - Get symbol details');
2006
+ console.error(chalk.cyan(' codegraph_files') + ' - Get project file structure');
2007
+ console.error(chalk.cyan(' codegraph_status') + ' - Get index status');
2008
+ }
2009
+ }
2010
+ catch (err) {
2011
+ error(`Failed to start server: ${err instanceof Error ? err.message : String(err)}`);
2012
+ process.exit(1);
2013
+ }
2014
+ });
2015
+ /**
2016
+ * codegraph unlock [path]
2017
+ */
2018
+ program
2019
+ .command('unlock [path]')
2020
+ .description('Remove a stale lock file that is blocking indexing')
2021
+ .action(async (pathArg) => {
2022
+ const projectPath = resolveProjectPath(pathArg);
2023
+ try {
2024
+ if (!(0, directory_1.isInitialized)(projectPath)) {
2025
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
2026
+ return;
2027
+ }
2028
+ const lockPath = path.join((0, directory_1.getAlphaCsDir)(projectPath), 'codegraph.lock');
2029
+ let removed = false;
2030
+ if (fs.existsSync(lockPath)) {
2031
+ fs.unlinkSync(lockPath);
2032
+ removed = true;
2033
+ }
2034
+ const { clearStaleDaemonArtifacts } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
2035
+ removed = await clearStaleDaemonArtifacts(projectPath) || removed;
2036
+ if (removed)
2037
+ success('Removed stale lock artifacts. You can now run indexing again.');
2038
+ else
2039
+ info(`No stale lock files found ${(0, glyphs_1.getGlyphs)().dash} nothing to do`);
2040
+ }
2041
+ catch (err) {
2042
+ error(`Failed to remove lock: ${err instanceof Error ? err.message : String(err)}`);
2043
+ process.exit(1);
2044
+ }
2045
+ });
2046
+ /**
2047
+ * CLI parity with MCP callers/callees: resolve once, then collect and limit
2048
+ * within each definition. The legacy JSON list remains an explicitly labeled
2049
+ * union, with its original total/limit/truncated contract (#1674).
2050
+ */
2051
+ for (const direction of ['callers', 'callees']) {
2052
+ const title = direction === 'callers' ? 'Callers' : 'Callees';
2053
+ program
2054
+ .command(`${direction} <symbol>`)
2055
+ .description(direction === 'callers'
2056
+ ? 'Find all functions/methods that call a specific symbol'
2057
+ : 'Find all functions/methods called by a specific symbol')
2058
+ .option('-p, --path <path>', 'Project path')
2059
+ .option('-f, --file <path>', 'Narrow definitions by file path or suffix (no match: show all with a note)')
2060
+ .option('-l, --limit <number>', 'Maximum results per definition (also caps the JSON union)', '20')
2061
+ .option('-j, --json', 'Output as JSON')
2062
+ .action(async (symbol, options) => {
2063
+ const projectPath = resolveProjectPath(options.path);
2064
+ try {
2065
+ if (!(0, directory_1.isInitialized)(projectPath)) {
2066
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
2067
+ process.exit(1);
2068
+ }
2069
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
2070
+ const cg = await AlphaCodeSense.open(projectPath);
2071
+ try {
2072
+ const limit = parseInt(options.limit || '20', 10);
2073
+ const { nodes: targets } = (0, symbol_lookup_1.lookupSymbolNodes)(cg, symbol);
2074
+ if (targets.length === 0) {
2075
+ info(formatSymbolNotFound(symbol, cg.searchNodes(symbol, { limit: 5 }).map((m) => m.node.name)));
2076
+ return;
2077
+ }
2078
+ const { groups, filteredOut } = (0, symbol_lookup_1.groupDefinitions)(targets, options.file);
2079
+ const ambiguous = groups.length > 1;
2080
+ const note = filteredOut
2081
+ ? `no definition of "${symbol}" matches file "${options.file}" — showing all definitions instead.`
2082
+ : undefined;
2083
+ const collected = groups.map((group) => {
2084
+ const nodes = new Map();
2085
+ const edges = new Map();
2086
+ for (const target of group) {
2087
+ const connections = direction === 'callers' ? cg.getCallers(target.id) : cg.getCallees(target.id);
2088
+ for (const { node, edge } of connections) {
2089
+ nodes.set(node.id, node);
2090
+ edges.set(`${edge.source}->${edge.target}:${edge.kind}`, edge);
2091
+ }
2092
+ }
2093
+ return { group, nodes: [...nodes.values()], edges: [...edges.values()] };
2094
+ });
2095
+ if (options.json) {
2096
+ const definitions = collected.map(({ group, nodes, edges }) => {
2097
+ const limited = nodes.slice(0, limit);
2098
+ const shown = new Set(limited.map((node) => node.id));
2099
+ return {
2100
+ ...cliDefinition(group),
2101
+ [direction]: limited.map((node) => ({ id: node.id, ...cliNode(node) })),
2102
+ edges: edges.filter((edge) => shown.has(direction === 'callers' ? edge.source : edge.target)),
2103
+ total: nodes.length,
2104
+ limit,
2105
+ truncated: nodes.length > limit,
2106
+ };
2107
+ });
2108
+ const union = new Map();
2109
+ for (const { nodes } of collected) {
2110
+ for (const node of nodes)
2111
+ union.set(node.id, node);
2112
+ }
2113
+ const total = union.size;
2114
+ console.log(JSON.stringify({
2115
+ symbol,
2116
+ targets: groups.flat().map((node) => cliDefinition([node]).definition),
2117
+ ambiguous,
2118
+ aggregation: ambiguous ? 'union' : 'definition',
2119
+ file: options.file,
2120
+ filteredOut,
2121
+ note,
2122
+ definitions,
2123
+ [direction]: [...union.values()].slice(0, limit).map(cliNode),
2124
+ total,
2125
+ limit,
2126
+ truncated: total > limit,
2127
+ }, null, 2));
2128
+ }
2129
+ else {
2130
+ if (note)
2131
+ warn(note);
2132
+ if (ambiguous) {
2133
+ console.log(chalk.bold(`\n${title} of "${symbol}" — ${groups.length} distinct definitions (narrow with --file):`));
2134
+ }
2135
+ for (const { group, nodes } of collected) {
2136
+ const limited = nodes.slice(0, limit);
2137
+ const total = nodes.length;
2138
+ const truncated = total > limit;
2139
+ const count = truncated ? `${limited.length} of ${total}` : String(total);
2140
+ if (ambiguous) {
2141
+ console.log(chalk.bold(`\n${(0, symbol_lookup_1.describeSymbolNode)(group[0])} (${count}):\n`));
2142
+ }
2143
+ else {
2144
+ console.log(chalk.bold(`\n${title} of "${symbol}" (${count}):\n`));
2145
+ console.log(chalk.dim((0, symbol_lookup_1.describeSymbolNode)(group[0])));
2146
+ }
2147
+ if (total === 0) {
2148
+ if (ambiguous)
2149
+ console.log(chalk.dim(` (no ${direction})`));
2150
+ else
2151
+ info(`No ${direction} found for "${symbol}"`);
2152
+ }
2153
+ for (const node of limited) {
2154
+ const loc = node.startLine ? `:${node.startLine}` : '';
2155
+ console.log(chalk.cyan(node.kind.padEnd(12)) + chalk.white(node.name));
2156
+ console.log(chalk.dim(` ${node.filePath}${loc}`));
2157
+ console.log();
2158
+ }
2159
+ if (truncated)
2160
+ console.log(chalk.dim(`Showing ${limited.length} of ${total}; pass --limit to widen.`));
2161
+ }
2162
+ }
2163
+ }
2164
+ finally {
2165
+ cg.destroy();
2166
+ }
2167
+ }
2168
+ catch (err) {
2169
+ error(`${direction} failed: ${err instanceof Error ? err.message : String(err)}`);
2170
+ process.exit(1);
2171
+ }
2172
+ });
2173
+ }
2174
+ /**
2175
+ * codegraph impact <symbol> — one blast radius per distinct definition.
2176
+ */
2177
+ program
2178
+ .command('impact <symbol>')
2179
+ .description('Analyze what code is affected by changing a symbol')
2180
+ .option('-p, --path <path>', 'Project path')
2181
+ .option('-f, --file <path>', 'Narrow definitions by file path or suffix (no match: show all with a note)')
2182
+ .option('-d, --depth <number>', 'Traversal depth', '2')
2183
+ .option('-j, --json', 'Output as JSON')
2184
+ .action(async (symbol, options) => {
2185
+ const projectPath = resolveProjectPath(options.path);
2186
+ try {
2187
+ if (!(0, directory_1.isInitialized)(projectPath)) {
2188
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
2189
+ process.exit(1);
2190
+ }
2191
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
2192
+ const cg = await AlphaCodeSense.open(projectPath);
2193
+ try {
2194
+ const depth = Math.min(Math.max(parseInt(options.depth || '2', 10), 1), 10);
2195
+ const { nodes: targets } = (0, symbol_lookup_1.lookupSymbolNodes)(cg, symbol);
2196
+ if (targets.length === 0) {
2197
+ info(formatSymbolNotFound(symbol, cg.searchNodes(symbol, { limit: 5 }).map((m) => m.node.name)));
2198
+ return;
2199
+ }
2200
+ const { groups, filteredOut } = (0, symbol_lookup_1.groupDefinitions)(targets, options.file);
2201
+ const ambiguous = groups.length > 1;
2202
+ const note = filteredOut
2203
+ ? `no definition of "${symbol}" matches file "${options.file}" — showing all definitions instead.`
2204
+ : undefined;
2205
+ const collected = groups.map((group) => {
2206
+ const nodes = new Map();
2207
+ const edges = new Map();
2208
+ for (const target of group) {
2209
+ const impact = cg.getImpactRadius(target.id, depth);
2210
+ for (const [id, node] of impact.nodes)
2211
+ nodes.set(id, node);
2212
+ for (const edge of impact.edges)
2213
+ edges.set(`${edge.source}->${edge.target}:${edge.kind}`, edge);
2214
+ }
2215
+ return { group, nodes, edges };
2216
+ });
2217
+ if (options.json) {
2218
+ const unionNodes = new Map();
2219
+ const unionEdges = new Map();
2220
+ const definitions = collected.map(({ group, nodes, edges }) => {
2221
+ for (const [id, node] of nodes)
2222
+ unionNodes.set(id, node);
2223
+ for (const [key, edge] of edges)
2224
+ unionEdges.set(key, edge);
2225
+ return {
2226
+ ...cliDefinition(group),
2227
+ nodeCount: nodes.size,
2228
+ edgeCount: edges.size,
2229
+ affected: [...nodes.values()].map((node) => ({ id: node.id, ...cliNode(node) })),
2230
+ edges: [...edges.values()],
2231
+ };
2232
+ });
2233
+ console.log(JSON.stringify({
2234
+ symbol,
2235
+ depth,
2236
+ targets: groups.flat().map((node) => cliDefinition([node]).definition),
2237
+ ambiguous,
2238
+ aggregation: ambiguous ? 'union' : 'definition',
2239
+ file: options.file,
2240
+ filteredOut,
2241
+ note,
2242
+ definitions,
2243
+ nodeCount: unionNodes.size,
2244
+ edgeCount: unionEdges.size,
2245
+ affected: [...unionNodes.values()].map(cliNode),
2246
+ }, null, 2));
2247
+ }
2248
+ else {
2249
+ if (note)
2250
+ warn(note);
2251
+ if (ambiguous) {
2252
+ console.log(chalk.bold(`\nImpact of changing "${symbol}" — ${groups.length} distinct definitions (each with its own blast radius; narrow with --file):`));
2253
+ }
2254
+ for (const { group, nodes } of collected) {
2255
+ if (ambiguous) {
2256
+ console.log(chalk.bold(`\n${(0, symbol_lookup_1.describeSymbolNode)(group[0])} — ${nodes.size} affected symbols:\n`));
2257
+ }
2258
+ else {
2259
+ console.log(chalk.bold(`\nImpact of changing "${symbol}" — ${nodes.size} affected symbols:\n`));
2260
+ console.log(chalk.dim((0, symbol_lookup_1.describeSymbolNode)(group[0])));
2261
+ }
2262
+ const byFile = new Map();
2263
+ for (const node of nodes.values()) {
2264
+ const list = byFile.get(node.filePath) || [];
2265
+ list.push(node);
2266
+ byFile.set(node.filePath, list);
2267
+ }
2268
+ for (const [file, affected] of byFile) {
2269
+ console.log(chalk.cyan(file));
2270
+ for (const node of affected) {
2271
+ const loc = node.startLine ? `:${node.startLine}` : '';
2272
+ console.log(` ${chalk.dim(node.kind.padEnd(12))}${node.name}${chalk.dim(loc)}`);
2273
+ }
2274
+ console.log();
2275
+ }
2276
+ }
2277
+ }
2278
+ }
2279
+ finally {
2280
+ cg.destroy();
2281
+ }
2282
+ }
2283
+ catch (err) {
2284
+ error(`impact failed: ${err instanceof Error ? err.message : String(err)}`);
2285
+ process.exit(1);
2286
+ }
2287
+ });
2288
+ /**
2289
+ * codegraph affected [files...]
2290
+ *
2291
+ * Find test files affected by the given source files.
2292
+ * Traces dependency edges transitively to find test files that depend on changed code.
2293
+ *
2294
+ * Usage:
2295
+ * git diff --name-only | codegraph affected --stdin
2296
+ * codegraph affected src/lib/components/Editor.svelte src/routes/+page.svelte
2297
+ */
2298
+ program
2299
+ .command('affected [files...]')
2300
+ .description('Find test files affected by changed source files')
2301
+ .option('-p, --path <path>', 'Project path')
2302
+ .option('--stdin', 'Read file list from stdin (one per line)')
2303
+ .option('-d, --depth <number>', 'Max dependency traversal depth', '5')
2304
+ .option('-f, --filter <glob>', 'Custom glob filter for test files (e.g. "e2e/*.spec.ts")')
2305
+ .option('-j, --json', 'Output as JSON')
2306
+ .option('-q, --quiet', 'Only output file paths, no decoration')
2307
+ .action(async (fileArgs, options) => {
2308
+ const projectPath = resolveProjectPath(options.path);
2309
+ try {
2310
+ if (!(0, directory_1.isInitialized)(projectPath)) {
2311
+ error(`Alpha Code Sense not initialized in ${projectPath}`);
2312
+ process.exit(1);
2313
+ }
2314
+ // Collect changed files from args or stdin
2315
+ let changedFiles = [...(fileArgs || [])];
2316
+ if (options.stdin) {
2317
+ const stdinData = fs.readFileSync(0, 'utf-8');
2318
+ const stdinFiles = stdinData.split('\n').map(f => f.trim()).filter(Boolean);
2319
+ changedFiles.push(...stdinFiles);
2320
+ }
2321
+ // Normalize inputs to the project-relative, forward-slash form the index
2322
+ // stores. Without this, `affected ./src/x.ts`, an absolute path (what a
2323
+ // wrapping script often passes), or a Windows back-slash path silently
2324
+ // matches nothing and reports 0 affected tests. (#825)
2325
+ changedFiles = changedFiles
2326
+ .map((f) => normalizeIndexPath(f, projectPath))
2327
+ .filter(Boolean);
2328
+ if (changedFiles.length === 0) {
2329
+ if (!options.quiet)
2330
+ info('No files provided. Use file arguments or --stdin.');
2331
+ process.exit(0);
2332
+ }
2333
+ const { default: AlphaCodeSense } = await loadAlphaCodeSense();
2334
+ const cg = await AlphaCodeSense.open(projectPath);
2335
+ const maxDepth = parseInt(options.depth || '5', 10);
2336
+ // Custom filter pattern
2337
+ let customFilter = null;
2338
+ if (options.filter) {
2339
+ // Convert glob to regex: ** → .+, * → [^/]*, . → \.
2340
+ const regex = options.filter
2341
+ .replace(/[+[\]{}()^$|\\]/g, '\\$&')
2342
+ .replace(/\./g, '\\.')
2343
+ .replace(/\*\*/g, '.+')
2344
+ .replace(/\*/g, '[^/]*');
2345
+ customFilter = new RegExp(regex);
2346
+ }
2347
+ // One notion of "a test" for the whole tool (#1507): the CLI used to keep
2348
+ // its own six regexes here, which knew `.test.` and `/tests/` but not Go's
2349
+ // `_test.go`, Python's `test_x.py` or the JVM's `FooTest.kt` — so
2350
+ // `affected` reported "no tests" for whole ecosystems while `search` and
2351
+ // the MCP tools counted those very files as tests.
2352
+ function isTestFile(filePath) {
2353
+ if (customFilter)
2354
+ return customFilter.test(filePath);
2355
+ return (0, query_utils_1.isTestPath)(filePath);
2356
+ }
2357
+ // BFS to find all transitive dependents of changed files, filtered to test files
2358
+ const affectedTests = new Set();
2359
+ const allDependents = new Set();
2360
+ for (const file of changedFiles) {
2361
+ // If the changed file is itself a test file, include it
2362
+ if (isTestFile(file)) {
2363
+ affectedTests.add(file);
2364
+ continue;
2365
+ }
2366
+ // BFS through dependents
2367
+ const queue = [{ file, depth: 0 }];
2368
+ const visited = new Set();
2369
+ visited.add(file);
2370
+ while (queue.length > 0) {
2371
+ const current = queue.shift();
2372
+ if (current.depth >= maxDepth)
2373
+ continue;
2374
+ const dependents = cg.getFileDependents(current.file);
2375
+ for (const dep of dependents) {
2376
+ if (visited.has(dep))
2377
+ continue;
2378
+ visited.add(dep);
2379
+ allDependents.add(dep);
2380
+ if (isTestFile(dep)) {
2381
+ affectedTests.add(dep);
2382
+ }
2383
+ else {
2384
+ queue.push({ file: dep, depth: current.depth + 1 });
2385
+ }
2386
+ }
2387
+ }
2388
+ }
2389
+ const sortedTests = Array.from(affectedTests).sort();
2390
+ // Output
2391
+ if (options.json) {
2392
+ console.log(JSON.stringify({
2393
+ changedFiles,
2394
+ affectedTests: sortedTests,
2395
+ totalDependentsTraversed: allDependents.size,
2396
+ }, null, 2));
2397
+ }
2398
+ else if (options.quiet) {
2399
+ for (const t of sortedTests)
2400
+ console.log(t);
2401
+ }
2402
+ else {
2403
+ if (sortedTests.length === 0) {
2404
+ info('No test files affected by the changed files.');
2405
+ }
2406
+ else {
2407
+ console.log(chalk.bold(`\nAffected test files (${sortedTests.length}):\n`));
2408
+ for (const t of sortedTests) {
2409
+ console.log(' ' + chalk.cyan(t));
2410
+ }
2411
+ console.log();
2412
+ }
2413
+ }
2414
+ cg.destroy();
2415
+ }
2416
+ catch (err) {
2417
+ error(`Affected analysis failed: ${err instanceof Error ? err.message : String(err)}`);
2418
+ process.exit(1);
2419
+ }
2420
+ });
2421
+ /**
2422
+ * codegraph install
2423
+ */
2424
+ program
2425
+ .command('install')
2426
+ .description('Install codegraph MCP server into one or more agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, Kiro, GitHub Copilot)')
2427
+ .option('-t, --target <ids>', 'Target agent(s): comma-separated ids, or "auto"|"all"|"none". Default: prompt')
2428
+ .option('-l, --location <where>', 'Install location: "global" or "local". Default: prompt')
2429
+ .option('-y, --yes', 'Non-interactive: defaults to --location=global --target=auto, auto-allow on')
2430
+ .option('-i, --init', 'After wiring agents, also run `codegraph init` in the current directory — builds this project’s index, so install + index is one command (combine with --yes for an unattended bootstrap)')
2431
+ .option('--no-permissions', 'Skip writing the auto-allow permissions list (Claude Code only)')
2432
+ .option('--print-config <id>', 'Print MCP config snippet for the named agent and exit (no file writes)')
2433
+ .option('--refresh', 'Rewrite what previous installs configured, for already-configured agents only (never adds new ones). Run automatically by `ltm-alpha-cs upgrade`')
2434
+ .action(async (opts) => {
2435
+ if (opts.printConfig) {
2436
+ const { getTarget, listTargetIds } = await Promise.resolve().then(() => __importStar(require('../installer/targets/registry')));
2437
+ const target = getTarget(opts.printConfig);
2438
+ if (!target) {
2439
+ const known = listTargetIds().join(', ');
2440
+ error(`Unknown target "${opts.printConfig}". Known: ${known}.`);
2441
+ process.exit(1);
2442
+ }
2443
+ const loc = (opts.location === 'local' ? 'local' : 'global');
2444
+ process.stdout.write(target.printConfig(loc));
2445
+ return;
2446
+ }
2447
+ // --refresh: non-interactive sweep that re-writes what previous
2448
+ // installs configured (instructions section, MCP entry, legacy-hook
2449
+ // cleanups) for already-configured agents, so those surfaces match
2450
+ // THIS binary's templates. Skips everything else — never a first
2451
+ // install, never touches permissions or the prompt hook. Sweeps both
2452
+ // locations unless --location narrows it.
2453
+ if (opts.refresh) {
2454
+ const { refreshTargets } = await Promise.resolve().then(() => __importStar(require('../installer')));
2455
+ const { ALL_TARGETS } = await Promise.resolve().then(() => __importStar(require('../installer/targets/registry')));
2456
+ if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
2457
+ error(`--location must be "global" or "local" (got "${opts.location}").`);
2458
+ process.exit(1);
2459
+ }
2460
+ const locs = opts.location
2461
+ ? [opts.location]
2462
+ : ['global', 'local'];
2463
+ let changed = 0;
2464
+ for (const loc of locs) {
2465
+ for (const report of refreshTargets(ALL_TARGETS, loc)) {
2466
+ for (const p of report.changedPaths) {
2467
+ changed += 1;
2468
+ console.log(` ${report.displayName}: refreshed ${p}`);
2469
+ }
2470
+ }
2471
+ }
2472
+ if (changed === 0) {
2473
+ console.log('All configured agent surfaces are already current.');
2474
+ }
2475
+ return;
2476
+ }
2477
+ const { runInstallerWithOptions } = await Promise.resolve().then(() => __importStar(require('../installer')));
2478
+ if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
2479
+ error(`--location must be "global" or "local" (got "${opts.location}").`);
2480
+ process.exit(1);
2481
+ }
2482
+ try {
2483
+ // Commander's `--no-permissions` makes `opts.permissions === false`;
2484
+ // omitting the flag leaves it `true` (the positive-form default).
2485
+ // We MUST treat the default-true as "user did not override — let
2486
+ // the orchestrator prompt" and only forward an explicit `false`
2487
+ // (or `true` when --yes implies it). Otherwise the auto-allow
2488
+ // prompt is silently skipped on every interactive run.
2489
+ const explicitNoPermissions = opts.permissions === false;
2490
+ const autoAllow = explicitNoPermissions
2491
+ ? false
2492
+ : opts.yes
2493
+ ? true
2494
+ : undefined;
2495
+ await runInstallerWithOptions({
2496
+ target: opts.target,
2497
+ location: opts.location,
2498
+ autoAllow,
2499
+ yes: opts.yes,
2500
+ });
2501
+ }
2502
+ catch (err) {
2503
+ error(err instanceof Error ? err.message : String(err));
2504
+ process.exit(1);
2505
+ }
2506
+ // --init: the one-shot "wire agents AND build this project's index"
2507
+ // bootstrap (#1578). The installer itself never indexes implicitly (a
2508
+ // surprise index of $HOME is the thing we refuse) — an explicit flag is
2509
+ // the user choosing. Runs after a successful install, including the
2510
+ // `--target none` / nothing-detected case (the installer returns normally
2511
+ // there), and shares every guard with `codegraph init`: an unsafe root
2512
+ // is refused (exit 1, no implied --force), an already-initialized
2513
+ // project just says so. `--yes` flows through so no offer prompts.
2514
+ if (opts.init) {
2515
+ await runInit(process.cwd(), { yes: opts.yes });
2516
+ }
2517
+ });
2518
+ /**
2519
+ * ltm-alpha-cs uninstall
2520
+ *
2521
+ * Inverse of `install`. Removes the codegraph MCP server entry,
2522
+ * instructions block, and permissions from every agent (or a
2523
+ * `--target` subset). Prompts global-vs-local when not given. Does NOT
2524
+ * delete the `.alpha-cs/` index — that's `codegraph uninit`.
2525
+ */
2526
+ program
2527
+ .command('uninstall')
2528
+ .description('Remove codegraph from your agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, Kiro, GitHub Copilot)')
2529
+ .option('-t, --target <ids>', 'Target agent(s): comma-separated ids, or "all". Default: all')
2530
+ .option('-l, --location <where>', 'Uninstall location: "global" or "local". Default: prompt')
2531
+ .option('-y, --yes', 'Non-interactive: defaults to --location=global --target=all')
2532
+ .option('--keep-cli', 'Remove agent configs only — leave the codegraph CLI installed')
2533
+ .action(async (opts) => {
2534
+ const { runUninstaller } = await Promise.resolve().then(() => __importStar(require('../installer')));
2535
+ if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
2536
+ error(`--location must be "global" or "local" (got "${opts.location}").`);
2537
+ process.exit(1);
2538
+ }
2539
+ try {
2540
+ await runUninstaller({
2541
+ target: opts.target,
2542
+ location: opts.location,
2543
+ yes: opts.yes,
2544
+ keepCli: opts.keepCli,
2545
+ cliFilename: __filename,
2546
+ });
2547
+ }
2548
+ catch (err) {
2549
+ error(err instanceof Error ? err.message : String(err));
2550
+ process.exit(1);
2551
+ }
2552
+ });
2553
+ /**
2554
+ * codegraph telemetry [on|off|status]
2555
+ */
2556
+ program
2557
+ .command('telemetry [action]')
2558
+ .description('Show or change anonymous usage telemetry (status, on, off)')
2559
+ .action((action) => {
2560
+ const t = (0, telemetry_1.getTelemetry)();
2561
+ if (action === 'on' || action === 'off') {
2562
+ t.setEnabled(action === 'on', 'cli');
2563
+ if (action === 'on') {
2564
+ success('Telemetry enabled — anonymous usage stats only (no code, paths, or names).');
2565
+ }
2566
+ else {
2567
+ success('Telemetry disabled. Buffered, unsent data was deleted.');
2568
+ }
2569
+ const effective = t.getStatus();
2570
+ if (effective.decidedBy === 'DO_NOT_TRACK' || effective.decidedBy === 'CODEGRAPH_TELEMETRY') {
2571
+ warn(`The ${effective.decidedBy} environment variable overrides this choice — ` +
2572
+ `effective state right now: ${effective.enabled ? 'enabled' : 'disabled'}.`);
2573
+ }
2574
+ return;
2575
+ }
2576
+ if (action !== undefined && action !== 'status') {
2577
+ error(`Unknown action: ${action} (expected status, on, or off)`);
2578
+ process.exit(1);
2579
+ }
2580
+ const s = t.getStatus();
2581
+ const decidedBy = {
2582
+ DO_NOT_TRACK: 'DO_NOT_TRACK environment variable',
2583
+ CODEGRAPH_TELEMETRY: 'CODEGRAPH_TELEMETRY environment variable',
2584
+ config: 'your saved choice',
2585
+ default: 'default',
2586
+ };
2587
+ console.log(`\nTelemetry: ${s.enabled ? chalk.green('enabled') : chalk.yellow('disabled')} ${chalk.dim(`(${decidedBy[s.decidedBy]})`)}`);
2588
+ console.log(`Machine ID: ${s.machineId ?? chalk.dim('(random UUID, created on first use)')}`);
2589
+ console.log(`Config: ${s.configPath}`);
2590
+ console.log(chalk.dim(`\nExactly what is collected (and never collected): ${telemetry_1.TELEMETRY_DOCS}\n`));
2591
+ });
2592
+ /**
2593
+ * ltm-alpha-cs upgrade [version]
2594
+ *
2595
+ * Self-update, however Alpha Code Sense was installed (bundle via install.sh/.ps1,
2596
+ * npm-global, npx, or a source checkout). See ../upgrade for the detection and
2597
+ * per-method upgrade logic.
2598
+ */
2599
+ program
2600
+ .command('upgrade [version]')
2601
+ .description('Update Alpha Code Sense to the latest release (or a specific version)')
2602
+ .option('--check', 'Check whether an update is available without installing')
2603
+ .option('-f, --force', 'Reinstall even if already on the target version')
2604
+ .action(async (versionArg, options) => {
2605
+ const up = await Promise.resolve().then(() => __importStar(require('../upgrade')));
2606
+ const method = up.detectInstallMethod({
2607
+ filename: __filename,
2608
+ platform: process.platform,
2609
+ cwd: process.cwd(),
2610
+ });
2611
+ const pin = versionArg || process.env.CODEGRAPH_VERSION || undefined;
2612
+ const code = await up.runUpgrade({ version: pin, check: options.check, force: options.force }, {
2613
+ currentVersion: packageJson.version,
2614
+ method,
2615
+ resolveLatest: () => up.resolveLatestVersion(),
2616
+ run: up.defaultRun,
2617
+ capture: up.defaultCapture,
2618
+ hasCommand: up.hasCommand,
2619
+ log: (m) => console.log(m),
2620
+ warn: (m) => warn(m),
2621
+ error: (m) => error(m),
2622
+ platform: process.platform,
2623
+ });
2624
+ process.exit(code);
2625
+ });
2626
+ /**
2627
+ * codegraph version
2628
+ *
2629
+ * The bare-noun form of `--version`. commander already provides `--version`
2630
+ * and `-V`, and the `-v` / `-version` spellings are intercepted before parse
2631
+ * (see top of main). This subcommand makes `codegraph version` work and lists
2632
+ * the version affordance in `codegraph --help`.
2633
+ */
2634
+ program
2635
+ .command('version')
2636
+ .description('Print the installed Alpha Code Sense version (also: -v, --version)')
2637
+ .action(() => {
2638
+ console.log(packageJson.version);
2639
+ });
2640
+ // Parse and run
2641
+ program.parse();
2642
+ } // end main()
2643
+ //# sourceMappingURL=ltm-alpha-cs.js.map