@colbymchenry/codegraph-win32-x64 0.9.9 → 1.0.1

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 (313) hide show
  1. package/lib/dist/bin/codegraph.d.ts +1 -0
  2. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  3. package/lib/dist/bin/codegraph.js +394 -10
  4. package/lib/dist/bin/codegraph.js.map +1 -1
  5. package/lib/dist/bin/fatal-handler.d.ts +20 -0
  6. package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
  7. package/lib/dist/bin/fatal-handler.js +118 -0
  8. package/lib/dist/bin/fatal-handler.js.map +1 -0
  9. package/lib/dist/context/index.d.ts.map +1 -1
  10. package/lib/dist/context/index.js +7 -0
  11. package/lib/dist/context/index.js.map +1 -1
  12. package/lib/dist/db/index.d.ts.map +1 -1
  13. package/lib/dist/db/index.js +2 -1
  14. package/lib/dist/db/index.js.map +1 -1
  15. package/lib/dist/db/migrations.d.ts +1 -1
  16. package/lib/dist/db/migrations.d.ts.map +1 -1
  17. package/lib/dist/db/migrations.js +10 -1
  18. package/lib/dist/db/migrations.js.map +1 -1
  19. package/lib/dist/db/queries.d.ts +43 -0
  20. package/lib/dist/db/queries.d.ts.map +1 -1
  21. package/lib/dist/db/queries.js +103 -7
  22. package/lib/dist/db/queries.js.map +1 -1
  23. package/lib/dist/db/schema.sql +1 -0
  24. package/lib/dist/db/sqlite-adapter.d.ts +7 -0
  25. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  26. package/lib/dist/db/sqlite-adapter.js +3 -0
  27. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  28. package/lib/dist/directory.d.ts +49 -2
  29. package/lib/dist/directory.d.ts.map +1 -1
  30. package/lib/dist/directory.js +173 -35
  31. package/lib/dist/directory.js.map +1 -1
  32. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  33. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  34. package/lib/dist/extraction/astro-extractor.js +320 -0
  35. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  36. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  37. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  38. package/lib/dist/extraction/extraction-version.js +28 -0
  39. package/lib/dist/extraction/extraction-version.js.map +1 -0
  40. package/lib/dist/extraction/function-ref.d.ts +118 -0
  41. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  42. package/lib/dist/extraction/function-ref.js +727 -0
  43. package/lib/dist/extraction/function-ref.js.map +1 -0
  44. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  45. package/lib/dist/extraction/generated-detection.js +3 -0
  46. package/lib/dist/extraction/generated-detection.js.map +1 -1
  47. package/lib/dist/extraction/grammars.d.ts +7 -1
  48. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  49. package/lib/dist/extraction/grammars.js +52 -4
  50. package/lib/dist/extraction/grammars.js.map +1 -1
  51. package/lib/dist/extraction/index.d.ts +34 -0
  52. package/lib/dist/extraction/index.d.ts.map +1 -1
  53. package/lib/dist/extraction/index.js +389 -62
  54. package/lib/dist/extraction/index.js.map +1 -1
  55. package/lib/dist/extraction/languages/c-cpp.d.ts +8 -0
  56. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  57. package/lib/dist/extraction/languages/c-cpp.js +87 -28
  58. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  59. package/lib/dist/extraction/languages/csharp.d.ts +22 -0
  60. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
  61. package/lib/dist/extraction/languages/csharp.js +84 -2
  62. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  63. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  64. package/lib/dist/extraction/languages/dart.js +161 -1
  65. package/lib/dist/extraction/languages/dart.js.map +1 -1
  66. package/lib/dist/extraction/languages/go.d.ts.map +1 -1
  67. package/lib/dist/extraction/languages/go.js +43 -2
  68. package/lib/dist/extraction/languages/go.js.map +1 -1
  69. package/lib/dist/extraction/languages/index.d.ts.map +1 -1
  70. package/lib/dist/extraction/languages/index.js +2 -0
  71. package/lib/dist/extraction/languages/index.js.map +1 -1
  72. package/lib/dist/extraction/languages/java.d.ts.map +1 -1
  73. package/lib/dist/extraction/languages/java.js +42 -1
  74. package/lib/dist/extraction/languages/java.js.map +1 -1
  75. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
  76. package/lib/dist/extraction/languages/javascript.js +16 -0
  77. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  78. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  79. package/lib/dist/extraction/languages/kotlin.js +69 -0
  80. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  81. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  82. package/lib/dist/extraction/languages/objc.js +42 -0
  83. package/lib/dist/extraction/languages/objc.js.map +1 -1
  84. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
  85. package/lib/dist/extraction/languages/pascal.js +11 -0
  86. package/lib/dist/extraction/languages/pascal.js.map +1 -1
  87. package/lib/dist/extraction/languages/php.d.ts.map +1 -1
  88. package/lib/dist/extraction/languages/php.js +90 -1
  89. package/lib/dist/extraction/languages/php.js.map +1 -1
  90. package/lib/dist/extraction/languages/r.d.ts +3 -0
  91. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  92. package/lib/dist/extraction/languages/r.js +314 -0
  93. package/lib/dist/extraction/languages/r.js.map +1 -0
  94. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
  95. package/lib/dist/extraction/languages/ruby.js +35 -0
  96. package/lib/dist/extraction/languages/ruby.js.map +1 -1
  97. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  98. package/lib/dist/extraction/languages/rust.js +35 -2
  99. package/lib/dist/extraction/languages/rust.js.map +1 -1
  100. package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
  101. package/lib/dist/extraction/languages/scala.js +61 -1
  102. package/lib/dist/extraction/languages/scala.js.map +1 -1
  103. package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
  104. package/lib/dist/extraction/languages/swift.js +61 -0
  105. package/lib/dist/extraction/languages/swift.js.map +1 -1
  106. package/lib/dist/extraction/languages/typescript.d.ts +13 -0
  107. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  108. package/lib/dist/extraction/languages/typescript.js +38 -0
  109. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  110. package/lib/dist/extraction/liquid-extractor.d.ts +7 -0
  111. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  112. package/lib/dist/extraction/liquid-extractor.js +53 -9
  113. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  114. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  115. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  116. package/lib/dist/extraction/razor-extractor.js +285 -0
  117. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  118. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  119. package/lib/dist/extraction/svelte-extractor.js +6 -3
  120. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  121. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  122. package/lib/dist/extraction/tree-sitter-helpers.js +59 -10
  123. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  124. package/lib/dist/extraction/tree-sitter-types.d.ts +33 -0
  125. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  126. package/lib/dist/extraction/tree-sitter.d.ts +211 -0
  127. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  128. package/lib/dist/extraction/tree-sitter.js +1681 -49
  129. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  130. package/lib/dist/extraction/vue-extractor.d.ts +15 -0
  131. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  132. package/lib/dist/extraction/vue-extractor.js +94 -3
  133. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  134. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  135. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  136. package/lib/dist/graph/queries.d.ts.map +1 -1
  137. package/lib/dist/graph/queries.js +13 -40
  138. package/lib/dist/graph/queries.js.map +1 -1
  139. package/lib/dist/graph/traversal.d.ts.map +1 -1
  140. package/lib/dist/graph/traversal.js +16 -4
  141. package/lib/dist/graph/traversal.js.map +1 -1
  142. package/lib/dist/index.d.ts +34 -2
  143. package/lib/dist/index.d.ts.map +1 -1
  144. package/lib/dist/index.js +90 -8
  145. package/lib/dist/index.js.map +1 -1
  146. package/lib/dist/installer/index.d.ts.map +1 -1
  147. package/lib/dist/installer/index.js +63 -2
  148. package/lib/dist/installer/index.js.map +1 -1
  149. package/lib/dist/installer/instructions-template.d.ts +34 -11
  150. package/lib/dist/installer/instructions-template.d.ts.map +1 -1
  151. package/lib/dist/installer/instructions-template.js +44 -12
  152. package/lib/dist/installer/instructions-template.js.map +1 -1
  153. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  154. package/lib/dist/installer/targets/claude.js +6 -10
  155. package/lib/dist/installer/targets/claude.js.map +1 -1
  156. package/lib/dist/installer/targets/codex.js +4 -6
  157. package/lib/dist/installer/targets/codex.js.map +1 -1
  158. package/lib/dist/installer/targets/gemini.js +4 -6
  159. package/lib/dist/installer/targets/gemini.js.map +1 -1
  160. package/lib/dist/installer/targets/opencode.d.ts +9 -1
  161. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  162. package/lib/dist/installer/targets/opencode.js +91 -40
  163. package/lib/dist/installer/targets/opencode.js.map +1 -1
  164. package/lib/dist/installer/targets/shared.d.ts +14 -0
  165. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  166. package/lib/dist/installer/targets/shared.js +16 -0
  167. package/lib/dist/installer/targets/shared.js.map +1 -1
  168. package/lib/dist/mcp/daemon-manager.d.ts +42 -0
  169. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
  170. package/lib/dist/mcp/daemon-manager.js +129 -0
  171. package/lib/dist/mcp/daemon-manager.js.map +1 -0
  172. package/lib/dist/mcp/daemon-registry.d.ts +47 -0
  173. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
  174. package/lib/dist/mcp/daemon-registry.js +229 -0
  175. package/lib/dist/mcp/daemon-registry.js.map +1 -0
  176. package/lib/dist/mcp/daemon.d.ts +60 -1
  177. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  178. package/lib/dist/mcp/daemon.js +226 -8
  179. package/lib/dist/mcp/daemon.js.map +1 -1
  180. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  181. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  182. package/lib/dist/mcp/dynamic-boundaries.js +359 -0
  183. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  184. package/lib/dist/mcp/index.d.ts +1 -0
  185. package/lib/dist/mcp/index.d.ts.map +1 -1
  186. package/lib/dist/mcp/index.js +31 -9
  187. package/lib/dist/mcp/index.js.map +1 -1
  188. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
  189. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  190. package/lib/dist/mcp/liveness-watchdog.js +207 -0
  191. package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
  192. package/lib/dist/mcp/ppid-watchdog.d.ts +44 -0
  193. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  194. package/lib/dist/mcp/ppid-watchdog.js +27 -0
  195. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  196. package/lib/dist/mcp/proxy.d.ts +6 -0
  197. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  198. package/lib/dist/mcp/proxy.js +153 -24
  199. package/lib/dist/mcp/proxy.js.map +1 -1
  200. package/lib/dist/mcp/server-instructions.d.ts +12 -1
  201. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  202. package/lib/dist/mcp/server-instructions.js +43 -16
  203. package/lib/dist/mcp/server-instructions.js.map +1 -1
  204. package/lib/dist/mcp/session.d.ts +2 -0
  205. package/lib/dist/mcp/session.d.ts.map +1 -1
  206. package/lib/dist/mcp/session.js +49 -2
  207. package/lib/dist/mcp/session.js.map +1 -1
  208. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  209. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  210. package/lib/dist/mcp/stdin-teardown.js +49 -0
  211. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  212. package/lib/dist/mcp/tools.d.ts +71 -0
  213. package/lib/dist/mcp/tools.d.ts.map +1 -1
  214. package/lib/dist/mcp/tools.js +703 -85
  215. package/lib/dist/mcp/tools.js.map +1 -1
  216. package/lib/dist/mcp/transport.d.ts.map +1 -1
  217. package/lib/dist/mcp/transport.js +18 -2
  218. package/lib/dist/mcp/transport.js.map +1 -1
  219. package/lib/dist/resolution/callback-synthesizer.d.ts +3 -3
  220. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  221. package/lib/dist/resolution/callback-synthesizer.js +549 -21
  222. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  223. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  224. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  225. package/lib/dist/resolution/frameworks/astro.js +169 -0
  226. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  227. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  228. package/lib/dist/resolution/frameworks/expo-modules.js +6 -1
  229. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  230. package/lib/dist/resolution/frameworks/index.d.ts +1 -0
  231. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  232. package/lib/dist/resolution/frameworks/index.js +5 -1
  233. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  234. package/lib/dist/resolution/frameworks/java.js +6 -1
  235. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  236. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  237. package/lib/dist/resolution/frameworks/python.js +7 -3
  238. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  239. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  240. package/lib/dist/resolution/frameworks/react-native.js +53 -3
  241. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  242. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  243. package/lib/dist/resolution/frameworks/react.js +15 -3
  244. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  245. package/lib/dist/resolution/frameworks/svelte.js +5 -1
  246. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  247. package/lib/dist/resolution/frameworks/vue.js +24 -27
  248. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  249. package/lib/dist/resolution/import-resolver.d.ts +10 -0
  250. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  251. package/lib/dist/resolution/import-resolver.js +620 -2
  252. package/lib/dist/resolution/import-resolver.js.map +1 -1
  253. package/lib/dist/resolution/index.d.ts +80 -0
  254. package/lib/dist/resolution/index.d.ts.map +1 -1
  255. package/lib/dist/resolution/index.js +457 -7
  256. package/lib/dist/resolution/index.js.map +1 -1
  257. package/lib/dist/resolution/name-matcher.d.ts +61 -0
  258. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  259. package/lib/dist/resolution/name-matcher.js +590 -14
  260. package/lib/dist/resolution/name-matcher.js.map +1 -1
  261. package/lib/dist/resolution/types.d.ts +27 -3
  262. package/lib/dist/resolution/types.d.ts.map +1 -1
  263. package/lib/dist/resolution/workspace-packages.d.ts +48 -0
  264. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  265. package/lib/dist/resolution/workspace-packages.js +208 -0
  266. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  267. package/lib/dist/search/query-utils.d.ts +17 -1
  268. package/lib/dist/search/query-utils.d.ts.map +1 -1
  269. package/lib/dist/search/query-utils.js +79 -10
  270. package/lib/dist/search/query-utils.js.map +1 -1
  271. package/lib/dist/sync/watcher.d.ts +124 -32
  272. package/lib/dist/sync/watcher.d.ts.map +1 -1
  273. package/lib/dist/sync/watcher.js +326 -111
  274. package/lib/dist/sync/watcher.js.map +1 -1
  275. package/lib/dist/telemetry/index.d.ts +146 -0
  276. package/lib/dist/telemetry/index.d.ts.map +1 -0
  277. package/lib/dist/telemetry/index.js +544 -0
  278. package/lib/dist/telemetry/index.js.map +1 -0
  279. package/lib/dist/types.d.ts +17 -2
  280. package/lib/dist/types.d.ts.map +1 -1
  281. package/lib/dist/types.js +3 -0
  282. package/lib/dist/types.js.map +1 -1
  283. package/lib/dist/upgrade/index.d.ts +132 -0
  284. package/lib/dist/upgrade/index.d.ts.map +1 -0
  285. package/lib/dist/upgrade/index.js +462 -0
  286. package/lib/dist/upgrade/index.js.map +1 -0
  287. package/lib/dist/utils.d.ts +30 -24
  288. package/lib/dist/utils.d.ts.map +1 -1
  289. package/lib/dist/utils.js +64 -48
  290. package/lib/dist/utils.js.map +1 -1
  291. package/lib/node_modules/.package-lock.json +1 -29
  292. package/lib/package.json +1 -2
  293. package/package.json +1 -1
  294. package/lib/node_modules/chokidar/LICENSE +0 -21
  295. package/lib/node_modules/chokidar/README.md +0 -305
  296. package/lib/node_modules/chokidar/esm/handler.d.ts +0 -90
  297. package/lib/node_modules/chokidar/esm/handler.js +0 -629
  298. package/lib/node_modules/chokidar/esm/index.d.ts +0 -215
  299. package/lib/node_modules/chokidar/esm/index.js +0 -798
  300. package/lib/node_modules/chokidar/esm/package.json +0 -1
  301. package/lib/node_modules/chokidar/handler.d.ts +0 -90
  302. package/lib/node_modules/chokidar/handler.js +0 -635
  303. package/lib/node_modules/chokidar/index.d.ts +0 -215
  304. package/lib/node_modules/chokidar/index.js +0 -804
  305. package/lib/node_modules/chokidar/package.json +0 -69
  306. package/lib/node_modules/readdirp/LICENSE +0 -21
  307. package/lib/node_modules/readdirp/README.md +0 -120
  308. package/lib/node_modules/readdirp/esm/index.d.ts +0 -108
  309. package/lib/node_modules/readdirp/esm/index.js +0 -257
  310. package/lib/node_modules/readdirp/esm/package.json +0 -1
  311. package/lib/node_modules/readdirp/index.d.ts +0 -108
  312. package/lib/node_modules/readdirp/index.js +0 -263
  313. package/lib/node_modules/readdirp/package.json +0 -70
@@ -20,6 +20,7 @@
20
20
  * codegraph callees <symbol> Find what a function/method calls
21
21
  * codegraph impact <symbol> Analyze what code is affected by changing a symbol
22
22
  * codegraph affected [files] Find test files affected by changes
23
+ * codegraph upgrade [version] Update CodeGraph to the latest release
23
24
  */
24
25
  export {};
25
26
  //# sourceMappingURL=codegraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegraph.d.ts","sourceRoot":"","sources":["../../src/bin/codegraph.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
1
+ {"version":3,"file":"codegraph.d.ts","sourceRoot":"","sources":["../../src/bin/codegraph.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -21,6 +21,7 @@
21
21
  * codegraph callees <symbol> Find what a function/method calls
22
22
  * codegraph impact <symbol> Analyze what code is affected by changing a symbol
23
23
  * codegraph affected [files] Find test files affected by changes
24
+ * codegraph upgrade [version] Update CodeGraph to the latest release
24
25
  */
25
26
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
27
  if (k2 === undefined) k2 = k;
@@ -64,7 +65,10 @@ const worktree_1 = require("../sync/worktree");
64
65
  const shimmer_progress_1 = require("../ui/shimmer-progress");
65
66
  const glyphs_1 = require("../ui/glyphs");
66
67
  const node_version_check_1 = require("./node-version-check");
68
+ const fatal_handler_1 = require("./fatal-handler");
67
69
  const wasm_runtime_flags_1 = require("../extraction/wasm-runtime-flags");
70
+ const extraction_version_1 = require("../extraction/extraction-version");
71
+ const telemetry_1 = require("../telemetry");
68
72
  // Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast.
69
73
  async function loadCodeGraph() {
70
74
  try {
@@ -115,6 +119,12 @@ if (nodeMajor < node_version_check_1.MIN_NODE_MAJOR) {
115
119
  // passes the flag. Must run before any grammar (in the parse worker, which
116
120
  // inherits this process's flags) is compiled. See ../extraction/wasm-runtime-flags.
117
121
  (0, wasm_runtime_flags_1.relaunchWithWasmRuntimeFlagsIfNeeded)(__filename);
122
+ // Last-resort fatal handlers: log a bounded line and exit non-zero. A fault
123
+ // that reaches here escaped every boundary, so the process is in an undefined
124
+ // state — keeping it alive is what let the detached MCP daemon orphan and pin a
125
+ // CPU core with no recovery (#799, #850). Installed before the command branch
126
+ // so it also covers a synchronous throw during startup. See ./fatal-handler.
127
+ (0, fatal_handler_1.installFatalHandlers)();
118
128
  // Check if running with no arguments - run installer
119
129
  if (process.argv.length === 2) {
120
130
  Promise.resolve().then(() => __importStar(require('../installer'))).then(({ runInstaller }) => runInstaller()).catch((err) => {
@@ -126,16 +136,21 @@ else {
126
136
  // Normal CLI flow
127
137
  main();
128
138
  }
129
- process.on('uncaughtException', (error) => {
130
- console.error('[CodeGraph] Uncaught exception:', error);
131
- });
132
- process.on('unhandledRejection', (reason) => {
133
- console.error('[CodeGraph] Unhandled rejection:', reason);
134
- });
135
139
  function main() {
136
140
  const program = new commander_1.Command();
137
141
  // Version from package.json
138
142
  const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8'));
143
+ // Make the version trivial to reach. commander's `.version()` (below) wires up
144
+ // `--version` and `-V`; intercept the spellings it can't — lowercase `-v` and
145
+ // single-dash `-version` — before any parsing. (commander's version short flag
146
+ // is the capital `-V`, and its parser rejects a multi-character single-dash
147
+ // flag.) The bare `codegraph version` subcommand is registered further down so
148
+ // the affordance also shows up in `codegraph --help`.
149
+ const firstArg = process.argv[2];
150
+ if (firstArg === '-v' || firstArg === '-version') {
151
+ console.log(packageJson.version);
152
+ return;
153
+ }
139
154
  // =============================================================================
140
155
  // ANSI Color Helpers (avoid chalk ESM issues)
141
156
  // =============================================================================
@@ -166,6 +181,30 @@ function main() {
166
181
  .name('codegraph')
167
182
  .description('Code intelligence and knowledge graph for any codebase')
168
183
  .version(packageJson.version);
184
+ // Anonymous usage telemetry (see TELEMETRY.md): record the invoked subcommand
185
+ // NAME only — never arguments or paths. Counts buffer locally; network sends
186
+ // piggyback on commands that run long anyway (quick commands only append to
187
+ // the local buffer at exit, costing nothing).
188
+ // install/uninstall are absent on purpose: the installer flushes at its own
189
+ // end, AFTER its consent prompt — a flush here would fire the first-run
190
+ // notice before the user ever sees the toggle.
191
+ const TELEMETRY_FLUSH_COMMANDS = new Set(['init', 'uninit', 'index', 'sync', 'upgrade']);
192
+ program.hook('preAction', (_thisCommand, actionCommand) => {
193
+ try {
194
+ // The detached daemon re-invokes `serve --mcp` internally — not a user action.
195
+ if (process.env.CODEGRAPH_DAEMON_INTERNAL)
196
+ return;
197
+ const name = actionCommand.name();
198
+ if (name === 'telemetry')
199
+ return; // managing telemetry is not usage
200
+ (0, telemetry_1.getTelemetry)().recordUsage('cli_command', name, true);
201
+ if (TELEMETRY_FLUSH_COMMANDS.has(name))
202
+ (0, telemetry_1.getTelemetry)().maybeFlush();
203
+ }
204
+ catch {
205
+ /* telemetry must never break the CLI */
206
+ }
207
+ });
169
208
  // =============================================================================
170
209
  // Helper Functions
171
210
  // =============================================================================
@@ -339,7 +378,7 @@ function main() {
339
378
  }
340
379
  }
341
380
  else if (projectPath) {
342
- const logPath = path.join(projectPath, '.codegraph', 'errors.log');
381
+ const logPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'errors.log');
343
382
  if (fs.existsSync(logPath)) {
344
383
  fs.unlinkSync(logPath);
345
384
  }
@@ -349,7 +388,7 @@ function main() {
349
388
  * Write detailed error log to .codegraph/errors.log
350
389
  */
351
390
  function writeErrorLog(projectPath, errors) {
352
- const cgDir = path.join(projectPath, '.codegraph');
391
+ const cgDir = (0, directory_1.getCodeGraphDir)(projectPath);
353
392
  if (!fs.existsSync(cgDir))
354
393
  return;
355
394
  const logPath = path.join(cgDir, 'errors.log');
@@ -386,6 +425,15 @@ function main() {
386
425
  }
387
426
  fs.writeFileSync(logPath, lines.join('\n') + '\n');
388
427
  }
428
+ /**
429
+ * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush
430
+ * keeps init/index responsive (these commands just ran for seconds anyway)
431
+ * while delivering the event promptly.
432
+ */
433
+ async function recordIndexTelemetry(cg, result) {
434
+ (0, telemetry_1.recordIndexEvent)(cg, result);
435
+ await (0, telemetry_1.getTelemetry)().flushNow();
436
+ }
389
437
  // =============================================================================
390
438
  // Commands
391
439
  // =============================================================================
@@ -396,12 +444,24 @@ function main() {
396
444
  .command('init [path]')
397
445
  .description('Initialize CodeGraph in a project directory and build the initial index')
398
446
  .option('-i, --index', 'Deprecated: indexing now runs by default; flag accepted for backward compatibility')
447
+ .option('-f, --force', 'Initialize even if the path looks like your home directory or a filesystem root')
399
448
  .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
400
449
  .action(async (pathArg, options) => {
401
450
  const projectPath = path.resolve(pathArg || process.cwd());
402
451
  const clack = await importESM('@clack/prompts');
403
452
  clack.intro('Initializing CodeGraph');
404
453
  try {
454
+ // Refuse to index your home directory / a filesystem root — it pulls in
455
+ // caches, other projects, and your whole tree (a multi-GB index + watcher
456
+ // churn, and on pre-1.0 macOS a machine-crashing fd blowup, #845).
457
+ const unsafe = (0, directory_1.unsafeIndexRootReason)(projectPath);
458
+ if (unsafe && !options.force) {
459
+ clack.log.error(`Refusing to initialize in ${projectPath} — it looks like ${unsafe}.`);
460
+ clack.log.info('Run this inside a specific project directory, or pass --force if you really mean to index everything under it.');
461
+ clack.outro('');
462
+ process.exitCode = 1;
463
+ return;
464
+ }
405
465
  if ((0, directory_1.isInitialized)(projectPath)) {
406
466
  clack.log.warn(`Already initialized in ${projectPath}`);
407
467
  clack.log.info('Use "codegraph index" to re-index or "codegraph sync" to update');
@@ -435,6 +495,7 @@ function main() {
435
495
  await progress.stop();
436
496
  }
437
497
  printIndexResult(clack, result, projectPath);
498
+ await recordIndexTelemetry(cg, result);
438
499
  try {
439
500
  const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
440
501
  await offerWatchFallback(clack, projectPath);
@@ -488,6 +549,13 @@ function main() {
488
549
  }
489
550
  catch { /* non-fatal */ }
490
551
  success(`Removed CodeGraph from ${projectPath}`);
552
+ // Churn signal — and flush now, since after an uninit there may be no
553
+ // "next run" to deliver it.
554
+ try {
555
+ (0, telemetry_1.getTelemetry)().recordLifecycle('uninstall', {});
556
+ await (0, telemetry_1.getTelemetry)().flushNow();
557
+ }
558
+ catch { /* non-fatal */ }
491
559
  }
492
560
  catch (err) {
493
561
  error(`Failed to uninitialize: ${err instanceof Error ? err.message : String(err)}`);
@@ -506,6 +574,13 @@ function main() {
506
574
  .action(async (pathArg, options) => {
507
575
  const projectPath = resolveProjectPath(pathArg);
508
576
  try {
577
+ // Don't (re)index your home directory / a filesystem root (#845). --force
578
+ // (already "force full re-index") doubles as the override.
579
+ const unsafe = (0, directory_1.unsafeIndexRootReason)(projectPath);
580
+ if (unsafe && !options.force) {
581
+ error(`Refusing to index ${projectPath} — it looks like ${unsafe}. Pass --force to override.`);
582
+ process.exit(1);
583
+ }
509
584
  if (!(0, directory_1.isInitialized)(projectPath)) {
510
585
  error(`CodeGraph not initialized in ${projectPath}`);
511
586
  info('Run "codegraph init" first');
@@ -545,6 +620,7 @@ function main() {
545
620
  await progress.stop();
546
621
  }
547
622
  printIndexResult(clack, result, projectPath);
623
+ await recordIndexTelemetry(cg, result);
548
624
  if (!result.success) {
549
625
  process.exit(1);
550
626
  }
@@ -629,7 +705,13 @@ function main() {
629
705
  try {
630
706
  if (!(0, directory_1.isInitialized)(projectPath)) {
631
707
  if (options.json) {
632
- console.log(JSON.stringify({ initialized: false, projectPath }));
708
+ console.log(JSON.stringify({
709
+ initialized: false,
710
+ version: packageJson.version,
711
+ projectPath,
712
+ indexPath: (0, directory_1.getCodeGraphDir)(projectPath),
713
+ lastIndexed: null,
714
+ }));
633
715
  return;
634
716
  }
635
717
  console.log(chalk.bold('\nCodeGraph Status\n'));
@@ -644,11 +726,17 @@ function main() {
644
726
  const changes = cg.getChangedFiles();
645
727
  const backend = cg.getBackend();
646
728
  const journalMode = cg.getJournalMode();
729
+ const buildInfo = cg.getIndexBuildInfo();
730
+ const reindexRecommended = cg.isIndexStale();
647
731
  // JSON output mode
648
732
  if (options.json) {
733
+ const lastIndexedMs = cg.getLastIndexedAt();
649
734
  console.log(JSON.stringify({
650
735
  initialized: true,
736
+ version: packageJson.version,
651
737
  projectPath,
738
+ indexPath: (0, directory_1.getCodeGraphDir)(projectPath),
739
+ lastIndexed: lastIndexedMs != null ? new Date(lastIndexedMs).toISOString() : null,
652
740
  fileCount: stats.fileCount,
653
741
  nodeCount: stats.nodeCount,
654
742
  edgeCount: stats.edgeCount,
@@ -665,6 +753,12 @@ function main() {
665
753
  worktreeMismatch: worktreeMismatch
666
754
  ? { worktreeRoot: worktreeMismatch.worktreeRoot, indexRoot: worktreeMismatch.indexRoot }
667
755
  : null,
756
+ index: {
757
+ builtWithVersion: buildInfo.version,
758
+ builtWithExtractionVersion: buildInfo.extractionVersion,
759
+ currentExtractionVersion: extraction_version_1.EXTRACTION_VERSION,
760
+ reindexRecommended,
761
+ },
668
762
  }));
669
763
  cg.destroy();
670
764
  return;
@@ -732,6 +826,14 @@ function main() {
732
826
  success('Index is up to date');
733
827
  }
734
828
  console.log();
829
+ // Re-index hint: the index was built by an older engine than the one now
830
+ // running, so a rebuild would add data a migration can't backfill.
831
+ if (reindexRecommended) {
832
+ const builtWith = buildInfo.version ? `v${buildInfo.version.replace(/^v/, '')}` : 'an earlier version';
833
+ warn(`Index was built by ${builtWith}; re-index to pick up this engine's improvements.`);
834
+ info('Run "codegraph index -f" (full rebuild) or "codegraph sync"');
835
+ console.log();
836
+ }
735
837
  cg.destroy();
736
838
  }
737
839
  catch (err) {
@@ -803,6 +905,106 @@ function main() {
803
905
  process.exit(1);
804
906
  }
805
907
  });
908
+ /**
909
+ * codegraph explore <query...>
910
+ *
911
+ * The CLI face of the MCP codegraph_explore tool — same handler, same
912
+ * output (source of the relevant symbols grouped by file + the call path
913
+ * among them). Exists so agents WITHOUT the MCP tools — Task-tool
914
+ * subagents (which don't inherit MCP tools, #704) and non-MCP harnesses —
915
+ * can reach the graph through a plain shell command.
916
+ */
917
+ program
918
+ .command('explore <query...>')
919
+ .description('Explore an area: relevant symbols\' source + call paths in one shot (same output as the codegraph_explore MCP tool)')
920
+ .option('-p, --path <path>', 'Project path')
921
+ .option('--max-files <number>', 'Maximum number of files to include source from')
922
+ .action(async (queryParts, options) => {
923
+ const projectPath = resolveProjectPath(options.path);
924
+ try {
925
+ if (!(0, directory_1.isInitialized)(projectPath)) {
926
+ 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'.)`);
927
+ process.exit(1);
928
+ }
929
+ const { default: CodeGraph } = await loadCodeGraph();
930
+ const cg = await CodeGraph.open(projectPath);
931
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
932
+ const handler = new ToolHandler(cg);
933
+ const args = { query: queryParts.join(' ') };
934
+ if (options.maxFiles)
935
+ args.maxFiles = parseInt(options.maxFiles, 10);
936
+ const result = await handler.execute('codegraph_explore', args);
937
+ console.log(result.content[0]?.text ?? '');
938
+ cg.destroy();
939
+ if (result.isError)
940
+ process.exit(1);
941
+ }
942
+ catch (err) {
943
+ error(`Explore failed: ${err instanceof Error ? err.message : String(err)}`);
944
+ process.exit(1);
945
+ }
946
+ });
947
+ /**
948
+ * codegraph node <name>
949
+ *
950
+ * The CLI face of the MCP codegraph_node tool: one symbol's source +
951
+ * caller/callee trail, or a whole file with line numbers + dependents
952
+ * (Read-parity). Same subagent/non-MCP rationale as `explore`.
953
+ */
954
+ program
955
+ .command('node <name>')
956
+ .description('One symbol\'s source + caller/callee trail, or read a file with line numbers + dependents (same output as the codegraph_node MCP tool)')
957
+ .option('-p, --path <path>', 'Project path')
958
+ .option('-f, --file <file>', 'Treat as file mode (or disambiguate a symbol to this file)')
959
+ .option('--offset <number>', 'File mode: 1-based start line')
960
+ .option('--limit <number>', 'File mode: maximum lines')
961
+ .option('--symbols-only', 'File mode: just the symbol map + dependents')
962
+ .action(async (name, options) => {
963
+ const projectPath = resolveProjectPath(options.path);
964
+ try {
965
+ if (!(0, directory_1.isInitialized)(projectPath)) {
966
+ 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'.)`);
967
+ process.exit(1);
968
+ }
969
+ const { default: CodeGraph } = await loadCodeGraph();
970
+ const cg = await CodeGraph.open(projectPath);
971
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
972
+ const handler = new ToolHandler(cg);
973
+ // A name with a path separator is a file read; otherwise a symbol
974
+ // (use --file for basename-only file reads or to pin an overload).
975
+ // Both separators: Windows users type src\auth\session.ts. Symbols
976
+ // never contain either ('/' isn't an identifier char anywhere we
977
+ // index; C++ scope is '::', JS members '.').
978
+ const args = {};
979
+ if (options.file) {
980
+ args.file = options.file;
981
+ if (name && name !== options.file)
982
+ args.symbol = name;
983
+ }
984
+ else if (name.includes('/') || name.includes('\\')) {
985
+ args.file = name.replace(/\\/g, '/');
986
+ }
987
+ else {
988
+ args.symbol = name;
989
+ args.includeCode = true;
990
+ }
991
+ if (options.offset)
992
+ args.offset = parseInt(options.offset, 10);
993
+ if (options.limit)
994
+ args.limit = parseInt(options.limit, 10);
995
+ if (options.symbolsOnly)
996
+ args.symbolsOnly = true;
997
+ const result = await handler.execute('codegraph_node', args);
998
+ console.log(result.content[0]?.text ?? '');
999
+ cg.destroy();
1000
+ if (result.isError)
1001
+ process.exit(1);
1002
+ }
1003
+ catch (err) {
1004
+ error(`Node lookup failed: ${err instanceof Error ? err.message : String(err)}`);
1005
+ process.exit(1);
1006
+ }
1007
+ });
806
1008
  /**
807
1009
  * codegraph files [path]
808
1010
  */
@@ -910,6 +1112,24 @@ function main() {
910
1112
  process.exit(1);
911
1113
  }
912
1114
  });
1115
+ /**
1116
+ * Normalize a user-supplied file path to the project-relative, forward-slash
1117
+ * form CodeGraph stores in the index. Accepts an absolute path, a `./`-prefixed
1118
+ * path, or Windows back-slashes; an empty string when the input is blank. Used
1119
+ * by `codegraph affected` so `./src/x.ts`, `/abs/repo/src/x.ts`, and
1120
+ * `src/x.ts` all match the same indexed file. (#825)
1121
+ */
1122
+ function normalizeIndexPath(filePath, projectPath) {
1123
+ let f = filePath.trim();
1124
+ if (!f)
1125
+ return '';
1126
+ if (path.isAbsolute(f))
1127
+ f = path.relative(projectPath, f);
1128
+ // Collapse `.`/`..` segments, then force forward slashes and drop a leading
1129
+ // `./` (path.normalize already strips it on POSIX; explicit for Windows).
1130
+ f = path.normalize(f).replace(/\\/g, '/').replace(/^\.\//, '');
1131
+ return f;
1132
+ }
913
1133
  /**
914
1134
  * Convert glob pattern to regex
915
1135
  */
@@ -972,11 +1192,66 @@ function main() {
972
1192
  };
973
1193
  renderNode(root, '', true, 0);
974
1194
  }
1195
+ /**
1196
+ * codegraph daemon — interactive manager for the background daemons. Arrow keys
1197
+ * to pick one (the current project's daemon floats to the top, auto-selected),
1198
+ * enter to stop it. Falls back to a plain list when output isn't a TTY.
1199
+ */
1200
+ program
1201
+ .command('daemon')
1202
+ .aliases(['daemons'])
1203
+ .description('Manage running CodeGraph background daemons — pick one and press enter to stop it')
1204
+ .action(async () => {
1205
+ const { listDaemons, stopDaemonAt, stopAllDaemons } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
1206
+ const { runDaemonPicker } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-manager')));
1207
+ const daemons = listDaemons();
1208
+ if (daemons.length === 0) {
1209
+ info('No CodeGraph daemons running.');
1210
+ return;
1211
+ }
1212
+ // No TTY (piped / CI / non-interactive) — can't do arrow-key selection, so
1213
+ // just print what's running instead of crashing on a prompt with no input.
1214
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
1215
+ for (const d of daemons) {
1216
+ console.log(`pid ${d.pid} v${d.version} up ${formatDuration(Date.now() - d.startedAt)} ${d.root}`);
1217
+ }
1218
+ return;
1219
+ }
1220
+ // The current project's daemon floats to the top and is pre-selected.
1221
+ let cwdRoot = null;
1222
+ const found = (0, directory_1.findNearestCodeGraphRoot)(process.cwd());
1223
+ if (found) {
1224
+ try {
1225
+ cwdRoot = fs.realpathSync(found);
1226
+ }
1227
+ catch {
1228
+ cwdRoot = found;
1229
+ }
1230
+ }
1231
+ const clack = await importESM('@clack/prompts');
1232
+ clack.intro('CodeGraph daemons');
1233
+ await runDaemonPicker({
1234
+ list: listDaemons,
1235
+ stop: stopDaemonAt,
1236
+ stopAll: stopAllDaemons,
1237
+ cwdRoot,
1238
+ now: () => Date.now(),
1239
+ select: (opts) => clack.select(opts),
1240
+ isCancel: (v) => clack.isCancel(v),
1241
+ note: (m) => clack.log.success(m),
1242
+ done: (m) => clack.outro(m),
1243
+ });
1244
+ });
975
1245
  /**
976
1246
  * codegraph serve
977
1247
  */
978
1248
  program
979
- .command('serve')
1249
+ // Hidden from `--help`: this is the stdio entry point an AI agent launches
1250
+ // for itself (the installer wires `args: ['serve','--mcp']` into every
1251
+ // agent's MCP config), not a command a human runs. It still works when
1252
+ // invoked — hiding only removes it from the listing. See the interactive-TTY
1253
+ // guard below, which explains this to anyone who runs it by hand.
1254
+ .command('serve', { hidden: true })
980
1255
  .description('Start CodeGraph as an MCP server for AI assistants')
981
1256
  .option('-p, --path <path>', 'Project path (optional for MCP mode, uses rootUri from client)')
982
1257
  .option('--mcp', 'Run as MCP server (stdio transport)')
@@ -990,6 +1265,22 @@ function main() {
990
1265
  }
991
1266
  try {
992
1267
  if (options.mcp) {
1268
+ // `serve --mcp` is the stdio MCP server an AI agent launches for itself,
1269
+ // not a command to run by hand. A human in a terminal would otherwise
1270
+ // see it hang waiting for JSON-RPC on stdin, which reads as broken. If
1271
+ // stdin is an interactive TTY, explain instead of hanging. The agent's
1272
+ // pipe and the detached daemon both have a non-TTY stdin, so this only
1273
+ // ever fires for a person who typed it.
1274
+ if (process.stdin.isTTY && !process.env.CODEGRAPH_DAEMON_INTERNAL) {
1275
+ console.error(chalk.bold('\nCodeGraph MCP server\n'));
1276
+ console.error("This is the MCP server your AI agent (Claude Code, Cursor, Codex, opencode, …)");
1277
+ console.error("starts automatically — you don't run it yourself.");
1278
+ console.error(`\nIt's already wired up by ${chalk.cyan('codegraph install')}. To check on things:`);
1279
+ console.error(` ${chalk.cyan('codegraph status')} ${chalk.dim('— is this project indexed and healthy?')}`);
1280
+ console.error(` ${chalk.cyan('codegraph daemon')} ${chalk.dim('— list or stop background MCP servers')}`);
1281
+ console.error(chalk.dim('\n(Running it directly only does something when an MCP client drives it over stdin.)'));
1282
+ return;
1283
+ }
993
1284
  // Start MCP server - it handles initialization lazily based on rootUri from client
994
1285
  const { MCPServer } = await Promise.resolve().then(() => __importStar(require('../mcp/index')));
995
1286
  const server = new MCPServer(projectPath);
@@ -1322,6 +1613,13 @@ function main() {
1322
1613
  const stdinFiles = stdinData.split('\n').map(f => f.trim()).filter(Boolean);
1323
1614
  changedFiles.push(...stdinFiles);
1324
1615
  }
1616
+ // Normalize inputs to the project-relative, forward-slash form the index
1617
+ // stores. Without this, `affected ./src/x.ts`, an absolute path (what a
1618
+ // wrapping script often passes), or a Windows back-slash path silently
1619
+ // matches nothing and reports 0 affected tests. (#825)
1620
+ changedFiles = changedFiles
1621
+ .map((f) => normalizeIndexPath(f, projectPath))
1622
+ .filter(Boolean);
1325
1623
  if (changedFiles.length === 0) {
1326
1624
  if (!options.quiet)
1327
1625
  info('No files provided. Use file arguments or --stdin.');
@@ -1505,6 +1803,92 @@ function main() {
1505
1803
  process.exit(1);
1506
1804
  }
1507
1805
  });
1806
+ /**
1807
+ * codegraph telemetry [on|off|status]
1808
+ */
1809
+ program
1810
+ .command('telemetry [action]')
1811
+ .description('Show or change anonymous usage telemetry (status, on, off)')
1812
+ .action((action) => {
1813
+ const t = (0, telemetry_1.getTelemetry)();
1814
+ if (action === 'on' || action === 'off') {
1815
+ t.setEnabled(action === 'on', 'cli');
1816
+ if (action === 'on') {
1817
+ success('Telemetry enabled — anonymous usage stats only (no code, paths, or names).');
1818
+ }
1819
+ else {
1820
+ success('Telemetry disabled. Buffered, unsent data was deleted.');
1821
+ }
1822
+ const effective = t.getStatus();
1823
+ if (effective.decidedBy === 'DO_NOT_TRACK' || effective.decidedBy === 'CODEGRAPH_TELEMETRY') {
1824
+ warn(`The ${effective.decidedBy} environment variable overrides this choice — ` +
1825
+ `effective state right now: ${effective.enabled ? 'enabled' : 'disabled'}.`);
1826
+ }
1827
+ return;
1828
+ }
1829
+ if (action !== undefined && action !== 'status') {
1830
+ error(`Unknown action: ${action} (expected status, on, or off)`);
1831
+ process.exit(1);
1832
+ }
1833
+ const s = t.getStatus();
1834
+ const decidedBy = {
1835
+ DO_NOT_TRACK: 'DO_NOT_TRACK environment variable',
1836
+ CODEGRAPH_TELEMETRY: 'CODEGRAPH_TELEMETRY environment variable',
1837
+ config: 'your saved choice',
1838
+ default: 'default',
1839
+ };
1840
+ console.log(`\nTelemetry: ${s.enabled ? chalk.green('enabled') : chalk.yellow('disabled')} ${chalk.dim(`(${decidedBy[s.decidedBy]})`)}`);
1841
+ console.log(`Machine ID: ${s.machineId ?? chalk.dim('(random UUID, created on first use)')}`);
1842
+ console.log(`Config: ${s.configPath}`);
1843
+ console.log(chalk.dim(`\nExactly what is collected (and never collected): ${telemetry_1.TELEMETRY_DOCS}\n`));
1844
+ });
1845
+ /**
1846
+ * codegraph upgrade [version]
1847
+ *
1848
+ * Self-update, however CodeGraph was installed (bundle via install.sh/.ps1,
1849
+ * npm-global, npx, or a source checkout). See ../upgrade for the detection and
1850
+ * per-method upgrade logic.
1851
+ */
1852
+ program
1853
+ .command('upgrade [version]')
1854
+ .description('Update CodeGraph to the latest release (or a specific version)')
1855
+ .option('--check', 'Check whether an update is available without installing')
1856
+ .option('-f, --force', 'Reinstall even if already on the target version')
1857
+ .action(async (versionArg, options) => {
1858
+ const up = await Promise.resolve().then(() => __importStar(require('../upgrade')));
1859
+ const method = up.detectInstallMethod({
1860
+ filename: __filename,
1861
+ platform: process.platform,
1862
+ cwd: process.cwd(),
1863
+ });
1864
+ const pin = versionArg || process.env.CODEGRAPH_VERSION || undefined;
1865
+ const code = await up.runUpgrade({ version: pin, check: options.check, force: options.force }, {
1866
+ currentVersion: packageJson.version,
1867
+ method,
1868
+ resolveLatest: () => up.resolveLatestVersion(),
1869
+ run: up.defaultRun,
1870
+ hasCommand: up.hasCommand,
1871
+ log: (m) => console.log(m),
1872
+ warn: (m) => warn(m),
1873
+ error: (m) => error(m),
1874
+ platform: process.platform,
1875
+ });
1876
+ process.exit(code);
1877
+ });
1878
+ /**
1879
+ * codegraph version
1880
+ *
1881
+ * The bare-noun form of `--version`. commander already provides `--version`
1882
+ * and `-V`, and the `-v` / `-version` spellings are intercepted before parse
1883
+ * (see top of main). This subcommand makes `codegraph version` work and lists
1884
+ * the version affordance in `codegraph --help`.
1885
+ */
1886
+ program
1887
+ .command('version')
1888
+ .description('Print the installed CodeGraph version (also: -v, --version)')
1889
+ .action(() => {
1890
+ console.log(packageJson.version);
1891
+ });
1508
1892
  // Parse and run
1509
1893
  program.parse();
1510
1894
  } // end main()