@colbymchenry/codegraph 0.9.6 → 0.9.8

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 (119) hide show
  1. package/README.md +122 -57
  2. package/dist/bin/codegraph.d.ts +25 -0
  3. package/dist/bin/node-version-check.d.ts +37 -0
  4. package/dist/bin/uninstall.d.ts +14 -0
  5. package/dist/context/formatter.d.ts +30 -0
  6. package/dist/context/index.d.ts +110 -0
  7. package/dist/db/index.d.ts +101 -0
  8. package/dist/db/migrations.d.ts +44 -0
  9. package/dist/db/queries.d.ts +344 -0
  10. package/dist/db/sqlite-adapter.d.ts +46 -0
  11. package/dist/directory.d.ts +57 -0
  12. package/dist/errors.d.ts +136 -0
  13. package/dist/extraction/dfm-extractor.d.ts +31 -0
  14. package/dist/extraction/generated-detection.d.ts +30 -0
  15. package/dist/extraction/grammars.d.ts +100 -0
  16. package/dist/extraction/index.d.ts +138 -0
  17. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  18. package/dist/extraction/languages/csharp.d.ts +3 -0
  19. package/dist/extraction/languages/dart.d.ts +3 -0
  20. package/dist/extraction/languages/go.d.ts +3 -0
  21. package/dist/extraction/languages/index.d.ts +10 -0
  22. package/dist/extraction/languages/java.d.ts +3 -0
  23. package/dist/extraction/languages/javascript.d.ts +3 -0
  24. package/dist/extraction/languages/kotlin.d.ts +3 -0
  25. package/dist/extraction/languages/lua.d.ts +3 -0
  26. package/dist/extraction/languages/luau.d.ts +3 -0
  27. package/dist/extraction/languages/objc.d.ts +3 -0
  28. package/dist/extraction/languages/pascal.d.ts +3 -0
  29. package/dist/extraction/languages/php.d.ts +3 -0
  30. package/dist/extraction/languages/python.d.ts +3 -0
  31. package/dist/extraction/languages/ruby.d.ts +3 -0
  32. package/dist/extraction/languages/rust.d.ts +3 -0
  33. package/dist/extraction/languages/scala.d.ts +3 -0
  34. package/dist/extraction/languages/swift.d.ts +3 -0
  35. package/dist/extraction/languages/typescript.d.ts +3 -0
  36. package/dist/extraction/liquid-extractor.d.ts +52 -0
  37. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  38. package/dist/extraction/parse-worker.d.ts +8 -0
  39. package/dist/extraction/svelte-extractor.d.ts +56 -0
  40. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  41. package/dist/extraction/tree-sitter-types.d.ts +193 -0
  42. package/dist/extraction/tree-sitter.d.ts +291 -0
  43. package/dist/extraction/vue-extractor.d.ts +36 -0
  44. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  45. package/dist/graph/index.d.ts +8 -0
  46. package/dist/graph/queries.d.ts +106 -0
  47. package/dist/graph/traversal.d.ts +127 -0
  48. package/dist/index.d.ts +492 -0
  49. package/dist/installer/config-writer.d.ts +28 -0
  50. package/dist/installer/index.d.ts +100 -0
  51. package/dist/installer/instructions-template.d.ts +18 -0
  52. package/dist/installer/targets/antigravity.d.ts +57 -0
  53. package/dist/installer/targets/claude.d.ts +56 -0
  54. package/dist/installer/targets/codex.d.ts +18 -0
  55. package/dist/installer/targets/cursor.d.ts +35 -0
  56. package/dist/installer/targets/gemini.d.ts +26 -0
  57. package/dist/installer/targets/hermes.d.ts +18 -0
  58. package/dist/installer/targets/kiro.d.ts +27 -0
  59. package/dist/installer/targets/opencode.d.ts +30 -0
  60. package/dist/installer/targets/registry.d.ts +35 -0
  61. package/dist/installer/targets/shared.d.ts +77 -0
  62. package/dist/installer/targets/toml.d.ts +52 -0
  63. package/dist/installer/targets/types.d.ts +101 -0
  64. package/dist/mcp/daemon-paths.d.ts +46 -0
  65. package/dist/mcp/daemon.d.ts +161 -0
  66. package/dist/mcp/engine.d.ts +105 -0
  67. package/dist/mcp/index.d.ts +112 -0
  68. package/dist/mcp/proxy.d.ts +81 -0
  69. package/dist/mcp/server-instructions.d.ts +19 -0
  70. package/dist/mcp/session.d.ts +77 -0
  71. package/dist/mcp/tools.d.ts +423 -0
  72. package/dist/mcp/transport.d.ts +188 -0
  73. package/dist/mcp/version.d.ts +19 -0
  74. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  75. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  76. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  77. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  78. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  79. package/dist/resolution/frameworks/express.d.ts +8 -0
  80. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  81. package/dist/resolution/frameworks/go.d.ts +8 -0
  82. package/dist/resolution/frameworks/index.d.ts +48 -0
  83. package/dist/resolution/frameworks/java.d.ts +8 -0
  84. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  85. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  86. package/dist/resolution/frameworks/play.d.ts +19 -0
  87. package/dist/resolution/frameworks/python.d.ts +10 -0
  88. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  89. package/dist/resolution/frameworks/react.d.ts +8 -0
  90. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  91. package/dist/resolution/frameworks/rust.d.ts +8 -0
  92. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  93. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  94. package/dist/resolution/frameworks/swift.d.ts +10 -0
  95. package/dist/resolution/frameworks/vue.d.ts +9 -0
  96. package/dist/resolution/go-module.d.ts +26 -0
  97. package/dist/resolution/import-resolver.d.ts +68 -0
  98. package/dist/resolution/index.d.ts +116 -0
  99. package/dist/resolution/lru-cache.d.ts +24 -0
  100. package/dist/resolution/name-matcher.d.ts +32 -0
  101. package/dist/resolution/path-aliases.d.ts +68 -0
  102. package/dist/resolution/strip-comments.d.ts +27 -0
  103. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  104. package/dist/resolution/types.d.ts +209 -0
  105. package/dist/search/query-parser.d.ts +57 -0
  106. package/dist/search/query-utils.d.ts +53 -0
  107. package/dist/sync/git-hooks.d.ts +45 -0
  108. package/dist/sync/index.d.ts +19 -0
  109. package/dist/sync/watch-policy.d.ts +48 -0
  110. package/dist/sync/watcher.d.ts +191 -0
  111. package/dist/sync/worktree.d.ts +54 -0
  112. package/dist/types.d.ts +369 -0
  113. package/dist/ui/glyphs.d.ts +42 -0
  114. package/dist/ui/shimmer-progress.d.ts +11 -0
  115. package/dist/ui/shimmer-worker.d.ts +2 -0
  116. package/dist/ui/types.d.ts +17 -0
  117. package/dist/utils.d.ts +205 -0
  118. package/npm-sdk.js +75 -0
  119. package/package.json +18 -7
@@ -0,0 +1,100 @@
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, Gemini CLI, Antigravity IDE).
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 { AgentTarget, Location, TargetId } from './targets/types';
15
+ export { writeMcpConfig, writePermissions, hasMcpConfig, hasPermissions, } from './config-writer';
16
+ export type { InstallLocation } from './config-writer';
17
+ export interface RunInstallerOptions {
18
+ /** Comma-separated target list, or `auto` / `all` / `none`. */
19
+ target?: string;
20
+ /** Skip the location prompt; use this value directly. */
21
+ location?: Location;
22
+ /** Skip the auto-allow prompt; use this value directly. */
23
+ autoAllow?: boolean;
24
+ /**
25
+ * Skip every confirm and use defaults: location=global,
26
+ * autoAllow=true, target=auto. For scripting / CI.
27
+ */
28
+ yes?: boolean;
29
+ }
30
+ /**
31
+ * Interactive entry point — preserves the historical UX (`codegraph
32
+ * install` with no args goes through the prompts), but now starts
33
+ * the targets multi-select pre-populated with detected agents.
34
+ */
35
+ export declare function runInstaller(): Promise<void>;
36
+ export declare function runInstallerWithOptions(opts: RunInstallerOptions): Promise<void>;
37
+ export interface RunUninstallerOptions {
38
+ /**
39
+ * Comma-separated target list, or `auto` / `all` / `none`. Defaults
40
+ * to `all` — uninstall sweeps every known agent and reports which
41
+ * ones it actually touched, so the user doesn't have to know where
42
+ * they configured it.
43
+ */
44
+ target?: string;
45
+ /** Skip the location prompt; use this value directly. */
46
+ location?: Location;
47
+ /** Non-interactive: location=global, target=all, no prompts. */
48
+ yes?: boolean;
49
+ }
50
+ export type UninstallStatus = 'removed' | 'not-configured' | 'unsupported';
51
+ /**
52
+ * Per-target outcome of an uninstall sweep. `removed` means we deleted
53
+ * at least one thing; `not-configured` means the agent had no codegraph
54
+ * config at this location (nothing to do); `unsupported` means the
55
+ * agent has no config concept for this location (e.g. Codex is
56
+ * global-only, so a `local` uninstall skips it).
57
+ */
58
+ export interface UninstallReport {
59
+ id: TargetId;
60
+ displayName: string;
61
+ status: UninstallStatus;
62
+ /** Absolute paths we actually edited/removed (action === 'removed'). */
63
+ removedPaths: string[];
64
+ /** Verbatim notes from the target (rare for uninstall). */
65
+ notes: string[];
66
+ }
67
+ /**
68
+ * Pure uninstall sweep — no prompts, no I/O beyond the targets' own
69
+ * file edits. Exposed (and unit-tested) separately from the clack UI in
70
+ * `runUninstaller` so the aggregation logic can be asserted directly.
71
+ *
72
+ * Each target's `uninstall()` is already safe to call when nothing was
73
+ * installed (it returns `not-found` actions), so this is safe to run
74
+ * across every target unconditionally.
75
+ */
76
+ export declare function uninstallTargets(targets: readonly AgentTarget[], location: Location): UninstallReport[];
77
+ /**
78
+ * Interactive uninstaller — the inverse of `runInstallerWithOptions`.
79
+ * Asks global-vs-local first (unless `--location`/`--yes` is given),
80
+ * then sweeps every agent target (or the `--target` subset) and prints
81
+ * one block per agent so the user sees exactly which providers it hit.
82
+ *
83
+ * Removes only what install wrote (MCP server entry, instructions
84
+ * block, permissions) — never the `.codegraph/` index, which `codegraph
85
+ * uninit` owns.
86
+ */
87
+ export declare function runUninstaller(opts: RunUninstallerOptions): Promise<void>;
88
+ /**
89
+ * When the live file watcher will be disabled for this project (e.g. WSL2
90
+ * /mnt drives, or CODEGRAPH_NO_WATCH), the index would silently go stale.
91
+ * Explain that, and offer to keep it fresh automatically via git hooks
92
+ * (commit / pull / checkout) instead of manual `codegraph sync`.
93
+ *
94
+ * No-op on environments where the watcher runs normally, so it's safe to
95
+ * call unconditionally after init.
96
+ */
97
+ export declare function offerWatchFallback(clack: typeof import('@clack/prompts'), projectPath: string, opts?: {
98
+ yes?: boolean;
99
+ }): Promise<void>;
100
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Marker constants for the legacy agent-instructions block.
3
+ *
4
+ * Codegraph used to write a `## CodeGraph` usage guide into each
5
+ * agent's instructions file (CLAUDE.md / AGENTS.md / GEMINI.md /
6
+ * codegraph.mdc / Kiro steering doc). That duplicated the guidance the
7
+ * MCP server already emits in its `initialize` response — every agent
8
+ * read the same playbook twice each turn (issue #529). The installer no
9
+ * longer writes an instructions file; the MCP server instructions in
10
+ * `mcp/server-instructions.ts` are the single source of truth.
11
+ *
12
+ * These markers are retained so install (self-heal on upgrade) and
13
+ * uninstall can find and strip the block a previous install wrote.
14
+ */
15
+ /** Markers used by the marker-based section removal. */
16
+ export declare const CODEGRAPH_SECTION_START = "<!-- CODEGRAPH_START -->";
17
+ export declare const CODEGRAPH_SECTION_END = "<!-- CODEGRAPH_END -->";
18
+ //# sourceMappingURL=instructions-template.d.ts.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Google Antigravity IDE target. Antigravity is Google's VS Code-derived
3
+ * multi-agent IDE; the Gemini CLI is in the process of consolidating with
4
+ * it under a single agent platform. Antigravity reads MCP server
5
+ * definitions from a separate config file from the CLI.
6
+ *
7
+ * ## Config path: unified vs legacy
8
+ *
9
+ * Antigravity recently migrated to a **unified** MCP config path shared
10
+ * across all Antigravity tools:
11
+ *
12
+ * - **Unified** (post-migration, current): `~/.gemini/config/mcp_config.json`
13
+ * — signalled by the `~/.gemini/config/.migrated` marker file.
14
+ * - **Legacy** (pre-migration): `~/.gemini/antigravity/mcp_config.json`
15
+ * — what the github-mcp-server install guide still documents.
16
+ *
17
+ * We detect the marker at install time and write to the right path. On
18
+ * uninstall we sweep BOTH — so a user who installed on the legacy path,
19
+ * was then auto-migrated by Antigravity, and re-ran `codegraph install`
20
+ * doesn't end up with stale codegraph entries in two files.
21
+ *
22
+ * ## Entry shape: no `type: stdio` field
23
+ *
24
+ * Antigravity rejects MCP entries that carry the `type: "stdio"` field
25
+ * the rest of our targets use — the working entries it manages itself
26
+ * (e.g. `code-review-graph`) omit it, and dropping it was load-bearing
27
+ * to get codegraph to appear in the Customizations UI. We build the
28
+ * entry locally instead of routing through `getMcpServerConfig()`.
29
+ *
30
+ * ## macOS GUI app PATH resolution
31
+ *
32
+ * Antigravity is a GUI Electron app. macOS gives Dock/Finder-launched
33
+ * apps a stripped PATH (`/usr/bin:/bin:/usr/sbin:/sbin`) — nvm-managed
34
+ * tools live outside that, so a bare `codegraph` command fails to spawn
35
+ * even when `which codegraph` resolves in the user's shell. We resolve
36
+ * `codegraph` to its absolute path on macOS at install time. (Linux GUI
37
+ * apps inherit user PATH; Windows uses `PATH` env directly — both are
38
+ * fine with the bare command.)
39
+ *
40
+ * ## Shared instructions (no GEMINI.md from here)
41
+ *
42
+ * The IDE shares `~/.gemini/GEMINI.md` with Gemini CLI for instructions
43
+ * — written by the `./gemini.ts` target. We deliberately don't touch it
44
+ * here so uninstalling Antigravity without uninstalling Gemini CLI
45
+ * leaves CLI instructions intact. Users who install only Antigravity
46
+ * still get a working MCP integration; the prefer-codegraph-over-grep
47
+ * guidance just won't be present unless they also install the gemini
48
+ * target.
49
+ *
50
+ * ## Location
51
+ *
52
+ * `supportsLocation('local')` returns false — Antigravity has no
53
+ * project-scoped config concept as of 2026-05.
54
+ */
55
+ import { AgentTarget } from './types';
56
+ export declare const antigravityTarget: AgentTarget;
57
+ //# sourceMappingURL=antigravity.d.ts.map
@@ -0,0 +1,56 @@
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(loc: Location): WriteResult['files'][number];
28
+ /**
29
+ * Remove stale codegraph auto-sync hooks from Claude `settings.json`.
30
+ *
31
+ * Surgical at the individual-command level: only entries matching
32
+ * `isLegacyCodegraphHookCommand` are dropped, so a sibling hook sharing
33
+ * a matcher group (or the Stop event) with ours survives. We prune a
34
+ * matcher group only once its `hooks` array is empty, an event only
35
+ * once it has no groups left, and `hooks` itself only once every event
36
+ * is gone — and none of that runs unless we actually removed a
37
+ * codegraph command, so a settings.json with no legacy hooks is left
38
+ * byte-for-byte untouched and reported `unchanged`.
39
+ *
40
+ * Exported so it can be unit-tested directly and reused by both
41
+ * `install` (an upgrade self-heals) and `uninstall`.
42
+ */
43
+ export declare function cleanupLegacyHooks(loc: Location): WriteResult['files'][number];
44
+ export declare function writePermissionsEntry(loc: Location): WriteResult['files'][number];
45
+ /**
46
+ * Strip the marker-delimited CodeGraph block from CLAUDE.md if a prior
47
+ * install wrote one. Codegraph no longer maintains an instructions file
48
+ * (issue #529) — the MCP server's `initialize` instructions are the
49
+ * single source of truth — so both install (self-heal on upgrade) and
50
+ * uninstall call this. `removeMarkedSection` returns `not-found`/`kept`
51
+ * when there's nothing to strip; the install caller drops those from
52
+ * the report so a fresh install stays quiet.
53
+ */
54
+ export declare function removeInstructionsEntry(loc: Location): WriteResult['files'][number];
55
+ export declare const claudeTarget: AgentTarget;
56
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,35 @@
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
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Gemini CLI target (also covers the rebranded "Antigravity CLI" —
3
+ * Google is in the middle of unifying its CLI tools under
4
+ * Antigravity, and the new CLI continues to read `~/.gemini/settings.json`
5
+ * + project-local `.gemini/settings.json`). Writes:
6
+ *
7
+ * - MCP server entry to `~/.gemini/settings.json` (global) or
8
+ * `./.gemini/settings.json` (local) under the standard
9
+ * `mcpServers.codegraph` key. Same shape as Claude / Cursor.
10
+ * - Instructions to `~/.gemini/GEMINI.md` (global) or `./GEMINI.md`
11
+ * (local — Gemini reads the project root file directly, not
12
+ * under `.gemini/`).
13
+ *
14
+ * No permissions concept — Gemini CLI gates tool invocations through
15
+ * the `trust` field per server, not an external allowlist. We leave
16
+ * `trust` unset so the user controls confirmation prompts.
17
+ *
18
+ * The Antigravity IDE shares `~/.gemini/GEMINI.md` for instructions
19
+ * but uses a separate MCP config file (`~/.gemini/antigravity/mcp_config.json`)
20
+ * — see `./antigravity.ts`. Both targets writing to GEMINI.md is
21
+ * safe: the marker-based section replacement makes the second write
22
+ * a byte-identical no-op.
23
+ */
24
+ import { AgentTarget } from './types';
25
+ export declare const geminiTarget: AgentTarget;
26
+ //# sourceMappingURL=gemini.d.ts.map
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Kiro CLI / IDE target. Writes:
3
+ *
4
+ * - MCP server entry to `~/.kiro/settings/mcp.json` (global) or
5
+ * `./.kiro/settings/mcp.json` (local). Standard `mcpServers.codegraph`
6
+ * shape, same as Claude / Cursor / Gemini.
7
+ * - Instructions to `~/.kiro/steering/codegraph.md` (global) or
8
+ * `./.kiro/steering/codegraph.md` (local). Kiro's "steering" system
9
+ * loads every `*.md` file in the steering dir as agent context, so
10
+ * a dedicated `codegraph.md` is the natural surface — we own the
11
+ * whole file outright (no marker-based merging needed) and delete
12
+ * it on uninstall.
13
+ *
14
+ * No permissions concept — Kiro gates tool invocations through its own
15
+ * UI prompts rather than an external allowlist. `autoAllow` is silently
16
+ * ignored.
17
+ *
18
+ * Paths are identical on macOS / Linux / Windows because Kiro resolves
19
+ * its config root from `os.homedir()` on all three (Windows `~` →
20
+ * `%USERPROFILE%\.kiro`).
21
+ *
22
+ * Docs: https://kiro.dev/docs/cli/mcp/
23
+ * https://kiro.dev/docs/cli/steering/
24
+ */
25
+ import { AgentTarget } from './types';
26
+ export declare const kiroTarget: AgentTarget;
27
+ //# sourceMappingURL=kiro.d.ts.map
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,35 @@
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(value: string, loc: Location): AgentTarget[];
35
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,77 @@
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(filePath: string, content: string): void;
41
+ /**
42
+ * Atomic JSON write. Trailing newline matches the convention every
43
+ * existing target had — preserves diff-friendly file shape.
44
+ */
45
+ export declare function writeJsonFile(filePath: string, data: Record<string, any>): void;
46
+ /**
47
+ * Compare two JSON values for deep equality, ignoring key order.
48
+ *
49
+ * Used for idempotency: when the on-disk config already exactly
50
+ * matches what we'd write, return action=`unchanged` instead of
51
+ * re-writing (and emitting a confusing "Updated" log line).
52
+ */
53
+ export declare function jsonDeepEqual(a: unknown, b: unknown): boolean;
54
+ /**
55
+ * Replace or append a marker-delimited section in a markdown-ish file.
56
+ *
57
+ * Used by Claude / Codex for the `<!-- CODEGRAPH_START --> ... <!--
58
+ * CODEGRAPH_END -->` block. Preserves all content outside the
59
+ * markers verbatim.
60
+ *
61
+ * Returns `created` when the file didn't exist; `updated` when
62
+ * markers were found and content swapped; `appended` when markers
63
+ * weren't found and section was added at end. `unchanged` when the
64
+ * existing block already matches `body`.
65
+ */
66
+ export declare function replaceOrAppendMarkedSection(filePath: string, body: string, startMarker: string, endMarker: string): 'created' | 'updated' | 'appended' | 'unchanged';
67
+ /**
68
+ * Inverse of `replaceOrAppendMarkedSection`. Strips the marker
69
+ * block from `filePath` if present. If the file becomes empty after
70
+ * removal, deletes the file entirely (matches the existing Claude
71
+ * uninstall behavior).
72
+ *
73
+ * Returns `removed` when content was stripped, `not-found` when
74
+ * the markers weren't present, `kept` when the file didn't exist.
75
+ */
76
+ export declare function removeMarkedSection(filePath: string, startMarker: string, endMarker: string): 'removed' | 'not-found' | 'kept';
77
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,52 @@
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(values: Record<string, string | string[]>): string;
27
+ /**
28
+ * Build a full table block: header line + body. Suitable for direct
29
+ * insertion into a TOML file.
30
+ */
31
+ export declare function buildTomlTable(header: string, values: Record<string, string | string[]>): string;
32
+ /**
33
+ * Insert or replace a top-level dotted-key TOML table block in the
34
+ * given file content. Preserves all other content verbatim.
35
+ *
36
+ * Returns `'inserted'` when the table was newly added, `'replaced'`
37
+ * when an existing one was rewritten, `'unchanged'` when the
38
+ * existing block already matches `block` byte-for-byte.
39
+ */
40
+ export declare function upsertTomlTable(fileContent: string, header: string, block: string): {
41
+ content: string;
42
+ action: 'inserted' | 'replaced' | 'unchanged';
43
+ };
44
+ /**
45
+ * Remove a top-level dotted-key TOML table block. Returns the
46
+ * possibly-empty new content + an action flag.
47
+ */
48
+ export declare function removeTomlTable(fileContent: string, header: string): {
49
+ content: string;
50
+ action: 'removed' | 'not-found';
51
+ };
52
+ //# sourceMappingURL=toml.d.ts.map
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Agent target abstraction for the installer.
3
+ *
4
+ * Each MCP-capable agent (Claude Code, Cursor, Codex CLI, opencode, ...)
5
+ * implements this interface so the installer orchestrator can write the
6
+ * right MCP-server config + instructions file + permissions for that
7
+ * agent without baking client-specific paths into core code. Adding a
8
+ * new agent = one new file in `targets/` + one entry in `registry.ts`.
9
+ *
10
+ * Closes the Claude-locked installer issue (upstream #137). The
11
+ * runtime MCP server is already agent-agnostic; this brings the
12
+ * installer to the same surface.
13
+ */
14
+ export type Location = 'global' | 'local';
15
+ /**
16
+ * Stable string id used in the `--target` CLI flag and the registry
17
+ * lookup. New targets add a value here when they're added to the
18
+ * registry. Keep these short and lowercase.
19
+ */
20
+ export type TargetId = 'claude' | 'cursor' | 'codex' | 'opencode' | 'hermes' | 'gemini' | 'antigravity' | 'kiro';
21
+ /**
22
+ * Result of `target.detect(location)`.
23
+ *
24
+ * `installed` is a best-effort heuristic that the agent's CLI / app /
25
+ * config dir is present on this system — used to default the
26
+ * multiselect prompt to "what's actually here." False positives are
27
+ * acceptable (we still write); false negatives just mean the user
28
+ * has to opt in manually.
29
+ *
30
+ * `alreadyConfigured` reports whether codegraph has already been
31
+ * wired into this target at this location — drives the
32
+ * "Updated"-vs-"Added" log line and lets `--check` exit 0/1.
33
+ */
34
+ export interface DetectionResult {
35
+ installed: boolean;
36
+ alreadyConfigured: boolean;
37
+ /** Path inspected; surfaced in diagnostic / dry-run output. */
38
+ configPath?: string;
39
+ }
40
+ /**
41
+ * What `target.install(location)` actually changed on disk. The
42
+ * orchestrator renders one log line per file using `action`.
43
+ *
44
+ * `unchanged` means we touched the file but its contents were already
45
+ * what we'd write — used for byte-identical idempotent re-runs.
46
+ */
47
+ export interface WriteResult {
48
+ files: Array<{
49
+ path: string;
50
+ action: 'created' | 'updated' | 'unchanged' | 'removed' | 'not-found' | 'kept';
51
+ }>;
52
+ /**
53
+ * Optional one-line notes the orchestrator surfaces verbatim — e.g.
54
+ * "Restart Cursor to apply." Keep these short; multi-line goes in
55
+ * the README.
56
+ */
57
+ notes?: string[];
58
+ }
59
+ export interface InstallOptions {
60
+ /**
61
+ * Whether to write the agent's permissions / auto-allow surface
62
+ * (Claude `settings.json`, others where applicable). When the
63
+ * target has no permissions concept this option is a no-op.
64
+ */
65
+ autoAllow: boolean;
66
+ }
67
+ export interface AgentTarget {
68
+ /** Stable id; matches the `TargetId` union. */
69
+ readonly id: TargetId;
70
+ /** Human-readable name shown in clack prompts and log lines. */
71
+ readonly displayName: string;
72
+ /** Optional URL for "where do I learn more about this agent." */
73
+ readonly docsUrl?: string;
74
+ /**
75
+ * Whether this target supports the given install location.
76
+ *
77
+ * Some agents (Codex CLI as of 2026-05) have no project-local
78
+ * config concept — only a single `~/.codex/` dir. Returning false
79
+ * for an unsupported (target, location) pair lets the orchestrator
80
+ * skip cleanly with a clear message.
81
+ */
82
+ supportsLocation(loc: Location): boolean;
83
+ detect(loc: Location): DetectionResult;
84
+ install(loc: Location, opts: InstallOptions): WriteResult;
85
+ /**
86
+ * Inverse of install. Removes only what install would have written;
87
+ * preserves sibling MCP servers, sibling permissions, and unrelated
88
+ * markdown sections. Must be safe to call when nothing was ever
89
+ * installed (returns `not-found` actions).
90
+ */
91
+ uninstall(loc: Location): WriteResult;
92
+ /**
93
+ * Print the MCP-server snippet a user would paste manually for this
94
+ * target. Used by `codegraph install --print-config <id>` and by
95
+ * the README. Must NOT touch the filesystem.
96
+ */
97
+ printConfig(loc: Location): string;
98
+ /** Filesystem paths this target would write to at this location. */
99
+ describePaths(loc: Location): string[];
100
+ }
101
+ //# sourceMappingURL=types.d.ts.map