@colbymchenry/codegraph-win32-arm64 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/lib/dist/bin/codegraph.js +145 -29
  2. package/lib/dist/bin/codegraph.js.map +1 -1
  3. package/lib/dist/context/formatter.d.ts +7 -1
  4. package/lib/dist/context/formatter.d.ts.map +1 -1
  5. package/lib/dist/context/formatter.js +12 -6
  6. package/lib/dist/context/formatter.js.map +1 -1
  7. package/lib/dist/context/index.d.ts +12 -0
  8. package/lib/dist/context/index.d.ts.map +1 -1
  9. package/lib/dist/context/index.js +60 -14
  10. package/lib/dist/context/index.js.map +1 -1
  11. package/lib/dist/db/index.d.ts +37 -0
  12. package/lib/dist/db/index.d.ts.map +1 -1
  13. package/lib/dist/db/index.js +101 -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 +25 -1
  18. package/lib/dist/db/migrations.js.map +1 -1
  19. package/lib/dist/db/queries.d.ts +160 -3
  20. package/lib/dist/db/queries.d.ts.map +1 -1
  21. package/lib/dist/db/queries.js +400 -33
  22. package/lib/dist/db/queries.js.map +1 -1
  23. package/lib/dist/db/schema.sql +16 -3
  24. package/lib/dist/directory.d.ts +29 -0
  25. package/lib/dist/directory.d.ts.map +1 -1
  26. package/lib/dist/directory.js +52 -0
  27. package/lib/dist/directory.js.map +1 -1
  28. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  29. package/lib/dist/extraction/extraction-version.js +1 -1
  30. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  31. package/lib/dist/extraction/function-ref.js +6 -0
  32. package/lib/dist/extraction/function-ref.js.map +1 -1
  33. package/lib/dist/extraction/generated-detection.d.ts +48 -12
  34. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  35. package/lib/dist/extraction/generated-detection.js +176 -11
  36. package/lib/dist/extraction/generated-detection.js.map +1 -1
  37. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  38. package/lib/dist/extraction/grammars.js +38 -2
  39. package/lib/dist/extraction/grammars.js.map +1 -1
  40. package/lib/dist/extraction/index.d.ts +106 -0
  41. package/lib/dist/extraction/index.d.ts.map +1 -1
  42. package/lib/dist/extraction/index.js +284 -53
  43. package/lib/dist/extraction/index.js.map +1 -1
  44. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  45. package/lib/dist/extraction/languages/c-cpp.js +19 -4
  46. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  47. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -1
  48. package/lib/dist/extraction/languages/erlang.js +58 -22
  49. package/lib/dist/extraction/languages/erlang.js.map +1 -1
  50. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  51. package/lib/dist/extraction/languages/objc.js +4 -0
  52. package/lib/dist/extraction/languages/objc.js.map +1 -1
  53. package/lib/dist/extraction/languages/rust.d.ts +20 -0
  54. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  55. package/lib/dist/extraction/languages/rust.js +47 -20
  56. package/lib/dist/extraction/languages/rust.js.map +1 -1
  57. package/lib/dist/extraction/parse-pool.d.ts +7 -0
  58. package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
  59. package/lib/dist/extraction/parse-pool.js +20 -1
  60. package/lib/dist/extraction/parse-pool.js.map +1 -1
  61. package/lib/dist/extraction/tree-sitter-types.d.ts +2 -0
  62. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  63. package/lib/dist/extraction/tree-sitter.d.ts +5 -1
  64. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  65. package/lib/dist/extraction/tree-sitter.js +106 -50
  66. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  67. package/lib/dist/graph/queries.d.ts.map +1 -1
  68. package/lib/dist/graph/queries.js +2 -0
  69. package/lib/dist/graph/queries.js.map +1 -1
  70. package/lib/dist/graph/traversal.js +1 -1
  71. package/lib/dist/graph/traversal.js.map +1 -1
  72. package/lib/dist/index.d.ts +22 -0
  73. package/lib/dist/index.d.ts.map +1 -1
  74. package/lib/dist/index.js +117 -1
  75. package/lib/dist/index.js.map +1 -1
  76. package/lib/dist/installer/index.d.ts +4 -3
  77. package/lib/dist/installer/index.d.ts.map +1 -1
  78. package/lib/dist/installer/index.js +8 -6
  79. package/lib/dist/installer/index.js.map +1 -1
  80. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  81. package/lib/dist/installer/targets/claude.js +37 -5
  82. package/lib/dist/installer/targets/claude.js.map +1 -1
  83. package/lib/dist/installer/targets/codex.d.ts +22 -8
  84. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  85. package/lib/dist/installer/targets/codex.js +65 -48
  86. package/lib/dist/installer/targets/codex.js.map +1 -1
  87. package/lib/dist/installer/targets/copilot-cli.d.ts +32 -0
  88. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  89. package/lib/dist/installer/targets/copilot-cli.js +209 -0
  90. package/lib/dist/installer/targets/copilot-cli.js.map +1 -0
  91. package/lib/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  92. package/lib/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  93. package/lib/dist/installer/targets/copilot-jetbrains.js +238 -0
  94. package/lib/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  95. package/lib/dist/installer/targets/copilot-vscode.d.ts +47 -0
  96. package/lib/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  97. package/lib/dist/installer/targets/copilot-vscode.js +219 -0
  98. package/lib/dist/installer/targets/copilot-vscode.js.map +1 -0
  99. package/lib/dist/installer/targets/registry.d.ts.map +1 -1
  100. package/lib/dist/installer/targets/registry.js +6 -0
  101. package/lib/dist/installer/targets/registry.js.map +1 -1
  102. package/lib/dist/installer/targets/toml.d.ts +6 -5
  103. package/lib/dist/installer/targets/toml.d.ts.map +1 -1
  104. package/lib/dist/installer/targets/toml.js +99 -20
  105. package/lib/dist/installer/targets/toml.js.map +1 -1
  106. package/lib/dist/installer/targets/types.d.ts +5 -5
  107. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  108. package/lib/dist/mcp/daemon-manager.d.ts +1 -1
  109. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
  110. package/lib/dist/mcp/daemon-manager.js +1 -1
  111. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  112. package/lib/dist/mcp/daemon-paths.d.ts +6 -0
  113. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  114. package/lib/dist/mcp/daemon-paths.js +54 -0
  115. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  116. package/lib/dist/mcp/daemon-registry.d.ts +10 -0
  117. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  118. package/lib/dist/mcp/daemon-registry.js +51 -3
  119. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  120. package/lib/dist/mcp/daemon.d.ts +9 -6
  121. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  122. package/lib/dist/mcp/daemon.js +10 -8
  123. package/lib/dist/mcp/daemon.js.map +1 -1
  124. package/lib/dist/mcp/engine.d.ts +3 -0
  125. package/lib/dist/mcp/engine.d.ts.map +1 -1
  126. package/lib/dist/mcp/engine.js +45 -3
  127. package/lib/dist/mcp/engine.js.map +1 -1
  128. package/lib/dist/mcp/explore-dedup.d.ts +137 -0
  129. package/lib/dist/mcp/explore-dedup.d.ts.map +1 -0
  130. package/lib/dist/mcp/explore-dedup.js +236 -0
  131. package/lib/dist/mcp/explore-dedup.js.map +1 -0
  132. package/lib/dist/mcp/explore-diagnostics.d.ts +289 -0
  133. package/lib/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  134. package/lib/dist/mcp/explore-diagnostics.js +558 -0
  135. package/lib/dist/mcp/explore-diagnostics.js.map +1 -0
  136. package/lib/dist/mcp/explore-session-state.d.ts +217 -0
  137. package/lib/dist/mcp/explore-session-state.d.ts.map +1 -0
  138. package/lib/dist/mcp/explore-session-state.js +322 -0
  139. package/lib/dist/mcp/explore-session-state.js.map +1 -0
  140. package/lib/dist/mcp/index.d.ts +24 -0
  141. package/lib/dist/mcp/index.d.ts.map +1 -1
  142. package/lib/dist/mcp/index.js +67 -6
  143. package/lib/dist/mcp/index.js.map +1 -1
  144. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  145. package/lib/dist/mcp/liveness-watchdog.js +3 -1
  146. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  147. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  148. package/lib/dist/mcp/proxy.js +6 -1
  149. package/lib/dist/mcp/proxy.js.map +1 -1
  150. package/lib/dist/mcp/server-instructions.d.ts +2 -2
  151. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  152. package/lib/dist/mcp/server-instructions.js +8 -3
  153. package/lib/dist/mcp/server-instructions.js.map +1 -1
  154. package/lib/dist/mcp/session.d.ts +16 -0
  155. package/lib/dist/mcp/session.d.ts.map +1 -1
  156. package/lib/dist/mcp/session.js +36 -13
  157. package/lib/dist/mcp/session.js.map +1 -1
  158. package/lib/dist/mcp/tools.d.ts +276 -10
  159. package/lib/dist/mcp/tools.d.ts.map +1 -1
  160. package/lib/dist/mcp/tools.js +2402 -241
  161. package/lib/dist/mcp/tools.js.map +1 -1
  162. package/lib/dist/project-config.d.ts +23 -0
  163. package/lib/dist/project-config.d.ts.map +1 -1
  164. package/lib/dist/project-config.js +39 -2
  165. package/lib/dist/project-config.js.map +1 -1
  166. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  167. package/lib/dist/resolution/c-fnptr-synthesizer.js +21 -19
  168. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  169. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  170. package/lib/dist/resolution/callback-synthesizer.js +39 -11
  171. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  172. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
  173. package/lib/dist/resolution/frameworks/swift.js +11 -1
  174. package/lib/dist/resolution/frameworks/swift.js.map +1 -1
  175. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  176. package/lib/dist/resolution/import-resolver.js +18 -2
  177. package/lib/dist/resolution/import-resolver.js.map +1 -1
  178. package/lib/dist/resolution/index.d.ts.map +1 -1
  179. package/lib/dist/resolution/index.js +15 -4
  180. package/lib/dist/resolution/index.js.map +1 -1
  181. package/lib/dist/resolution/name-matcher.d.ts +30 -0
  182. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  183. package/lib/dist/resolution/name-matcher.js +295 -5
  184. package/lib/dist/resolution/name-matcher.js.map +1 -1
  185. package/lib/dist/resolution/path-aliases.d.ts +6 -4
  186. package/lib/dist/resolution/path-aliases.d.ts.map +1 -1
  187. package/lib/dist/resolution/path-aliases.js +125 -17
  188. package/lib/dist/resolution/path-aliases.js.map +1 -1
  189. package/lib/dist/search/identifier-segments.d.ts +10 -0
  190. package/lib/dist/search/identifier-segments.d.ts.map +1 -1
  191. package/lib/dist/search/identifier-segments.js +29 -0
  192. package/lib/dist/search/identifier-segments.js.map +1 -1
  193. package/lib/dist/search/query-paths.d.ts +57 -0
  194. package/lib/dist/search/query-paths.d.ts.map +1 -0
  195. package/lib/dist/search/query-paths.js +298 -0
  196. package/lib/dist/search/query-paths.js.map +1 -0
  197. package/lib/dist/search/query-utils.d.ts +1 -1
  198. package/lib/dist/search/query-utils.d.ts.map +1 -1
  199. package/lib/dist/search/query-utils.js +13 -3
  200. package/lib/dist/search/query-utils.js.map +1 -1
  201. package/lib/dist/sync/watcher.d.ts +22 -0
  202. package/lib/dist/sync/watcher.d.ts.map +1 -1
  203. package/lib/dist/sync/watcher.js +51 -5
  204. package/lib/dist/sync/watcher.js.map +1 -1
  205. package/lib/dist/types.d.ts +20 -1
  206. package/lib/dist/types.d.ts.map +1 -1
  207. package/lib/dist/types.js +1 -0
  208. package/lib/dist/types.js.map +1 -1
  209. package/lib/kernel/codegraph-kernel.node +0 -0
  210. package/lib/node_modules/.package-lock.json +1 -1
  211. package/lib/package.json +1 -1
  212. package/package.json +1 -1
@@ -392,6 +392,16 @@ function main() {
392
392
  for (const w of result.errors.filter((e) => e.code === 'index_partial')) {
393
393
  clack.log.warn(w.message);
394
394
  }
395
+ // Files salvaged from comment-stripped source after repeated parser
396
+ // failures are indexed but possibly incomplete — say so here, or the run
397
+ // reads as fully clean and the index quietly disagrees with a later
398
+ // re-parse of the same bytes (#1565).
399
+ const salvaged = result.errors.filter((e) => e.code === 'salvaged_stripped');
400
+ if (salvaged.length > 0) {
401
+ const sample = salvaged.slice(0, 3).map((e) => e.filePath).filter(Boolean).join(', ');
402
+ const more = salvaged.length > 3 ? ', ...' : '';
403
+ clack.log.warn(`${formatNumber(salvaged.length)} file(s) indexed from comment-stripped source after repeated parse failures ${(0, glyphs_1.getGlyphs)().dash} symbols may be incomplete (${sample}${more})`);
404
+ }
395
405
  }
396
406
  else if (hasErrors) {
397
407
  clack.log.error(`Indexing failed ${(0, glyphs_1.getGlyphs)().dash} all ${formatNumber(result.filesErrored)} files had errors`);
@@ -428,9 +438,17 @@ function main() {
428
438
  }
429
439
  }
430
440
  else if (projectPath) {
431
- const logPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'errors.log');
432
- if (fs.existsSync(logPath)) {
433
- fs.unlinkSync(logPath);
441
+ // No hard errors. Salvaged-file warnings still belong in the log — it
442
+ // carries the per-file detail behind the one-line summary above.
443
+ if (result.errors.some((e) => e.code === 'salvaged_stripped')) {
444
+ writeErrorLog(projectPath, result.errors);
445
+ clack.log.info('See .codegraph/errors.log for details');
446
+ }
447
+ else {
448
+ const logPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'errors.log');
449
+ if (fs.existsSync(logPath)) {
450
+ fs.unlinkSync(logPath);
451
+ }
434
452
  }
435
453
  }
436
454
  }
@@ -550,16 +568,14 @@ function main() {
550
568
  // Commands
551
569
  // =============================================================================
552
570
  /**
553
- * codegraph init [path]
571
+ * The `init` flow — shared by `codegraph init` and `codegraph install --init`
572
+ * (#1578): refuse an unsafe root, create `.codegraph/`, build the initial
573
+ * index under supervision, then the post-index offers. `yes` makes every
574
+ * offer non-interactive (defaults only), so a container / CI bootstrap never
575
+ * blocks on a prompt. An unsafe root sets `process.exitCode = 1` and returns
576
+ * (no `--force` is implied by any caller); an index failure exits 1.
554
577
  */
555
- program
556
- .command('init [path]')
557
- .description('Initialize CodeGraph in a project directory and build the initial index')
558
- .option('-i, --index', 'Deprecated: indexing now runs by default; flag accepted for backward compatibility')
559
- .option('-f, --force', 'Initialize even if the path looks like your home directory or a filesystem root')
560
- .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
561
- .action(async (pathArg, options) => {
562
- const projectPath = path.resolve(pathArg || process.cwd());
578
+ async function runInit(projectPath, options) {
563
579
  const clack = await importESM('@clack/prompts');
564
580
  clack.intro('Initializing CodeGraph');
565
581
  try {
@@ -579,7 +595,7 @@ function main() {
579
595
  clack.log.info('Use "codegraph index" to re-index or "codegraph sync" to update');
580
596
  try {
581
597
  const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
582
- await offerWatchFallback(clack, projectPath);
598
+ await offerWatchFallback(clack, projectPath, { yes: options.yes });
583
599
  }
584
600
  catch { /* non-fatal */ }
585
601
  clack.outro('');
@@ -619,12 +635,14 @@ function main() {
619
635
  // An empty graph at a git super-repo usually means `.gitignore` excludes
620
636
  // the child repos that hold the code — surface them and offer to opt in
621
637
  // rather than leaving the user with a silent 0-node "Done". (#1156)
638
+ // Under --yes the offer prints its one-line opt-in snippet instead of
639
+ // prompting (same as a non-TTY run).
622
640
  if (result.nodesCreated === 0) {
623
- await offerIndexIgnoredRepos(clack, projectPath, runIndex, { interactive: true });
641
+ await offerIndexIgnoredRepos(clack, projectPath, runIndex, { interactive: !options.yes });
624
642
  }
625
643
  try {
626
644
  const { offerWatchFallback } = await Promise.resolve().then(() => __importStar(require('../installer')));
627
- await offerWatchFallback(clack, projectPath);
645
+ await offerWatchFallback(clack, projectPath, { yes: options.yes });
628
646
  }
629
647
  catch { /* non-fatal */ }
630
648
  clack.outro('Done');
@@ -634,6 +652,19 @@ function main() {
634
652
  clack.log.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
635
653
  process.exit(1);
636
654
  }
655
+ }
656
+ /**
657
+ * codegraph init [path]
658
+ */
659
+ program
660
+ .command('init [path]')
661
+ .description('Initialize CodeGraph in a project directory and build the initial index')
662
+ .option('-i, --index', 'Deprecated: indexing now runs by default; flag accepted for backward compatibility')
663
+ .option('-f, --force', 'Initialize even if the path looks like your home directory or a filesystem root')
664
+ .option('-v, --verbose', 'Show detailed worker lifecycle and memory info')
665
+ .option('-y, --yes', 'Non-interactive: skip every prompt and take the defaults (for scripts / CI / container bootstraps)')
666
+ .action(async (pathArg, options) => {
667
+ await runInit(path.resolve(pathArg || process.cwd()), options);
637
668
  });
638
669
  /**
639
670
  * codegraph uninit [path]
@@ -889,6 +920,7 @@ function main() {
889
920
  nodeCount: stats.nodeCount,
890
921
  edgeCount: stats.edgeCount,
891
922
  dbSizeBytes: stats.dbSizeBytes,
923
+ walSizeBytes: stats.walSizeBytes,
892
924
  backend,
893
925
  journalMode,
894
926
  nodesByKind: stats.nodesByKind,
@@ -944,6 +976,19 @@ function main() {
944
976
  console.log(` Nodes: ${formatNumber(stats.nodeCount)}`);
945
977
  console.log(` Edges: ${formatNumber(stats.edgeCount)}`);
946
978
  console.log(` DB Size: ${(stats.dbSizeBytes / 1024 / 1024).toFixed(2)} MB`);
979
+ // Surface the WAL sidecar (#1431): a WAL that dwarfs the DB at rest is
980
+ // the killed-session leak — invisible before this line, it only showed
981
+ // up as a mysteriously full disk. open() above already kicked off the
982
+ // automatic heal for the oversized case.
983
+ if (stats.walSizeBytes > 0) {
984
+ const { WAL_HEAL_THRESHOLD_BYTES } = await Promise.resolve().then(() => __importStar(require('../db/index')));
985
+ const oversized = stats.walSizeBytes > Math.max(WAL_HEAL_THRESHOLD_BYTES, stats.dbSizeBytes);
986
+ const walLabel = `${(stats.walSizeBytes / 1024 / 1024).toFixed(2)} MB`;
987
+ console.log(` WAL Size: ${oversized ? chalk.yellow(walLabel) : walLabel}`);
988
+ if (oversized) {
989
+ warn('The write-ahead log is larger than the database — killed sessions left it behind. It is reclaimed automatically on open; if it persists across runs, another live CodeGraph process is holding it.');
990
+ }
991
+ }
947
992
  // Surface the active SQLite backend (node:sqlite — Node's built-in real
948
993
  // SQLite, full WAL + FTS5, no native build).
949
994
  const backendLabel = chalk.green(`node:sqlite ${(0, glyphs_1.getGlyphs)().dash} built-in (full WAL)`);
@@ -1036,10 +1081,10 @@ function main() {
1036
1081
  // Mirror the MCP search down-rank so the CLI also surfaces the
1037
1082
  // hand-written implementation before protobuf/gRPC scaffolding
1038
1083
  // when both share a name. See extraction/generated-detection.ts.
1039
- const { isGeneratedFile } = await Promise.resolve().then(() => __importStar(require('../extraction/generated-detection')));
1084
+ const isGen = cg.generatedFilePredicate(rawResults.map((r) => r.node.filePath));
1040
1085
  const results = [...rawResults].sort((a, b) => {
1041
- const aGen = isGeneratedFile(a.node.filePath) ? 1 : 0;
1042
- const bGen = isGeneratedFile(b.node.filePath) ? 1 : 0;
1086
+ const aGen = isGen(a.node.filePath) ? 1 : 0;
1087
+ const bGen = isGen(b.node.filePath) ? 1 : 0;
1043
1088
  return aGen - bGen;
1044
1089
  });
1045
1090
  if (options.json) {
@@ -1115,6 +1160,60 @@ function main() {
1115
1160
  process.exit(1);
1116
1161
  }
1117
1162
  });
1163
+ /**
1164
+ * codegraph context <task...>
1165
+ *
1166
+ * The CLI face of the public `buildContext` API (ContextBuilder): FTS entry
1167
+ * points + graph expansion + code blocks, formatted as markdown or JSON.
1168
+ * Advertised in the usage header since the first release but never actually
1169
+ * registered (#1611); external integrations (e.g. Memorix) invoke it as
1170
+ * `codegraph context --path <root> --format json --max-nodes 8 --no-code <task>`.
1171
+ */
1172
+ program
1173
+ .command('context <task...>')
1174
+ .description('Build context for a task: relevant symbols, relationships, and code blocks')
1175
+ .option('-p, --path <path>', 'Project path')
1176
+ .option('-f, --format <format>', 'Output format: markdown or json', 'markdown')
1177
+ .option('-n, --max-nodes <number>', 'Maximum number of symbols to include')
1178
+ .option('--no-code', 'Omit code blocks (structure only)')
1179
+ .action(async (taskParts, options) => {
1180
+ const projectPath = resolveProjectPath(options.path);
1181
+ const format = options.format ?? 'markdown';
1182
+ if (format !== 'markdown' && format !== 'json') {
1183
+ error(`Unknown format "${options.format}" — use "markdown" or "json".`);
1184
+ process.exit(1);
1185
+ }
1186
+ let maxNodes;
1187
+ if (options.maxNodes !== undefined) {
1188
+ maxNodes = parseInt(options.maxNodes, 10);
1189
+ if (Number.isNaN(maxNodes) || maxNodes < 1) {
1190
+ error(`--max-nodes expects a positive integer, got "${options.maxNodes}".`);
1191
+ process.exit(1);
1192
+ }
1193
+ }
1194
+ try {
1195
+ if (!(0, directory_1.isInitialized)(projectPath)) {
1196
+ error(`CodeGraph not initialized in ${projectPath}`);
1197
+ process.exit(1);
1198
+ }
1199
+ const { default: CodeGraph } = await loadCodeGraph();
1200
+ const cg = await CodeGraph.open(projectPath);
1201
+ const result = await cg.buildContext(taskParts.join(' '), {
1202
+ format,
1203
+ includeCode: options.code !== false,
1204
+ ...(maxNodes !== undefined ? { maxNodes } : {}),
1205
+ });
1206
+ // Both supported formats return a formatted string; print it verbatim so
1207
+ // `--format json` stays machine-parseable on stdout (error()/warnings go
1208
+ // to stderr only).
1209
+ console.log(typeof result === 'string' ? result : JSON.stringify(result, null, 2));
1210
+ cg.destroy();
1211
+ }
1212
+ catch (err) {
1213
+ error(`Context build failed: ${err instanceof Error ? err.message : String(err)}`);
1214
+ process.exit(1);
1215
+ }
1216
+ });
1118
1217
  /**
1119
1218
  * codegraph prompt-hook (hidden)
1120
1219
  *
@@ -1562,9 +1661,9 @@ function main() {
1562
1661
  .aliases(['daemons'])
1563
1662
  .description('Manage running CodeGraph background daemons — pick one and press enter to stop it')
1564
1663
  .action(async () => {
1565
- const { listDaemons, stopDaemonAt, stopAllDaemons } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
1664
+ const { listVerifiedDaemons, stopDaemonAt, stopAllDaemons } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
1566
1665
  const { runDaemonPicker } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-manager')));
1567
- const daemons = listDaemons();
1666
+ const daemons = await listVerifiedDaemons();
1568
1667
  if (daemons.length === 0) {
1569
1668
  info('No CodeGraph daemons running.');
1570
1669
  return;
@@ -1591,7 +1690,7 @@ function main() {
1591
1690
  const clack = await importESM('@clack/prompts');
1592
1691
  clack.intro('CodeGraph daemons');
1593
1692
  await runDaemonPicker({
1594
- list: listDaemons,
1693
+ list: listVerifiedDaemons,
1595
1694
  stop: stopDaemonAt,
1596
1695
  stopAll: stopAllDaemons,
1597
1696
  cwdRoot,
@@ -1693,12 +1792,17 @@ function main() {
1693
1792
  return;
1694
1793
  }
1695
1794
  const lockPath = path.join((0, directory_1.getCodeGraphDir)(projectPath), 'codegraph.lock');
1696
- if (!fs.existsSync(lockPath)) {
1697
- info(`No lock file found ${(0, glyphs_1.getGlyphs)().dash} nothing to do`);
1698
- return;
1699
- }
1700
- fs.unlinkSync(lockPath);
1701
- success('Removed lock file. You can now run indexing again.');
1795
+ let removed = false;
1796
+ if (fs.existsSync(lockPath)) {
1797
+ fs.unlinkSync(lockPath);
1798
+ removed = true;
1799
+ }
1800
+ const { clearStaleDaemonArtifacts } = await Promise.resolve().then(() => __importStar(require('../mcp/daemon-registry')));
1801
+ removed = await clearStaleDaemonArtifacts(projectPath) || removed;
1802
+ if (removed)
1803
+ success('Removed stale lock artifacts. You can now run indexing again.');
1804
+ else
1805
+ info(`No stale lock files found ${(0, glyphs_1.getGlyphs)().dash} nothing to do`);
1702
1806
  }
1703
1807
  catch (err) {
1704
1808
  error(`Failed to remove lock: ${err instanceof Error ? err.message : String(err)}`);
@@ -2082,10 +2186,11 @@ function main() {
2082
2186
  */
2083
2187
  program
2084
2188
  .command('install')
2085
- .description('Install codegraph MCP server into one or more agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent)')
2189
+ .description('Install codegraph MCP server into one or more agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, Kiro, GitHub Copilot)')
2086
2190
  .option('-t, --target <ids>', 'Target agent(s): comma-separated ids, or "auto"|"all"|"none". Default: prompt')
2087
2191
  .option('-l, --location <where>', 'Install location: "global" or "local". Default: prompt')
2088
2192
  .option('-y, --yes', 'Non-interactive: defaults to --location=global --target=auto, auto-allow on')
2193
+ .option('-i, --init', 'After wiring agents, also run `codegraph init` in the current directory — builds this project’s index, so install + index is one command (combine with --yes for an unattended bootstrap)')
2089
2194
  .option('--no-permissions', 'Skip writing the auto-allow permissions list (Claude Code only)')
2090
2195
  .option('--print-config <id>', 'Print MCP config snippet for the named agent and exit (no file writes)')
2091
2196
  .option('--refresh', 'Rewrite what previous installs configured, for already-configured agents only (never adds new ones). Run automatically by `codegraph upgrade`')
@@ -2161,6 +2266,17 @@ function main() {
2161
2266
  error(err instanceof Error ? err.message : String(err));
2162
2267
  process.exit(1);
2163
2268
  }
2269
+ // --init: the one-shot "wire agents AND build this project's index"
2270
+ // bootstrap (#1578). The installer itself never indexes implicitly (a
2271
+ // surprise index of $HOME is the thing we refuse) — an explicit flag is
2272
+ // the user choosing. Runs after a successful install, including the
2273
+ // `--target none` / nothing-detected case (the installer returns normally
2274
+ // there), and shares every guard with `codegraph init`: an unsafe root
2275
+ // is refused (exit 1, no implied --force), an already-initialized
2276
+ // project just says so. `--yes` flows through so no offer prompts.
2277
+ if (opts.init) {
2278
+ await runInit(process.cwd(), { yes: opts.yes });
2279
+ }
2164
2280
  });
2165
2281
  /**
2166
2282
  * codegraph uninstall
@@ -2172,7 +2288,7 @@ function main() {
2172
2288
  */
2173
2289
  program
2174
2290
  .command('uninstall')
2175
- .description('Remove codegraph from your agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent)')
2291
+ .description('Remove codegraph from your agents (Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, Kiro, GitHub Copilot)')
2176
2292
  .option('-t, --target <ids>', 'Target agent(s): comma-separated ids, or "all". Default: all')
2177
2293
  .option('-l, --location <where>', 'Uninstall location: "global" or "local". Default: prompt')
2178
2294
  .option('-y, --yes', 'Non-interactive: defaults to --location=global --target=all')