@aroman22/codegraph-vba-darwin-arm64 1.3.3

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 (800) hide show
  1. package/bin/codegraph +14 -0
  2. package/lib/dist/bin/codegraph.d.ts +26 -0
  3. package/lib/dist/bin/codegraph.d.ts.map +1 -0
  4. package/lib/dist/bin/codegraph.js +2018 -0
  5. package/lib/dist/bin/codegraph.js.map +1 -0
  6. package/lib/dist/bin/command-supervision.d.ts +12 -0
  7. package/lib/dist/bin/command-supervision.d.ts.map +1 -0
  8. package/lib/dist/bin/command-supervision.js +76 -0
  9. package/lib/dist/bin/command-supervision.js.map +1 -0
  10. package/lib/dist/bin/fatal-handler.d.ts +20 -0
  11. package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
  12. package/lib/dist/bin/fatal-handler.js +118 -0
  13. package/lib/dist/bin/fatal-handler.js.map +1 -0
  14. package/lib/dist/bin/node-version-check.d.ts +37 -0
  15. package/lib/dist/bin/node-version-check.d.ts.map +1 -0
  16. package/lib/dist/bin/node-version-check.js +79 -0
  17. package/lib/dist/bin/node-version-check.js.map +1 -0
  18. package/lib/dist/bin/uninstall.d.ts +14 -0
  19. package/lib/dist/bin/uninstall.d.ts.map +1 -0
  20. package/lib/dist/bin/uninstall.js +36 -0
  21. package/lib/dist/bin/uninstall.js.map +1 -0
  22. package/lib/dist/context/formatter.d.ts +30 -0
  23. package/lib/dist/context/formatter.d.ts.map +1 -0
  24. package/lib/dist/context/formatter.js +263 -0
  25. package/lib/dist/context/formatter.js.map +1 -0
  26. package/lib/dist/context/index.d.ts +119 -0
  27. package/lib/dist/context/index.d.ts.map +1 -0
  28. package/lib/dist/context/index.js +1296 -0
  29. package/lib/dist/context/index.js.map +1 -0
  30. package/lib/dist/context/markers.d.ts +19 -0
  31. package/lib/dist/context/markers.d.ts.map +1 -0
  32. package/lib/dist/context/markers.js +22 -0
  33. package/lib/dist/context/markers.js.map +1 -0
  34. package/lib/dist/db/index.d.ts +122 -0
  35. package/lib/dist/db/index.d.ts.map +1 -0
  36. package/lib/dist/db/index.js +296 -0
  37. package/lib/dist/db/index.js.map +1 -0
  38. package/lib/dist/db/migrations.d.ts +44 -0
  39. package/lib/dist/db/migrations.d.ts.map +1 -0
  40. package/lib/dist/db/migrations.js +140 -0
  41. package/lib/dist/db/migrations.js.map +1 -0
  42. package/lib/dist/db/queries.d.ts +402 -0
  43. package/lib/dist/db/queries.d.ts.map +1 -0
  44. package/lib/dist/db/queries.js +1626 -0
  45. package/lib/dist/db/queries.js.map +1 -0
  46. package/lib/dist/db/schema.sql +152 -0
  47. package/lib/dist/db/sqlite-adapter.d.ts +53 -0
  48. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
  49. package/lib/dist/db/sqlite-adapter.js +117 -0
  50. package/lib/dist/db/sqlite-adapter.js.map +1 -0
  51. package/lib/dist/directory.d.ts +179 -0
  52. package/lib/dist/directory.d.ts.map +1 -0
  53. package/lib/dist/directory.js +625 -0
  54. package/lib/dist/directory.js.map +1 -0
  55. package/lib/dist/errors.d.ts +136 -0
  56. package/lib/dist/errors.d.ts.map +1 -0
  57. package/lib/dist/errors.js +219 -0
  58. package/lib/dist/errors.js.map +1 -0
  59. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  60. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  61. package/lib/dist/extraction/astro-extractor.js +320 -0
  62. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  63. package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
  64. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
  65. package/lib/dist/extraction/dfm-extractor.js +151 -0
  66. package/lib/dist/extraction/dfm-extractor.js.map +1 -0
  67. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  68. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  69. package/lib/dist/extraction/extraction-version.js +28 -0
  70. package/lib/dist/extraction/extraction-version.js.map +1 -0
  71. package/lib/dist/extraction/function-ref.d.ts +118 -0
  72. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  73. package/lib/dist/extraction/function-ref.js +727 -0
  74. package/lib/dist/extraction/function-ref.js.map +1 -0
  75. package/lib/dist/extraction/generated-detection.d.ts +30 -0
  76. package/lib/dist/extraction/generated-detection.d.ts.map +1 -0
  77. package/lib/dist/extraction/generated-detection.js +83 -0
  78. package/lib/dist/extraction/generated-detection.js.map +1 -0
  79. package/lib/dist/extraction/grammars.d.ts +128 -0
  80. package/lib/dist/extraction/grammars.d.ts.map +1 -0
  81. package/lib/dist/extraction/grammars.js +537 -0
  82. package/lib/dist/extraction/grammars.js.map +1 -0
  83. package/lib/dist/extraction/index.d.ts +187 -0
  84. package/lib/dist/extraction/index.d.ts.map +1 -0
  85. package/lib/dist/extraction/index.js +1951 -0
  86. package/lib/dist/extraction/index.js.map +1 -0
  87. package/lib/dist/extraction/languages/c-cpp.d.ts +12 -0
  88. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  89. package/lib/dist/extraction/languages/c-cpp.js +275 -0
  90. package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
  91. package/lib/dist/extraction/languages/csharp.d.ts +25 -0
  92. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/csharp.js +175 -0
  94. package/lib/dist/extraction/languages/csharp.js.map +1 -0
  95. package/lib/dist/extraction/languages/dart.d.ts +3 -0
  96. package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
  97. package/lib/dist/extraction/languages/dart.js +374 -0
  98. package/lib/dist/extraction/languages/dart.js.map +1 -0
  99. package/lib/dist/extraction/languages/go.d.ts +3 -0
  100. package/lib/dist/extraction/languages/go.d.ts.map +1 -0
  101. package/lib/dist/extraction/languages/go.js +111 -0
  102. package/lib/dist/extraction/languages/go.js.map +1 -0
  103. package/lib/dist/extraction/languages/index.d.ts +10 -0
  104. package/lib/dist/extraction/languages/index.d.ts.map +1 -0
  105. package/lib/dist/extraction/languages/index.js +53 -0
  106. package/lib/dist/extraction/languages/index.js.map +1 -0
  107. package/lib/dist/extraction/languages/java.d.ts +3 -0
  108. package/lib/dist/extraction/languages/java.d.ts.map +1 -0
  109. package/lib/dist/extraction/languages/java.js +315 -0
  110. package/lib/dist/extraction/languages/java.js.map +1 -0
  111. package/lib/dist/extraction/languages/javascript.d.ts +3 -0
  112. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
  113. package/lib/dist/extraction/languages/javascript.js +106 -0
  114. package/lib/dist/extraction/languages/javascript.js.map +1 -0
  115. package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
  116. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
  117. package/lib/dist/extraction/languages/kotlin.js +379 -0
  118. package/lib/dist/extraction/languages/kotlin.js.map +1 -0
  119. package/lib/dist/extraction/languages/lua.d.ts +3 -0
  120. package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
  121. package/lib/dist/extraction/languages/lua.js +150 -0
  122. package/lib/dist/extraction/languages/lua.js.map +1 -0
  123. package/lib/dist/extraction/languages/luau.d.ts +3 -0
  124. package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
  125. package/lib/dist/extraction/languages/luau.js +37 -0
  126. package/lib/dist/extraction/languages/luau.js.map +1 -0
  127. package/lib/dist/extraction/languages/objc.d.ts +3 -0
  128. package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
  129. package/lib/dist/extraction/languages/objc.js +175 -0
  130. package/lib/dist/extraction/languages/objc.js.map +1 -0
  131. package/lib/dist/extraction/languages/pascal.d.ts +3 -0
  132. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
  133. package/lib/dist/extraction/languages/pascal.js +77 -0
  134. package/lib/dist/extraction/languages/pascal.js.map +1 -0
  135. package/lib/dist/extraction/languages/php.d.ts +3 -0
  136. package/lib/dist/extraction/languages/php.d.ts.map +1 -0
  137. package/lib/dist/extraction/languages/php.js +196 -0
  138. package/lib/dist/extraction/languages/php.js.map +1 -0
  139. package/lib/dist/extraction/languages/python.d.ts +3 -0
  140. package/lib/dist/extraction/languages/python.d.ts.map +1 -0
  141. package/lib/dist/extraction/languages/python.js +56 -0
  142. package/lib/dist/extraction/languages/python.js.map +1 -0
  143. package/lib/dist/extraction/languages/r.d.ts +3 -0
  144. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  145. package/lib/dist/extraction/languages/r.js +314 -0
  146. package/lib/dist/extraction/languages/r.js.map +1 -0
  147. package/lib/dist/extraction/languages/ruby.d.ts +3 -0
  148. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
  149. package/lib/dist/extraction/languages/ruby.js +149 -0
  150. package/lib/dist/extraction/languages/ruby.js.map +1 -0
  151. package/lib/dist/extraction/languages/rust.d.ts +3 -0
  152. package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
  153. package/lib/dist/extraction/languages/rust.js +142 -0
  154. package/lib/dist/extraction/languages/rust.js.map +1 -0
  155. package/lib/dist/extraction/languages/scala.d.ts +3 -0
  156. package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
  157. package/lib/dist/extraction/languages/scala.js +209 -0
  158. package/lib/dist/extraction/languages/scala.js.map +1 -0
  159. package/lib/dist/extraction/languages/swift.d.ts +3 -0
  160. package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
  161. package/lib/dist/extraction/languages/swift.js +152 -0
  162. package/lib/dist/extraction/languages/swift.js.map +1 -0
  163. package/lib/dist/extraction/languages/typescript.d.ts +16 -0
  164. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
  165. package/lib/dist/extraction/languages/typescript.js +167 -0
  166. package/lib/dist/extraction/languages/typescript.js.map +1 -0
  167. package/lib/dist/extraction/liquid-extractor.d.ts +59 -0
  168. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
  169. package/lib/dist/extraction/liquid-extractor.js +357 -0
  170. package/lib/dist/extraction/liquid-extractor.js.map +1 -0
  171. package/lib/dist/extraction/mybatis-extractor.d.ts +48 -0
  172. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  173. package/lib/dist/extraction/mybatis-extractor.js +198 -0
  174. package/lib/dist/extraction/mybatis-extractor.js.map +1 -0
  175. package/lib/dist/extraction/parse-pool.d.ts +126 -0
  176. package/lib/dist/extraction/parse-pool.d.ts.map +1 -0
  177. package/lib/dist/extraction/parse-pool.js +319 -0
  178. package/lib/dist/extraction/parse-pool.js.map +1 -0
  179. package/lib/dist/extraction/parse-worker.d.ts +8 -0
  180. package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
  181. package/lib/dist/extraction/parse-worker.js +97 -0
  182. package/lib/dist/extraction/parse-worker.js.map +1 -0
  183. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  184. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  185. package/lib/dist/extraction/razor-extractor.js +285 -0
  186. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  187. package/lib/dist/extraction/sql-query-extractor.d.ts +25 -0
  188. package/lib/dist/extraction/sql-query-extractor.d.ts.map +1 -0
  189. package/lib/dist/extraction/sql-query-extractor.js +177 -0
  190. package/lib/dist/extraction/sql-query-extractor.js.map +1 -0
  191. package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
  192. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
  193. package/lib/dist/extraction/svelte-extractor.js +275 -0
  194. package/lib/dist/extraction/svelte-extractor.js.map +1 -0
  195. package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  196. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  197. package/lib/dist/extraction/tree-sitter-helpers.js +152 -0
  198. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
  199. package/lib/dist/extraction/tree-sitter-types.d.ts +239 -0
  200. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  201. package/lib/dist/extraction/tree-sitter-types.js +10 -0
  202. package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
  203. package/lib/dist/extraction/tree-sitter.d.ts +647 -0
  204. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
  205. package/lib/dist/extraction/tree-sitter.js +5647 -0
  206. package/lib/dist/extraction/tree-sitter.js.map +1 -0
  207. package/lib/dist/extraction/vba-extractor.d.ts +394 -0
  208. package/lib/dist/extraction/vba-extractor.d.ts.map +1 -0
  209. package/lib/dist/extraction/vba-extractor.js +1716 -0
  210. package/lib/dist/extraction/vba-extractor.js.map +1 -0
  211. package/lib/dist/extraction/vba-form-extractor.d.ts +89 -0
  212. package/lib/dist/extraction/vba-form-extractor.d.ts.map +1 -0
  213. package/lib/dist/extraction/vba-form-extractor.js +367 -0
  214. package/lib/dist/extraction/vba-form-extractor.js.map +1 -0
  215. package/lib/dist/extraction/vba-preprocess.d.ts +81 -0
  216. package/lib/dist/extraction/vba-preprocess.d.ts.map +1 -0
  217. package/lib/dist/extraction/vba-preprocess.js +287 -0
  218. package/lib/dist/extraction/vba-preprocess.js.map +1 -0
  219. package/lib/dist/extraction/vue-extractor.d.ts +51 -0
  220. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
  221. package/lib/dist/extraction/vue-extractor.js +254 -0
  222. package/lib/dist/extraction/vue-extractor.js.map +1 -0
  223. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  224. package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  225. package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  226. package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  227. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  228. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  229. package/lib/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  230. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  231. package/lib/dist/extraction/wasm-runtime-flags.js +106 -0
  232. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -0
  233. package/lib/dist/graph/index.d.ts +8 -0
  234. package/lib/dist/graph/index.d.ts.map +1 -0
  235. package/lib/dist/graph/index.js +13 -0
  236. package/lib/dist/graph/index.js.map +1 -0
  237. package/lib/dist/graph/queries.d.ts +106 -0
  238. package/lib/dist/graph/queries.d.ts.map +1 -0
  239. package/lib/dist/graph/queries.js +339 -0
  240. package/lib/dist/graph/queries.js.map +1 -0
  241. package/lib/dist/graph/traversal.d.ts +127 -0
  242. package/lib/dist/graph/traversal.d.ts.map +1 -0
  243. package/lib/dist/graph/traversal.js +540 -0
  244. package/lib/dist/graph/traversal.js.map +1 -0
  245. package/lib/dist/index.d.ts +563 -0
  246. package/lib/dist/index.d.ts.map +1 -0
  247. package/lib/dist/index.js +1041 -0
  248. package/lib/dist/index.js.map +1 -0
  249. package/lib/dist/installer/config-writer.d.ts +28 -0
  250. package/lib/dist/installer/config-writer.d.ts.map +1 -0
  251. package/lib/dist/installer/config-writer.js +91 -0
  252. package/lib/dist/installer/config-writer.js.map +1 -0
  253. package/lib/dist/installer/index.d.ts +100 -0
  254. package/lib/dist/installer/index.d.ts.map +1 -0
  255. package/lib/dist/installer/index.js +524 -0
  256. package/lib/dist/installer/index.js.map +1 -0
  257. package/lib/dist/installer/instructions-template.d.ts +41 -0
  258. package/lib/dist/installer/instructions-template.d.ts.map +1 -0
  259. package/lib/dist/installer/instructions-template.js +53 -0
  260. package/lib/dist/installer/instructions-template.js.map +1 -0
  261. package/lib/dist/installer/targets/antigravity.d.ts +57 -0
  262. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -0
  263. package/lib/dist/installer/targets/antigravity.js +308 -0
  264. package/lib/dist/installer/targets/antigravity.js.map +1 -0
  265. package/lib/dist/installer/targets/claude.d.ts +62 -0
  266. package/lib/dist/installer/targets/claude.d.ts.map +1 -0
  267. package/lib/dist/installer/targets/claude.js +454 -0
  268. package/lib/dist/installer/targets/claude.js.map +1 -0
  269. package/lib/dist/installer/targets/codex.d.ts +18 -0
  270. package/lib/dist/installer/targets/codex.d.ts.map +1 -0
  271. package/lib/dist/installer/targets/codex.js +185 -0
  272. package/lib/dist/installer/targets/codex.js.map +1 -0
  273. package/lib/dist/installer/targets/cursor.d.ts +35 -0
  274. package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
  275. package/lib/dist/installer/targets/cursor.js +254 -0
  276. package/lib/dist/installer/targets/cursor.js.map +1 -0
  277. package/lib/dist/installer/targets/gemini.d.ts +26 -0
  278. package/lib/dist/installer/targets/gemini.d.ts.map +1 -0
  279. package/lib/dist/installer/targets/gemini.js +165 -0
  280. package/lib/dist/installer/targets/gemini.js.map +1 -0
  281. package/lib/dist/installer/targets/hermes.d.ts +18 -0
  282. package/lib/dist/installer/targets/hermes.d.ts.map +1 -0
  283. package/lib/dist/installer/targets/hermes.js +359 -0
  284. package/lib/dist/installer/targets/hermes.js.map +1 -0
  285. package/lib/dist/installer/targets/kiro.d.ts +27 -0
  286. package/lib/dist/installer/targets/kiro.d.ts.map +1 -0
  287. package/lib/dist/installer/targets/kiro.js +178 -0
  288. package/lib/dist/installer/targets/kiro.js.map +1 -0
  289. package/lib/dist/installer/targets/opencode.d.ts +38 -0
  290. package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
  291. package/lib/dist/installer/targets/opencode.js +307 -0
  292. package/lib/dist/installer/targets/opencode.js.map +1 -0
  293. package/lib/dist/installer/targets/registry.d.ts +35 -0
  294. package/lib/dist/installer/targets/registry.d.ts.map +1 -0
  295. package/lib/dist/installer/targets/registry.js +91 -0
  296. package/lib/dist/installer/targets/registry.js.map +1 -0
  297. package/lib/dist/installer/targets/shared.d.ts +101 -0
  298. package/lib/dist/installer/targets/shared.d.ts.map +1 -0
  299. package/lib/dist/installer/targets/shared.js +264 -0
  300. package/lib/dist/installer/targets/shared.js.map +1 -0
  301. package/lib/dist/installer/targets/toml.d.ts +52 -0
  302. package/lib/dist/installer/targets/toml.d.ts.map +1 -0
  303. package/lib/dist/installer/targets/toml.js +147 -0
  304. package/lib/dist/installer/targets/toml.js.map +1 -0
  305. package/lib/dist/installer/targets/types.d.ts +108 -0
  306. package/lib/dist/installer/targets/types.d.ts.map +1 -0
  307. package/lib/dist/installer/targets/types.js +16 -0
  308. package/lib/dist/installer/targets/types.js.map +1 -0
  309. package/lib/dist/mcp/daemon-manager.d.ts +42 -0
  310. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
  311. package/lib/dist/mcp/daemon-manager.js +129 -0
  312. package/lib/dist/mcp/daemon-manager.js.map +1 -0
  313. package/lib/dist/mcp/daemon-paths.d.ts +73 -0
  314. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
  315. package/lib/dist/mcp/daemon-paths.js +165 -0
  316. package/lib/dist/mcp/daemon-paths.js.map +1 -0
  317. package/lib/dist/mcp/daemon-registry.d.ts +47 -0
  318. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
  319. package/lib/dist/mcp/daemon-registry.js +233 -0
  320. package/lib/dist/mcp/daemon-registry.js.map +1 -0
  321. package/lib/dist/mcp/daemon.d.ts +258 -0
  322. package/lib/dist/mcp/daemon.d.ts.map +1 -0
  323. package/lib/dist/mcp/daemon.js +770 -0
  324. package/lib/dist/mcp/daemon.js.map +1 -0
  325. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  326. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  327. package/lib/dist/mcp/dynamic-boundaries.js +359 -0
  328. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  329. package/lib/dist/mcp/engine.d.ts +122 -0
  330. package/lib/dist/mcp/engine.d.ts.map +1 -0
  331. package/lib/dist/mcp/engine.js +350 -0
  332. package/lib/dist/mcp/engine.js.map +1 -0
  333. package/lib/dist/mcp/index.d.ts +113 -0
  334. package/lib/dist/mcp/index.d.ts.map +1 -0
  335. package/lib/dist/mcp/index.js +481 -0
  336. package/lib/dist/mcp/index.js.map +1 -0
  337. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
  338. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  339. package/lib/dist/mcp/liveness-watchdog.js +207 -0
  340. package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
  341. package/lib/dist/mcp/ppid-watchdog.d.ts +62 -0
  342. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  343. package/lib/dist/mcp/ppid-watchdog.js +64 -0
  344. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  345. package/lib/dist/mcp/proxy.d.ts +87 -0
  346. package/lib/dist/mcp/proxy.d.ts.map +1 -0
  347. package/lib/dist/mcp/proxy.js +641 -0
  348. package/lib/dist/mcp/proxy.js.map +1 -0
  349. package/lib/dist/mcp/query-pool.d.ts +94 -0
  350. package/lib/dist/mcp/query-pool.d.ts.map +1 -0
  351. package/lib/dist/mcp/query-pool.js +297 -0
  352. package/lib/dist/mcp/query-pool.js.map +1 -0
  353. package/lib/dist/mcp/query-worker.d.ts +24 -0
  354. package/lib/dist/mcp/query-worker.d.ts.map +1 -0
  355. package/lib/dist/mcp/query-worker.js +87 -0
  356. package/lib/dist/mcp/query-worker.js.map +1 -0
  357. package/lib/dist/mcp/server-instructions.d.ts +34 -0
  358. package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
  359. package/lib/dist/mcp/server-instructions.js +126 -0
  360. package/lib/dist/mcp/server-instructions.js.map +1 -0
  361. package/lib/dist/mcp/session.d.ts +79 -0
  362. package/lib/dist/mcp/session.d.ts.map +1 -0
  363. package/lib/dist/mcp/session.js +330 -0
  364. package/lib/dist/mcp/session.js.map +1 -0
  365. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  366. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  367. package/lib/dist/mcp/stdin-teardown.js +49 -0
  368. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  369. package/lib/dist/mcp/tools.d.ts +591 -0
  370. package/lib/dist/mcp/tools.d.ts.map +1 -0
  371. package/lib/dist/mcp/tools.js +4211 -0
  372. package/lib/dist/mcp/tools.js.map +1 -0
  373. package/lib/dist/mcp/transport.d.ts +188 -0
  374. package/lib/dist/mcp/transport.d.ts.map +1 -0
  375. package/lib/dist/mcp/transport.js +359 -0
  376. package/lib/dist/mcp/transport.js.map +1 -0
  377. package/lib/dist/mcp/version.d.ts +19 -0
  378. package/lib/dist/mcp/version.d.ts.map +1 -0
  379. package/lib/dist/mcp/version.js +71 -0
  380. package/lib/dist/mcp/version.js.map +1 -0
  381. package/lib/dist/project-config.d.ts +56 -0
  382. package/lib/dist/project-config.d.ts.map +1 -0
  383. package/lib/dist/project-config.js +297 -0
  384. package/lib/dist/project-config.js.map +1 -0
  385. package/lib/dist/reasoning/config.d.ts +45 -0
  386. package/lib/dist/reasoning/config.d.ts.map +1 -0
  387. package/lib/dist/reasoning/config.js +171 -0
  388. package/lib/dist/reasoning/config.js.map +1 -0
  389. package/lib/dist/reasoning/credentials.d.ts +5 -0
  390. package/lib/dist/reasoning/credentials.d.ts.map +1 -0
  391. package/lib/dist/reasoning/credentials.js +83 -0
  392. package/lib/dist/reasoning/credentials.js.map +1 -0
  393. package/lib/dist/reasoning/login.d.ts +21 -0
  394. package/lib/dist/reasoning/login.d.ts.map +1 -0
  395. package/lib/dist/reasoning/login.js +85 -0
  396. package/lib/dist/reasoning/login.js.map +1 -0
  397. package/lib/dist/reasoning/reasoner.d.ts +43 -0
  398. package/lib/dist/reasoning/reasoner.d.ts.map +1 -0
  399. package/lib/dist/reasoning/reasoner.js +308 -0
  400. package/lib/dist/reasoning/reasoner.js.map +1 -0
  401. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
  402. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  403. package/lib/dist/resolution/c-fnptr-synthesizer.js +1038 -0
  404. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  405. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -0
  406. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  407. package/lib/dist/resolution/callback-synthesizer.js +2926 -0
  408. package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
  409. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  410. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  411. package/lib/dist/resolution/frameworks/astro.js +169 -0
  412. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  413. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  414. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  415. package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
  416. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  417. package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
  418. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  419. package/lib/dist/resolution/frameworks/csharp.js +241 -0
  420. package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
  421. package/lib/dist/resolution/frameworks/drupal.d.ts +51 -0
  422. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  423. package/lib/dist/resolution/frameworks/drupal.js +367 -0
  424. package/lib/dist/resolution/frameworks/drupal.js.map +1 -0
  425. package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  426. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  427. package/lib/dist/resolution/frameworks/expo-modules.js +148 -0
  428. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
  429. package/lib/dist/resolution/frameworks/express.d.ts +8 -0
  430. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
  431. package/lib/dist/resolution/frameworks/express.js +308 -0
  432. package/lib/dist/resolution/frameworks/express.js.map +1 -0
  433. package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
  434. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  435. package/lib/dist/resolution/frameworks/fabric.js +354 -0
  436. package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
  437. package/lib/dist/resolution/frameworks/go.d.ts +8 -0
  438. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
  439. package/lib/dist/resolution/frameworks/go.js +161 -0
  440. package/lib/dist/resolution/frameworks/go.js.map +1 -0
  441. package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
  442. package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  443. package/lib/dist/resolution/frameworks/goframe.js +112 -0
  444. package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
  445. package/lib/dist/resolution/frameworks/index.d.ts +50 -0
  446. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
  447. package/lib/dist/resolution/frameworks/index.js +169 -0
  448. package/lib/dist/resolution/frameworks/index.js.map +1 -0
  449. package/lib/dist/resolution/frameworks/java.d.ts +8 -0
  450. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
  451. package/lib/dist/resolution/frameworks/java.js +509 -0
  452. package/lib/dist/resolution/frameworks/java.js.map +1 -0
  453. package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
  454. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  455. package/lib/dist/resolution/frameworks/laravel.js +257 -0
  456. package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
  457. package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
  458. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  459. package/lib/dist/resolution/frameworks/nestjs.js +698 -0
  460. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
  461. package/lib/dist/resolution/frameworks/play.d.ts +19 -0
  462. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
  463. package/lib/dist/resolution/frameworks/play.js +111 -0
  464. package/lib/dist/resolution/frameworks/play.js.map +1 -0
  465. package/lib/dist/resolution/frameworks/python.d.ts +10 -0
  466. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
  467. package/lib/dist/resolution/frameworks/python.js +400 -0
  468. package/lib/dist/resolution/frameworks/python.js.map +1 -0
  469. package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
  470. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  471. package/lib/dist/resolution/frameworks/react-native.js +410 -0
  472. package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
  473. package/lib/dist/resolution/frameworks/react.d.ts +8 -0
  474. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
  475. package/lib/dist/resolution/frameworks/react.js +334 -0
  476. package/lib/dist/resolution/frameworks/react.js.map +1 -0
  477. package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
  478. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  479. package/lib/dist/resolution/frameworks/ruby.js +302 -0
  480. package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
  481. package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
  482. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
  483. package/lib/dist/resolution/frameworks/rust.js +304 -0
  484. package/lib/dist/resolution/frameworks/rust.js.map +1 -0
  485. package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
  486. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  487. package/lib/dist/resolution/frameworks/svelte.js +253 -0
  488. package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
  489. package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  490. package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  491. package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
  492. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
  493. package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
  494. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
  495. package/lib/dist/resolution/frameworks/swift.js +400 -0
  496. package/lib/dist/resolution/frameworks/swift.js.map +1 -0
  497. package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
  498. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
  499. package/lib/dist/resolution/frameworks/vue.js +303 -0
  500. package/lib/dist/resolution/frameworks/vue.js.map +1 -0
  501. package/lib/dist/resolution/go-module.d.ts +26 -0
  502. package/lib/dist/resolution/go-module.d.ts.map +1 -0
  503. package/lib/dist/resolution/go-module.js +78 -0
  504. package/lib/dist/resolution/go-module.js.map +1 -0
  505. package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
  506. package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  507. package/lib/dist/resolution/goframe-synthesizer.js +158 -0
  508. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
  509. package/lib/dist/resolution/import-resolver.d.ts +78 -0
  510. package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
  511. package/lib/dist/resolution/import-resolver.js +1849 -0
  512. package/lib/dist/resolution/import-resolver.js.map +1 -0
  513. package/lib/dist/resolution/index.d.ts +196 -0
  514. package/lib/dist/resolution/index.d.ts.map +1 -0
  515. package/lib/dist/resolution/index.js +1328 -0
  516. package/lib/dist/resolution/index.js.map +1 -0
  517. package/lib/dist/resolution/lru-cache.d.ts +24 -0
  518. package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
  519. package/lib/dist/resolution/lru-cache.js +62 -0
  520. package/lib/dist/resolution/lru-cache.js.map +1 -0
  521. package/lib/dist/resolution/name-matcher.d.ts +93 -0
  522. package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
  523. package/lib/dist/resolution/name-matcher.js +1256 -0
  524. package/lib/dist/resolution/name-matcher.js.map +1 -0
  525. package/lib/dist/resolution/path-aliases.d.ts +68 -0
  526. package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
  527. package/lib/dist/resolution/path-aliases.js +238 -0
  528. package/lib/dist/resolution/path-aliases.js.map +1 -0
  529. package/lib/dist/resolution/strip-comments.d.ts +27 -0
  530. package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
  531. package/lib/dist/resolution/strip-comments.js +443 -0
  532. package/lib/dist/resolution/strip-comments.js.map +1 -0
  533. package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
  534. package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  535. package/lib/dist/resolution/swift-objc-bridge.js +256 -0
  536. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
  537. package/lib/dist/resolution/types.d.ts +233 -0
  538. package/lib/dist/resolution/types.d.ts.map +1 -0
  539. package/lib/dist/resolution/types.js +8 -0
  540. package/lib/dist/resolution/types.js.map +1 -0
  541. package/lib/dist/resolution/workspace-packages.d.ts +48 -0
  542. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  543. package/lib/dist/resolution/workspace-packages.js +208 -0
  544. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  545. package/lib/dist/search/query-parser.d.ts +57 -0
  546. package/lib/dist/search/query-parser.d.ts.map +1 -0
  547. package/lib/dist/search/query-parser.js +177 -0
  548. package/lib/dist/search/query-parser.js.map +1 -0
  549. package/lib/dist/search/query-utils.d.ts +87 -0
  550. package/lib/dist/search/query-utils.d.ts.map +1 -0
  551. package/lib/dist/search/query-utils.js +449 -0
  552. package/lib/dist/search/query-utils.js.map +1 -0
  553. package/lib/dist/sync/git-hooks.d.ts +45 -0
  554. package/lib/dist/sync/git-hooks.d.ts.map +1 -0
  555. package/lib/dist/sync/git-hooks.js +225 -0
  556. package/lib/dist/sync/git-hooks.js.map +1 -0
  557. package/lib/dist/sync/index.d.ts +19 -0
  558. package/lib/dist/sync/index.d.ts.map +1 -0
  559. package/lib/dist/sync/index.js +35 -0
  560. package/lib/dist/sync/index.js.map +1 -0
  561. package/lib/dist/sync/watch-policy.d.ts +48 -0
  562. package/lib/dist/sync/watch-policy.d.ts.map +1 -0
  563. package/lib/dist/sync/watch-policy.js +124 -0
  564. package/lib/dist/sync/watch-policy.js.map +1 -0
  565. package/lib/dist/sync/watcher.d.ts +358 -0
  566. package/lib/dist/sync/watcher.d.ts.map +1 -0
  567. package/lib/dist/sync/watcher.js +829 -0
  568. package/lib/dist/sync/watcher.js.map +1 -0
  569. package/lib/dist/sync/worktree.d.ts +54 -0
  570. package/lib/dist/sync/worktree.d.ts.map +1 -0
  571. package/lib/dist/sync/worktree.js +145 -0
  572. package/lib/dist/sync/worktree.js.map +1 -0
  573. package/lib/dist/telemetry/index.d.ts +143 -0
  574. package/lib/dist/telemetry/index.d.ts.map +1 -0
  575. package/lib/dist/telemetry/index.js +541 -0
  576. package/lib/dist/telemetry/index.js.map +1 -0
  577. package/lib/dist/types.d.ts +409 -0
  578. package/lib/dist/types.d.ts.map +1 -0
  579. package/lib/dist/types.js +101 -0
  580. package/lib/dist/types.js.map +1 -0
  581. package/lib/dist/ui/glyphs.d.ts +42 -0
  582. package/lib/dist/ui/glyphs.d.ts.map +1 -0
  583. package/lib/dist/ui/glyphs.js +78 -0
  584. package/lib/dist/ui/glyphs.js.map +1 -0
  585. package/lib/dist/ui/shimmer-progress.d.ts +11 -0
  586. package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
  587. package/lib/dist/ui/shimmer-progress.js +90 -0
  588. package/lib/dist/ui/shimmer-progress.js.map +1 -0
  589. package/lib/dist/ui/shimmer-worker.d.ts +2 -0
  590. package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
  591. package/lib/dist/ui/shimmer-worker.js +118 -0
  592. package/lib/dist/ui/shimmer-worker.js.map +1 -0
  593. package/lib/dist/ui/types.d.ts +17 -0
  594. package/lib/dist/ui/types.d.ts.map +1 -0
  595. package/lib/dist/ui/types.js +3 -0
  596. package/lib/dist/ui/types.js.map +1 -0
  597. package/lib/dist/upgrade/index.d.ts +132 -0
  598. package/lib/dist/upgrade/index.d.ts.map +1 -0
  599. package/lib/dist/upgrade/index.js +576 -0
  600. package/lib/dist/upgrade/index.js.map +1 -0
  601. package/lib/dist/utils.d.ts +224 -0
  602. package/lib/dist/utils.d.ts.map +1 -0
  603. package/lib/dist/utils.js +583 -0
  604. package/lib/dist/utils.js.map +1 -0
  605. package/lib/node_modules/.modules.yaml +45 -0
  606. package/lib/node_modules/.pnpm/lock.yaml +126 -0
  607. package/lib/node_modules/.pnpm-workspace-state-v1.json +25 -0
  608. package/lib/node_modules/@clack/core/CHANGELOG.md +397 -0
  609. package/lib/node_modules/@clack/core/LICENSE +9 -0
  610. package/lib/node_modules/@clack/core/README.md +22 -0
  611. package/lib/node_modules/@clack/core/dist/index.d.mts +469 -0
  612. package/lib/node_modules/@clack/core/dist/index.mjs +981 -0
  613. package/lib/node_modules/@clack/core/package.json +64 -0
  614. package/lib/node_modules/@clack/prompts/CHANGELOG.md +672 -0
  615. package/lib/node_modules/@clack/prompts/LICENSE +9 -0
  616. package/lib/node_modules/@clack/prompts/README.md +396 -0
  617. package/lib/node_modules/@clack/prompts/dist/index.d.mts +928 -0
  618. package/lib/node_modules/@clack/prompts/dist/index.mjs +1398 -0
  619. package/lib/node_modules/@clack/prompts/package.json +68 -0
  620. package/lib/node_modules/commander/LICENSE +22 -0
  621. package/lib/node_modules/commander/Readme.md +1176 -0
  622. package/lib/node_modules/commander/esm.mjs +16 -0
  623. package/lib/node_modules/commander/index.js +24 -0
  624. package/lib/node_modules/commander/lib/argument.js +150 -0
  625. package/lib/node_modules/commander/lib/command.js +2777 -0
  626. package/lib/node_modules/commander/lib/error.js +39 -0
  627. package/lib/node_modules/commander/lib/help.js +747 -0
  628. package/lib/node_modules/commander/lib/option.js +380 -0
  629. package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
  630. package/lib/node_modules/commander/package-support.json +19 -0
  631. package/lib/node_modules/commander/package.json +82 -0
  632. package/lib/node_modules/commander/typings/esm.d.mts +3 -0
  633. package/lib/node_modules/commander/typings/index.d.ts +1113 -0
  634. package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  635. package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  636. package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  637. package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  638. package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  639. package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  640. package/lib/node_modules/fast-string-truncated-width/license +21 -0
  641. package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
  642. package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
  643. package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
  644. package/lib/node_modules/fast-string-width/dist/index.js +14 -0
  645. package/lib/node_modules/fast-string-width/license +21 -0
  646. package/lib/node_modules/fast-string-width/package.json +34 -0
  647. package/lib/node_modules/fast-string-width/readme.md +42 -0
  648. package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
  649. package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
  650. package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  651. package/lib/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  652. package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
  653. package/lib/node_modules/ignore/LICENSE-MIT +21 -0
  654. package/lib/node_modules/ignore/README.md +452 -0
  655. package/lib/node_modules/ignore/index.d.ts +81 -0
  656. package/lib/node_modules/ignore/index.js +784 -0
  657. package/lib/node_modules/ignore/legacy.js +681 -0
  658. package/lib/node_modules/ignore/package.json +87 -0
  659. package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  660. package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
  661. package/lib/node_modules/jsonc-parser/README.md +364 -0
  662. package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
  663. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  664. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  665. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  666. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  667. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  668. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  669. package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  670. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  671. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  672. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  673. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  674. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  675. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  676. package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  677. package/lib/node_modules/jsonc-parser/package.json +37 -0
  678. package/lib/node_modules/picomatch/LICENSE +21 -0
  679. package/lib/node_modules/picomatch/README.md +749 -0
  680. package/lib/node_modules/picomatch/index.js +17 -0
  681. package/lib/node_modules/picomatch/lib/constants.js +184 -0
  682. package/lib/node_modules/picomatch/lib/parse.js +1386 -0
  683. package/lib/node_modules/picomatch/lib/picomatch.js +349 -0
  684. package/lib/node_modules/picomatch/lib/scan.js +391 -0
  685. package/lib/node_modules/picomatch/lib/utils.js +72 -0
  686. package/lib/node_modules/picomatch/package.json +82 -0
  687. package/lib/node_modules/picomatch/posix.js +3 -0
  688. package/lib/node_modules/sisteransi/license +21 -0
  689. package/lib/node_modules/sisteransi/package.json +34 -0
  690. package/lib/node_modules/sisteransi/readme.md +113 -0
  691. package/lib/node_modules/sisteransi/src/index.js +58 -0
  692. package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  693. package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
  694. package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
  695. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  696. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  697. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  698. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  699. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  700. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  701. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  702. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  703. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  704. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  705. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  706. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  707. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  708. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  709. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  710. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  711. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  712. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  713. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  714. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  715. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  716. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  717. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  718. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  719. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  720. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  721. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  722. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  723. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  724. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  725. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  726. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  727. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  728. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  729. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  730. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  731. package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
  732. package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
  733. package/lib/node_modules/web-tree-sitter/README.md +269 -0
  734. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
  735. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
  736. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
  737. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
  738. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  739. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
  740. package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
  741. package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
  742. package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
  743. package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
  744. package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
  745. package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
  746. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  747. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  748. package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
  749. package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
  750. package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
  751. package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
  752. package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
  753. package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
  754. package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
  755. package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
  756. package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
  757. package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
  758. package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
  759. package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
  760. package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
  761. package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
  762. package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
  763. package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
  764. package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
  765. package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
  766. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
  767. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  768. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  769. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  770. package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
  771. package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
  772. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
  773. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
  774. package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
  775. package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
  776. package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
  777. package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
  778. package/lib/node_modules/web-tree-sitter/package.json +98 -0
  779. package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
  780. package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
  781. package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
  782. package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
  783. package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
  784. package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
  785. package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
  786. package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
  787. package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
  788. package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
  789. package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
  790. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
  791. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
  792. package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
  793. package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
  794. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  795. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
  796. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
  797. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
  798. package/lib/package.json +57 -0
  799. package/node +0 -0
  800. package/package.json +17 -0
@@ -0,0 +1,2018 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * CodeGraph CLI
5
+ *
6
+ * Command-line interface for CodeGraph code intelligence.
7
+ *
8
+ * Usage:
9
+ * codegraph Run interactive installer (when no args)
10
+ * codegraph install Run interactive installer
11
+ * codegraph uninstall Remove CodeGraph from your agents
12
+ * codegraph init [path] Initialize CodeGraph in a project
13
+ * codegraph uninit [path] Remove CodeGraph from a project
14
+ * codegraph index [path] Index all files in the project
15
+ * codegraph sync [path] Sync changes since last index
16
+ * codegraph 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 upgrade [version] Update CodeGraph to the latest release
25
+ */
26
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ var desc = Object.getOwnPropertyDescriptor(m, k);
29
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
+ desc = { enumerable: true, get: function() { return m[k]; } };
31
+ }
32
+ Object.defineProperty(o, k2, desc);
33
+ }) : (function(o, m, k, k2) {
34
+ if (k2 === undefined) k2 = k;
35
+ o[k2] = m[k];
36
+ }));
37
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
38
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
39
+ }) : function(o, v) {
40
+ o["default"] = v;
41
+ });
42
+ var __importStar = (this && this.__importStar) || (function () {
43
+ var ownKeys = function(o) {
44
+ ownKeys = Object.getOwnPropertyNames || function (o) {
45
+ var ar = [];
46
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
47
+ return ar;
48
+ };
49
+ return ownKeys(o);
50
+ };
51
+ return function (mod) {
52
+ if (mod && mod.__esModule) return mod;
53
+ var result = {};
54
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
55
+ __setModuleDefault(result, mod);
56
+ return result;
57
+ };
58
+ })();
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ const commander_1 = require("commander");
61
+ const path = __importStar(require("path"));
62
+ const fs = __importStar(require("fs"));
63
+ const directory_1 = require("../directory");
64
+ const worktree_1 = require("../sync/worktree");
65
+ const shimmer_progress_1 = require("../ui/shimmer-progress");
66
+ const glyphs_1 = require("../ui/glyphs");
67
+ const node_version_check_1 = require("./node-version-check");
68
+ const fatal_handler_1 = require("./fatal-handler");
69
+ const wasm_runtime_flags_1 = require("../extraction/wasm-runtime-flags");
70
+ const command_supervision_1 = require("./command-supervision");
71
+ const extraction_version_1 = require("../extraction/extraction-version");
72
+ const telemetry_1 = require("../telemetry");
73
+ // Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast.
74
+ async function loadCodeGraph() {
75
+ try {
76
+ return await Promise.resolve().then(() => __importStar(require('../index')));
77
+ }
78
+ catch (err) {
79
+ const msg = err instanceof Error ? err.message : String(err);
80
+ console.error(`\x1b[31m${(0, glyphs_1.getGlyphs)().err}\x1b[0m Failed to load CodeGraph modules.`);
81
+ console.error(`\n Node: ${process.version} Platform: ${process.platform} ${process.arch}`);
82
+ console.error(`\n Error: ${msg}`);
83
+ console.error('\n Try reinstalling with: npm install -g @colbymchenry/codegraph\n');
84
+ process.exit(1);
85
+ }
86
+ }
87
+ // Dynamic import helper — tsc compiles import() to require() in CJS mode,
88
+ // which fails for ESM-only packages. This bypasses the transformation.
89
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
90
+ const importESM = new Function('specifier', 'return import(specifier)');
91
+ // Block CodeGraph on Node.js 25.x — V8's turboshaft WASM JIT has a Zone
92
+ // allocator bug that reliably crashes when compiling tree-sitter
93
+ // grammars (see #54, #81, #140). The previous behaviour was a soft
94
+ // console.warn that scrolls off-screen before the OOM crash 30 seconds
95
+ // later, leading to a steady stream of "what is this OOM" reports.
96
+ // Hard-exit before any WASM work; allow override via env var for users
97
+ // who patched V8 themselves or want to test a future fix.
98
+ const nodeVersion = process.versions.node;
99
+ const nodeMajor = parseInt(nodeVersion.split('.')[0] ?? '0', 10);
100
+ if (nodeMajor >= 25) {
101
+ process.env.CODEGRAPH_ALLOW_UNSAFE_NODE = '1';
102
+ }
103
+ // Enforce the supported Node floor. `engines` in package.json only *warns* on
104
+ // install (unless engine-strict), so hard-block here to actually keep users off
105
+ // unsupported versions. Mirrors the 25+ block above. See package.json `engines`.
106
+ if (nodeMajor < node_version_check_1.MIN_NODE_MAJOR) {
107
+ process.stderr.write((0, node_version_check_1.buildNodeTooOldBanner)(nodeVersion) + '\n');
108
+ if (!process.env.CODEGRAPH_ALLOW_UNSAFE_NODE) {
109
+ process.exit(1);
110
+ }
111
+ // Override active — banner shown for visibility, continuing.
112
+ }
113
+ // Re-exec with V8's `--liftoff-only` if it isn't already set, so tree-sitter's
114
+ // large WASM grammars never hit the turboshaft Zone OOM (`Fatal process out of
115
+ // memory: Zone`) on Node >= 22. No-op under the bundled launcher, which already
116
+ // passes the flag. Must run before any grammar (in the parse worker, which
117
+ // inherits this process's flags) is compiled. See ../extraction/wasm-runtime-flags.
118
+ (0, wasm_runtime_flags_1.relaunchWithWasmRuntimeFlagsIfNeeded)(__filename);
119
+ // Last-resort fatal handlers: log a bounded line and exit non-zero. A fault
120
+ // that reaches here escaped every boundary, so the process is in an undefined
121
+ // state — keeping it alive is what let the detached MCP daemon orphan and pin a
122
+ // CPU core with no recovery (#799, #850). Installed before the command branch
123
+ // so it also covers a synchronous throw during startup. See ./fatal-handler.
124
+ (0, fatal_handler_1.installFatalHandlers)();
125
+ // Check if running with no arguments - run installer
126
+ if (process.argv.length === 2) {
127
+ Promise.resolve().then(() => __importStar(require('../installer'))).then(({ runInstaller }) => runInstaller()).catch((err) => {
128
+ console.error('Installation failed:', err instanceof Error ? err.message : String(err));
129
+ process.exit(1);
130
+ });
131
+ }
132
+ else {
133
+ // Normal CLI flow
134
+ main();
135
+ }
136
+ function main() {
137
+ const program = new commander_1.Command();
138
+ // Version from package.json
139
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8'));
140
+ // Make the version trivial to reach. commander's `.version()` (below) wires up
141
+ // `--version` and `-V`; intercept the spellings it can't — lowercase `-v` and
142
+ // single-dash `-version` — before any parsing. (commander's version short flag
143
+ // is the capital `-V`, and its parser rejects a multi-character single-dash
144
+ // flag.) The bare `codegraph version` subcommand is registered further down so
145
+ // the affordance also shows up in `codegraph --help`.
146
+ const firstArg = process.argv[2];
147
+ if (firstArg === '-v' || firstArg === '-version') {
148
+ console.log(packageJson.version);
149
+ return;
150
+ }
151
+ // =============================================================================
152
+ // ANSI Color Helpers (avoid chalk ESM issues)
153
+ // =============================================================================
154
+ const colors = {
155
+ reset: '\x1b[0m',
156
+ bold: '\x1b[1m',
157
+ dim: '\x1b[2m',
158
+ red: '\x1b[31m',
159
+ green: '\x1b[32m',
160
+ yellow: '\x1b[33m',
161
+ blue: '\x1b[34m',
162
+ cyan: '\x1b[36m',
163
+ white: '\x1b[37m',
164
+ gray: '\x1b[90m',
165
+ };
166
+ const chalk = {
167
+ bold: (s) => `${colors.bold}${s}${colors.reset}`,
168
+ dim: (s) => `${colors.dim}${s}${colors.reset}`,
169
+ red: (s) => `${colors.red}${s}${colors.reset}`,
170
+ green: (s) => `${colors.green}${s}${colors.reset}`,
171
+ yellow: (s) => `${colors.yellow}${s}${colors.reset}`,
172
+ blue: (s) => `${colors.blue}${s}${colors.reset}`,
173
+ cyan: (s) => `${colors.cyan}${s}${colors.reset}`,
174
+ white: (s) => `${colors.white}${s}${colors.reset}`,
175
+ gray: (s) => `${colors.gray}${s}${colors.reset}`,
176
+ };
177
+ program
178
+ .name('codegraph-vba')
179
+ .description('Code intelligence and knowledge graph for any codebase')
180
+ .version(packageJson.version);
181
+ // Anonymous usage telemetry (see TELEMETRY.md): record the invoked subcommand
182
+ // NAME only — never arguments or paths. Counts buffer locally; network sends
183
+ // piggyback on commands that run long anyway (quick commands only append to
184
+ // the local buffer at exit, costing nothing).
185
+ // install/uninstall are absent on purpose: the installer flushes at its own
186
+ // end, AFTER its consent prompt — a flush here would fire the first-run
187
+ // notice before the user ever sees the toggle.
188
+ const TELEMETRY_FLUSH_COMMANDS = new Set(['init', 'uninit', 'index', 'sync', 'upgrade']);
189
+ program.hook('preAction', (_thisCommand, actionCommand) => {
190
+ try {
191
+ // The detached daemon re-invokes `serve --mcp` internally — not a user action.
192
+ if (process.env.CODEGRAPH_DAEMON_INTERNAL)
193
+ return;
194
+ const name = actionCommand.name();
195
+ if (name === 'telemetry')
196
+ return; // managing telemetry is not usage
197
+ (0, telemetry_1.getTelemetry)().recordUsage('cli_command', name, true);
198
+ if (TELEMETRY_FLUSH_COMMANDS.has(name))
199
+ (0, telemetry_1.getTelemetry)().maybeFlush();
200
+ }
201
+ catch {
202
+ /* telemetry must never break the CLI */
203
+ }
204
+ });
205
+ // =============================================================================
206
+ // Helper Functions
207
+ // =============================================================================
208
+ /**
209
+ * Resolve project path from argument or current directory
210
+ * Walks up parent directories to find nearest initialized CodeGraph project
211
+ * (must have .codegraph/codegraph.db, not just .codegraph/lessons.db)
212
+ */
213
+ function resolveProjectPath(pathArg) {
214
+ const absolutePath = path.resolve(pathArg || process.cwd());
215
+ // If exact path is initialized (has codegraph.db), use it
216
+ if ((0, directory_1.isInitialized)(absolutePath)) {
217
+ return absolutePath;
218
+ }
219
+ // Walk up to find nearest parent with CodeGraph initialized
220
+ // Note: findNearestCodeGraphRoot finds any .codegraph folder, but we need one with codegraph.db
221
+ let current = absolutePath;
222
+ const root = path.parse(current).root;
223
+ while (current !== root) {
224
+ const parent = path.dirname(current);
225
+ if (parent === current)
226
+ break;
227
+ current = parent;
228
+ if ((0, directory_1.isInitialized)(current)) {
229
+ return current;
230
+ }
231
+ }
232
+ // Not found - return original path (will fail later with helpful error)
233
+ return absolutePath;
234
+ }
235
+ /**
236
+ * Format a number with commas
237
+ */
238
+ function formatNumber(n) {
239
+ return n.toLocaleString();
240
+ }
241
+ /**
242
+ * Format duration in milliseconds to human readable
243
+ */
244
+ function formatDuration(ms) {
245
+ if (ms < 1000) {
246
+ return `${ms}ms`;
247
+ }
248
+ const seconds = ms / 1000;
249
+ if (seconds < 60) {
250
+ return `${seconds.toFixed(1)}s`;
251
+ }
252
+ const minutes = Math.floor(seconds / 60);
253
+ const remainingSeconds = seconds % 60;
254
+ return `${minutes}m ${remainingSeconds.toFixed(0)}s`;
255
+ }
256
+ // Shimmer progress renderer (runs in a worker thread for smooth animation)
257
+ // Imported at top of file from '../ui/shimmer-progress'
258
+ /**
259
+ * Create a plain-text progress callback for --verbose mode.
260
+ * No animations, no ANSI tricks — just timestamped lines to stdout.
261
+ */
262
+ function createVerboseProgress() {
263
+ let lastPhase = '';
264
+ let lastPct = -1;
265
+ const startTime = Date.now();
266
+ return (progress) => {
267
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
268
+ if (progress.phase !== lastPhase) {
269
+ lastPhase = progress.phase;
270
+ lastPct = -1;
271
+ console.log(`[${elapsed}s] Phase: ${progress.phase}`);
272
+ }
273
+ if (progress.total > 0) {
274
+ const pct = Math.floor((progress.current / progress.total) * 100);
275
+ // Log every 5% to keep output manageable
276
+ if (pct >= lastPct + 5 || progress.current === progress.total) {
277
+ lastPct = pct;
278
+ console.log(`[${elapsed}s] ${progress.current}/${progress.total} (${pct}%)${progress.currentFile ? ` ${(0, glyphs_1.getGlyphs)().dash} ${progress.currentFile}` : ''}`);
279
+ }
280
+ }
281
+ else if (progress.current > 0) {
282
+ // Scanning phase (no total yet) — log periodically
283
+ if (progress.current % 1000 === 0 || progress.current === 1) {
284
+ console.log(`[${elapsed}s] ${formatNumber(progress.current)} files found`);
285
+ }
286
+ }
287
+ };
288
+ }
289
+ /**
290
+ * Print success message
291
+ */
292
+ function success(message) {
293
+ console.log(chalk.green((0, glyphs_1.getGlyphs)().ok) + ' ' + message);
294
+ }
295
+ /**
296
+ * Print error message
297
+ */
298
+ function error(message) {
299
+ console.error(chalk.red((0, glyphs_1.getGlyphs)().err) + ' ' + message);
300
+ }
301
+ /**
302
+ * Print info message
303
+ */
304
+ function info(message) {
305
+ console.log(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' ' + message);
306
+ }
307
+ /**
308
+ * Print warning message
309
+ */
310
+ function warn(message) {
311
+ console.log(chalk.yellow((0, glyphs_1.getGlyphs)().warn) + ' ' + message);
312
+ }
313
+ /**
314
+ * Print indexing results using clack log methods
315
+ */
316
+ function printIndexResult(clack, result, projectPath) {
317
+ const hasErrors = result.filesErrored > 0;
318
+ // Surface non-file-level failures (e.g. lock-acquisition failure
319
+ // when another indexer is running) before the file-count branches.
320
+ // Without this the CLI falls through to "No files found to index",
321
+ // which is actively misleading — the index DID run, it just couldn't
322
+ // get the lock.
323
+ //
324
+ // If success is false but no severity:'error' entry exists in
325
+ // `result.errors` (degenerate case — shouldn't happen in practice
326
+ // but worth guarding because the result shape is plumbed through
327
+ // multiple call sites), fall back to a generic message rather than
328
+ // continuing to the misleading "No files found" branch or throwing.
329
+ if (!result.success && !hasErrors && result.filesIndexed === 0) {
330
+ const generic = result.errors.find((e) => e.severity === 'error');
331
+ clack.log.error(generic?.message ?? `Indexing failed ${(0, glyphs_1.getGlyphs)().dash} no further details available`);
332
+ return;
333
+ }
334
+ if (result.filesIndexed > 0) {
335
+ if (hasErrors) {
336
+ clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files (${formatNumber(result.filesErrored)} could not be parsed)`);
337
+ }
338
+ else {
339
+ clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files`);
340
+ }
341
+ clack.log.info(`${formatNumber(result.nodesCreated)} nodes, ${formatNumber(result.edgesCreated)} edges in ${formatDuration(result.durationMs)}`);
342
+ }
343
+ else if (hasErrors) {
344
+ clack.log.error(`Indexing failed ${(0, glyphs_1.getGlyphs)().dash} all ${formatNumber(result.filesErrored)} files had errors`);
345
+ }
346
+ else {
347
+ clack.log.warn('No files found to index');
348
+ }
349
+ if (hasErrors) {
350
+ const errorsByCode = new Map();
351
+ for (const err of result.errors) {
352
+ if (err.severity === 'error') {
353
+ const code = err.code || 'unknown';
354
+ errorsByCode.set(code, (errorsByCode.get(code) || 0) + 1);
355
+ }
356
+ }
357
+ const codeLabels = {
358
+ parse_error: 'files failed to parse',
359
+ read_error: 'files could not be read',
360
+ size_exceeded: 'files exceeded size limit',
361
+ path_traversal: 'blocked paths',
362
+ unsupported_language: 'unsupported language',
363
+ parser_error: 'parser initialization failures',
364
+ };
365
+ const breakdown = Array.from(errorsByCode)
366
+ .map(([code, count]) => `${formatNumber(count)} ${codeLabels[code] || code}`)
367
+ .join('\n');
368
+ clack.note(breakdown, 'Error breakdown');
369
+ if (projectPath) {
370
+ writeErrorLog(projectPath, result.errors);
371
+ clack.log.info('See .codegraph/errors.log for details');
372
+ }
373
+ if (result.filesIndexed > 0) {
374
+ clack.log.info(`The index is fully usable ${(0, glyphs_1.getGlyphs)().dash} only the failed files are missing.`);
375
+ }
376
+ }
377
+ else if (projectPath) {
378
+ const logPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'errors.log');
379
+ if (fs.existsSync(logPath)) {
380
+ fs.unlinkSync(logPath);
381
+ }
382
+ }
383
+ }
384
+ /**
385
+ * Write detailed error log to .codegraph/errors.log
386
+ */
387
+ function writeErrorLog(projectPath, errors) {
388
+ const cgDir = (0, directory_1.getCodeGraphDir)(projectPath);
389
+ if (!fs.existsSync(cgDir))
390
+ return;
391
+ const logPath = path.join(cgDir, 'errors.log');
392
+ // Group errors by file path
393
+ const errorsByFile = new Map();
394
+ const noFileErrors = [];
395
+ for (const err of errors) {
396
+ if (err.severity !== 'error')
397
+ continue;
398
+ if (err.filePath) {
399
+ let list = errorsByFile.get(err.filePath);
400
+ if (!list) {
401
+ list = [];
402
+ errorsByFile.set(err.filePath, list);
403
+ }
404
+ list.push({ message: err.message, code: err.code });
405
+ }
406
+ else {
407
+ noFileErrors.push({ message: err.message, code: err.code });
408
+ }
409
+ }
410
+ const lines = [
411
+ `CodeGraph Error Log - ${new Date().toISOString()}`,
412
+ `${errorsByFile.size} files with errors`,
413
+ '',
414
+ ];
415
+ for (const [filePath, fileErrors] of errorsByFile) {
416
+ for (const err of fileErrors) {
417
+ lines.push(`${filePath}: ${err.message}`);
418
+ }
419
+ }
420
+ for (const err of noFileErrors) {
421
+ lines.push(err.message);
422
+ }
423
+ fs.writeFileSync(logPath, lines.join('\n') + '\n');
424
+ }
425
+ /**
426
+ * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush
427
+ * keeps init/index responsive (these commands just ran for seconds anyway)
428
+ * while delivering the event promptly.
429
+ */
430
+ async function recordIndexTelemetry(cg, result) {
431
+ (0, telemetry_1.recordIndexEvent)(cg, result);
432
+ await (0, telemetry_1.getTelemetry)().flushNow();
433
+ }
434
+ // =============================================================================
435
+ // Commands
436
+ // =============================================================================
437
+ /**
438
+ * codegraph init [path]
439
+ */
440
+ program
441
+ .command('init [path]')
442
+ .description('Initialize CodeGraph in a project directory and build the initial index')
443
+ .option('-i, --index', 'Deprecated: indexing now runs by default; flag accepted for backward compatibility')
444
+ .option('-f, --force', 'Initialize even if the path looks like your home directory or a filesystem root')
445
+ .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
446
+ .action(async (pathArg, options) => {
447
+ const projectPath = path.resolve(pathArg || process.cwd());
448
+ const clack = await importESM('@clack/prompts');
449
+ clack.intro('Initializing CodeGraph');
450
+ try {
451
+ // Refuse to index your home directory / a filesystem root — it pulls in
452
+ // caches, other projects, and your whole tree (a multi-GB index + watcher
453
+ // churn, and on pre-1.0 macOS a machine-crashing fd blowup, #845).
454
+ const unsafe = (0, directory_1.unsafeIndexRootReason)(projectPath);
455
+ if (unsafe && !options.force) {
456
+ clack.log.error(`Refusing to initialize in ${projectPath} — it looks like ${unsafe}.`);
457
+ clack.log.info('Run this inside a specific project directory, or pass --force if you really mean to index everything under it.');
458
+ clack.outro('');
459
+ process.exitCode = 1;
460
+ return;
461
+ }
462
+ if ((0, directory_1.isInitialized)(projectPath)) {
463
+ clack.log.warn(`Already initialized in ${projectPath}`);
464
+ clack.log.info('Use "codegraph index" to re-index or "codegraph sync" to update');
465
+ try {
466
+ const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
467
+ await offerWatchFallback(clack, projectPath);
468
+ }
469
+ catch { /* non-fatal */ }
470
+ clack.outro('');
471
+ return;
472
+ }
473
+ const { default: CodeGraph } = await loadCodeGraph();
474
+ const cg = await CodeGraph.init(projectPath, { index: false });
475
+ clack.log.success(`Initialized in ${projectPath}`);
476
+ // Indexing runs by default now. The legacy -i/--index flag is still
477
+ // accepted (so existing muscle memory and scripts don't break) but is a
478
+ // no-op — initializing always builds the initial index.
479
+ // Supervise the index: self-terminate if orphaned or wedged (#999).
480
+ const supervision = (0, command_supervision_1.installCommandSupervision)('init');
481
+ let result;
482
+ try {
483
+ if (options.verbose) {
484
+ result = await cg.indexAll({
485
+ onProgress: createVerboseProgress(),
486
+ verbose: true,
487
+ });
488
+ }
489
+ else {
490
+ process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
491
+ const progress = (0, shimmer_progress_1.createShimmerProgress)();
492
+ result = await cg.indexAll({
493
+ onProgress: progress.onProgress,
494
+ });
495
+ await progress.stop();
496
+ }
497
+ }
498
+ finally {
499
+ supervision.stop();
500
+ }
501
+ printIndexResult(clack, result, projectPath);
502
+ await recordIndexTelemetry(cg, result);
503
+ try {
504
+ const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
505
+ await offerWatchFallback(clack, projectPath);
506
+ }
507
+ catch { /* non-fatal */ }
508
+ clack.outro('Done');
509
+ cg.destroy();
510
+ }
511
+ catch (err) {
512
+ clack.log.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
513
+ process.exit(1);
514
+ }
515
+ });
516
+ /**
517
+ * codegraph uninit [path]
518
+ */
519
+ program
520
+ .command('uninit [path]')
521
+ .description('Remove CodeGraph from a project (deletes .codegraph/ directory)')
522
+ .option('-f, --force', 'Skip confirmation prompt')
523
+ .action(async (pathArg, options) => {
524
+ const projectPath = resolveProjectPath(pathArg);
525
+ try {
526
+ if (!(0, directory_1.isInitialized)(projectPath)) {
527
+ warn(`CodeGraph is not initialized in ${projectPath}`);
528
+ return;
529
+ }
530
+ if (!options.force) {
531
+ // Confirm with user
532
+ const readline = await Promise.resolve().then(() => __importStar(require('readline')));
533
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
534
+ const answer = await new Promise((resolve) => {
535
+ rl.question(chalk.yellow(`${(0, glyphs_1.getGlyphs)().warn} This will permanently delete all CodeGraph data. Continue? (y/N) `), resolve);
536
+ });
537
+ rl.close();
538
+ if (answer.toLowerCase() !== 'y') {
539
+ info('Cancelled');
540
+ return;
541
+ }
542
+ }
543
+ const { default: CodeGraph } = await loadCodeGraph();
544
+ const cg = CodeGraph.openSync(projectPath);
545
+ cg.uninitialize();
546
+ // Clean up any git sync hooks we installed (no-op if none / not a repo).
547
+ try {
548
+ const { removeGitSyncHook } = await Promise.resolve().then(() => __importStar(require('../sync/git-hooks')));
549
+ const removed = removeGitSyncHook(projectPath);
550
+ if (removed.installed.length > 0) {
551
+ info(`Removed git ${removed.installed.join(', ')} sync hook${removed.installed.length > 1 ? 's' : ''}`);
552
+ }
553
+ }
554
+ catch { /* non-fatal */ }
555
+ success(`Removed CodeGraph from ${projectPath}`);
556
+ // Churn signal — and flush now, since after an uninit there may be no
557
+ // "next run" to deliver it.
558
+ try {
559
+ (0, telemetry_1.getTelemetry)().recordLifecycle('uninstall', {});
560
+ await (0, telemetry_1.getTelemetry)().flushNow();
561
+ }
562
+ catch { /* non-fatal */ }
563
+ }
564
+ catch (err) {
565
+ error(`Failed to uninitialize: ${err instanceof Error ? err.message : String(err)}`);
566
+ process.exit(1);
567
+ }
568
+ });
569
+ /**
570
+ * codegraph index [path]
571
+ */
572
+ program
573
+ .command('index [path]')
574
+ .description('Rebuild the full index from scratch (same result as a fresh init)')
575
+ .option('-f, --force', 'Index even if the path looks like your home directory or a filesystem root')
576
+ .option('-q, --quiet', 'Suppress progress output')
577
+ .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
578
+ .action(async (pathArg, options) => {
579
+ const projectPath = resolveProjectPath(pathArg);
580
+ try {
581
+ // Don't (re)index your home directory / a filesystem root (#845). --force
582
+ // doubles as the override.
583
+ const unsafe = (0, directory_1.unsafeIndexRootReason)(projectPath);
584
+ if (unsafe && !options.force) {
585
+ error(`Refusing to index ${projectPath} — it looks like ${unsafe}. Pass --force to override.`);
586
+ process.exit(1);
587
+ }
588
+ if (!(0, directory_1.isInitialized)(projectPath)) {
589
+ error(`CodeGraph not initialized in ${projectPath}`);
590
+ info('Run "codegraph init" first');
591
+ process.exit(1);
592
+ }
593
+ const { default: CodeGraph } = await loadCodeGraph();
594
+ const cg = await CodeGraph.open(projectPath);
595
+ // Supervise the indexer: self-terminate if orphaned (parent shim killed)
596
+ // or if the main thread wedges — neither was guarded on this path (#999).
597
+ const supervision = (0, command_supervision_1.installCommandSupervision)('index');
598
+ try {
599
+ if (options.quiet) {
600
+ // Quiet mode: no UI, just run. `index` is a full re-index, so clear the
601
+ // existing graph and rebuild from scratch (see the note below — #874).
602
+ cg.clear();
603
+ const result = await cg.indexAll();
604
+ if (!result.success)
605
+ process.exit(1);
606
+ cg.destroy();
607
+ return;
608
+ }
609
+ const clack = await importESM('@clack/prompts');
610
+ clack.intro('Indexing project');
611
+ // `index` is a FULL re-index: clear the existing graph and rebuild it from
612
+ // scratch so the result is identical to a fresh `init`. Without the clear,
613
+ // indexAll() skips every unchanged file by its content hash and reports
614
+ // "0 nodes, 0 edges" against the already-populated graph — which reads as
615
+ // "index wiped my index" (#874). For fast incremental updates use `sync`.
616
+ cg.clear();
617
+ let result;
618
+ if (options.verbose) {
619
+ result = await cg.indexAll({
620
+ onProgress: createVerboseProgress(),
621
+ verbose: true,
622
+ });
623
+ }
624
+ else {
625
+ process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
626
+ const progress = (0, shimmer_progress_1.createShimmerProgress)();
627
+ result = await cg.indexAll({
628
+ onProgress: progress.onProgress,
629
+ });
630
+ await progress.stop();
631
+ }
632
+ printIndexResult(clack, result, projectPath);
633
+ await recordIndexTelemetry(cg, result);
634
+ if (!result.success) {
635
+ process.exit(1);
636
+ }
637
+ clack.outro('Done');
638
+ cg.destroy();
639
+ }
640
+ finally {
641
+ supervision.stop();
642
+ }
643
+ }
644
+ catch (err) {
645
+ error(`Failed to index: ${err instanceof Error ? err.message : String(err)}`);
646
+ process.exit(1);
647
+ }
648
+ });
649
+ /**
650
+ * codegraph sync [path]
651
+ */
652
+ program
653
+ .command('sync [path]')
654
+ .description('Sync changes since last index')
655
+ .option('-q, --quiet', 'Suppress output (for git hooks)')
656
+ .action(async (pathArg, options) => {
657
+ const projectPath = resolveProjectPath(pathArg);
658
+ try {
659
+ if (!(0, directory_1.isInitialized)(projectPath)) {
660
+ if (!options.quiet) {
661
+ error(`CodeGraph not initialized in ${projectPath}`);
662
+ }
663
+ process.exit(1);
664
+ }
665
+ const { default: CodeGraph } = await loadCodeGraph();
666
+ const cg = await CodeGraph.open(projectPath);
667
+ if (options.quiet) {
668
+ await cg.sync();
669
+ cg.destroy();
670
+ return;
671
+ }
672
+ const clack = await importESM('@clack/prompts');
673
+ clack.intro('Syncing CodeGraph');
674
+ process.stdout.write(`${colors.dim}${(0, glyphs_1.getGlyphs)().rail}${colors.reset}\n`);
675
+ const progress = (0, shimmer_progress_1.createShimmerProgress)();
676
+ const result = await cg.sync({
677
+ onProgress: progress.onProgress,
678
+ });
679
+ await progress.stop();
680
+ const totalChanges = result.filesAdded + result.filesModified + result.filesRemoved;
681
+ if (totalChanges === 0) {
682
+ clack.log.info('Already up to date');
683
+ }
684
+ else {
685
+ clack.log.success(`Synced ${formatNumber(totalChanges)} changed files`);
686
+ const details = [];
687
+ if (result.filesAdded > 0)
688
+ details.push(`Added: ${result.filesAdded}`);
689
+ if (result.filesModified > 0)
690
+ details.push(`Modified: ${result.filesModified}`);
691
+ if (result.filesRemoved > 0)
692
+ details.push(`Removed: ${result.filesRemoved}`);
693
+ clack.log.info(`${details.join(', ')} ${(0, glyphs_1.getGlyphs)().dash} ${formatNumber(result.nodesUpdated)} nodes in ${formatDuration(result.durationMs)}`);
694
+ }
695
+ clack.outro('Done');
696
+ cg.destroy();
697
+ }
698
+ catch (err) {
699
+ if (!options.quiet) {
700
+ error(`Failed to sync: ${err instanceof Error ? err.message : String(err)}`);
701
+ }
702
+ process.exit(1);
703
+ }
704
+ });
705
+ /**
706
+ * codegraph status [path]
707
+ */
708
+ program
709
+ .command('status [path]')
710
+ .description('Show index status and statistics')
711
+ .option('-j, --json', 'Output as JSON')
712
+ .action(async (pathArg, options) => {
713
+ const projectPath = resolveProjectPath(pathArg);
714
+ // The directory the user actually ran from, before walking up to the index
715
+ // root. Used to detect when the resolved index lives in a different git
716
+ // working tree (e.g. a nested worktree borrowing the main checkout's index).
717
+ const startPath = path.resolve(pathArg || process.cwd());
718
+ const worktreeMismatch = (0, worktree_1.detectWorktreeIndexMismatch)(startPath, projectPath);
719
+ try {
720
+ if (!(0, directory_1.isInitialized)(projectPath)) {
721
+ if (options.json) {
722
+ console.log(JSON.stringify({
723
+ initialized: false,
724
+ version: packageJson.version,
725
+ projectPath,
726
+ indexPath: (0, directory_1.getCodeGraphDir)(projectPath),
727
+ lastIndexed: null,
728
+ }));
729
+ return;
730
+ }
731
+ console.log(chalk.bold('\nCodeGraph Status\n'));
732
+ info(`Project: ${projectPath}`);
733
+ warn('Not initialized');
734
+ info('Run "codegraph init" to initialize');
735
+ return;
736
+ }
737
+ const { default: CodeGraph } = await loadCodeGraph();
738
+ const cg = await CodeGraph.open(projectPath);
739
+ const stats = cg.getStats();
740
+ const changes = cg.getChangedFiles();
741
+ const backend = cg.getBackend();
742
+ const journalMode = cg.getJournalMode();
743
+ const buildInfo = cg.getIndexBuildInfo();
744
+ const reindexRecommended = cg.isIndexStale();
745
+ // JSON output mode
746
+ if (options.json) {
747
+ const lastIndexedMs = cg.getLastIndexedAt();
748
+ console.log(JSON.stringify({
749
+ initialized: true,
750
+ version: packageJson.version,
751
+ projectPath,
752
+ indexPath: (0, directory_1.getCodeGraphDir)(projectPath),
753
+ lastIndexed: lastIndexedMs != null ? new Date(lastIndexedMs).toISOString() : null,
754
+ fileCount: stats.fileCount,
755
+ nodeCount: stats.nodeCount,
756
+ edgeCount: stats.edgeCount,
757
+ dbSizeBytes: stats.dbSizeBytes,
758
+ backend,
759
+ journalMode,
760
+ nodesByKind: stats.nodesByKind,
761
+ languages: Object.entries(stats.filesByLanguage).filter(([, count]) => count > 0).map(([lang]) => lang),
762
+ pendingChanges: {
763
+ added: changes.added.length,
764
+ modified: changes.modified.length,
765
+ removed: changes.removed.length,
766
+ },
767
+ worktreeMismatch: worktreeMismatch
768
+ ? { worktreeRoot: worktreeMismatch.worktreeRoot, indexRoot: worktreeMismatch.indexRoot }
769
+ : null,
770
+ index: {
771
+ builtWithVersion: buildInfo.version,
772
+ builtWithExtractionVersion: buildInfo.extractionVersion,
773
+ currentExtractionVersion: extraction_version_1.EXTRACTION_VERSION,
774
+ reindexRecommended,
775
+ },
776
+ }));
777
+ cg.destroy();
778
+ return;
779
+ }
780
+ console.log(chalk.bold('\nCodeGraph Status\n'));
781
+ // Project info
782
+ console.log(chalk.cyan('Project:'), projectPath);
783
+ if (worktreeMismatch) {
784
+ warn((0, worktree_1.worktreeMismatchWarning)(worktreeMismatch));
785
+ }
786
+ console.log();
787
+ // Index stats
788
+ console.log(chalk.bold('Index Statistics:'));
789
+ console.log(` Files: ${formatNumber(stats.fileCount)}`);
790
+ console.log(` Nodes: ${formatNumber(stats.nodeCount)}`);
791
+ console.log(` Edges: ${formatNumber(stats.edgeCount)}`);
792
+ console.log(` DB Size: ${(stats.dbSizeBytes / 1024 / 1024).toFixed(2)} MB`);
793
+ // Surface the active SQLite backend (node:sqlite — Node's built-in real
794
+ // SQLite, full WAL + FTS5, no native build).
795
+ const backendLabel = chalk.green(`node:sqlite ${(0, glyphs_1.getGlyphs)().dash} built-in (full WAL)`);
796
+ console.log(` Backend: ${backendLabel}`);
797
+ // Effective journal mode: 'wal' means concurrent reads never block on a
798
+ // writer; anything else means they can ("database is locked"). node:sqlite
799
+ // supports WAL everywhere, so a non-wal mode means the filesystem can't
800
+ // (network mounts, WSL2 /mnt). See issue #238.
801
+ const journalLabel = journalMode === 'wal'
802
+ ? chalk.green('wal')
803
+ : chalk.yellow(`${journalMode || 'unknown'} ${(0, glyphs_1.getGlyphs)().dash} WAL inactive; reads can block on writes`);
804
+ console.log(` Journal: ${journalLabel}`);
805
+ console.log();
806
+ // Node breakdown
807
+ console.log(chalk.bold('Nodes by Kind:'));
808
+ const nodesByKind = Object.entries(stats.nodesByKind)
809
+ .filter(([, count]) => count > 0)
810
+ .sort((a, b) => b[1] - a[1]);
811
+ for (const [kind, count] of nodesByKind) {
812
+ console.log(` ${kind.padEnd(15)} ${formatNumber(count)}`);
813
+ }
814
+ console.log();
815
+ // Language breakdown
816
+ console.log(chalk.bold('Files by Language:'));
817
+ const filesByLang = Object.entries(stats.filesByLanguage)
818
+ .filter(([, count]) => count > 0)
819
+ .sort((a, b) => b[1] - a[1]);
820
+ for (const [lang, count] of filesByLang) {
821
+ console.log(` ${lang.padEnd(15)} ${formatNumber(count)}`);
822
+ }
823
+ console.log();
824
+ // Pending changes
825
+ const totalChanges = changes.added.length + changes.modified.length + changes.removed.length;
826
+ if (totalChanges > 0) {
827
+ console.log(chalk.bold('Pending Changes:'));
828
+ if (changes.added.length > 0) {
829
+ console.log(` Added: ${changes.added.length} files`);
830
+ }
831
+ if (changes.modified.length > 0) {
832
+ console.log(` Modified: ${changes.modified.length} files`);
833
+ }
834
+ if (changes.removed.length > 0) {
835
+ console.log(` Removed: ${changes.removed.length} files`);
836
+ }
837
+ info('Run "codegraph sync" to update the index');
838
+ }
839
+ else {
840
+ success('Index is up to date');
841
+ }
842
+ console.log();
843
+ // Re-index hint: the index was built by an older engine than the one now
844
+ // running, so a rebuild would add data a migration can't backfill.
845
+ if (reindexRecommended) {
846
+ const builtWith = buildInfo.version ? `v${buildInfo.version.replace(/^v/, '')}` : 'an earlier version';
847
+ warn(`Index was built by ${builtWith}; re-index to pick up this engine's improvements.`);
848
+ info('Run "codegraph index" (full rebuild) or "codegraph sync"');
849
+ console.log();
850
+ }
851
+ cg.destroy();
852
+ }
853
+ catch (err) {
854
+ error(`Failed to get status: ${err instanceof Error ? err.message : String(err)}`);
855
+ process.exit(1);
856
+ }
857
+ });
858
+ /**
859
+ * codegraph query <search>
860
+ */
861
+ program
862
+ .command('query <search>')
863
+ .description('Search for symbols in the codebase')
864
+ .option('-p, --path <path>', 'Project path')
865
+ .option('-l, --limit <number>', 'Maximum results', '10')
866
+ .option('-k, --kind <kind>', 'Filter by node kind (function, class, etc.)')
867
+ .option('-j, --json', 'Output as JSON')
868
+ .action(async (search, options) => {
869
+ const projectPath = resolveProjectPath(options.path);
870
+ try {
871
+ if (!(0, directory_1.isInitialized)(projectPath)) {
872
+ error(`CodeGraph not initialized in ${projectPath}`);
873
+ process.exit(1);
874
+ }
875
+ const { default: CodeGraph } = await loadCodeGraph();
876
+ const cg = await CodeGraph.open(projectPath);
877
+ const limit = parseInt(options.limit || '10', 10);
878
+ const rawResults = cg.searchNodes(search, {
879
+ limit,
880
+ kinds: options.kind ? [options.kind] : undefined,
881
+ });
882
+ // Mirror the MCP search down-rank so the CLI also surfaces the
883
+ // hand-written implementation before protobuf/gRPC scaffolding
884
+ // when both share a name. See extraction/generated-detection.ts.
885
+ const { isGeneratedFile } = await Promise.resolve().then(() => __importStar(require('../extraction/generated-detection')));
886
+ const results = [...rawResults].sort((a, b) => {
887
+ const aGen = isGeneratedFile(a.node.filePath) ? 1 : 0;
888
+ const bGen = isGeneratedFile(b.node.filePath) ? 1 : 0;
889
+ return aGen - bGen;
890
+ });
891
+ if (options.json) {
892
+ console.log(JSON.stringify(results, null, 2));
893
+ }
894
+ else {
895
+ if (results.length === 0) {
896
+ info(`No results found for "${search}"`);
897
+ }
898
+ else {
899
+ console.log(chalk.bold(`\nSearch Results for "${search}":\n`));
900
+ for (const result of results) {
901
+ const node = result.node;
902
+ const location = `${node.filePath}:${node.startLine}`;
903
+ const score = chalk.dim(`(${(result.score * 100).toFixed(0)}%)`);
904
+ console.log(chalk.cyan(node.kind.padEnd(12)) +
905
+ chalk.white(node.qualifiedName || node.name) +
906
+ ' ' + score);
907
+ console.log(chalk.dim(` ${location}`));
908
+ if (node.signature) {
909
+ console.log(chalk.dim(` ${node.signature}`));
910
+ }
911
+ console.log();
912
+ }
913
+ }
914
+ }
915
+ cg.destroy();
916
+ }
917
+ catch (err) {
918
+ error(`Search failed: ${err instanceof Error ? err.message : String(err)}`);
919
+ process.exit(1);
920
+ }
921
+ });
922
+ /**
923
+ * codegraph explore <query...>
924
+ *
925
+ * The CLI face of the MCP codegraph_explore tool — same handler, same
926
+ * output (source of the relevant symbols grouped by file + the call path
927
+ * among them). Exists so agents WITHOUT the MCP tools — Task-tool
928
+ * subagents (which don't inherit MCP tools, #704) and non-MCP harnesses —
929
+ * can reach the graph through a plain shell command.
930
+ */
931
+ program
932
+ .command('explore <query...>')
933
+ .description('Explore an area: relevant symbols\' source + call paths in one shot (same output as the codegraph_explore MCP tool)')
934
+ .option('-p, --path <path>', 'Project path')
935
+ .option('--max-files <number>', 'Maximum number of files to include source from')
936
+ .action(async (queryParts, options) => {
937
+ const projectPath = resolveProjectPath(options.path);
938
+ try {
939
+ if (!(0, directory_1.isInitialized)(projectPath)) {
940
+ error(`CodeGraph isn't available here — no .codegraph/ 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 CodeGraph with 'codegraph init'.)`);
941
+ process.exit(1);
942
+ }
943
+ const { default: CodeGraph } = await loadCodeGraph();
944
+ const cg = await CodeGraph.open(projectPath);
945
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
946
+ const handler = new ToolHandler(cg);
947
+ const args = { query: queryParts.join(' ') };
948
+ if (options.maxFiles)
949
+ args.maxFiles = parseInt(options.maxFiles, 10);
950
+ const result = await handler.execute('codegraph_explore', args);
951
+ console.log(result.content[0]?.text ?? '');
952
+ cg.destroy();
953
+ if (result.isError)
954
+ process.exit(1);
955
+ }
956
+ catch (err) {
957
+ error(`Explore failed: ${err instanceof Error ? err.message : String(err)}`);
958
+ process.exit(1);
959
+ }
960
+ });
961
+ /**
962
+ * codegraph prompt-hook (hidden)
963
+ *
964
+ * A Claude Code `UserPromptSubmit` hook entry point. Reads `{prompt, cwd}` JSON
965
+ * on stdin; for a structural/flow/impact prompt it runs `codegraph_explore` on
966
+ * the indexed project and prints the result to stdout, which Claude injects into
967
+ * the agent's context — so the agent's reflex grep/read has nothing left to find
968
+ * and reliably uses CodeGraph (the adoption problem). Installed by the installer
969
+ * into Claude's settings.json (opt-in, default-yes).
970
+ *
971
+ * LOAD-BEARING: this must NEVER break the user's prompt. Every failure path —
972
+ * kill-switch, non-structural prompt, no index, engine error — exits 0 with no
973
+ * output. The only effect is additive context when it can confidently provide it.
974
+ */
975
+ program
976
+ .command('prompt-hook', { hidden: true })
977
+ .description('Claude UserPromptSubmit hook: inject CodeGraph context for structural prompts (reads {prompt,cwd} JSON on stdin)')
978
+ .action(async () => {
979
+ try {
980
+ // Kill-switch: lets a user disable the nudge without uninstalling /
981
+ // editing settings.json (CI, low-power machines, personal preference).
982
+ if (process.env.CODEGRAPH_NO_PROMPT_HOOK === '1' || process.env.CODEGRAPH_PROMPT_HOOK === '0')
983
+ return;
984
+ if (process.stdin.isTTY)
985
+ return; // invoked by hand, no piped payload
986
+ const raw = await new Promise((resolve) => {
987
+ let data = '';
988
+ process.stdin.setEncoding('utf8');
989
+ process.stdin.on('data', (c) => { data += c; });
990
+ process.stdin.on('end', () => resolve(data));
991
+ process.stdin.on('error', () => resolve(data));
992
+ });
993
+ let input = {};
994
+ try {
995
+ input = JSON.parse(raw);
996
+ }
997
+ catch {
998
+ return;
999
+ }
1000
+ const prompt = String(input.prompt || '');
1001
+ // Gate: only structural / flow / impact / where-how prompts get context, so
1002
+ // every other prompt ("fix this typo") stays a zero-cost no-op. Language-aware
1003
+ // (English + CJK keywords, plus code-shaped tokens) so it fires for non-English
1004
+ // prompts too (issue #994). A keyword fires on its own; a code-token is only a
1005
+ // CANDIDATE — verified against the graph below, so a tech brand ("JavaScript")
1006
+ // that looks like a symbol but isn't one here doesn't inject spurious context.
1007
+ const keyworded = (0, directory_1.hasStructuralKeyword)(prompt);
1008
+ const codeTokens = keyworded ? [] : (0, directory_1.extractCodeTokens)(prompt);
1009
+ if (!keyworded && codeTokens.length === 0)
1010
+ return;
1011
+ // Decide what to inject, shaped by WHERE the index(es) are: the nearest
1012
+ // indexed ancestor of cwd, or — when cwd is an un-indexed workspace root
1013
+ // whose indexed project(s) live in sub-dirs (the monorepo case, #964) —
1014
+ // the sub-project the prompt points at, plus a `projectPath` nudge for any
1015
+ // others. Without the down-scan the hook injected nothing at a monorepo
1016
+ // root (it only walked up), so the validated adoption lever never fired
1017
+ // exactly where the agent most needs it.
1018
+ const plan = (0, directory_1.planFrontload)(String(input.cwd || process.cwd()), prompt);
1019
+ if (!plan.exploreRoot && plan.nudgeProjects.length === 0)
1020
+ return; // nothing reachable — the agent's normal tools apply
1021
+ // A "pass projectPath" line for indexed sub-projects we did NOT front-load.
1022
+ // Follow-up codegraph_explore calls against a sub-project (cwd isn't its
1023
+ // index root) need an explicit projectPath, so spell it out.
1024
+ const nudge = (projects, lead) => `${lead}\n${projects.map((p) => ` - projectPath: "${p}"`).join('\n')}\n`;
1025
+ if (plan.exploreRoot) {
1026
+ const { default: CodeGraph } = await loadCodeGraph();
1027
+ const cg = await CodeGraph.open(plan.exploreRoot);
1028
+ try {
1029
+ // Code-token-only prompt: require that at least one token is a REAL symbol
1030
+ // in THIS index before front-loading. Without it, a brand name or common
1031
+ // word that merely looks like code ("JavaScript", "GitHub") would run
1032
+ // explore and inject ~16KB of low-relevance context (issue #994 follow-up).
1033
+ // A keyword-bearing prompt skips this — the keyword is signal enough.
1034
+ if (!keyworded && !codeTokens.some((t) => cg.getNodesByName(t).length > 0))
1035
+ return;
1036
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
1037
+ const handler = new ToolHandler(cg);
1038
+ const result = await handler.execute('codegraph_explore', { query: prompt });
1039
+ const text = result.content[0]?.text ?? '';
1040
+ if (!result.isError && text.trim()) {
1041
+ // Cap the injection so a large-repo explore can't flood the prompt.
1042
+ const MAX = 16000;
1043
+ const body = text.length > MAX ? `${text.slice(0, MAX)}\n…(truncated; call codegraph_explore for the rest)` : text;
1044
+ // For a front-loaded SUB-project, a follow-up explore needs its path.
1045
+ const more = plan.viaSubScan
1046
+ ? `call codegraph_explore with projectPath: "${plan.exploreRoot}" for more`
1047
+ : 'call codegraph_explore for more';
1048
+ const others = plan.nudgeProjects.length
1049
+ ? `\n${nudge(plan.nudgeProjects, 'Other indexed projects in this workspace — pass projectPath to query them:')}`
1050
+ : '';
1051
+ process.stdout.write(`<codegraph_context note="Structural context from CodeGraph for this prompt — treat returned source as already read; ${more}.">\n${body}${others}\n</codegraph_context>\n`);
1052
+ }
1053
+ }
1054
+ finally {
1055
+ cg.destroy();
1056
+ }
1057
+ }
1058
+ else {
1059
+ // Several indexed sub-projects, none a clear match — don't guess; tell
1060
+ // the agent they exist and how to query one.
1061
+ process.stdout.write(`<codegraph_context note="CodeGraph is available for this workspace's indexed sub-projects — query one by passing projectPath to codegraph_explore.">\n` +
1062
+ nudge(plan.nudgeProjects, "This workspace's CodeGraph indexes live in sub-projects. To use CodeGraph, call codegraph_explore with the projectPath of the relevant one:") +
1063
+ `</codegraph_context>\n`);
1064
+ }
1065
+ }
1066
+ catch {
1067
+ // Degradable by contract: never surface an error to the prompt pipeline.
1068
+ }
1069
+ });
1070
+ /**
1071
+ * codegraph node <name>
1072
+ *
1073
+ * The CLI face of the MCP codegraph_node tool: one symbol's source +
1074
+ * caller/callee trail, or a whole file with line numbers + dependents
1075
+ * (Read-parity). Same subagent/non-MCP rationale as `explore`.
1076
+ */
1077
+ program
1078
+ .command('node <name>')
1079
+ .description('One symbol\'s source + caller/callee trail, or read a file with line numbers + dependents (same output as the codegraph_node MCP tool)')
1080
+ .option('-p, --path <path>', 'Project path')
1081
+ .option('-f, --file <file>', 'Treat as file mode (or disambiguate a symbol to this file)')
1082
+ .option('--offset <number>', 'File mode: 1-based start line')
1083
+ .option('--limit <number>', 'File mode: maximum lines')
1084
+ .option('--symbols-only', 'File mode: just the symbol map + dependents')
1085
+ .action(async (name, options) => {
1086
+ const projectPath = resolveProjectPath(options.path);
1087
+ try {
1088
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1089
+ error(`CodeGraph isn't available here — no .codegraph/ 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 CodeGraph with 'codegraph init'.)`);
1090
+ process.exit(1);
1091
+ }
1092
+ const { default: CodeGraph } = await loadCodeGraph();
1093
+ const cg = await CodeGraph.open(projectPath);
1094
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
1095
+ const handler = new ToolHandler(cg);
1096
+ // A name with a path separator is a file read; otherwise a symbol
1097
+ // (use --file for basename-only file reads or to pin an overload).
1098
+ // Both separators: Windows users type src\auth\session.ts. Symbols
1099
+ // never contain either ('/' isn't an identifier char anywhere we
1100
+ // index; C++ scope is '::', JS members '.').
1101
+ const args = {};
1102
+ if (options.file) {
1103
+ args.file = options.file;
1104
+ if (name && name !== options.file)
1105
+ args.symbol = name;
1106
+ }
1107
+ else if (name.includes('/') || name.includes('\\')) {
1108
+ args.file = name.replace(/\\/g, '/');
1109
+ }
1110
+ else {
1111
+ args.symbol = name;
1112
+ args.includeCode = true;
1113
+ }
1114
+ if (options.offset)
1115
+ args.offset = parseInt(options.offset, 10);
1116
+ if (options.limit)
1117
+ args.limit = parseInt(options.limit, 10);
1118
+ if (options.symbolsOnly)
1119
+ args.symbolsOnly = true;
1120
+ const result = await handler.execute('codegraph_node', args);
1121
+ console.log(result.content[0]?.text ?? '');
1122
+ cg.destroy();
1123
+ if (result.isError)
1124
+ process.exit(1);
1125
+ }
1126
+ catch (err) {
1127
+ error(`Node lookup failed: ${err instanceof Error ? err.message : String(err)}`);
1128
+ process.exit(1);
1129
+ }
1130
+ });
1131
+ /**
1132
+ * codegraph files [path]
1133
+ */
1134
+ program
1135
+ .command('files')
1136
+ .description('Show project file structure from the index')
1137
+ .option('-p, --path <path>', 'Project path')
1138
+ .option('--filter <dir>', 'Filter to files under this directory')
1139
+ .option('--pattern <glob>', 'Filter files matching this glob pattern')
1140
+ .option('--format <format>', 'Output format (tree, flat, grouped)', 'tree')
1141
+ .option('--max-depth <number>', 'Maximum directory depth for tree format')
1142
+ .option('--no-metadata', 'Hide file metadata (language, symbol count)')
1143
+ .option('-j, --json', 'Output as JSON')
1144
+ .action(async (options) => {
1145
+ const projectPath = resolveProjectPath(options.path);
1146
+ try {
1147
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1148
+ error(`CodeGraph not initialized in ${projectPath}`);
1149
+ process.exit(1);
1150
+ }
1151
+ const { default: CodeGraph } = await loadCodeGraph();
1152
+ const cg = await CodeGraph.open(projectPath);
1153
+ let files = cg.getFiles();
1154
+ if (files.length === 0) {
1155
+ info('No files indexed. Run "codegraph index" first.');
1156
+ cg.destroy();
1157
+ return;
1158
+ }
1159
+ // Filter by path prefix
1160
+ if (options.filter) {
1161
+ const filter = options.filter;
1162
+ files = files.filter(f => f.path.startsWith(filter) || f.path.startsWith('./' + filter));
1163
+ }
1164
+ // Filter by glob pattern
1165
+ if (options.pattern) {
1166
+ const regex = globToRegex(options.pattern);
1167
+ files = files.filter(f => regex.test(f.path));
1168
+ }
1169
+ if (files.length === 0) {
1170
+ info('No files found matching the criteria.');
1171
+ cg.destroy();
1172
+ return;
1173
+ }
1174
+ // JSON output
1175
+ if (options.json) {
1176
+ const output = files.map(f => ({
1177
+ path: f.path,
1178
+ language: f.language,
1179
+ nodeCount: f.nodeCount,
1180
+ size: f.size,
1181
+ }));
1182
+ console.log(JSON.stringify(output, null, 2));
1183
+ cg.destroy();
1184
+ return;
1185
+ }
1186
+ const includeMetadata = options.metadata !== false;
1187
+ const format = options.format || 'tree';
1188
+ const maxDepth = options.maxDepth ? parseInt(options.maxDepth, 10) : undefined;
1189
+ // Format output
1190
+ switch (format) {
1191
+ case 'flat':
1192
+ console.log(chalk.bold(`\nFiles (${files.length}):\n`));
1193
+ for (const file of files.sort((a, b) => a.path.localeCompare(b.path))) {
1194
+ if (includeMetadata) {
1195
+ console.log(` ${file.path} ${chalk.dim(`(${file.language}, ${file.nodeCount} symbols)`)}`);
1196
+ }
1197
+ else {
1198
+ console.log(` ${file.path}`);
1199
+ }
1200
+ }
1201
+ break;
1202
+ case 'grouped':
1203
+ console.log(chalk.bold(`\nFiles by Language (${files.length} total):\n`));
1204
+ const byLang = new Map();
1205
+ for (const file of files) {
1206
+ const existing = byLang.get(file.language) || [];
1207
+ existing.push(file);
1208
+ byLang.set(file.language, existing);
1209
+ }
1210
+ const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
1211
+ for (const [lang, langFiles] of sortedLangs) {
1212
+ console.log(chalk.cyan(`${lang} (${langFiles.length}):`));
1213
+ for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
1214
+ if (includeMetadata) {
1215
+ console.log(` ${file.path} ${chalk.dim(`(${file.nodeCount} symbols)`)}`);
1216
+ }
1217
+ else {
1218
+ console.log(` ${file.path}`);
1219
+ }
1220
+ }
1221
+ console.log();
1222
+ }
1223
+ break;
1224
+ case 'tree':
1225
+ default:
1226
+ console.log(chalk.bold(`\nProject Structure (${files.length} files):\n`));
1227
+ printFileTree(files, includeMetadata, maxDepth, chalk);
1228
+ break;
1229
+ }
1230
+ console.log();
1231
+ cg.destroy();
1232
+ }
1233
+ catch (err) {
1234
+ error(`Failed to list files: ${err instanceof Error ? err.message : String(err)}`);
1235
+ process.exit(1);
1236
+ }
1237
+ });
1238
+ /**
1239
+ * Normalize a user-supplied file path to the project-relative, forward-slash
1240
+ * form CodeGraph stores in the index. Accepts an absolute path, a `./`-prefixed
1241
+ * path, or Windows back-slashes; an empty string when the input is blank. Used
1242
+ * by `codegraph affected` so `./src/x.ts`, `/abs/repo/src/x.ts`, and
1243
+ * `src/x.ts` all match the same indexed file. (#825)
1244
+ */
1245
+ function normalizeIndexPath(filePath, projectPath) {
1246
+ let f = filePath.trim();
1247
+ if (!f)
1248
+ return '';
1249
+ if (path.isAbsolute(f))
1250
+ f = path.relative(projectPath, f);
1251
+ // Collapse `.`/`..` segments, then force forward slashes and drop a leading
1252
+ // `./` (path.normalize already strips it on POSIX; explicit for Windows).
1253
+ f = path.normalize(f).replace(/\\/g, '/').replace(/^\.\//, '');
1254
+ return f;
1255
+ }
1256
+ /**
1257
+ * Convert glob pattern to regex
1258
+ */
1259
+ function globToRegex(pattern) {
1260
+ const escaped = pattern
1261
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
1262
+ .replace(/\*\*/g, '{{GLOBSTAR}}')
1263
+ .replace(/\*/g, '[^/]*')
1264
+ .replace(/\?/g, '[^/]')
1265
+ .replace(/\{\{GLOBSTAR\}\}/g, '.*');
1266
+ return new RegExp(escaped);
1267
+ }
1268
+ /**
1269
+ * Print files as a tree
1270
+ */
1271
+ function printFileTree(files, includeMetadata, maxDepth, chalk) {
1272
+ const root = { name: '', children: new Map() };
1273
+ for (const file of files) {
1274
+ const parts = file.path.split('/');
1275
+ let current = root;
1276
+ for (let i = 0; i < parts.length; i++) {
1277
+ const part = parts[i];
1278
+ if (!part)
1279
+ continue;
1280
+ if (!current.children.has(part)) {
1281
+ current.children.set(part, { name: part, children: new Map() });
1282
+ }
1283
+ current = current.children.get(part);
1284
+ if (i === parts.length - 1) {
1285
+ current.file = { language: file.language, nodeCount: file.nodeCount };
1286
+ }
1287
+ }
1288
+ }
1289
+ const renderNode = (node, prefix, isLast, depth) => {
1290
+ if (maxDepth !== undefined && depth > maxDepth)
1291
+ return;
1292
+ const glyphs = (0, glyphs_1.getGlyphs)();
1293
+ const connector = isLast ? glyphs.treeLast : glyphs.treeBranch;
1294
+ const childPrefix = isLast ? ' ' : glyphs.treePipe;
1295
+ if (node.name) {
1296
+ let line = prefix + connector + node.name;
1297
+ if (node.file && includeMetadata) {
1298
+ line += chalk.dim(` (${node.file.language}, ${node.file.nodeCount} symbols)`);
1299
+ }
1300
+ console.log(line);
1301
+ }
1302
+ const children = [...node.children.values()];
1303
+ children.sort((a, b) => {
1304
+ const aIsDir = a.children.size > 0 && !a.file;
1305
+ const bIsDir = b.children.size > 0 && !b.file;
1306
+ if (aIsDir !== bIsDir)
1307
+ return aIsDir ? -1 : 1;
1308
+ return a.name.localeCompare(b.name);
1309
+ });
1310
+ for (let i = 0; i < children.length; i++) {
1311
+ const child = children[i];
1312
+ const nextPrefix = node.name ? prefix + childPrefix : prefix;
1313
+ renderNode(child, nextPrefix, i === children.length - 1, depth + 1);
1314
+ }
1315
+ };
1316
+ renderNode(root, '', true, 0);
1317
+ }
1318
+ /**
1319
+ * codegraph daemon — interactive manager for the background daemons. Arrow keys
1320
+ * to pick one (the current project's daemon floats to the top, auto-selected),
1321
+ * enter to stop it. Falls back to a plain list when output isn't a TTY.
1322
+ */
1323
+ program
1324
+ .command('daemon')
1325
+ .aliases(['daemons'])
1326
+ .description('Manage running CodeGraph background daemons — pick one and press enter to stop it')
1327
+ .action(async () => {
1328
+ const { listDaemons, stopDaemonAt, stopAllDaemons } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
1329
+ const { runDaemonPicker } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-manager')));
1330
+ const daemons = listDaemons();
1331
+ if (daemons.length === 0) {
1332
+ info('No CodeGraph daemons running.');
1333
+ return;
1334
+ }
1335
+ // No TTY (piped / CI / non-interactive) — can't do arrow-key selection, so
1336
+ // just print what's running instead of crashing on a prompt with no input.
1337
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
1338
+ for (const d of daemons) {
1339
+ console.log(`pid ${d.pid} v${d.version} up ${formatDuration(Date.now() - d.startedAt)} ${d.root}`);
1340
+ }
1341
+ return;
1342
+ }
1343
+ // The current project's daemon floats to the top and is pre-selected.
1344
+ let cwdRoot = null;
1345
+ const found = (0, directory_1.findNearestCodeGraphRoot)(process.cwd());
1346
+ if (found) {
1347
+ try {
1348
+ cwdRoot = fs.realpathSync(found);
1349
+ }
1350
+ catch {
1351
+ cwdRoot = found;
1352
+ }
1353
+ }
1354
+ const clack = await importESM('@clack/prompts');
1355
+ clack.intro('CodeGraph daemons');
1356
+ await runDaemonPicker({
1357
+ list: listDaemons,
1358
+ stop: stopDaemonAt,
1359
+ stopAll: stopAllDaemons,
1360
+ cwdRoot,
1361
+ now: () => Date.now(),
1362
+ select: (opts) => clack.select(opts),
1363
+ isCancel: (v) => clack.isCancel(v),
1364
+ note: (m) => clack.log.success(m),
1365
+ done: (m) => clack.outro(m),
1366
+ });
1367
+ });
1368
+ /**
1369
+ * codegraph serve
1370
+ */
1371
+ program
1372
+ // Hidden from `--help`: this is the stdio entry point an AI agent launches
1373
+ // for itself (the installer wires `args: ['serve','--mcp']` into every
1374
+ // agent's MCP config), not a command a human runs. It still works when
1375
+ // invoked — hiding only removes it from the listing. See the interactive-TTY
1376
+ // guard below, which explains this to anyone who runs it by hand.
1377
+ .command('serve', { hidden: true })
1378
+ .description('Start CodeGraph as an MCP server for AI assistants')
1379
+ .option('-p, --path <path>', 'Project path (optional for MCP mode, uses rootUri from client)')
1380
+ .option('--mcp', 'Run as MCP server (stdio transport)')
1381
+ .option('--no-watch', 'Disable the file watcher (no auto-sync; useful on slow filesystems like WSL2 /mnt drives)')
1382
+ .action(async (options) => {
1383
+ const projectPath = options.path ? resolveProjectPath(options.path) : undefined;
1384
+ // Commander sets watch=false when --no-watch is passed. Route it through
1385
+ // the same env-var chokepoint the watcher and MCP server already honor.
1386
+ if (options.watch === false) {
1387
+ process.env.CODEGRAPH_NO_WATCH = '1';
1388
+ }
1389
+ try {
1390
+ if (options.mcp) {
1391
+ // `serve --mcp` is the stdio MCP server an AI agent launches for itself,
1392
+ // not a command to run by hand. A human in a terminal would otherwise
1393
+ // see it hang waiting for JSON-RPC on stdin, which reads as broken. If
1394
+ // stdin is an interactive TTY, explain instead of hanging. The agent's
1395
+ // pipe and the detached daemon both have a non-TTY stdin, so this only
1396
+ // ever fires for a person who typed it.
1397
+ if (process.stdin.isTTY && !process.env.CODEGRAPH_DAEMON_INTERNAL) {
1398
+ console.error(chalk.bold('\nCodeGraph MCP server\n'));
1399
+ console.error("This is the MCP server your AI agent (Claude Code, Cursor, Codex, opencode, …)");
1400
+ console.error("starts automatically — you don't run it yourself.");
1401
+ console.error(`\nIt's already wired up by ${chalk.cyan('codegraph install')}. To check on things:`);
1402
+ console.error(` ${chalk.cyan('codegraph status')} ${chalk.dim('— is this project indexed and healthy?')}`);
1403
+ console.error(` ${chalk.cyan('codegraph daemon')} ${chalk.dim('— list or stop background MCP servers')}`);
1404
+ console.error(chalk.dim('\n(Running it directly only does something when an MCP client drives it over stdin.)'));
1405
+ return;
1406
+ }
1407
+ // Start MCP server - it handles initialization lazily based on rootUri from client
1408
+ const { MCPServer } = await Promise.resolve().then(() => __importStar(require('../mcp/index')));
1409
+ const server = new MCPServer(projectPath);
1410
+ await server.start();
1411
+ // Server will run until terminated
1412
+ }
1413
+ else {
1414
+ // Default: show info about MCP mode.
1415
+ // Use stderr so stdout stays clean for any piped/stdio usage.
1416
+ console.error(chalk.bold('\nCodeGraph MCP Server\n'));
1417
+ console.error(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' Use --mcp flag to start the MCP server');
1418
+ console.error('\nTo use with Claude Code, add to your MCP configuration:');
1419
+ console.error(chalk.dim(`
1420
+ {
1421
+ "mcpServers": {
1422
+ "codegraph": {
1423
+ "command": "codegraph",
1424
+ "args": ["serve", "--mcp"]
1425
+ }
1426
+ }
1427
+ }
1428
+ `));
1429
+ console.error('Available tools:');
1430
+ console.error(chalk.cyan(' codegraph_explore') + ' - Primary: source of the relevant symbols for any question');
1431
+ console.error(chalk.cyan(' codegraph_search') + ' - Search for code symbols');
1432
+ console.error(chalk.cyan(' codegraph_callers') + ' - Find callers of a symbol');
1433
+ console.error(chalk.cyan(' codegraph_callees') + ' - Find what a symbol calls');
1434
+ console.error(chalk.cyan(' codegraph_impact') + ' - Analyze impact of changes');
1435
+ console.error(chalk.cyan(' codegraph_node') + ' - Get symbol details');
1436
+ console.error(chalk.cyan(' codegraph_files') + ' - Get project file structure');
1437
+ console.error(chalk.cyan(' codegraph_status') + ' - Get index status');
1438
+ }
1439
+ }
1440
+ catch (err) {
1441
+ error(`Failed to start server: ${err instanceof Error ? err.message : String(err)}`);
1442
+ process.exit(1);
1443
+ }
1444
+ });
1445
+ /**
1446
+ * codegraph unlock [path]
1447
+ */
1448
+ program
1449
+ .command('unlock [path]')
1450
+ .description('Remove a stale lock file that is blocking indexing')
1451
+ .action(async (pathArg) => {
1452
+ const projectPath = resolveProjectPath(pathArg);
1453
+ try {
1454
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1455
+ error(`CodeGraph not initialized in ${projectPath}`);
1456
+ return;
1457
+ }
1458
+ const lockPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'codegraph.lock');
1459
+ if (!fs.existsSync(lockPath)) {
1460
+ info(`No lock file found ${(0, glyphs_1.getGlyphs)().dash} nothing to do`);
1461
+ return;
1462
+ }
1463
+ fs.unlinkSync(lockPath);
1464
+ success('Removed lock file. You can now run indexing again.');
1465
+ }
1466
+ catch (err) {
1467
+ error(`Failed to remove lock: ${err instanceof Error ? err.message : String(err)}`);
1468
+ process.exit(1);
1469
+ }
1470
+ });
1471
+ /**
1472
+ * codegraph callers <symbol>
1473
+ *
1474
+ * CLI parity with the MCP graph tools (codegraph_callers/callees/impact) so the
1475
+ * traversal queries work in scripts, CI, and git hooks without a running MCP
1476
+ * server.
1477
+ */
1478
+ program
1479
+ .command('callers <symbol>')
1480
+ .description('Find all functions/methods that call a specific symbol')
1481
+ .option('-p, --path <path>', 'Project path')
1482
+ .option('-l, --limit <number>', 'Maximum results', '20')
1483
+ .option('-j, --json', 'Output as JSON')
1484
+ .action(async (symbol, options) => {
1485
+ const projectPath = resolveProjectPath(options.path);
1486
+ try {
1487
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1488
+ error(`CodeGraph not initialized in ${projectPath}`);
1489
+ process.exit(1);
1490
+ }
1491
+ const { default: CodeGraph } = await loadCodeGraph();
1492
+ const cg = await CodeGraph.open(projectPath);
1493
+ const limit = parseInt(options.limit || '20', 10);
1494
+ const matches = cg.searchNodes(symbol, { limit: 50 });
1495
+ if (matches.length === 0) {
1496
+ info(`Symbol "${symbol}" not found`);
1497
+ cg.destroy();
1498
+ return;
1499
+ }
1500
+ const seen = new Set();
1501
+ const allCallers = [];
1502
+ for (const match of matches) {
1503
+ const exactMatch = match.node.name === symbol || match.node.name.endsWith(`.${symbol}`) || match.node.name.endsWith(`::${symbol}`);
1504
+ if (!exactMatch && matches.length > 1)
1505
+ continue;
1506
+ for (const c of cg.getCallers(match.node.id)) {
1507
+ if (!seen.has(c.node.id)) {
1508
+ seen.add(c.node.id);
1509
+ allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeLabel: c.edge.kind });
1510
+ }
1511
+ }
1512
+ }
1513
+ // Fallback: if exact filter removed everything, use the top match
1514
+ if (allCallers.length === 0 && matches[0]) {
1515
+ for (const c of cg.getCallers(matches[0].node.id)) {
1516
+ if (!seen.has(c.node.id)) {
1517
+ seen.add(c.node.id);
1518
+ allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeLabel: c.edge.kind });
1519
+ }
1520
+ }
1521
+ }
1522
+ const limited = allCallers.slice(0, limit);
1523
+ if (options.json) {
1524
+ console.log(JSON.stringify({ symbol, callers: limited }, null, 2));
1525
+ }
1526
+ else if (limited.length === 0) {
1527
+ info(`No callers found for "${symbol}"`);
1528
+ }
1529
+ else {
1530
+ console.log(chalk.bold(`\nCallers of "${symbol}" (${limited.length}):\n`));
1531
+ for (const node of limited) {
1532
+ const loc = node.startLine ? `:${node.startLine}` : '';
1533
+ console.log(chalk.cyan(node.kind.padEnd(12)) +
1534
+ chalk.white(node.name));
1535
+ console.log(chalk.dim(` ${node.filePath}${loc}`));
1536
+ console.log();
1537
+ }
1538
+ }
1539
+ cg.destroy();
1540
+ }
1541
+ catch (err) {
1542
+ error(`callers failed: ${err instanceof Error ? err.message : String(err)}`);
1543
+ process.exit(1);
1544
+ }
1545
+ });
1546
+ /**
1547
+ * codegraph callees <symbol>
1548
+ */
1549
+ program
1550
+ .command('callees <symbol>')
1551
+ .description('Find all functions/methods that a specific symbol calls')
1552
+ .option('-p, --path <path>', 'Project path')
1553
+ .option('-l, --limit <number>', 'Maximum results', '20')
1554
+ .option('-j, --json', 'Output as JSON')
1555
+ .action(async (symbol, options) => {
1556
+ const projectPath = resolveProjectPath(options.path);
1557
+ try {
1558
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1559
+ error(`CodeGraph not initialized in ${projectPath}`);
1560
+ process.exit(1);
1561
+ }
1562
+ const { default: CodeGraph } = await loadCodeGraph();
1563
+ const cg = await CodeGraph.open(projectPath);
1564
+ const limit = parseInt(options.limit || '20', 10);
1565
+ const matches = cg.searchNodes(symbol, { limit: 50 });
1566
+ if (matches.length === 0) {
1567
+ info(`Symbol "${symbol}" not found`);
1568
+ cg.destroy();
1569
+ return;
1570
+ }
1571
+ const seen = new Set();
1572
+ const allCallees = [];
1573
+ for (const match of matches) {
1574
+ const exactMatch = match.node.name === symbol || match.node.name.endsWith(`.${symbol}`) || match.node.name.endsWith(`::${symbol}`);
1575
+ if (!exactMatch && matches.length > 1)
1576
+ continue;
1577
+ for (const c of cg.getCallees(match.node.id)) {
1578
+ if (!seen.has(c.node.id)) {
1579
+ seen.add(c.node.id);
1580
+ allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeLabel: c.edge.kind });
1581
+ }
1582
+ }
1583
+ }
1584
+ if (allCallees.length === 0 && matches[0]) {
1585
+ for (const c of cg.getCallees(matches[0].node.id)) {
1586
+ if (!seen.has(c.node.id)) {
1587
+ seen.add(c.node.id);
1588
+ allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeLabel: c.edge.kind });
1589
+ }
1590
+ }
1591
+ }
1592
+ const limited = allCallees.slice(0, limit);
1593
+ if (options.json) {
1594
+ console.log(JSON.stringify({ symbol, callees: limited }, null, 2));
1595
+ }
1596
+ else if (limited.length === 0) {
1597
+ info(`No callees found for "${symbol}"`);
1598
+ }
1599
+ else {
1600
+ console.log(chalk.bold(`\nCallees of "${symbol}" (${limited.length}):\n`));
1601
+ for (const node of limited) {
1602
+ const loc = node.startLine ? `:${node.startLine}` : '';
1603
+ console.log(chalk.cyan(node.kind.padEnd(12)) +
1604
+ chalk.white(node.name));
1605
+ console.log(chalk.dim(` ${node.filePath}${loc}`));
1606
+ console.log();
1607
+ }
1608
+ }
1609
+ cg.destroy();
1610
+ }
1611
+ catch (err) {
1612
+ error(`callees failed: ${err instanceof Error ? err.message : String(err)}`);
1613
+ process.exit(1);
1614
+ }
1615
+ });
1616
+ /**
1617
+ * codegraph impact <symbol>
1618
+ */
1619
+ program
1620
+ .command('impact <symbol>')
1621
+ .description('Analyze what code is affected by changing a symbol')
1622
+ .option('-p, --path <path>', 'Project path')
1623
+ .option('-d, --depth <number>', 'Traversal depth', '2')
1624
+ .option('-j, --json', 'Output as JSON')
1625
+ .action(async (symbol, options) => {
1626
+ const projectPath = resolveProjectPath(options.path);
1627
+ try {
1628
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1629
+ error(`CodeGraph not initialized in ${projectPath}`);
1630
+ process.exit(1);
1631
+ }
1632
+ const { default: CodeGraph } = await loadCodeGraph();
1633
+ const cg = await CodeGraph.open(projectPath);
1634
+ const depth = Math.min(Math.max(parseInt(options.depth || '2', 10), 1), 10);
1635
+ const matches = cg.searchNodes(symbol, { limit: 50 });
1636
+ if (matches.length === 0) {
1637
+ info(`Symbol "${symbol}" not found`);
1638
+ cg.destroy();
1639
+ return;
1640
+ }
1641
+ // Merge impact subgraphs across all exact-matching symbols
1642
+ const mergedNodes = new Map();
1643
+ const seenEdges = new Set();
1644
+ let edgeCount = 0;
1645
+ for (const match of matches) {
1646
+ const exactMatch = match.node.name === symbol || match.node.name.endsWith(`.${symbol}`) || match.node.name.endsWith(`::${symbol}`);
1647
+ if (!exactMatch && matches.length > 1)
1648
+ continue;
1649
+ const impact = cg.getImpactRadius(match.node.id, depth);
1650
+ for (const [id, n] of impact.nodes) {
1651
+ mergedNodes.set(id, { name: n.name, kind: n.kind, filePath: n.filePath, startLine: n.startLine });
1652
+ }
1653
+ for (const e of impact.edges) {
1654
+ const key = `${e.source}->${e.target}:${e.kind}`;
1655
+ if (!seenEdges.has(key)) {
1656
+ seenEdges.add(key);
1657
+ edgeCount++;
1658
+ }
1659
+ }
1660
+ }
1661
+ // Fallback to top match if exact filter removed everything
1662
+ if (mergedNodes.size === 0 && matches[0]) {
1663
+ const impact = cg.getImpactRadius(matches[0].node.id, depth);
1664
+ for (const [id, n] of impact.nodes) {
1665
+ mergedNodes.set(id, { name: n.name, kind: n.kind, filePath: n.filePath, startLine: n.startLine });
1666
+ }
1667
+ edgeCount = impact.edges.length;
1668
+ }
1669
+ if (options.json) {
1670
+ console.log(JSON.stringify({
1671
+ symbol,
1672
+ depth,
1673
+ nodeCount: mergedNodes.size,
1674
+ edgeCount,
1675
+ affected: Array.from(mergedNodes.values()),
1676
+ }, null, 2));
1677
+ }
1678
+ else if (mergedNodes.size === 0) {
1679
+ info(`No affected symbols found for "${symbol}"`);
1680
+ }
1681
+ else {
1682
+ console.log(chalk.bold(`\nImpact of changing "${symbol}" — ${mergedNodes.size} affected symbols:\n`));
1683
+ // Group by file
1684
+ const byFile = new Map();
1685
+ for (const node of mergedNodes.values()) {
1686
+ const list = byFile.get(node.filePath) || [];
1687
+ list.push({ name: node.name, kind: node.kind, startLine: node.startLine });
1688
+ byFile.set(node.filePath, list);
1689
+ }
1690
+ for (const [file, nodes] of byFile) {
1691
+ console.log(chalk.cyan(file));
1692
+ for (const node of nodes) {
1693
+ const loc = node.startLine ? `:${node.startLine}` : '';
1694
+ console.log(` ${chalk.dim(node.kind.padEnd(12))}${node.name}${chalk.dim(loc)}`);
1695
+ }
1696
+ console.log();
1697
+ }
1698
+ }
1699
+ cg.destroy();
1700
+ }
1701
+ catch (err) {
1702
+ error(`impact failed: ${err instanceof Error ? err.message : String(err)}`);
1703
+ process.exit(1);
1704
+ }
1705
+ });
1706
+ /**
1707
+ * codegraph affected [files...]
1708
+ *
1709
+ * Find test files affected by the given source files.
1710
+ * Traces dependency edges transitively to find test files that depend on changed code.
1711
+ *
1712
+ * Usage:
1713
+ * git diff --name-only | codegraph affected --stdin
1714
+ * codegraph affected src/lib/components/Editor.svelte src/routes/+page.svelte
1715
+ */
1716
+ program
1717
+ .command('affected [files...]')
1718
+ .description('Find test files affected by changed source files')
1719
+ .option('-p, --path <path>', 'Project path')
1720
+ .option('--stdin', 'Read file list from stdin (one per line)')
1721
+ .option('-d, --depth <number>', 'Max dependency traversal depth', '5')
1722
+ .option('-f, --filter <glob>', 'Custom glob filter for test files (e.g. "e2e/*.spec.ts")')
1723
+ .option('-j, --json', 'Output as JSON')
1724
+ .option('-q, --quiet', 'Only output file paths, no decoration')
1725
+ .action(async (fileArgs, options) => {
1726
+ const projectPath = resolveProjectPath(options.path);
1727
+ try {
1728
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1729
+ error(`CodeGraph not initialized in ${projectPath}`);
1730
+ process.exit(1);
1731
+ }
1732
+ // Collect changed files from args or stdin
1733
+ let changedFiles = [...(fileArgs || [])];
1734
+ if (options.stdin) {
1735
+ const stdinData = fs.readFileSync(0, 'utf-8');
1736
+ const stdinFiles = stdinData.split('\n').map(f => f.trim()).filter(Boolean);
1737
+ changedFiles.push(...stdinFiles);
1738
+ }
1739
+ // Normalize inputs to the project-relative, forward-slash form the index
1740
+ // stores. Without this, `affected ./src/x.ts`, an absolute path (what a
1741
+ // wrapping script often passes), or a Windows back-slash path silently
1742
+ // matches nothing and reports 0 affected tests. (#825)
1743
+ changedFiles = changedFiles
1744
+ .map((f) => normalizeIndexPath(f, projectPath))
1745
+ .filter(Boolean);
1746
+ if (changedFiles.length === 0) {
1747
+ if (!options.quiet)
1748
+ info('No files provided. Use file arguments or --stdin.');
1749
+ process.exit(0);
1750
+ }
1751
+ const { default: CodeGraph } = await loadCodeGraph();
1752
+ const cg = await CodeGraph.open(projectPath);
1753
+ const maxDepth = parseInt(options.depth || '5', 10);
1754
+ // Common test file patterns
1755
+ const defaultTestPatterns = [
1756
+ /\.spec\./,
1757
+ /\.test\./,
1758
+ /\/__tests__\//,
1759
+ /\/tests?\//,
1760
+ /\/e2e\//,
1761
+ /\/spec\//,
1762
+ ];
1763
+ // Custom filter pattern
1764
+ let customFilter = null;
1765
+ if (options.filter) {
1766
+ // Convert glob to regex: ** → .+, * → [^/]*, . → \.
1767
+ const regex = options.filter
1768
+ .replace(/[+[\]{}()^$|\\]/g, '\\$&')
1769
+ .replace(/\./g, '\\.')
1770
+ .replace(/\*\*/g, '.+')
1771
+ .replace(/\*/g, '[^/]*');
1772
+ customFilter = new RegExp(regex);
1773
+ }
1774
+ function isTestFile(filePath) {
1775
+ if (customFilter)
1776
+ return customFilter.test(filePath);
1777
+ return defaultTestPatterns.some(p => p.test(filePath));
1778
+ }
1779
+ // BFS to find all transitive dependents of changed files, filtered to test files
1780
+ const affectedTests = new Set();
1781
+ const allDependents = new Set();
1782
+ for (const file of changedFiles) {
1783
+ // If the changed file is itself a test file, include it
1784
+ if (isTestFile(file)) {
1785
+ affectedTests.add(file);
1786
+ continue;
1787
+ }
1788
+ // BFS through dependents
1789
+ const queue = [{ file, depth: 0 }];
1790
+ const visited = new Set();
1791
+ visited.add(file);
1792
+ while (queue.length > 0) {
1793
+ const current = queue.shift();
1794
+ if (current.depth >= maxDepth)
1795
+ continue;
1796
+ const dependents = cg.getFileDependents(current.file);
1797
+ for (const dep of dependents) {
1798
+ if (visited.has(dep))
1799
+ continue;
1800
+ visited.add(dep);
1801
+ allDependents.add(dep);
1802
+ if (isTestFile(dep)) {
1803
+ affectedTests.add(dep);
1804
+ }
1805
+ else {
1806
+ queue.push({ file: dep, depth: current.depth + 1 });
1807
+ }
1808
+ }
1809
+ }
1810
+ }
1811
+ const sortedTests = Array.from(affectedTests).sort();
1812
+ // Output
1813
+ if (options.json) {
1814
+ console.log(JSON.stringify({
1815
+ changedFiles,
1816
+ affectedTests: sortedTests,
1817
+ totalDependentsTraversed: allDependents.size,
1818
+ }, null, 2));
1819
+ }
1820
+ else if (options.quiet) {
1821
+ for (const t of sortedTests)
1822
+ console.log(t);
1823
+ }
1824
+ else {
1825
+ if (sortedTests.length === 0) {
1826
+ info('No test files affected by the changed files.');
1827
+ }
1828
+ else {
1829
+ console.log(chalk.bold(`\nAffected test files (${sortedTests.length}):\n`));
1830
+ for (const t of sortedTests) {
1831
+ console.log(' ' + chalk.cyan(t));
1832
+ }
1833
+ console.log();
1834
+ }
1835
+ }
1836
+ cg.destroy();
1837
+ }
1838
+ catch (err) {
1839
+ error(`Affected analysis failed: ${err instanceof Error ? err.message : String(err)}`);
1840
+ process.exit(1);
1841
+ }
1842
+ });
1843
+ /**
1844
+ * codegraph install
1845
+ */
1846
+ program
1847
+ .command('install')
1848
+ .description('Install codegraph MCP server into one or more agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent)')
1849
+ .option('-t, --target <ids>', 'Target agent(s): comma-separated ids, or "auto"|"all"|"none". Default: prompt')
1850
+ .option('-l, --location <where>', 'Install location: "global" or "local". Default: prompt')
1851
+ .option('-y, --yes', 'Non-interactive: defaults to --location=global --target=auto, auto-allow on')
1852
+ .option('--no-permissions', 'Skip writing the auto-allow permissions list (Claude Code only)')
1853
+ .option('--print-config <id>', 'Print MCP config snippet for the named agent and exit (no file writes)')
1854
+ .action(async (opts) => {
1855
+ if (opts.printConfig) {
1856
+ const { getTarget, listTargetIds } = await Promise.resolve().then(() => __importStar(require('../installer/targets/registry')));
1857
+ const target = getTarget(opts.printConfig);
1858
+ if (!target) {
1859
+ const known = listTargetIds().join(', ');
1860
+ error(`Unknown target "${opts.printConfig}". Known: ${known}.`);
1861
+ process.exit(1);
1862
+ }
1863
+ const loc = (opts.location === 'local' ? 'local' : 'global');
1864
+ process.stdout.write(target.printConfig(loc));
1865
+ return;
1866
+ }
1867
+ const { runInstallerWithOptions } = await Promise.resolve().then(() => __importStar(require('../installer')));
1868
+ if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
1869
+ error(`--location must be "global" or "local" (got "${opts.location}").`);
1870
+ process.exit(1);
1871
+ }
1872
+ try {
1873
+ // Commander's `--no-permissions` makes `opts.permissions === false`;
1874
+ // omitting the flag leaves it `true` (the positive-form default).
1875
+ // We MUST treat the default-true as "user did not override — let
1876
+ // the orchestrator prompt" and only forward an explicit `false`
1877
+ // (or `true` when --yes implies it). Otherwise the auto-allow
1878
+ // prompt is silently skipped on every interactive run.
1879
+ const explicitNoPermissions = opts.permissions === false;
1880
+ const autoAllow = explicitNoPermissions
1881
+ ? false
1882
+ : opts.yes
1883
+ ? true
1884
+ : undefined;
1885
+ await runInstallerWithOptions({
1886
+ target: opts.target,
1887
+ location: opts.location,
1888
+ autoAllow,
1889
+ yes: opts.yes,
1890
+ });
1891
+ }
1892
+ catch (err) {
1893
+ error(err instanceof Error ? err.message : String(err));
1894
+ process.exit(1);
1895
+ }
1896
+ });
1897
+ /**
1898
+ * codegraph uninstall
1899
+ *
1900
+ * Inverse of `install`. Removes the codegraph MCP server entry,
1901
+ * instructions block, and permissions from every agent (or a
1902
+ * `--target` subset). Prompts global-vs-local when not given. Does NOT
1903
+ * delete the `.codegraph/` index — that's `codegraph uninit`.
1904
+ */
1905
+ program
1906
+ .command('uninstall')
1907
+ .description('Remove codegraph from your agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent)')
1908
+ .option('-t, --target <ids>', 'Target agent(s): comma-separated ids, or "all". Default: all')
1909
+ .option('-l, --location <where>', 'Uninstall location: "global" or "local". Default: prompt')
1910
+ .option('-y, --yes', 'Non-interactive: defaults to --location=global --target=all')
1911
+ .action(async (opts) => {
1912
+ const { runUninstaller } = await Promise.resolve().then(() => __importStar(require('../installer')));
1913
+ if (opts.location && opts.location !== 'global' && opts.location !== 'local') {
1914
+ error(`--location must be "global" or "local" (got "${opts.location}").`);
1915
+ process.exit(1);
1916
+ }
1917
+ try {
1918
+ await runUninstaller({
1919
+ target: opts.target,
1920
+ location: opts.location,
1921
+ yes: opts.yes,
1922
+ });
1923
+ }
1924
+ catch (err) {
1925
+ error(err instanceof Error ? err.message : String(err));
1926
+ process.exit(1);
1927
+ }
1928
+ });
1929
+ /**
1930
+ * codegraph telemetry [on|off|status]
1931
+ */
1932
+ program
1933
+ .command('telemetry [action]')
1934
+ .description('Show or change anonymous usage telemetry (status, on, off)')
1935
+ .action((action) => {
1936
+ const t = (0, telemetry_1.getTelemetry)();
1937
+ if (action === 'on' || action === 'off') {
1938
+ t.setEnabled(action === 'on', 'cli');
1939
+ if (action === 'on') {
1940
+ success('Telemetry enabled — anonymous usage stats only (no code, paths, or names).');
1941
+ }
1942
+ else {
1943
+ success('Telemetry disabled. Buffered, unsent data was deleted.');
1944
+ }
1945
+ const effective = t.getStatus();
1946
+ if (effective.decidedBy === 'DO_NOT_TRACK' || effective.decidedBy === 'CODEGRAPH_TELEMETRY') {
1947
+ warn(`The ${effective.decidedBy} environment variable overrides this choice — ` +
1948
+ `effective state right now: ${effective.enabled ? 'enabled' : 'disabled'}.`);
1949
+ }
1950
+ return;
1951
+ }
1952
+ if (action !== undefined && action !== 'status') {
1953
+ error(`Unknown action: ${action} (expected status, on, or off)`);
1954
+ process.exit(1);
1955
+ }
1956
+ const s = t.getStatus();
1957
+ const decidedBy = {
1958
+ DO_NOT_TRACK: 'DO_NOT_TRACK environment variable',
1959
+ CODEGRAPH_TELEMETRY: 'CODEGRAPH_TELEMETRY environment variable',
1960
+ config: 'your saved choice',
1961
+ default: 'default',
1962
+ };
1963
+ console.log(`\nTelemetry: ${s.enabled ? chalk.green('enabled') : chalk.yellow('disabled')} ${chalk.dim(`(${decidedBy[s.decidedBy]})`)}`);
1964
+ console.log(`Machine ID: ${s.machineId ?? chalk.dim('(random UUID, created on first use)')}`);
1965
+ console.log(`Config: ${s.configPath}`);
1966
+ console.log(chalk.dim(`\nExactly what is collected (and never collected): ${telemetry_1.TELEMETRY_DOCS}\n`));
1967
+ });
1968
+ /**
1969
+ * codegraph upgrade [version]
1970
+ *
1971
+ * Self-update, however CodeGraph was installed (bundle via install.sh/.ps1,
1972
+ * npm-global, npx, or a source checkout). See ../upgrade for the detection and
1973
+ * per-method upgrade logic.
1974
+ */
1975
+ program
1976
+ .command('upgrade [version]')
1977
+ .description('Update CodeGraph to the latest release (or a specific version)')
1978
+ .option('--check', 'Check whether an update is available without installing')
1979
+ .option('-f, --force', 'Reinstall even if already on the target version')
1980
+ .action(async (versionArg, options) => {
1981
+ const up = await Promise.resolve().then(() => __importStar(require('../upgrade')));
1982
+ const method = up.detectInstallMethod({
1983
+ filename: __filename,
1984
+ platform: process.platform,
1985
+ cwd: process.cwd(),
1986
+ });
1987
+ const pin = versionArg || process.env.CODEGRAPH_VERSION || undefined;
1988
+ const code = await up.runUpgrade({ version: pin, check: options.check, force: options.force }, {
1989
+ currentVersion: packageJson.version,
1990
+ method,
1991
+ resolveLatest: () => up.resolveLatestVersion(),
1992
+ run: up.defaultRun,
1993
+ hasCommand: up.hasCommand,
1994
+ log: (m) => console.log(m),
1995
+ warn: (m) => warn(m),
1996
+ error: (m) => error(m),
1997
+ platform: process.platform,
1998
+ });
1999
+ process.exit(code);
2000
+ });
2001
+ /**
2002
+ * codegraph version
2003
+ *
2004
+ * The bare-noun form of `--version`. commander already provides `--version`
2005
+ * and `-V`, and the `-v` / `-version` spellings are intercepted before parse
2006
+ * (see top of main). This subcommand makes `codegraph version` work and lists
2007
+ * the version affordance in `codegraph --help`.
2008
+ */
2009
+ program
2010
+ .command('version')
2011
+ .description('Print the installed CodeGraph version (also: -v, --version)')
2012
+ .action(() => {
2013
+ console.log(packageJson.version);
2014
+ });
2015
+ // Parse and run
2016
+ program.parse();
2017
+ } // end main()
2018
+ //# sourceMappingURL=codegraph.js.map