@colbymchenry/codegraph-darwin-x64 0.9.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) 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 +246 -3
  4. package/lib/dist/bin/codegraph.js.map +1 -1
  5. package/lib/dist/context/index.d.ts.map +1 -1
  6. package/lib/dist/context/index.js +7 -0
  7. package/lib/dist/context/index.js.map +1 -1
  8. package/lib/dist/db/index.d.ts.map +1 -1
  9. package/lib/dist/db/index.js +2 -1
  10. package/lib/dist/db/index.js.map +1 -1
  11. package/lib/dist/db/migrations.d.ts +1 -1
  12. package/lib/dist/db/migrations.d.ts.map +1 -1
  13. package/lib/dist/db/migrations.js +10 -1
  14. package/lib/dist/db/migrations.js.map +1 -1
  15. package/lib/dist/db/queries.d.ts +43 -0
  16. package/lib/dist/db/queries.d.ts.map +1 -1
  17. package/lib/dist/db/queries.js +103 -7
  18. package/lib/dist/db/queries.js.map +1 -1
  19. package/lib/dist/db/schema.sql +1 -0
  20. package/lib/dist/db/sqlite-adapter.d.ts +7 -0
  21. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  22. package/lib/dist/db/sqlite-adapter.js +3 -0
  23. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  24. package/lib/dist/directory.d.ts +34 -2
  25. package/lib/dist/directory.d.ts.map +1 -1
  26. package/lib/dist/directory.js +129 -35
  27. package/lib/dist/directory.js.map +1 -1
  28. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  29. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  30. package/lib/dist/extraction/astro-extractor.js +320 -0
  31. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  32. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  33. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  34. package/lib/dist/extraction/extraction-version.js +28 -0
  35. package/lib/dist/extraction/extraction-version.js.map +1 -0
  36. package/lib/dist/extraction/function-ref.d.ts +118 -0
  37. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  38. package/lib/dist/extraction/function-ref.js +727 -0
  39. package/lib/dist/extraction/function-ref.js.map +1 -0
  40. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  41. package/lib/dist/extraction/generated-detection.js +3 -0
  42. package/lib/dist/extraction/generated-detection.js.map +1 -1
  43. package/lib/dist/extraction/grammars.d.ts +7 -1
  44. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  45. package/lib/dist/extraction/grammars.js +52 -4
  46. package/lib/dist/extraction/grammars.js.map +1 -1
  47. package/lib/dist/extraction/index.d.ts +34 -0
  48. package/lib/dist/extraction/index.d.ts.map +1 -1
  49. package/lib/dist/extraction/index.js +346 -62
  50. package/lib/dist/extraction/index.js.map +1 -1
  51. package/lib/dist/extraction/languages/c-cpp.d.ts +8 -0
  52. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  53. package/lib/dist/extraction/languages/c-cpp.js +87 -28
  54. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  55. package/lib/dist/extraction/languages/csharp.d.ts +22 -0
  56. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
  57. package/lib/dist/extraction/languages/csharp.js +84 -2
  58. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  59. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  60. package/lib/dist/extraction/languages/dart.js +161 -1
  61. package/lib/dist/extraction/languages/dart.js.map +1 -1
  62. package/lib/dist/extraction/languages/go.d.ts.map +1 -1
  63. package/lib/dist/extraction/languages/go.js +43 -2
  64. package/lib/dist/extraction/languages/go.js.map +1 -1
  65. package/lib/dist/extraction/languages/index.d.ts.map +1 -1
  66. package/lib/dist/extraction/languages/index.js +2 -0
  67. package/lib/dist/extraction/languages/index.js.map +1 -1
  68. package/lib/dist/extraction/languages/java.d.ts.map +1 -1
  69. package/lib/dist/extraction/languages/java.js +42 -1
  70. package/lib/dist/extraction/languages/java.js.map +1 -1
  71. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
  72. package/lib/dist/extraction/languages/javascript.js +16 -0
  73. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  74. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  75. package/lib/dist/extraction/languages/kotlin.js +69 -0
  76. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  77. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  78. package/lib/dist/extraction/languages/objc.js +42 -0
  79. package/lib/dist/extraction/languages/objc.js.map +1 -1
  80. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
  81. package/lib/dist/extraction/languages/pascal.js +11 -0
  82. package/lib/dist/extraction/languages/pascal.js.map +1 -1
  83. package/lib/dist/extraction/languages/php.d.ts.map +1 -1
  84. package/lib/dist/extraction/languages/php.js +90 -1
  85. package/lib/dist/extraction/languages/php.js.map +1 -1
  86. package/lib/dist/extraction/languages/r.d.ts +3 -0
  87. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  88. package/lib/dist/extraction/languages/r.js +314 -0
  89. package/lib/dist/extraction/languages/r.js.map +1 -0
  90. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
  91. package/lib/dist/extraction/languages/ruby.js +35 -0
  92. package/lib/dist/extraction/languages/ruby.js.map +1 -1
  93. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  94. package/lib/dist/extraction/languages/rust.js +35 -2
  95. package/lib/dist/extraction/languages/rust.js.map +1 -1
  96. package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
  97. package/lib/dist/extraction/languages/scala.js +61 -1
  98. package/lib/dist/extraction/languages/scala.js.map +1 -1
  99. package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
  100. package/lib/dist/extraction/languages/swift.js +61 -0
  101. package/lib/dist/extraction/languages/swift.js.map +1 -1
  102. package/lib/dist/extraction/languages/typescript.d.ts +13 -0
  103. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  104. package/lib/dist/extraction/languages/typescript.js +38 -0
  105. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  106. package/lib/dist/extraction/liquid-extractor.d.ts +7 -0
  107. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  108. package/lib/dist/extraction/liquid-extractor.js +53 -9
  109. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  110. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  111. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  112. package/lib/dist/extraction/razor-extractor.js +285 -0
  113. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  114. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  115. package/lib/dist/extraction/svelte-extractor.js +6 -3
  116. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  117. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  118. package/lib/dist/extraction/tree-sitter-helpers.js +59 -10
  119. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  120. package/lib/dist/extraction/tree-sitter-types.d.ts +33 -0
  121. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  122. package/lib/dist/extraction/tree-sitter.d.ts +211 -0
  123. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  124. package/lib/dist/extraction/tree-sitter.js +1681 -49
  125. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  126. package/lib/dist/extraction/vue-extractor.d.ts +15 -0
  127. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  128. package/lib/dist/extraction/vue-extractor.js +94 -3
  129. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  130. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  131. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  132. package/lib/dist/graph/queries.d.ts.map +1 -1
  133. package/lib/dist/graph/queries.js +13 -40
  134. package/lib/dist/graph/queries.js.map +1 -1
  135. package/lib/dist/graph/traversal.d.ts.map +1 -1
  136. package/lib/dist/graph/traversal.js +16 -4
  137. package/lib/dist/graph/traversal.js.map +1 -1
  138. package/lib/dist/index.d.ts +34 -2
  139. package/lib/dist/index.d.ts.map +1 -1
  140. package/lib/dist/index.js +90 -8
  141. package/lib/dist/index.js.map +1 -1
  142. package/lib/dist/installer/index.d.ts.map +1 -1
  143. package/lib/dist/installer/index.js +52 -2
  144. package/lib/dist/installer/index.js.map +1 -1
  145. package/lib/dist/installer/instructions-template.d.ts +34 -11
  146. package/lib/dist/installer/instructions-template.d.ts.map +1 -1
  147. package/lib/dist/installer/instructions-template.js +44 -12
  148. package/lib/dist/installer/instructions-template.js.map +1 -1
  149. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  150. package/lib/dist/installer/targets/claude.js +6 -10
  151. package/lib/dist/installer/targets/claude.js.map +1 -1
  152. package/lib/dist/installer/targets/codex.js +4 -6
  153. package/lib/dist/installer/targets/codex.js.map +1 -1
  154. package/lib/dist/installer/targets/gemini.js +4 -6
  155. package/lib/dist/installer/targets/gemini.js.map +1 -1
  156. package/lib/dist/installer/targets/opencode.d.ts +9 -1
  157. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  158. package/lib/dist/installer/targets/opencode.js +91 -40
  159. package/lib/dist/installer/targets/opencode.js.map +1 -1
  160. package/lib/dist/installer/targets/shared.d.ts +14 -0
  161. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  162. package/lib/dist/installer/targets/shared.js +16 -0
  163. package/lib/dist/installer/targets/shared.js.map +1 -1
  164. package/lib/dist/mcp/daemon.d.ts +60 -1
  165. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  166. package/lib/dist/mcp/daemon.js +221 -8
  167. package/lib/dist/mcp/daemon.js.map +1 -1
  168. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  169. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  170. package/lib/dist/mcp/dynamic-boundaries.js +359 -0
  171. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  172. package/lib/dist/mcp/index.d.ts.map +1 -1
  173. package/lib/dist/mcp/index.js +18 -9
  174. package/lib/dist/mcp/index.js.map +1 -1
  175. package/lib/dist/mcp/ppid-watchdog.d.ts +44 -0
  176. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  177. package/lib/dist/mcp/ppid-watchdog.js +27 -0
  178. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  179. package/lib/dist/mcp/proxy.d.ts +6 -0
  180. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  181. package/lib/dist/mcp/proxy.js +153 -24
  182. package/lib/dist/mcp/proxy.js.map +1 -1
  183. package/lib/dist/mcp/server-instructions.d.ts +12 -1
  184. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  185. package/lib/dist/mcp/server-instructions.js +43 -16
  186. package/lib/dist/mcp/server-instructions.js.map +1 -1
  187. package/lib/dist/mcp/session.d.ts +2 -0
  188. package/lib/dist/mcp/session.d.ts.map +1 -1
  189. package/lib/dist/mcp/session.js +49 -2
  190. package/lib/dist/mcp/session.js.map +1 -1
  191. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  192. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  193. package/lib/dist/mcp/stdin-teardown.js +49 -0
  194. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  195. package/lib/dist/mcp/tools.d.ts +71 -0
  196. package/lib/dist/mcp/tools.d.ts.map +1 -1
  197. package/lib/dist/mcp/tools.js +703 -85
  198. package/lib/dist/mcp/tools.js.map +1 -1
  199. package/lib/dist/mcp/transport.d.ts.map +1 -1
  200. package/lib/dist/mcp/transport.js +18 -2
  201. package/lib/dist/mcp/transport.js.map +1 -1
  202. package/lib/dist/resolution/callback-synthesizer.d.ts +3 -3
  203. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  204. package/lib/dist/resolution/callback-synthesizer.js +549 -21
  205. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  206. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  207. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  208. package/lib/dist/resolution/frameworks/astro.js +169 -0
  209. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  210. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  211. package/lib/dist/resolution/frameworks/expo-modules.js +6 -1
  212. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  213. package/lib/dist/resolution/frameworks/index.d.ts +1 -0
  214. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  215. package/lib/dist/resolution/frameworks/index.js +5 -1
  216. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  217. package/lib/dist/resolution/frameworks/java.js +6 -1
  218. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  219. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  220. package/lib/dist/resolution/frameworks/python.js +7 -3
  221. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  222. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  223. package/lib/dist/resolution/frameworks/react-native.js +53 -3
  224. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  225. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  226. package/lib/dist/resolution/frameworks/react.js +15 -3
  227. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  228. package/lib/dist/resolution/frameworks/svelte.js +5 -1
  229. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  230. package/lib/dist/resolution/frameworks/vue.js +24 -27
  231. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  232. package/lib/dist/resolution/import-resolver.d.ts +10 -0
  233. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  234. package/lib/dist/resolution/import-resolver.js +564 -2
  235. package/lib/dist/resolution/import-resolver.js.map +1 -1
  236. package/lib/dist/resolution/index.d.ts +80 -0
  237. package/lib/dist/resolution/index.d.ts.map +1 -1
  238. package/lib/dist/resolution/index.js +457 -7
  239. package/lib/dist/resolution/index.js.map +1 -1
  240. package/lib/dist/resolution/name-matcher.d.ts +61 -0
  241. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  242. package/lib/dist/resolution/name-matcher.js +590 -14
  243. package/lib/dist/resolution/name-matcher.js.map +1 -1
  244. package/lib/dist/resolution/types.d.ts +27 -3
  245. package/lib/dist/resolution/types.d.ts.map +1 -1
  246. package/lib/dist/resolution/workspace-packages.d.ts +48 -0
  247. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  248. package/lib/dist/resolution/workspace-packages.js +208 -0
  249. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  250. package/lib/dist/search/query-utils.d.ts +17 -1
  251. package/lib/dist/search/query-utils.d.ts.map +1 -1
  252. package/lib/dist/search/query-utils.js +79 -10
  253. package/lib/dist/search/query-utils.js.map +1 -1
  254. package/lib/dist/sync/watcher.d.ts +124 -32
  255. package/lib/dist/sync/watcher.d.ts.map +1 -1
  256. package/lib/dist/sync/watcher.js +326 -111
  257. package/lib/dist/sync/watcher.js.map +1 -1
  258. package/lib/dist/telemetry/index.d.ts +146 -0
  259. package/lib/dist/telemetry/index.d.ts.map +1 -0
  260. package/lib/dist/telemetry/index.js +544 -0
  261. package/lib/dist/telemetry/index.js.map +1 -0
  262. package/lib/dist/types.d.ts +17 -2
  263. package/lib/dist/types.d.ts.map +1 -1
  264. package/lib/dist/types.js +3 -0
  265. package/lib/dist/types.js.map +1 -1
  266. package/lib/dist/upgrade/index.d.ts +132 -0
  267. package/lib/dist/upgrade/index.d.ts.map +1 -0
  268. package/lib/dist/upgrade/index.js +462 -0
  269. package/lib/dist/upgrade/index.js.map +1 -0
  270. package/lib/dist/utils.d.ts +30 -24
  271. package/lib/dist/utils.d.ts.map +1 -1
  272. package/lib/dist/utils.js +64 -48
  273. package/lib/dist/utils.js.map +1 -1
  274. package/lib/node_modules/.package-lock.json +1 -29
  275. package/lib/package.json +1 -2
  276. package/package.json +1 -1
  277. package/lib/node_modules/chokidar/LICENSE +0 -21
  278. package/lib/node_modules/chokidar/README.md +0 -305
  279. package/lib/node_modules/chokidar/esm/handler.d.ts +0 -90
  280. package/lib/node_modules/chokidar/esm/handler.js +0 -629
  281. package/lib/node_modules/chokidar/esm/index.d.ts +0 -215
  282. package/lib/node_modules/chokidar/esm/index.js +0 -798
  283. package/lib/node_modules/chokidar/esm/package.json +0 -1
  284. package/lib/node_modules/chokidar/handler.d.ts +0 -90
  285. package/lib/node_modules/chokidar/handler.js +0 -635
  286. package/lib/node_modules/chokidar/index.d.ts +0 -215
  287. package/lib/node_modules/chokidar/index.js +0 -804
  288. package/lib/node_modules/chokidar/package.json +0 -69
  289. package/lib/node_modules/readdirp/LICENSE +0 -21
  290. package/lib/node_modules/readdirp/README.md +0 -120
  291. package/lib/node_modules/readdirp/esm/index.d.ts +0 -108
  292. package/lib/node_modules/readdirp/esm/index.js +0 -257
  293. package/lib/node_modules/readdirp/esm/package.json +0 -1
  294. package/lib/node_modules/readdirp/index.d.ts +0 -108
  295. package/lib/node_modules/readdirp/index.js +0 -263
  296. 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;
@@ -65,6 +66,8 @@ 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");
67
68
  const wasm_runtime_flags_1 = require("../extraction/wasm-runtime-flags");
69
+ const extraction_version_1 = require("../extraction/extraction-version");
70
+ const telemetry_1 = require("../telemetry");
68
71
  // Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast.
69
72
  async function loadCodeGraph() {
70
73
  try {
@@ -166,6 +169,30 @@ function main() {
166
169
  .name('codegraph')
167
170
  .description('Code intelligence and knowledge graph for any codebase')
168
171
  .version(packageJson.version);
172
+ // Anonymous usage telemetry (see TELEMETRY.md): record the invoked subcommand
173
+ // NAME only — never arguments or paths. Counts buffer locally; network sends
174
+ // piggyback on commands that run long anyway (quick commands only append to
175
+ // the local buffer at exit, costing nothing).
176
+ // install/uninstall are absent on purpose: the installer flushes at its own
177
+ // end, AFTER its consent prompt — a flush here would fire the first-run
178
+ // notice before the user ever sees the toggle.
179
+ const TELEMETRY_FLUSH_COMMANDS = new Set(['init', 'uninit', 'index', 'sync', 'upgrade']);
180
+ program.hook('preAction', (_thisCommand, actionCommand) => {
181
+ try {
182
+ // The detached daemon re-invokes `serve --mcp` internally — not a user action.
183
+ if (process.env.CODEGRAPH_DAEMON_INTERNAL)
184
+ return;
185
+ const name = actionCommand.name();
186
+ if (name === 'telemetry')
187
+ return; // managing telemetry is not usage
188
+ (0, telemetry_1.getTelemetry)().recordUsage('cli_command', name, true);
189
+ if (TELEMETRY_FLUSH_COMMANDS.has(name))
190
+ (0, telemetry_1.getTelemetry)().maybeFlush();
191
+ }
192
+ catch {
193
+ /* telemetry must never break the CLI */
194
+ }
195
+ });
169
196
  // =============================================================================
170
197
  // Helper Functions
171
198
  // =============================================================================
@@ -339,7 +366,7 @@ function main() {
339
366
  }
340
367
  }
341
368
  else if (projectPath) {
342
- const logPath = path.join(projectPath, '.codegraph', 'errors.log');
369
+ const logPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'errors.log');
343
370
  if (fs.existsSync(logPath)) {
344
371
  fs.unlinkSync(logPath);
345
372
  }
@@ -349,7 +376,7 @@ function main() {
349
376
  * Write detailed error log to .codegraph/errors.log
350
377
  */
351
378
  function writeErrorLog(projectPath, errors) {
352
- const cgDir = path.join(projectPath, '.codegraph');
379
+ const cgDir = (0, directory_1.getCodeGraphDir)(projectPath);
353
380
  if (!fs.existsSync(cgDir))
354
381
  return;
355
382
  const logPath = path.join(cgDir, 'errors.log');
@@ -386,6 +413,15 @@ function main() {
386
413
  }
387
414
  fs.writeFileSync(logPath, lines.join('\n') + '\n');
388
415
  }
416
+ /**
417
+ * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush
418
+ * keeps init/index responsive (these commands just ran for seconds anyway)
419
+ * while delivering the event promptly.
420
+ */
421
+ async function recordIndexTelemetry(cg, result) {
422
+ (0, telemetry_1.recordIndexEvent)(cg, result);
423
+ await (0, telemetry_1.getTelemetry)().flushNow();
424
+ }
389
425
  // =============================================================================
390
426
  // Commands
391
427
  // =============================================================================
@@ -435,6 +471,7 @@ function main() {
435
471
  await progress.stop();
436
472
  }
437
473
  printIndexResult(clack, result, projectPath);
474
+ await recordIndexTelemetry(cg, result);
438
475
  try {
439
476
  const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
440
477
  await offerWatchFallback(clack, projectPath);
@@ -488,6 +525,13 @@ function main() {
488
525
  }
489
526
  catch { /* non-fatal */ }
490
527
  success(`Removed CodeGraph from ${projectPath}`);
528
+ // Churn signal — and flush now, since after an uninit there may be no
529
+ // "next run" to deliver it.
530
+ try {
531
+ (0, telemetry_1.getTelemetry)().recordLifecycle('uninstall', {});
532
+ await (0, telemetry_1.getTelemetry)().flushNow();
533
+ }
534
+ catch { /* non-fatal */ }
491
535
  }
492
536
  catch (err) {
493
537
  error(`Failed to uninitialize: ${err instanceof Error ? err.message : String(err)}`);
@@ -545,6 +589,7 @@ function main() {
545
589
  await progress.stop();
546
590
  }
547
591
  printIndexResult(clack, result, projectPath);
592
+ await recordIndexTelemetry(cg, result);
548
593
  if (!result.success) {
549
594
  process.exit(1);
550
595
  }
@@ -629,7 +674,13 @@ function main() {
629
674
  try {
630
675
  if (!(0, directory_1.isInitialized)(projectPath)) {
631
676
  if (options.json) {
632
- console.log(JSON.stringify({ initialized: false, projectPath }));
677
+ console.log(JSON.stringify({
678
+ initialized: false,
679
+ version: packageJson.version,
680
+ projectPath,
681
+ indexPath: (0, directory_1.getCodeGraphDir)(projectPath),
682
+ lastIndexed: null,
683
+ }));
633
684
  return;
634
685
  }
635
686
  console.log(chalk.bold('\nCodeGraph Status\n'));
@@ -644,11 +695,17 @@ function main() {
644
695
  const changes = cg.getChangedFiles();
645
696
  const backend = cg.getBackend();
646
697
  const journalMode = cg.getJournalMode();
698
+ const buildInfo = cg.getIndexBuildInfo();
699
+ const reindexRecommended = cg.isIndexStale();
647
700
  // JSON output mode
648
701
  if (options.json) {
702
+ const lastIndexedMs = cg.getLastIndexedAt();
649
703
  console.log(JSON.stringify({
650
704
  initialized: true,
705
+ version: packageJson.version,
651
706
  projectPath,
707
+ indexPath: (0, directory_1.getCodeGraphDir)(projectPath),
708
+ lastIndexed: lastIndexedMs != null ? new Date(lastIndexedMs).toISOString() : null,
652
709
  fileCount: stats.fileCount,
653
710
  nodeCount: stats.nodeCount,
654
711
  edgeCount: stats.edgeCount,
@@ -665,6 +722,12 @@ function main() {
665
722
  worktreeMismatch: worktreeMismatch
666
723
  ? { worktreeRoot: worktreeMismatch.worktreeRoot, indexRoot: worktreeMismatch.indexRoot }
667
724
  : null,
725
+ index: {
726
+ builtWithVersion: buildInfo.version,
727
+ builtWithExtractionVersion: buildInfo.extractionVersion,
728
+ currentExtractionVersion: extraction_version_1.EXTRACTION_VERSION,
729
+ reindexRecommended,
730
+ },
668
731
  }));
669
732
  cg.destroy();
670
733
  return;
@@ -732,6 +795,14 @@ function main() {
732
795
  success('Index is up to date');
733
796
  }
734
797
  console.log();
798
+ // Re-index hint: the index was built by an older engine than the one now
799
+ // running, so a rebuild would add data a migration can't backfill.
800
+ if (reindexRecommended) {
801
+ const builtWith = buildInfo.version ? `v${buildInfo.version.replace(/^v/, '')}` : 'an earlier version';
802
+ warn(`Index was built by ${builtWith}; re-index to pick up this engine's improvements.`);
803
+ info('Run "codegraph index -f" (full rebuild) or "codegraph sync"');
804
+ console.log();
805
+ }
735
806
  cg.destroy();
736
807
  }
737
808
  catch (err) {
@@ -803,6 +874,106 @@ function main() {
803
874
  process.exit(1);
804
875
  }
805
876
  });
877
+ /**
878
+ * codegraph explore <query...>
879
+ *
880
+ * The CLI face of the MCP codegraph_explore tool — same handler, same
881
+ * output (source of the relevant symbols grouped by file + the call path
882
+ * among them). Exists so agents WITHOUT the MCP tools — Task-tool
883
+ * subagents (which don't inherit MCP tools, #704) and non-MCP harnesses —
884
+ * can reach the graph through a plain shell command.
885
+ */
886
+ program
887
+ .command('explore <query...>')
888
+ .description('Explore an area: relevant symbols\' source + call paths in one shot (same output as the codegraph_explore MCP tool)')
889
+ .option('-p, --path <path>', 'Project path')
890
+ .option('--max-files <number>', 'Maximum number of files to include source from')
891
+ .action(async (queryParts, options) => {
892
+ const projectPath = resolveProjectPath(options.path);
893
+ try {
894
+ if (!(0, directory_1.isInitialized)(projectPath)) {
895
+ 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'.)`);
896
+ process.exit(1);
897
+ }
898
+ const { default: CodeGraph } = await loadCodeGraph();
899
+ const cg = await CodeGraph.open(projectPath);
900
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
901
+ const handler = new ToolHandler(cg);
902
+ const args = { query: queryParts.join(' ') };
903
+ if (options.maxFiles)
904
+ args.maxFiles = parseInt(options.maxFiles, 10);
905
+ const result = await handler.execute('codegraph_explore', args);
906
+ console.log(result.content[0]?.text ?? '');
907
+ cg.destroy();
908
+ if (result.isError)
909
+ process.exit(1);
910
+ }
911
+ catch (err) {
912
+ error(`Explore failed: ${err instanceof Error ? err.message : String(err)}`);
913
+ process.exit(1);
914
+ }
915
+ });
916
+ /**
917
+ * codegraph node <name>
918
+ *
919
+ * The CLI face of the MCP codegraph_node tool: one symbol's source +
920
+ * caller/callee trail, or a whole file with line numbers + dependents
921
+ * (Read-parity). Same subagent/non-MCP rationale as `explore`.
922
+ */
923
+ program
924
+ .command('node <name>')
925
+ .description('One symbol\'s source + caller/callee trail, or read a file with line numbers + dependents (same output as the codegraph_node MCP tool)')
926
+ .option('-p, --path <path>', 'Project path')
927
+ .option('-f, --file <file>', 'Treat as file mode (or disambiguate a symbol to this file)')
928
+ .option('--offset <number>', 'File mode: 1-based start line')
929
+ .option('--limit <number>', 'File mode: maximum lines')
930
+ .option('--symbols-only', 'File mode: just the symbol map + dependents')
931
+ .action(async (name, options) => {
932
+ const projectPath = resolveProjectPath(options.path);
933
+ try {
934
+ if (!(0, directory_1.isInitialized)(projectPath)) {
935
+ 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'.)`);
936
+ process.exit(1);
937
+ }
938
+ const { default: CodeGraph } = await loadCodeGraph();
939
+ const cg = await CodeGraph.open(projectPath);
940
+ const { ToolHandler } = await Promise.resolve().then(() => __importStar(require('../mcp/tools')));
941
+ const handler = new ToolHandler(cg);
942
+ // A name with a path separator is a file read; otherwise a symbol
943
+ // (use --file for basename-only file reads or to pin an overload).
944
+ // Both separators: Windows users type src\auth\session.ts. Symbols
945
+ // never contain either ('/' isn't an identifier char anywhere we
946
+ // index; C++ scope is '::', JS members '.').
947
+ const args = {};
948
+ if (options.file) {
949
+ args.file = options.file;
950
+ if (name && name !== options.file)
951
+ args.symbol = name;
952
+ }
953
+ else if (name.includes('/') || name.includes('\\')) {
954
+ args.file = name.replace(/\\/g, '/');
955
+ }
956
+ else {
957
+ args.symbol = name;
958
+ args.includeCode = true;
959
+ }
960
+ if (options.offset)
961
+ args.offset = parseInt(options.offset, 10);
962
+ if (options.limit)
963
+ args.limit = parseInt(options.limit, 10);
964
+ if (options.symbolsOnly)
965
+ args.symbolsOnly = true;
966
+ const result = await handler.execute('codegraph_node', args);
967
+ console.log(result.content[0]?.text ?? '');
968
+ cg.destroy();
969
+ if (result.isError)
970
+ process.exit(1);
971
+ }
972
+ catch (err) {
973
+ error(`Node lookup failed: ${err instanceof Error ? err.message : String(err)}`);
974
+ process.exit(1);
975
+ }
976
+ });
806
977
  /**
807
978
  * codegraph files [path]
808
979
  */
@@ -1505,6 +1676,78 @@ function main() {
1505
1676
  process.exit(1);
1506
1677
  }
1507
1678
  });
1679
+ /**
1680
+ * codegraph telemetry [on|off|status]
1681
+ */
1682
+ program
1683
+ .command('telemetry [action]')
1684
+ .description('Show or change anonymous usage telemetry (status, on, off)')
1685
+ .action((action) => {
1686
+ const t = (0, telemetry_1.getTelemetry)();
1687
+ if (action === 'on' || action === 'off') {
1688
+ t.setEnabled(action === 'on', 'cli');
1689
+ if (action === 'on') {
1690
+ success('Telemetry enabled — anonymous usage stats only (no code, paths, or names).');
1691
+ }
1692
+ else {
1693
+ success('Telemetry disabled. Buffered, unsent data was deleted.');
1694
+ }
1695
+ const effective = t.getStatus();
1696
+ if (effective.decidedBy === 'DO_NOT_TRACK' || effective.decidedBy === 'CODEGRAPH_TELEMETRY') {
1697
+ warn(`The ${effective.decidedBy} environment variable overrides this choice — ` +
1698
+ `effective state right now: ${effective.enabled ? 'enabled' : 'disabled'}.`);
1699
+ }
1700
+ return;
1701
+ }
1702
+ if (action !== undefined && action !== 'status') {
1703
+ error(`Unknown action: ${action} (expected status, on, or off)`);
1704
+ process.exit(1);
1705
+ }
1706
+ const s = t.getStatus();
1707
+ const decidedBy = {
1708
+ DO_NOT_TRACK: 'DO_NOT_TRACK environment variable',
1709
+ CODEGRAPH_TELEMETRY: 'CODEGRAPH_TELEMETRY environment variable',
1710
+ config: 'your saved choice',
1711
+ default: 'default',
1712
+ };
1713
+ console.log(`\nTelemetry: ${s.enabled ? chalk.green('enabled') : chalk.yellow('disabled')} ${chalk.dim(`(${decidedBy[s.decidedBy]})`)}`);
1714
+ console.log(`Machine ID: ${s.machineId ?? chalk.dim('(random UUID, created on first use)')}`);
1715
+ console.log(`Config: ${s.configPath}`);
1716
+ console.log(chalk.dim(`\nExactly what is collected (and never collected): ${telemetry_1.TELEMETRY_DOCS}\n`));
1717
+ });
1718
+ /**
1719
+ * codegraph upgrade [version]
1720
+ *
1721
+ * Self-update, however CodeGraph was installed (bundle via install.sh/.ps1,
1722
+ * npm-global, npx, or a source checkout). See ../upgrade for the detection and
1723
+ * per-method upgrade logic.
1724
+ */
1725
+ program
1726
+ .command('upgrade [version]')
1727
+ .description('Update CodeGraph to the latest release (or a specific version)')
1728
+ .option('--check', 'Check whether an update is available without installing')
1729
+ .option('-f, --force', 'Reinstall even if already on the target version')
1730
+ .action(async (versionArg, options) => {
1731
+ const up = await Promise.resolve().then(() => __importStar(require('../upgrade')));
1732
+ const method = up.detectInstallMethod({
1733
+ filename: __filename,
1734
+ platform: process.platform,
1735
+ cwd: process.cwd(),
1736
+ });
1737
+ const pin = versionArg || process.env.CODEGRAPH_VERSION || undefined;
1738
+ const code = await up.runUpgrade({ version: pin, check: options.check, force: options.force }, {
1739
+ currentVersion: packageJson.version,
1740
+ method,
1741
+ resolveLatest: () => up.resolveLatestVersion(),
1742
+ run: up.defaultRun,
1743
+ hasCommand: up.hasCommand,
1744
+ log: (m) => console.log(m),
1745
+ warn: (m) => warn(m),
1746
+ error: (m) => error(m),
1747
+ platform: process.platform,
1748
+ });
1749
+ process.exit(code);
1750
+ });
1508
1751
  // Parse and run
1509
1752
  program.parse();
1510
1753
  } // end main()