@saluzi/codegraph 0.1.0 → 0.2.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 (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +885 -0
  3. package/package.json +42 -10
  4. package/scripts/add-lang/bench.sh +60 -0
  5. package/scripts/add-lang/check-grammar.mjs +75 -0
  6. package/scripts/add-lang/dump-ast.mjs +103 -0
  7. package/scripts/add-lang/verify-extraction.mjs +70 -0
  8. package/scripts/agent-eval/ab-adoption.sh +91 -0
  9. package/scripts/agent-eval/ab-hook.sh +86 -0
  10. package/scripts/agent-eval/ab-impl.sh +78 -0
  11. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  12. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  13. package/scripts/agent-eval/arms-F.sh +21 -0
  14. package/scripts/agent-eval/arms-matrix.sh +37 -0
  15. package/scripts/agent-eval/audit.sh +68 -0
  16. package/scripts/agent-eval/bench-readme.sh +28 -0
  17. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  18. package/scripts/agent-eval/block-read-hook.sh +19 -0
  19. package/scripts/agent-eval/hook-settings.json +15 -0
  20. package/scripts/agent-eval/itrun.sh +120 -0
  21. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  22. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  23. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  24. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  25. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  26. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  27. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  28. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  29. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  30. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  31. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  32. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  33. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  34. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  35. package/scripts/agent-eval/offload-eval.md +76 -0
  36. package/scripts/agent-eval/parse-arms.mjs +116 -0
  37. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  38. package/scripts/agent-eval/parse-run.mjs +45 -0
  39. package/scripts/agent-eval/parse-session.mjs +93 -0
  40. package/scripts/agent-eval/probe-context.mjs +21 -0
  41. package/scripts/agent-eval/probe-explore.mjs +40 -0
  42. package/scripts/agent-eval/probe-node.mjs +20 -0
  43. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  44. package/scripts/agent-eval/probe-trace.mjs +20 -0
  45. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  46. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  47. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  48. package/scripts/agent-eval/run-agent.sh +34 -0
  49. package/scripts/agent-eval/run-all.sh +75 -0
  50. package/scripts/agent-eval/run-arms.sh +56 -0
  51. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  52. package/scripts/build-bundle.sh +123 -0
  53. package/scripts/extract-release-notes.mjs +130 -0
  54. package/scripts/local-install.sh +41 -0
  55. package/scripts/npm-sdk.js +75 -0
  56. package/scripts/npm-shim.js +275 -0
  57. package/scripts/pack-npm.sh +119 -0
  58. package/scripts/prepare-release.mjs +270 -0
  59. package/dist/bin/codegraph.d.ts +0 -25
  60. package/dist/bin/node-version-check.d.ts +0 -37
  61. package/dist/bin/uninstall.d.ts +0 -14
  62. package/dist/context/formatter.d.ts +0 -33
  63. package/dist/context/formatter.js +0 -244
  64. package/dist/context/index.d.ts +0 -117
  65. package/dist/context/index.js +0 -1050
  66. package/dist/db/index.d.ts +0 -101
  67. package/dist/db/index.js +0 -250
  68. package/dist/db/migrations.d.ts +0 -47
  69. package/dist/db/migrations.js +0 -131
  70. package/dist/db/queries.d.ts +0 -291
  71. package/dist/db/queries.js +0 -1349
  72. package/dist/db/schema.sql +0 -151
  73. package/dist/db/sqlite-adapter.d.ts +0 -49
  74. package/dist/db/sqlite-adapter.js +0 -141
  75. package/dist/directory.d.ts +0 -62
  76. package/dist/directory.js +0 -264
  77. package/dist/errors.d.ts +0 -149
  78. package/dist/errors.js +0 -219
  79. package/dist/extraction/dfm-extractor.d.ts +0 -31
  80. package/dist/extraction/dfm-extractor.js +0 -151
  81. package/dist/extraction/grammars.d.ts +0 -94
  82. package/dist/extraction/grammars.js +0 -357
  83. package/dist/extraction/index.d.ts +0 -148
  84. package/dist/extraction/index.js +0 -1286
  85. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  86. package/dist/extraction/languages/c-cpp.js +0 -126
  87. package/dist/extraction/languages/csharp.d.ts +0 -3
  88. package/dist/extraction/languages/csharp.js +0 -72
  89. package/dist/extraction/languages/dart.d.ts +0 -3
  90. package/dist/extraction/languages/dart.js +0 -192
  91. package/dist/extraction/languages/go.d.ts +0 -3
  92. package/dist/extraction/languages/go.js +0 -58
  93. package/dist/extraction/languages/index.d.ts +0 -10
  94. package/dist/extraction/languages/index.js +0 -49
  95. package/dist/extraction/languages/java.d.ts +0 -3
  96. package/dist/extraction/languages/java.js +0 -64
  97. package/dist/extraction/languages/javascript.d.ts +0 -3
  98. package/dist/extraction/languages/javascript.js +0 -90
  99. package/dist/extraction/languages/kotlin.d.ts +0 -3
  100. package/dist/extraction/languages/kotlin.js +0 -253
  101. package/dist/extraction/languages/lua.d.ts +0 -3
  102. package/dist/extraction/languages/lua.js +0 -150
  103. package/dist/extraction/languages/luau.d.ts +0 -3
  104. package/dist/extraction/languages/luau.js +0 -37
  105. package/dist/extraction/languages/pascal.d.ts +0 -3
  106. package/dist/extraction/languages/pascal.js +0 -66
  107. package/dist/extraction/languages/php.d.ts +0 -3
  108. package/dist/extraction/languages/php.js +0 -107
  109. package/dist/extraction/languages/python.d.ts +0 -3
  110. package/dist/extraction/languages/python.js +0 -56
  111. package/dist/extraction/languages/ruby.d.ts +0 -3
  112. package/dist/extraction/languages/ruby.js +0 -114
  113. package/dist/extraction/languages/rust.d.ts +0 -3
  114. package/dist/extraction/languages/rust.js +0 -109
  115. package/dist/extraction/languages/scala.d.ts +0 -3
  116. package/dist/extraction/languages/scala.js +0 -139
  117. package/dist/extraction/languages/swift.d.ts +0 -3
  118. package/dist/extraction/languages/swift.js +0 -91
  119. package/dist/extraction/languages/typescript.d.ts +0 -3
  120. package/dist/extraction/languages/typescript.js +0 -129
  121. package/dist/extraction/liquid-extractor.d.ts +0 -52
  122. package/dist/extraction/liquid-extractor.js +0 -313
  123. package/dist/extraction/parse-worker.d.ts +0 -8
  124. package/dist/extraction/parse-worker.js +0 -94
  125. package/dist/extraction/svelte-extractor.d.ts +0 -56
  126. package/dist/extraction/svelte-extractor.js +0 -272
  127. package/dist/extraction/tree-sitter-helpers.d.ts +0 -39
  128. package/dist/extraction/tree-sitter-helpers.js +0 -103
  129. package/dist/extraction/tree-sitter-types.d.ts +0 -191
  130. package/dist/extraction/tree-sitter-types.js +0 -10
  131. package/dist/extraction/tree-sitter.d.ts +0 -238
  132. package/dist/extraction/tree-sitter.js +0 -2430
  133. package/dist/extraction/vue-extractor.d.ts +0 -36
  134. package/dist/extraction/vue-extractor.js +0 -163
  135. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  136. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  137. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  138. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  139. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  140. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  141. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  144. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  145. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  146. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  147. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  148. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  149. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  150. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  151. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  152. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  153. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  154. package/dist/extraction/wasm-runtime-flags.d.ts +0 -46
  155. package/dist/extraction/wasm-runtime-flags.js +0 -105
  156. package/dist/graph/index.d.ts +0 -8
  157. package/dist/graph/index.js +0 -13
  158. package/dist/graph/queries.d.ts +0 -109
  159. package/dist/graph/queries.js +0 -366
  160. package/dist/graph/traversal.d.ts +0 -137
  161. package/dist/graph/traversal.js +0 -528
  162. package/dist/index.d.ts +0 -509
  163. package/dist/index.js +0 -800
  164. package/dist/installer/claude-md-template.d.ts +0 -19
  165. package/dist/installer/config-writer.d.ts +0 -29
  166. package/dist/installer/index.d.ts +0 -140
  167. package/dist/installer/instructions-template.d.ts +0 -30
  168. package/dist/installer/targets/claude.d.ts +0 -55
  169. package/dist/installer/targets/codex.d.ts +0 -18
  170. package/dist/installer/targets/cursor.d.ts +0 -35
  171. package/dist/installer/targets/hermes.d.ts +0 -18
  172. package/dist/installer/targets/opencode.d.ts +0 -30
  173. package/dist/installer/targets/registry.d.ts +0 -38
  174. package/dist/installer/targets/shared.d.ts +0 -92
  175. package/dist/installer/targets/toml.d.ts +0 -64
  176. package/dist/installer/targets/types.d.ts +0 -122
  177. package/dist/mcp/index.d.ts +0 -98
  178. package/dist/mcp/server-instructions.d.ts +0 -20
  179. package/dist/mcp/tools.d.ts +0 -269
  180. package/dist/mcp/transport.d.ts +0 -117
  181. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -20
  182. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  183. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  184. package/dist/resolution/frameworks/csharp.js +0 -213
  185. package/dist/resolution/frameworks/drupal.d.ts +0 -51
  186. package/dist/resolution/frameworks/drupal.js +0 -335
  187. package/dist/resolution/frameworks/express.d.ts +0 -8
  188. package/dist/resolution/frameworks/express.js +0 -225
  189. package/dist/resolution/frameworks/go.d.ts +0 -8
  190. package/dist/resolution/frameworks/go.js +0 -158
  191. package/dist/resolution/frameworks/index.d.ts +0 -52
  192. package/dist/resolution/frameworks/index.js +0 -137
  193. package/dist/resolution/frameworks/java.d.ts +0 -8
  194. package/dist/resolution/frameworks/java.js +0 -177
  195. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  196. package/dist/resolution/frameworks/laravel.js +0 -248
  197. package/dist/resolution/frameworks/nestjs.d.ts +0 -26
  198. package/dist/resolution/frameworks/nestjs.js +0 -374
  199. package/dist/resolution/frameworks/python.d.ts +0 -10
  200. package/dist/resolution/frameworks/python.js +0 -278
  201. package/dist/resolution/frameworks/react.d.ts +0 -8
  202. package/dist/resolution/frameworks/react.js +0 -272
  203. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  204. package/dist/resolution/frameworks/ruby.js +0 -198
  205. package/dist/resolution/frameworks/rust.d.ts +0 -8
  206. package/dist/resolution/frameworks/rust.js +0 -207
  207. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  208. package/dist/resolution/frameworks/svelte.js +0 -249
  209. package/dist/resolution/frameworks/swift.d.ts +0 -10
  210. package/dist/resolution/frameworks/swift.js +0 -376
  211. package/dist/resolution/frameworks/vue.d.ts +0 -9
  212. package/dist/resolution/frameworks/vue.js +0 -306
  213. package/dist/resolution/import-resolver.d.ts +0 -61
  214. package/dist/resolution/import-resolver.js +0 -663
  215. package/dist/resolution/index.d.ts +0 -118
  216. package/dist/resolution/index.js +0 -744
  217. package/dist/resolution/lru-cache.d.ts +0 -24
  218. package/dist/resolution/lru-cache.js +0 -62
  219. package/dist/resolution/name-matcher.d.ts +0 -50
  220. package/dist/resolution/name-matcher.js +0 -384
  221. package/dist/resolution/path-aliases.d.ts +0 -72
  222. package/dist/resolution/path-aliases.js +0 -238
  223. package/dist/resolution/strip-comments.d.ts +0 -40
  224. package/dist/resolution/strip-comments.js +0 -441
  225. package/dist/resolution/types.d.ts +0 -181
  226. package/dist/resolution/types.js +0 -8
  227. package/dist/search/query-parser.d.ts +0 -61
  228. package/dist/search/query-parser.js +0 -177
  229. package/dist/search/query-utils.d.ts +0 -59
  230. package/dist/search/query-utils.js +0 -383
  231. package/dist/sync/git-hooks.d.ts +0 -54
  232. package/dist/sync/git-hooks.js +0 -223
  233. package/dist/sync/index.d.ts +0 -25
  234. package/dist/sync/index.js +0 -28
  235. package/dist/sync/watch-policy.d.ts +0 -51
  236. package/dist/sync/watch-policy.js +0 -124
  237. package/dist/sync/watcher.d.ts +0 -83
  238. package/dist/sync/watcher.js +0 -192
  239. package/dist/types.d.ts +0 -433
  240. package/dist/types.js +0 -75
  241. package/dist/ui/glyphs.d.ts +0 -42
  242. package/dist/ui/shimmer-progress.d.ts +0 -11
  243. package/dist/ui/shimmer-worker.d.ts +0 -2
  244. package/dist/ui/types.d.ts +0 -20
  245. package/dist/utils.d.ts +0 -231
  246. package/dist/utils.js +0 -549
@@ -1,19 +0,0 @@
1
- /**
2
- * Backwards-compat re-export shim.
3
- *
4
- * The instructions template moved to `instructions-template.ts` so it
5
- * can be shared across all agent targets (Claude Code, Cursor, Codex
6
- * CLI, opencode). This file is preserved purely so existing imports
7
- * (`@colbymchenry/codegraph` consumers, downstream tooling) keep
8
- * working unchanged. New code should import from
9
- * `./instructions-template` directly.
10
- *
11
- * @deprecated Import from `./instructions-template` instead.
12
- */
13
- export {
14
- CODEGRAPH_SECTION_START,
15
- CODEGRAPH_SECTION_END,
16
- CLAUDE_MD_TEMPLATE,
17
- INSTRUCTIONS_TEMPLATE,
18
- } from './instructions-template'
19
- //# sourceMappingURL=claude-md-template.d.ts.map
@@ -1,29 +0,0 @@
1
- /**
2
- * Backwards-compat shim — original Claude-only writer functions.
3
- *
4
- * The installer now uses the multi-target architecture in
5
- * `./targets/`. This file is preserved so existing imports (the test
6
- * suite, downstream tooling) keep working unchanged. Each function
7
- * delegates to the Claude target. New code should import the target
8
- * registry from `./targets/registry` directly.
9
- *
10
- * @deprecated Use `targets/registry.ts` and the `AgentTarget`
11
- * abstraction instead.
12
- */
13
- export type InstallLocation = 'global' | 'local'
14
- /**
15
- * Each shim calls ONLY the named per-file helper — writeMcpConfig
16
- * writes only the MCP JSON, writePermissions only settings.json,
17
- * writeClaudeMd only CLAUDE.md. The full multi-file install lives
18
- * in `claudeTarget.install()` which the new orchestrator uses.
19
- */
20
- export declare function writeMcpConfig(location: InstallLocation): void
21
- export declare function writePermissions(location: InstallLocation): void
22
- export declare function writeClaudeMd(location: InstallLocation): {
23
- created: boolean
24
- updated: boolean
25
- }
26
- export declare function hasMcpConfig(location: InstallLocation): boolean
27
- export declare function hasPermissions(location: InstallLocation): boolean
28
- export declare function hasClaudeMdSection(location: InstallLocation): boolean
29
- //# sourceMappingURL=config-writer.d.ts.map
@@ -1,140 +0,0 @@
1
- /**
2
- * CodeGraph Interactive Installer
3
- *
4
- * Multi-target: writes MCP server config + instructions for the
5
- * agents the user picks (Claude Code, Cursor, Codex CLI, opencode,
6
- * Hermes Agent).
7
- * Defaults to the Claude-only behavior for backwards compatibility
8
- * when no targets are explicitly chosen and nothing else is detected.
9
- *
10
- * Uses @clack/prompts for the interactive UI; `runInstallerWithOptions`
11
- * is the non-interactive entry point used by the `--target` /
12
- * `--print-config` CLI flags.
13
- */
14
- import type {
15
- AgentTarget,
16
- Location,
17
- TargetId,
18
- WriteResult,
19
- } from './targets/types'
20
- export {
21
- writeMcpConfig,
22
- writePermissions,
23
- writeClaudeMd,
24
- hasMcpConfig,
25
- hasPermissions,
26
- hasClaudeMdSection,
27
- } from './config-writer'
28
- export type { InstallLocation } from './config-writer'
29
- export interface RunInstallerOptions {
30
- /** Comma-separated target list, or `auto` / `all` / `none`. */
31
- target?: string
32
- /** Skip the location prompt; use this value directly. */
33
- location?: Location
34
- /** Skip the auto-allow prompt; use this value directly. */
35
- autoAllow?: boolean
36
- /**
37
- * Skip every confirm and use defaults: location=global,
38
- * autoAllow=true, target=auto. For scripting / CI.
39
- */
40
- yes?: boolean
41
- }
42
- /**
43
- * Interactive entry point — preserves the historical UX (`codegraph
44
- * install` with no args goes through the prompts), but now starts
45
- * the targets multi-select pre-populated with detected agents.
46
- */
47
- export declare function runInstaller(): Promise<void>
48
- export declare function runInstallerWithOptions(
49
- opts: RunInstallerOptions,
50
- ): Promise<void>
51
- export interface RunUninstallerOptions {
52
- /**
53
- * Comma-separated target list, or `auto` / `all` / `none`. Defaults
54
- * to `all` — uninstall sweeps every known agent and reports which
55
- * ones it actually touched, so the user doesn't have to know where
56
- * they configured it.
57
- */
58
- target?: string
59
- /** Skip the location prompt; use this value directly. */
60
- location?: Location
61
- /** Non-interactive: location=global, target=all, no prompts. */
62
- yes?: boolean
63
- }
64
- export type UninstallStatus = 'removed' | 'not-configured' | 'unsupported'
65
- /**
66
- * Per-target outcome of an uninstall sweep. `removed` means we deleted
67
- * at least one thing; `not-configured` means the agent had no codegraph
68
- * config at this location (nothing to do); `unsupported` means the
69
- * agent has no config concept for this location (e.g. Codex is
70
- * global-only, so a `local` uninstall skips it).
71
- */
72
- export interface UninstallReport {
73
- id: TargetId
74
- displayName: string
75
- status: UninstallStatus
76
- /** Absolute paths we actually edited/removed (action === 'removed'). */
77
- removedPaths: string[]
78
- /** Verbatim notes from the target (rare for uninstall). */
79
- notes: string[]
80
- }
81
- /**
82
- * Pure uninstall sweep — no prompts, no I/O beyond the targets' own
83
- * file edits. Exposed (and unit-tested) separately from the clack UI in
84
- * `runUninstaller` so the aggregation logic can be asserted directly.
85
- *
86
- * Each target's `uninstall()` is already safe to call when nothing was
87
- * installed (it returns `not-found` actions), so this is safe to run
88
- * across every target unconditionally.
89
- */
90
- export declare function uninstallTargets(
91
- targets: readonly AgentTarget[],
92
- location: Location,
93
- ): UninstallReport[]
94
- /**
95
- * Interactive uninstaller — the inverse of `runInstallerWithOptions`.
96
- * Asks global-vs-local first (unless `--location`/`--yes` is given),
97
- * then sweeps every agent target (or the `--target` subset) and prints
98
- * one block per agent so the user sees exactly which providers it hit.
99
- *
100
- * Removes only what install wrote (MCP server entry, instructions
101
- * block, permissions) — never the `.codegraph/` index, which `codegraph
102
- * uninit` owns.
103
- */
104
- export declare function runUninstaller(
105
- opts: RunUninstallerOptions,
106
- ): Promise<void>
107
- /**
108
- * For every target that has a global config and exposes
109
- * `wireProjectSurfaces`, write its project-local surfaces (e.g.
110
- * Cursor's `.cursor/rules/codegraph.mdc`). Idempotent — runs
111
- * silently when there's nothing to write.
112
- *
113
- * Called by `codegraph init` so that a user who ran
114
- * `codegraph install` once globally doesn't have to re-run it per
115
- * project to get full agent support.
116
- *
117
- * Returns the list of `(target, file)` pairs that were created or
118
- * updated — caller decides how to surface them.
119
- */
120
- export declare function wireProjectSurfacesForGlobalAgents(): Array<{
121
- target: AgentTarget
122
- file: WriteResult['files'][number]
123
- }>
124
- /**
125
- * When the live file watcher will be disabled for this project (e.g. WSL2
126
- * /mnt drives, or CODEGRAPH_NO_WATCH), the index would silently go stale.
127
- * Explain that, and offer to keep it fresh automatically via git hooks
128
- * (commit / pull / checkout) instead of manual `codegraph sync`.
129
- *
130
- * No-op on environments where the watcher runs normally, so it's safe to
131
- * call unconditionally after init.
132
- */
133
- export declare function offerWatchFallback(
134
- clack: typeof import('@clack/prompts'),
135
- projectPath: string,
136
- opts?: {
137
- yes?: boolean
138
- },
139
- ): Promise<void>
140
- //# sourceMappingURL=index.d.ts.map
@@ -1,30 +0,0 @@
1
- /**
2
- * Agent-instructions template — the markdown body each agent target
3
- * writes into its conventional instructions file (CLAUDE.md /
4
- * AGENTS.md / codegraph.mdc / etc.).
5
- *
6
- * The body content is identical across agents because the codegraph
7
- * usage advice is agent-agnostic — only the destination filename and
8
- * any optional frontmatter (Cursor `.mdc`) varies per target.
9
- *
10
- * The legacy `claude-md-template.ts` re-exports these names for
11
- * backwards compatibility with downstream importers.
12
- */
13
- /** Markers used by the marker-based section replacement. */
14
- export declare const CODEGRAPH_SECTION_START = '<!-- CODEGRAPH_START -->'
15
- export declare const CODEGRAPH_SECTION_END = '<!-- CODEGRAPH_END -->'
16
- /**
17
- * The full marker-delimited block written into each agent's
18
- * instructions file. Includes the start/end markers so the section
19
- * can be detected and replaced on re-install.
20
- */
21
- export declare const INSTRUCTIONS_TEMPLATE =
22
- '<!-- CODEGRAPH_START -->\n## CodeGraph\n\nThis project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.\n\n### When to prefer codegraph over native search\n\nUse codegraph for **structural** questions \u2014 what calls what, what would break, where is X defined, what is X\'s signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.\n\n| Question | Tool |\n|---|---|\n| "Where is X defined?" / "Find symbol named X" | `codegraph_search` |\n| "What calls function Y?" | `codegraph_callers` |\n| "What does Y call?" | `codegraph_callees` |\n| "What would break if I changed Z?" | `codegraph_impact` |\n| "Show me Y\'s signature / source / docstring" | `codegraph_node` |\n| "Give me focused context for a task/area" | `codegraph_context` |\n| "See several related symbols\' source at once" | `codegraph_explore` |\n| "What files exist under path/" | `codegraph_files` |\n| "Is the index healthy?" | `codegraph_status` |\n\n### Rules of thumb\n\n- **Answer directly \u2014 don\'t delegate exploration.** For "how does X work" / architecture / trace questions, answer with 2-3 codegraph calls: `codegraph_context` first, then ONE `codegraph_explore` for the source of the symbols it surfaces. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent \u2014 or running a grep + read loop \u2014 repeats work codegraph already did and costs more for the same answer.\n- **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep \u2014 that\'s slower, less accurate, and wastes context.\n- **Don\'t grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.\n- **Don\'t chain `codegraph_search` + `codegraph_node`** when you just want context \u2014 `codegraph_context` is one call.\n- **Don\'t loop `codegraph_node` over many symbols** \u2014 one `codegraph_explore` call returns several symbols\' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.\n- **Index lag**: the file watcher debounces ~500ms behind writes; don\'t re-query immediately after editing a file in the same turn.\n\n### If `.codegraph/` doesn\'t exist\n\nThe MCP server returns "not initialized." Ask the user: *"I notice this project doesn\'t have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"*\n<!-- CODEGRAPH_END -->'
23
- /**
24
- * Backwards-compat alias. Existing downstream code may import
25
- * `CLAUDE_MD_TEMPLATE` from this module via the re-export shim in
26
- * `claude-md-template.ts`.
27
- */
28
- export declare const CLAUDE_MD_TEMPLATE =
29
- '<!-- CODEGRAPH_START -->\n## CodeGraph\n\nThis project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.\n\n### When to prefer codegraph over native search\n\nUse codegraph for **structural** questions \u2014 what calls what, what would break, where is X defined, what is X\'s signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.\n\n| Question | Tool |\n|---|---|\n| "Where is X defined?" / "Find symbol named X" | `codegraph_search` |\n| "What calls function Y?" | `codegraph_callers` |\n| "What does Y call?" | `codegraph_callees` |\n| "What would break if I changed Z?" | `codegraph_impact` |\n| "Show me Y\'s signature / source / docstring" | `codegraph_node` |\n| "Give me focused context for a task/area" | `codegraph_context` |\n| "See several related symbols\' source at once" | `codegraph_explore` |\n| "What files exist under path/" | `codegraph_files` |\n| "Is the index healthy?" | `codegraph_status` |\n\n### Rules of thumb\n\n- **Answer directly \u2014 don\'t delegate exploration.** For "how does X work" / architecture / trace questions, answer with 2-3 codegraph calls: `codegraph_context` first, then ONE `codegraph_explore` for the source of the symbols it surfaces. Codegraph IS the pre-built index, so spawning a separate file-reading sub-task/agent \u2014 or running a grep + read loop \u2014 repeats work codegraph already did and costs more for the same answer.\n- **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep \u2014 that\'s slower, less accurate, and wastes context.\n- **Don\'t grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.\n- **Don\'t chain `codegraph_search` + `codegraph_node`** when you just want context \u2014 `codegraph_context` is one call.\n- **Don\'t loop `codegraph_node` over many symbols** \u2014 one `codegraph_explore` call returns several symbols\' source grouped in a single capped call, while each separate node/Read call re-reads the whole context and costs far more.\n- **Index lag**: the file watcher debounces ~500ms behind writes; don\'t re-query immediately after editing a file in the same turn.\n\n### If `.codegraph/` doesn\'t exist\n\nThe MCP server returns "not initialized." Ask the user: *"I notice this project doesn\'t have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"*\n<!-- CODEGRAPH_END -->'
30
- //# sourceMappingURL=instructions-template.d.ts.map
@@ -1,55 +0,0 @@
1
- /**
2
- * Claude Code target. Writes:
3
- *
4
- * - MCP server entry to `~/.claude.json` (global = user scope, loads
5
- * in every project) or `./.mcp.json` (local = project scope, the
6
- * file Claude Code actually reads for a single project). See the
7
- * scope table at https://code.claude.com/docs/en/mcp.
8
- * - Permissions to `~/.claude/settings.json` (global) or
9
- * `./.claude/settings.json` (local), gated on `autoAllow`.
10
- * - Instructions to `~/.claude/CLAUDE.md` (global) or
11
- * `./.claude/CLAUDE.md` (local).
12
- *
13
- * Earlier versions wrote the local MCP entry to `./.claude.json` — a
14
- * file Claude Code never reads — so the server silently never loaded
15
- * until the user manually renamed it to `.mcp.json` (issue #207). We
16
- * now write `./.mcp.json` and migrate any stale `./.claude.json` entry
17
- * out of the way on install and uninstall.
18
- */
19
- import { AgentTarget, Location, WriteResult } from './types'
20
- /**
21
- * Per-file write helpers, exported so the legacy `config-writer.ts`
22
- * shim can call only the named operation (writeMcpConfig writes ONLY
23
- * the MCP entry, etc.) instead of `claudeTarget.install()` which
24
- * writes all three files. Without this split the shims silently
25
- * cause side effects callers don't expect.
26
- */
27
- export declare function writeMcpEntry(
28
- loc: Location,
29
- ): WriteResult['files'][number]
30
- /**
31
- * Remove stale codegraph auto-sync hooks from Claude `settings.json`.
32
- *
33
- * Surgical at the individual-command level: only entries matching
34
- * `isLegacyCodegraphHookCommand` are dropped, so a sibling hook sharing
35
- * a matcher group (or the Stop event) with ours survives. We prune a
36
- * matcher group only once its `hooks` array is empty, an event only
37
- * once it has no groups left, and `hooks` itself only once every event
38
- * is gone — and none of that runs unless we actually removed a
39
- * codegraph command, so a settings.json with no legacy hooks is left
40
- * byte-for-byte untouched and reported `unchanged`.
41
- *
42
- * Exported so it can be unit-tested directly and reused by both
43
- * `install` (an upgrade self-heals) and `uninstall`.
44
- */
45
- export declare function cleanupLegacyHooks(
46
- loc: Location,
47
- ): WriteResult['files'][number]
48
- export declare function writePermissionsEntry(
49
- loc: Location,
50
- ): WriteResult['files'][number]
51
- export declare function writeInstructionsEntry(
52
- loc: Location,
53
- ): WriteResult['files'][number]
54
- export declare const claudeTarget: AgentTarget
55
- //# sourceMappingURL=claude.d.ts.map
@@ -1,18 +0,0 @@
1
- /**
2
- * OpenAI Codex CLI target.
3
- *
4
- * - MCP server entry to `~/.codex/config.toml` as the dotted-key
5
- * table `[mcp_servers.codegraph]`. TOML — not JSON — handled by
6
- * the narrow serializer in `./toml.ts`.
7
- * - Instructions to `~/.codex/AGENTS.md`.
8
- *
9
- * Codex CLI as of 2026-05 has no project-local config concept —
10
- * everything lives under `~/.codex/`. `supportsLocation('local')`
11
- * returns false; the orchestrator skips Codex when the user picks
12
- * the local install location.
13
- *
14
- * No permissions concept.
15
- */
16
- import { AgentTarget } from './types'
17
- export declare const codexTarget: AgentTarget
18
- //# sourceMappingURL=codex.d.ts.map
@@ -1,35 +0,0 @@
1
- /**
2
- * Cursor target.
3
- *
4
- * - MCP server entry to `~/.cursor/mcp.json` (global) or
5
- * `./.cursor/mcp.json` (local). Same `{mcpServers: {...}}` shape
6
- * as Claude.
7
- * - Instructions to `./.cursor/rules/codegraph.mdc` (project-local
8
- * ONLY). Cursor's rules system is a project-scoped surface;
9
- * global cursor rules aren't a stable convention as of 2026-05.
10
- * For `--location=global`, only mcp.json is written.
11
- *
12
- * ## Why we hardcode `--path` for Cursor
13
- *
14
- * Cursor launches MCP-server subprocesses with a working directory
15
- * that ISN'T the workspace root AND doesn't pass `rootUri` /
16
- * `workspaceFolders` in the MCP initialize call. The codegraph MCP
17
- * server's `process.cwd()` fallback therefore misses the workspace's
18
- * `.codegraph/` and reports "not initialized" on every tool call.
19
- *
20
- * So we inject `--path` into the args ourselves:
21
- *
22
- * - `local` install: absolute path (we know it at install time).
23
- * - `global` install: `${workspaceFolder}` — Cursor expands this to
24
- * the open workspace's root, giving us per-workspace behavior
25
- * from a single global config.
26
- *
27
- * Codex and Claude do not need this — they launch MCP servers with
28
- * `cwd = workspace` and pass `rootUri`, respectively.
29
- *
30
- * No permissions concept — Cursor doesn't have an auto-allow list
31
- * the installer can populate. `autoAllow` is silently ignored.
32
- */
33
- import { AgentTarget } from './types'
34
- export declare const cursorTarget: AgentTarget
35
- //# sourceMappingURL=cursor.d.ts.map
@@ -1,18 +0,0 @@
1
- /**
2
- * Hermes Agent target.
3
- *
4
- * Hermes reads MCP servers from `$HERMES_HOME/config.yaml` under the
5
- * top-level `mcp_servers` key, and exposes discovered MCP tools through
6
- * dynamic toolsets named `mcp-<server>`. We add:
7
- *
8
- * mcp_servers.codegraph -> `codegraph serve --mcp`
9
- * platform_toolsets.cli -> `mcp-codegraph`
10
- *
11
- * The second entry matters because Hermes CLI profiles often enable an
12
- * explicit `platform_toolsets.cli` list. Without `mcp-codegraph` in that
13
- * list, the MCP server can be configured and connected but its tools may
14
- * still be filtered out of normal CLI sessions.
15
- */
16
- import { AgentTarget } from './types'
17
- export declare const hermesTarget: AgentTarget
18
- //# sourceMappingURL=hermes.d.ts.map
@@ -1,30 +0,0 @@
1
- /**
2
- * opencode target.
3
- *
4
- * - MCP server entry to `~/.config/opencode/opencode.jsonc` (global,
5
- * XDG-style; `%APPDATA%/opencode/opencode.jsonc` on Windows) or
6
- * `./opencode.jsonc` (local). Falls back to `opencode.json` when a
7
- * `.json` file already exists; defaults new installs to `.jsonc`
8
- * because that's what opencode itself creates on first run.
9
- * - Instructions to `~/.config/opencode/AGENTS.md` (global) or
10
- * `./AGENTS.md` (local). opencode reads AGENTS.md for agent
11
- * instructions — same convention Codex CLI uses.
12
- * - No permissions concept.
13
- *
14
- * Config shape uses opencode's wrapper:
15
- * {
16
- * "$schema": "https://opencode.ai/config.json",
17
- * "mcp": { "codegraph": { "type": "local", "command": [...], "enabled": true } }
18
- * }
19
- *
20
- * The shape differs from Claude/Cursor — opencode uses `mcp.<name>`
21
- * (not `mcpServers`), takes `command` as a string array combining
22
- * binary + args, and includes an explicit `enabled` flag.
23
- *
24
- * Reads + writes go through `jsonc-parser` so any `//` and `/* *\/`
25
- * comments the user has added to their `.jsonc` survive idempotent
26
- * re-runs.
27
- */
28
- import { AgentTarget } from './types'
29
- export declare const opencodeTarget: AgentTarget
30
- //# sourceMappingURL=opencode.d.ts.map
@@ -1,38 +0,0 @@
1
- /**
2
- * Registry of all known agent targets.
3
- *
4
- * Adding a new target = create `targets/<id>.ts` exporting an
5
- * `AgentTarget`, then add it to the array below. Order here is the
6
- * order they appear in the multiselect prompt, in `--target=all`,
7
- * and in `--print-config`'s help listing — keep it stable.
8
- */
9
- import { AgentTarget, Location, TargetId } from './types'
10
- export declare const ALL_TARGETS: readonly AgentTarget[]
11
- export declare function getTarget(id: string): AgentTarget | undefined
12
- export declare function listTargetIds(): TargetId[]
13
- /**
14
- * Run `detect()` for every target at the given location. Returns the
15
- * full registry zipped with detection results — orchestrator uses
16
- * this to seed the multiselect prompt with installed agents
17
- * pre-checked.
18
- */
19
- export declare function detectAll(loc: Location): Array<{
20
- target: AgentTarget
21
- detection: ReturnType<AgentTarget['detect']>
22
- }>
23
- /**
24
- * Resolve a `--target=` flag value to a list of `AgentTarget`
25
- * instances. Accepts:
26
- *
27
- * - `auto` — return all targets whose `detect().installed` is true,
28
- * or `['claude']` as a fallback if none detected (least-surprise
29
- * for existing users).
30
- * - `all` — every target in the registry.
31
- * - `none` — empty list (caller skips agent writes entirely).
32
- * - csv list — `'claude,cursor'` etc. Unknown ids throw.
33
- */
34
- export declare function resolveTargetFlag(
35
- value: string,
36
- loc: Location,
37
- ): AgentTarget[]
38
- //# sourceMappingURL=registry.d.ts.map
@@ -1,92 +0,0 @@
1
- /**
2
- * Helpers shared across `AgentTarget` implementations.
3
- *
4
- * Lifted from the original `config-writer.ts` so each target can
5
- * compose them without inheritance. Kept deliberately small — the
6
- * targets are different enough (JSON vs TOML vs Markdown, varying
7
- * idempotency markers) that a base class would force the awkward
8
- * shape onto everyone.
9
- */
10
- /**
11
- * The MCP-server config block codegraph injects. Same shape across
12
- * all JSON-shaped agent configs (Claude, Cursor, opencode), only the
13
- * surrounding wrapper differs. Codex (TOML) builds its own block.
14
- */
15
- export declare function getMcpServerConfig(): {
16
- type: string
17
- command: string
18
- args: string[]
19
- }
20
- /**
21
- * Permissions list for Claude `settings.json`. Other targets that
22
- * have a permissions concept can compose this list directly. The
23
- * permission strings follow Claude's `mcp__<server>__<tool>` format.
24
- */
25
- export declare function getCodeGraphPermissions(): string[]
26
- /**
27
- * Read a JSON file, returning `{}` when missing or unparseable.
28
- *
29
- * Unparseable files are backed up to `<path>.backup` BEFORE we return
30
- * `{}` — so an idempotent re-run never silently deletes a user's
31
- * existing config that happened to break JSON parse temporarily.
32
- */
33
- export declare function readJsonFile(filePath: string): Record<string, any>
34
- /**
35
- * Write a file atomically: write to `<path>.tmp.<pid>`, then rename.
36
- *
37
- * Prevents corruption if the process crashes mid-write. The temp
38
- * file is cleaned up on rename failure.
39
- */
40
- export declare function atomicWriteFileSync(
41
- filePath: string,
42
- content: string,
43
- ): void
44
- /**
45
- * Atomic JSON write. Trailing newline matches the convention every
46
- * existing target had — preserves diff-friendly file shape.
47
- */
48
- export declare function writeJsonFile(
49
- filePath: string,
50
- data: Record<string, any>,
51
- ): void
52
- /**
53
- * Compare two JSON values for deep equality, ignoring key order.
54
- *
55
- * Used for idempotency: when the on-disk config already exactly
56
- * matches what we'd write, return action=`unchanged` instead of
57
- * re-writing (and emitting a confusing "Updated" log line).
58
- */
59
- export declare function jsonDeepEqual(a: unknown, b: unknown): boolean
60
- /**
61
- * Replace or append a marker-delimited section in a markdown-ish file.
62
- *
63
- * Used by Claude / Codex for the `<!-- CODEGRAPH_START --> ... <!--
64
- * CODEGRAPH_END -->` block. Preserves all content outside the
65
- * markers verbatim.
66
- *
67
- * Returns `created` when the file didn't exist; `updated` when
68
- * markers were found and content swapped; `appended` when markers
69
- * weren't found and section was added at end. `unchanged` when the
70
- * existing block already matches `body`.
71
- */
72
- export declare function replaceOrAppendMarkedSection(
73
- filePath: string,
74
- body: string,
75
- startMarker: string,
76
- endMarker: string,
77
- ): 'created' | 'updated' | 'appended' | 'unchanged'
78
- /**
79
- * Inverse of `replaceOrAppendMarkedSection`. Strips the marker
80
- * block from `filePath` if present. If the file becomes empty after
81
- * removal, deletes the file entirely (matches the existing Claude
82
- * uninstall behavior).
83
- *
84
- * Returns `removed` when content was stripped, `not-found` when
85
- * the markers weren't present, `kept` when the file didn't exist.
86
- */
87
- export declare function removeMarkedSection(
88
- filePath: string,
89
- startMarker: string,
90
- endMarker: string,
91
- ): 'removed' | 'not-found' | 'kept'
92
- //# sourceMappingURL=shared.d.ts.map
@@ -1,64 +0,0 @@
1
- /**
2
- * Tiny TOML helpers — just enough to inject / replace / remove a
3
- * single dotted-key table block (`[mcp_servers.codegraph]`) inside an
4
- * existing `~/.codex/config.toml`. We deliberately do NOT try to be a
5
- * general TOML parser/serializer; that would mean pulling in a
6
- * dependency (~50KB) for ~6 lines of output.
7
- *
8
- * Strategy: treat the file as text. Find the `[mcp_servers.codegraph]`
9
- * header line, splice it (and the lines that follow it until the next
10
- * `[...]` header or EOF) in or out. Everything outside that block is
11
- * preserved verbatim, byte-for-byte.
12
- *
13
- * Limitations (acceptable for our narrow use):
14
- * - Only handles top-level table headers; not array-of-tables or
15
- * subtables nested inside `[mcp_servers]` itself (we always write
16
- * the full dotted key `[mcp_servers.codegraph]`).
17
- * - Doesn't validate sibling TOML — if the file is malformed
18
- * elsewhere, our injection won't fix it but won't make it worse.
19
- * - Quotes string values with double quotes; escapes `\` and `"`.
20
- */
21
- /**
22
- * Serialize a record into the body lines of a TOML table. Values
23
- * supported: string, string[]. Other types throw — the codex MCP
24
- * config only needs these two.
25
- */
26
- export declare function serializeTomlTableBody(
27
- values: Record<string, string | string[]>,
28
- ): string
29
- /**
30
- * Build a full table block: header line + body. Suitable for direct
31
- * insertion into a TOML file.
32
- */
33
- export declare function buildTomlTable(
34
- header: string,
35
- values: Record<string, string | string[]>,
36
- ): string
37
- /**
38
- * Insert or replace a top-level dotted-key TOML table block in the
39
- * given file content. Preserves all other content verbatim.
40
- *
41
- * Returns `'inserted'` when the table was newly added, `'replaced'`
42
- * when an existing one was rewritten, `'unchanged'` when the
43
- * existing block already matches `block` byte-for-byte.
44
- */
45
- export declare function upsertTomlTable(
46
- fileContent: string,
47
- header: string,
48
- block: string,
49
- ): {
50
- content: string
51
- action: 'inserted' | 'replaced' | 'unchanged'
52
- }
53
- /**
54
- * Remove a top-level dotted-key TOML table block. Returns the
55
- * possibly-empty new content + an action flag.
56
- */
57
- export declare function removeTomlTable(
58
- fileContent: string,
59
- header: string,
60
- ): {
61
- content: string
62
- action: 'removed' | 'not-found'
63
- }
64
- //# sourceMappingURL=toml.d.ts.map