codebase-snapshot 0.20.13 → 0.22.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 (51) hide show
  1. package/CHANGELOG.md +45 -6
  2. package/README.md +46 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/bin.js +14535 -12036
  5. package/dist/{chunk-GNVRD7XS.js → chunk-NPCDJBE4.js} +6097 -4425
  6. package/dist/cli.cjs +11184 -8708
  7. package/dist/cli.d.cts +94 -2
  8. package/dist/cli.d.ts +94 -2
  9. package/dist/cli.js +944 -95
  10. package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-BUNhTXkj.d.cts} +2 -2
  11. package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-TUMvHlgz.d.ts} +2 -2
  12. package/dist/index.cjs +6073 -4423
  13. package/dist/index.d.cts +281 -63
  14. package/dist/index.d.ts +281 -63
  15. package/dist/index.js +1 -1
  16. package/dist/mcp.cjs +10240 -4315
  17. package/dist/mcp.d.cts +13 -7
  18. package/dist/mcp.d.ts +13 -7
  19. package/dist/mcp.js +1 -1
  20. package/dist/{types-C5ytHMYz.d.ts → types-DQXKiaXk.d.cts} +50 -2
  21. package/dist/{types-C5ytHMYz.d.cts → types-DQXKiaXk.d.ts} +50 -2
  22. package/docs/about.md +86 -0
  23. package/docs/agent.md +28 -6
  24. package/docs/answer.md +99 -48
  25. package/docs/benchmarks.md +34 -34
  26. package/docs/brief.md +80 -81
  27. package/docs/cli.md +126 -25
  28. package/docs/codebase-token-budget.md +14 -13
  29. package/docs/contents.md +68 -0
  30. package/docs/deploy.md +2 -2
  31. package/docs/faq.md +112 -0
  32. package/docs/glossary.md +152 -0
  33. package/docs/guard.md +154 -0
  34. package/docs/health.md +1 -1
  35. package/docs/how-to-feed-a-repo-to-claude.md +6 -0
  36. package/docs/impact.md +102 -0
  37. package/docs/install.md +4 -3
  38. package/docs/llm-codebase-context.md +166 -0
  39. package/docs/mcp-server-for-codebase.md +163 -0
  40. package/docs/mcp.md +48 -67
  41. package/docs/migration.md +83 -90
  42. package/docs/output.md +1 -3
  43. package/docs/security-review.md +8 -8
  44. package/docs/slice.md +1 -1
  45. package/docs/tools.md +159 -185
  46. package/docs/troubleshooting.md +11 -11
  47. package/docs/vs-code2prompt.md +7 -0
  48. package/docs/vs-gitingest.md +7 -0
  49. package/docs/vs-repomix.md +10 -1
  50. package/docs/workspace.md +1 -1
  51. package/package.json +8 -2
package/docs/migration.md CHANGED
@@ -1,91 +1,84 @@
1
- # Migrating to 0.20.13
2
-
3
- Nothing was removed. Every command, flag, config key and MCP tool that existed in 0.12.14 still
4
- works. This page maps what was added and the behaviour changes that matter when upgrading an old
5
- checkout, config or snapshot.
6
-
7
- ## New commands
8
-
9
- | Command | Since | What it does |
10
- | :--- | :--- | :--- |
11
- | `snapshot health` | 0.12.15 | Audits the written snapshot: hashes, artifacts, secrets, host paths, tokens, freshness, signature. `--strict`, `--format json`, `--deep`, `--all-members`. |
12
- | `snapshot serve` | 0.12.19 | A browser page to generate, preview and download a snapshot; MCP on the same port. |
13
- | `snapshot mcp --http` | 0.12.18 | MCP over Streamable HTTP instead of stdio; `GET /sse` for legacy clients since 0.12.29. |
14
- | `snapshot update` | 0.18.0 | Bypasses the update cache, prints the registry answer, exits 0 current / 1 newer / 2 unreachable. |
15
-
16
- ## New `generate` flags
17
-
18
- | Flag | Since | What it does |
19
- | :--- | :--- | :--- |
20
- | `--remote <url>` | 0.12.20 | Shallow, SSRF-safe clone of a public repository; provenance in the manifest. |
21
- | `--ref <branch>` | 0.12.20 | Branch or tag for `--remote`. |
22
- | `--allow-private` | 0.12.20 | Explicit override for private addresses and `file:` URLs. |
23
- | `--keep-clone` | 0.12.20 | Keep the temporary clone. |
24
- | `--include-diffs` | 0.12.24 | `reports/diff.md` from the uncommitted diff. |
25
- | `--include-logs <n>` | 0.12.24 | `reports/log.md` with the last n commits. |
26
- | `--token-tree` | 0.12.24 | `reports/tokens.md` with per-file estimates. |
27
- | `--delta <path>` | 0.12.25 | Only what changed since a base snapshot, plus its importers. |
28
- | `--slice "<question>"` | 0.12.26 | Only what the retrieval planner picks for a question. |
29
- | `--slice-tokens <n>` | 0.12.26 | The slice budget (default 30000). |
30
- | `--pack single|xml|json` | 0.12.31 | One full-repository file in the chosen shape. |
31
- | `--sign` | 0.12.32 | Ed25519 signature over the manifest. |
32
- | `--budget-tokens <n>` | 0.12.33 | Fit the repository into a token budget by selecting whole files. |
33
-
34
- ## New config keys
35
-
36
- | Key | Since | Notes |
37
- | :--- | :--- | :--- |
38
- | `artifacts.diff`, `artifacts.log`, `artifacts.tokenTree` | 0.12.24 | Default `false`. `--skip-artifacts` still wins. |
39
- | `logCount` | 0.12.24 | 1-500, default 20. |
40
- | `pack` | 0.12.31 | `single`, `xml` or `json`; unset keeps the monolith pair. |
41
- | `discovery` | 0.13.x | `auto`, `git` or `walk`; recorded in the config digest. |
42
- | `maxParts` | 0.16.x | Grow the part budget until the snapshot has at most this many parts. |
43
-
44
- ## MCP
45
-
46
- Tools went from eight to **26**: health, budget, history, tests, workspace, entrypoints,
47
- neighbors, routes, cycles, search, stats, review, diff_context, symbol, context, query,
48
- plan_for, answer, plan, generate, validate, locate, dependents, read, explain and status.
49
- Prompts went from two (`orient`, `keep-current`) to seven (`audit`, `review`, `explain`,
50
- `onboard`, `security-review` were added). Resources gained `snapshot://prompt` and the three
51
- opt-in reports.
52
-
53
- stdio is still the default. `--http` adds Streamable HTTP with a bearer token and a loopback
54
- bind; `--no-auth` is refused on a non-loopback bind. The page and the MCP endpoint can share
55
- one port with `serve`.
56
-
57
- ## 0.18.0 to 0.20.13: what changed
58
-
59
- | Change | Since | Why it matters |
1
+ # Migrating to 0.21.0
2
+
3
+ 0.21.0 is a breaking release. The MCP surface is deliberately smaller, `impact` and `brief` work
4
+ without a generated snapshot, and the default read path is live. There is no silent compatibility
5
+ layer: a removed tool or a changed default fails loudly.
6
+
7
+ ## Before you upgrade
8
+
9
+ 1. Pin the exact 0.21.0 release in the manifest or lockfile you deploy.
10
+ 2. Run `codebase-snapshot validate` against the old snapshot. Re-generate before relying on the
11
+ new live tools; the manifest format is still readable, but the MCP surface changed.
12
+ 3. If an agent or CI job calls an MCP tool by name, update it from the table below. The seven tools
13
+ are the complete set: `snapshot_impact`, `snapshot_context`, `snapshot_locate`,
14
+ `snapshot_read`, `snapshot_validate`, `snapshot_explain`, `snapshot_generate`.
15
+
16
+ ## MCP: 27 tools to 7
17
+
18
+ | Removed tool(s) | Replacement |
19
+ | :--- | :--- |
20
+ | `snapshot_status`, `snapshot_stats`, `snapshot_review` | `snapshot_validate` with `mode: "status"` or `mode: "audit"` |
21
+ | `snapshot_health` | `snapshot_validate` with `mode: "audit"` and `deep: true` |
22
+ | `snapshot_dependents`, `snapshot_neighbors`, `snapshot_tests`, `snapshot_diff_context`, `snapshot_cycles` | `snapshot_impact` |
23
+ | `snapshot_plan_for`, `snapshot_answer`, `snapshot_budget` | `snapshot_context` (use `planOnly: true` for the plan without bodies) |
24
+ | `snapshot_search`, `snapshot_symbol`, `snapshot_query`, `snapshot_routes`, `snapshot_entrypoints` | `snapshot_locate` |
25
+ | `snapshot_history` | `snapshot://reports/log`, or the report file on disk |
26
+ | `snapshot_workspace` | `context/WORKSPACE.json` and the CLI |
27
+
28
+ The seven remaining tools keep the same read/write rule: only `snapshot_generate` writes. The
29
+ other six are read-only and must never create a cache, a temp file, or a snapshot inside the
30
+ repository. Live reads may write the documented OS cache under the user cache directory, never
31
+ inside the served repository.
32
+
33
+ ## Changed defaults
34
+
35
+ - `impact` defaults to `HEAD`. It no longer requires a prior `generate`; it builds a live index in
36
+ memory and overlays uncommitted edits.
37
+ - `impact` and `brief` use the live index by default. Pass `--no-live` to require the persisted
38
+ snapshot. `--no-cache` bypasses only the OS summary cache.
39
+ - `snapshot_read` prefers snapshot part bodies when the index source is `snapshot`; live bytes are
40
+ used only for `live-overlay` or `live-memory`.
41
+ - `snapshot_validate` with `mode: "status"` reports presence, counts, fingerprint and timestamps;
42
+ it does **not** claim `current`. Use the default drift mode for freshness. Audit mode reports
43
+ health, not drift.
44
+ - `brief` was added. It emits redacted diff hunks and bounded source windows, with every omitted
45
+ file named. `--out` refuses symbolic and hard links.
46
+ - `skill --install` writes three registries: `.agents/`, `.claude/` and `.cursor/`.
47
+ `--with-mcp` merges one entry into `.mcp.json` and preserves other servers.
48
+
49
+ ## New flags
50
+
51
+ | Flag | Command | Meaning |
60
52
  | :--- | :--- | :--- |
61
- | `snapshot update` and a corrected update cache | 0.18.0, 0.20.0 | The command bypasses the cache; a failed check is remembered for five minutes, not an hour. |
62
- | `health` recognises its own redaction marker and scans parts per section | 0.18.2, 0.19.0 | A clean snapshot no longer scores 70 for leaks that do not exist. The remaining host-path warning is documentation examples, not a credential. |
63
- | The audit verifies snapshot claims, not only hashes | 0.20.1, 0.20.2 | Artifact counts, bodies, packs and workspace indexes are recomputed; a hand-edited snapshot fails. |
64
- | `health` skips a secret check in linear time | 0.20.3 | A large skipped-secret set no longer re-reads the snapshot per token. |
65
- | Security hardening across CLI, scanner, redaction, MCP, serve and remote | 0.20.4-0.20.12 | CodeQL, audit and live-verdict findings: path confinement, redaction continuations, rate limiting, 413 flushing, part-size caps, IPv6 remote parsing, git/walk parity and clone cleanup. |
66
- | MCP 2026-07-28 transport conformance | 0.20.13 | Required HTTP routing headers and header/body agreement, cache hints on every cacheable result, `-32602` for a missing modern resource, and stateless handling of `mcp-session-id`. Official v2 client tests cover modern stdio and HTTP. |
67
-
68
- ## Behaviour changes to know
69
-
70
- 1. **`validate` accepts `--include-diffs`, `--include-logs` and `--token-tree`** (0.12.28).
71
- Those flags change the artifact selection the manifest records, so pass the same flags to
72
- compare like with like.
73
- 2. **The 0.20 line is published in place.** Every 0.20.x patch is committed, tagged and may be
74
- published; earlier lines published only at `x.y.0`. Pin an exact version when the same build
75
- must run everywhere.
76
- 3. **The 0.20.12 HTTP/MCP limits are stricter.** Empty JSON-RPC batches are invalid, oversized
77
- bodies return 413 before the socket closes, and content tools refuse a part above 16 MiB.
78
- 4. **The 0.20.13 modern transport is stricter.** A `2026-07-28` HTTP request must carry
79
- `MCP-Protocol-Version`, `Mcp-Method` and, for named calls, `Mcp-Name`; a mismatch is
80
- refused before dispatch instead of being silently routed on the body. Modern cacheable
81
- results carry `ttlMs: 0` and `cacheScope: "private"`, and a missing resource is `-32602`.
82
-
83
- `validate` on a snapshot written by an older version still works: newer manifest keys are
84
- optional, and an artifact the manifest does not record is not required to exist.
85
-
86
- ## If you are on an older 0.12.x
87
-
88
- Upgrade to the latest 0.12.x first; every change since 0.12.14 is a patch on the same line, and
89
- the configuration file format has not changed. Run `snapshot health` after the first generate on
90
- the new version - it is the fastest way to see whether an old snapshot carries anything the
91
- newer checks would refuse.
53
+ | `--brief <path>` | generate, validate | Merge an owner-written half into `PROMPT.md`. |
54
+ | `--prompt-task <task>` | generate, validate | `audit`, `review` or `explain`. |
55
+ | `--attachment-slots <n>` | generate | Plan delivery for a destination that accepts n files. |
56
+ | `--max-parts <n>` | generate, validate | Grow the part budget until the snapshot has at most n parts. |
57
+ | `--tests-paths` | impact | Print candidate test paths, one per line. |
58
+ | `--run` | impact | Run the detected runner on the candidate tests (text output only). |
59
+ | `--precise` | impact | Add bounded compiler-resolved symbol references. |
60
+ | `--include-imports`, `--include-cycles` | impact | Add outgoing imports or cycles. |
61
+ | `--no-live`, `--no-cache` | impact, brief | Require the snapshot, or bypass the live-index cache. |
62
+ | `--copy`, `--out` | brief | Copy the brief, or write it inside the repository. |
63
+ | `--with-mcp` | skill | Merge a server entry into `.mcp.json`. |
64
+
65
+ ## Configuration and behaviour
66
+
67
+ - `maxPartBytes` is a hard byte ceiling. `maxParts` is explicitly experimental: it may grow the
68
+ budget and records a warning when it does.
69
+ - `--delta` and `--changed-since` record unchanged paths as `unchanged`; a file dropped later by
70
+ `--budget-tokens` or `--slice` is `not-selected`, not `unchanged`. Validate therefore does not
71
+ confuse a budget drop with an unchanged file.
72
+ - `--only` narrows the CLI. On the MCP surface it cannot replace an include allow-list declared in
73
+ `snapshot.config.json`; the request is refused instead of widening scope.
74
+ - A snapshot generated with `--include-sensitive-files` is refused by the MCP server, including
75
+ its part resources. Regenerate without that flag before serving a prompt.
76
+
77
+ ## Older lines
78
+
79
+ The 0.20 line was published in place and remains documented in its own history. If you are on
80
+ 0.12.x, upgrade to the newest 0.20 release first, then follow this page. The configuration file
81
+ format has not changed; removed MCP tools and the new live defaults are the migration work.
82
+
83
+ `validate` on a snapshot written by an older version still works: newer manifest keys are optional,
84
+ and an artifact the manifest does not record is not required to exist.
package/docs/output.md CHANGED
@@ -96,9 +96,7 @@ examples from its own incidents. Each is marked as written by the project owner.
96
96
  - the delivery arithmetic below.
97
97
 
98
98
  Everything factual is rendered from the manifest and the repository, so the brief cannot describe
99
- a different run. It only names artifacts that were actually written: `--skip-artifacts
100
- parts,audit` produces a brief that does not tell a model to read parts, and says the per-file
101
- redaction detail is unavailable rather than pointing at a file that is not there.
99
+ a different run.
102
100
 
103
101
  It also does the arithmetic of sending it. Hosted chats take a fixed number of files — 10 is the
104
102
  common cap — and every part is one file, so a 12-part snapshot cannot be delivered whole. The
@@ -35,8 +35,8 @@ untrusted input can arrive.
35
35
  tracked `notes.txt`.
36
36
  - **Every snapshot file read is confined.** PROMPT.md, reports, the manifest, WORKSPACE.json and
37
37
  signature.json are opened through one reader that refuses a symlink and requires the canonical
38
- target inside the snapshot directory. The MCP resources, `snapshot_history`,
39
- `snapshot_workspace`, signing verification and `serve` use it; a part lookup also requires its
38
+ target inside the snapshot directory. The MCP resources, `snapshot_validate`,
39
+ `snapshot_explain`, signing verification and `serve` use it; a part lookup also requires its
40
40
  `parts/` directory and the resolved part to stay inside the snapshot.
41
41
  - **The diff report fails closed.** Git is forced to emit unquoted ASCII prefixes, a section that
42
42
  cannot be attributed to a path is omitted rather than trusted, redaction runs before truncation
@@ -66,8 +66,7 @@ executable config in it is refused, because a fetched repository is not a truste
66
66
  - **Bounded work**: 2 MiB bodies, 60 requests per 10 s per address, one JSON document per response,
67
67
  and at most four MCP tool calls in flight across all HTTP sessions. The session and rate maps are
68
68
  capped and evicted, so a client cannot grow either without bound.
69
- - **Untrusted regexes are bounded.** `snapshot_search`, `snapshot_routes` and `snapshot_query`
70
- reject nested quantifiers, more than one unbounded repetition, optional-chain blowups and
69
+ - **Untrusted regexes are bounded.** `snapshot_locate` rejects nested quantifiers, more than one unbounded repetition, optional-chain blowups and
71
70
  backreferences before compiling; glob and gitignore patterns are bounded by wildcard, brace and
72
71
  alternative counts. JavaScript has no regex timeout, so the alternative is a main-thread stall.
73
72
  - **Errors are JSON-RPC error objects**, never stack traces.
@@ -131,10 +130,11 @@ addition was reviewed with the same question — what new input arrives, and wha
131
130
  - **The audit stopped trusting the manifest** (0.13.6-0.13.10): bodies, counts and pack membership
132
131
  are recomputed. An attacker who edits a part and updates its hash, or edits a manifest count,
133
132
  now fails the audit; before, both passed. This turns a tampered snapshot into a detected one.
134
- - **`snapshot_answer`** (0.15.5) reads only `parts/` through the same parser, so redaction and
133
+ - **`snapshot_context`** (0.15.5) reads only `parts/` through the same parser, so redaction and
135
134
  exclusions apply exactly as they do to `snapshot_read`; it adds no file-system surface.
136
- - **`--only`/`--ignore`** (0.14.6) widen nothing: `--ignore` adds excludes, and `--only` can only
137
- narrow the allow-list the config already permits. Sensitive files stay excluded by default.
135
+ - **`--only`/`--ignore`** (0.14.6, tightened 0.21.0) never widen the MCP surface: the CLI may
136
+ replace its own config's allow-list, but an MCP request that tries to replace a declared
137
+ `include` allow-list is refused. `--ignore` only adds excludes. Sensitive files stay excluded.
138
138
  - **The 0.20.5 second audit** closed the bypasses left by 0.20.4: symlink targets now have to be
139
139
  included under their own name, uppercase authorization headers are masked, C-quoted diff paths
140
140
  and gitignore/exclude targets are handled, resource/manifest/report reads are confined,
@@ -154,7 +154,7 @@ addition was reviewed with the same question — what new input arrives, and wha
154
154
  credentials and unterminated PEM bodies have no length/prefix blind spot; alternation and glob
155
155
  branch budgets bound the event loop; workspace members inherit every generation flag;
156
156
  `validate` agrees with `--skip-artifacts parts`; HTTP batches are charged per message and
157
- batched `initialize` mints a session; `snapshot_symbol` is bounded; explicit false overrides
157
+ batched `initialize` mints a session; `snapshot_locate` is bounded; explicit false overrides
158
158
  reach validation; `..notes.ts` is accepted at the segment boundary; `health --all-members`
159
159
  confines the index and members; `serve` rejects non-HTTP loopback origins and records nested
160
160
  repository roots; and report fences grow with their content.
package/docs/slice.md CHANGED
@@ -5,7 +5,7 @@ codebase-snapshot generate --slice "how does checkout retry a failed payment" --
5
5
  ```
6
6
 
7
7
  A slice is a snapshot built for a question. The retrieval planner that powers
8
- [`snapshot_plan_for`](mcp.md) runs at generate time, and only the files it chooses are written. The
8
+ [`snapshot_context`](tools.md) planner runs at generate time, and only the files it chooses are written. The
9
9
  result is a snapshot small enough to paste, with the selection and the omissions recorded.
10
10
 
11
11
  ## What it keeps
package/docs/tools.md CHANGED
@@ -1,187 +1,161 @@
1
1
  # MCP tools
2
2
 
3
- The server exposes 26 tools. This page is the reference: what each answers, what it costs, and one
4
- call you can send as it stands. [MCP](mcp.md) covers the transports and the protocol; this page is
5
- the catalogue.
6
-
7
- Every tool is read-only unless it says **writes**. Cost is the class `tools/list` publishes as
8
- `_meta["codebase-snapshot/cost"]`: **cheap** reads the manifest, **medium** reads one or a few parts,
9
- **expensive** reads the repository or writes it.
10
-
11
- ## Orientation
12
-
13
- - **`snapshot_status`** — cheap, read-only. Is there a snapshot, when was it built, what does it
14
- cover, what is stale?
15
- ```json
16
- { "name": "snapshot_status", "arguments": {} }
17
- ```
18
- - **`snapshot_explain`** — expensive, read-only. Why is a path in or out of the snapshot? It
19
- resolves the same scan the generator would use, so a `--slice` drop is reported as
20
- `not-selected` with the run's detail.
21
- ```json
22
- { "name": "snapshot_explain", "arguments": { "path": "src/index.ts" } }
23
- ```
24
- - **`snapshot_entrypoints`** — cheap, read-only. The files a reader should start from: manifests
25
- first, then `index`/`main`/`app`/`server`/`cli`, with importer counts.
26
- ```json
27
- { "name": "snapshot_entrypoints", "arguments": {} }
28
- ```
29
- - **`snapshot_stats`** — cheap, read-only. Files by layer and kind, part sizes, token estimate,
30
- heaviest files.
31
- ```json
32
- { "name": "snapshot_stats", "arguments": {} }
33
- ```
34
- - **`snapshot_workspace`** — cheap, read-only. Members of a multi-repository workspace and the
35
- imports that cross between them, from `WORKSPACE.json`.
36
- ```json
37
- { "name": "snapshot_workspace", "arguments": {} }
38
- ```
39
-
40
- ## Finding things
41
-
42
- - **`snapshot_search`** — medium, read-only. Literal or regular-expression search over every part,
43
- with the file and part for each hit. Stops at 4 MB of text and says so.
44
- ```json
45
- { "name": "snapshot_search", "arguments": { "query": "partitionFiles", "regex": false } }
46
- ```
47
- - **`snapshot_query`** — cheap, read-only. Filter the index by layer, kind, path pattern, symbol or
48
- test status; no part is read.
49
- ```json
50
- { "name": "snapshot_query", "arguments": { "layer": "src", "symbol": "plan" } }
51
- ```
52
- - **`snapshot_locate`** — cheap, read-only. Which part holds a path or symbol, and where in it.
53
- ```json
54
- { "name": "snapshot_locate", "arguments": { "query": "src/mcp/tools.ts", "by": "path" } }
55
- ```
56
- - **`snapshot_symbol`** — medium, read-only. A symbol by name: defining file, kind, signature,
57
- and — unless `references: false` — the call sites where the name appears, with line numbers.
58
-
59
- the exports that reference it.
60
- ```json
61
- { "name": "snapshot_symbol", "arguments": { "name": "generateSnapshot" } }
62
- ```
63
- - **`snapshot_routes`**
64
- > Records the **path** with the method for framework route registration (`GET /health`). A
65
- > method-only handler (`export async function GET()` in Next.js) has no literal path to record and
66
- > is reported as the method alone. — cheap, read-only. Every route the summaries recorded, with file and part.
67
- ```json
68
- { "name": "snapshot_routes", "arguments": { "pattern": "users" } }
69
- ```
70
-
71
- ## Reading
72
-
73
- - **`snapshot_answer`** — medium, read-only. One call from question to context: plans the
74
- question, then returns each chosen file as a head window with line numbers inside the token
75
- budget. Every file says why it is there; every planned file that did not fit says why not.
76
- ```json
77
- { "name": "snapshot_answer", "arguments": { "question": "how does redaction work", "maxTokens": 20000 } }
78
- ```
79
- - **`snapshot_budget`** — medium, read-only. The planner at several budgets, with what each
80
- one adds: files, tokens used, and the paths gained over the previous budget. The answer to
81
- "should I raise the budget, and what would I get?"
82
- ```json
83
- { "name": "snapshot_budget", "arguments": { "budgets": [10000, 30000, 60000] } }
84
- ```
85
- - **`snapshot_history`** — cheap, read-only. The commits behind the snapshot, from
86
- `reports/log.md`; says how to generate the report when it is absent.
87
- ```json
88
- { "name": "snapshot_history", "arguments": { "limit": 10 } }
89
- ```
90
- - **`snapshot_tests`** — cheap, read-only. The test side of the graph: given a path, the tests
91
- that import it or are named after it; with no path, every test file and what it covers.
92
- ```json
93
- { "name": "snapshot_tests", "arguments": { "path": "src/mcp/tools.ts" } }
94
- ```
95
- - **`snapshot_read`** — medium, read-only. A bounded window of one file: line range, or the whole
96
- body when it is small.
97
- ```json
98
- { "name": "snapshot_read", "arguments": { "path": "src/index.ts", "fromLine": 1, "lines": 80 } }
99
- ```
100
- - **`snapshot_context`** — medium, read-only. Whole bodies for the files that fit a token budget, in
101
- the order the planner ranks them.
102
- ```json
103
- { "name": "snapshot_context", "arguments": { "files": ["src/mcp/retrieval.ts"], "maxTokens": 12000 } }
104
- ```
105
-
106
- ## The planner
107
-
108
- - **`snapshot_plan_for`** — cheap, read-only. The plan for a question: which files fit a budget, why
109
- each was chosen, what did not fit. Matches stems (`charge`/`chargeCard`), follows imports and
110
- callers, prefers entry points.
111
- ```json
112
- { "name": "snapshot_plan_for", "arguments": { "question": "how does a snapshot get partitioned", "maxTokens": 20000 } }
113
- ```
114
- - **`snapshot_plan`** — expensive, read-only. Would a generate succeed, and what would it include?
115
- Runs the real pipeline in a worker with nothing written.
116
- ```json
117
- { "name": "snapshot_plan", "arguments": {} }
118
- ```
119
-
120
- ## Reviewing a change
121
-
122
- - **`snapshot_review`**
123
- > Validates with the settings the manifest recorded, not with a bare config file: a snapshot
124
- > generated with `--token-tree`, `--include-diffs`, `--remove-empty-lines` or a pack is current
125
- > if the files are, and the review says so instead of telling you to regenerate. — expensive, read-only. Is the snapshot current, what does the health audit
126
- say, what do the given paths contain, and which route methods do they touch?
127
- ```json
128
- { "name": "snapshot_review", "arguments": { "paths": ["src/mcp/tools.ts"] } }
129
- ```
130
- - **`snapshot_diff_context`** — medium, read-only. A changed file's head plus the files that import
131
- it, within a token budget.
132
- ```json
133
- { "name": "snapshot_diff_context", "arguments": { "paths": ["src/mcp/tools.ts"], "maxTokens": 15000 } }
134
- ```
135
- - **`snapshot_dependents`** — cheap, read-only. What imports this path, one or more hops out.
136
- ```json
137
- { "name": "snapshot_dependents", "arguments": { "path": "src/mcp/server.ts", "direction": "imported-by", "limit": 50 } }
138
- ```
139
- - **`snapshot_neighbors`** — medium, read-only. Both directions of the import graph for one path.
140
- ```json
141
- { "name": "snapshot_neighbors", "arguments": { "path": "src/mcp/retrieval.ts" } }
142
- ```
143
- - **`snapshot_cycles`** — medium, read-only. Strongly connected components: files that import each
144
- other in a loop.
145
- ```json
146
- { "name": "snapshot_cycles", "arguments": { "maxComponents": 10 } }
147
- ```
148
-
149
- ## Health and writing
150
-
151
- - **`snapshot_health`** — expensive, read-only. The full audit: hashes, missing parts, secrets, host
152
- paths, token accounting, freshness, signature. Score out of 100, severities, failed check ids.
153
- ```json
154
- { "name": "snapshot_health", "arguments": { "maxScanBytes": 2000000 } }
155
- ```
156
- - **`snapshot_generate`** — expensive, **writes**. Builds the snapshot in a worker. Accepts
157
- `includeDiffs`, `includeLogs`, `tokenTree`, `stripComments`, and reports progress and cancellation.
158
- ```json
159
- { "name": "snapshot_generate", "arguments": { "tokenTree": true, "pack": "xml" } }
160
- ```
161
- It also takes `only` and `ignore` arrays — the CLI's per-run narrowing — which enter the config
162
- digest, so `snapshot_validate` takes the same arrays to compare like with like.
163
- It can also narrow: `slice` with `sliceTokens`, or `budgetTokens` (not both — the tool refuses
164
- the pair, as the CLI does).
165
- ```json
166
- { "name": "snapshot_generate", "arguments": { "slice": "how is auth done", "sliceTokens": 20000 } }
167
- ```
168
- - **`snapshot_validate`** — expensive, read-only. Drift check: files changed or deleted since the
169
- snapshot, part damage, bookkeeping, **and the settings the manifest recorded** — a snapshot
170
- generated with `tokenTree`, `includeDiffs`, `removeEmptyLines` or `skeleton` validates clean
171
- without re-passing the flags, while a changed config file is still drift.
172
- snapshot, part hashes, bookkeeping. A selection snapshot is not second-guessed, and says so.
173
- ```json
174
- { "name": "snapshot_validate", "arguments": {} }
175
- ```
176
-
177
- ## Conventions these tools share
178
-
179
- - Relative paths resolve against the repository the server was started for; `root` moves that for one
180
- call and is bounded by the roots the server allows.
181
- - `outDir` names a snapshot directory other than the configured one; absent means the configured
182
- one.
183
- - A tool that cannot answer says why in `text` and sets `isError`. It does not return an empty list
184
- that looks like a true negative — `snapshot_workspace` without a workspace index tells you to make
185
- one.
186
- - Structured results are returned as `structuredContent` alongside the text, so a client can read
187
- the same answer either way.
3
+ The server exposes **7 tools**. This page is the reference: what each answers, what it costs, and
4
+ a call it accepts. Every read-only tool works against the live index by default: a current
5
+ `manifest.json` is reused, changed files are overlaid in memory, and a repository with no snapshot
6
+ is scanned without writing one. Pass `"live": false` to require the persisted snapshot.
7
+
8
+ `snapshot_generate` is the only writable tool. Every structured response carries a `trust`
9
+ envelope with `indexSource`, `freshness`, `coverage`, redaction and omission counts, and named
10
+ reasons when coverage is partial.
11
+
12
+ ## The seven tools
13
+
14
+ - **`snapshot_impact`**
15
+
16
+ **Cost:** medium · **Read-only:** yes
17
+
18
+ What a change reaches: changed files, symbol-pruned transitive importers, routes, candidate tests,
19
+ unresolved internal imports, optional outgoing imports and import cycles. Barrel re-exports are
20
+ parsed; a consumer of a different symbol is not reported. Test files stay out of `affected[]` and
21
+ appear in `tests[]`.
22
+
23
+ ```json
24
+ {
25
+ "name": "snapshot_impact",
26
+ "arguments": {
27
+ "paths": ["src/impact.ts"],
28
+ "includeCycles": true,
29
+ "includeSnippets": true
30
+ }
31
+ }
32
+ ```
33
+
34
+ Omit `paths` and `base` to compare the working tree with `HEAD`. `symbols` seeds explicit
35
+ symbols; `precise` adds compiler-resolved references; `depth` (1–8) and `maxResults` bound the
36
+ walk.
37
+
38
+ - **`snapshot_context`**
39
+
40
+ **Cost:** medium · **Read-only:** yes
41
+
42
+ The minimum redacted, line-numbered context for a question, file list or symbol list inside a hard
43
+ token budget. `planOnly` returns the ranked reading plan without bodies. Every requested file that
44
+ does not fit is named in `omitted[]`.
45
+
46
+ ```json
47
+ {
48
+ "name": "snapshot_context",
49
+ "arguments": {
50
+ "question": "how does impact pruning work",
51
+ "maxTokens": 12000,
52
+ "linesPerFile": 100
53
+ }
54
+ }
55
+ ```
56
+
57
+ - **`snapshot_locate`**
58
+
59
+ **Cost:** cheap · **Read-only:** yes
60
+
61
+ Find paths, symbols, routes, entrypoints or text in one call. Text mode reads redacted bodies and
62
+ is bounded to 4 MiB. Regex mode passes the same ReDoS guard as the rest of the server. For a
63
+ symbol, `includeReferences` adds compiler-resolved references with `confidence: "ts-semantic"`.
64
+
65
+ ```json
66
+ {
67
+ "name": "snapshot_locate",
68
+ "arguments": { "query": "parseImpact", "by": "symbol" }
69
+ }
70
+ ```
71
+
72
+ - **`snapshot_read`**
73
+
74
+ **Cost:** medium · **Read-only:** yes
75
+
76
+ A line window of one redacted file. A sensitive path (`.env`, `*.pem`, `.npmrc`, `.ssh/`,
77
+ `.tfstate`) is refused even when the path exists on disk, and a response never exceeds 64 KiB.
78
+
79
+ ```json
80
+ {
81
+ "name": "snapshot_read",
82
+ "arguments": { "path": "src/impact.ts", "fromLine": 1, "lines": 120 }
83
+ }
84
+ ```
85
+
86
+ - **`snapshot_validate`**
87
+
88
+ **Cost:** cheap · **Read-only:** yes
89
+
90
+ Three questions in one tool:
91
+
92
+ - `mode: "status"` — does a snapshot exist, and what does it claim?
93
+ - `mode: "drift"` — does it still match the repository? This is the default.
94
+ - `mode: "audit"` — hash, secret, host-path and integrity checks; `deep: true` replays every full
95
+ body.
96
+
97
+ ```json
98
+ {
99
+ "name": "snapshot_validate",
100
+ "arguments": { "mode": "drift" }
101
+ }
102
+ ```
103
+
104
+ A missing snapshot is an answer (`present: false`) in `status` and `drift` mode, not a tool
105
+ failure.
106
+
107
+ - **`snapshot_explain`**
108
+
109
+ **Cost:** expensive · **Read-only:** yes
110
+
111
+ Why a path is included, excluded, sensitive, ignored, binary or truncated. `included: false` is a
112
+ successful explanation, not an error.
113
+
114
+ ```json
115
+ {
116
+ "name": "snapshot_explain",
117
+ "arguments": { "path": ".env" }
118
+ }
119
+ ```
120
+
121
+ - **`snapshot_generate`**
122
+
123
+ **Cost:** expensive · **Writable:** yes
124
+
125
+ Write the snapshot, or preview it with `dryRun: true`. This is the only tool that writes; it never
126
+ installs packages and never edits configuration. It accepts the generation options the CLI accepts,
127
+ including `slice`, `budgetTokens`, `pack`, `stripComments`, `removeEmptyLines`, `skeleton`,
128
+ `sarif`, `changedSince`, `staged` and `withDependents`.
129
+
130
+ ```json
131
+ {
132
+ "name": "snapshot_generate",
133
+ "arguments": { "dryRun": true }
134
+ }
135
+ ```
136
+
137
+ ## Types and visibility
138
+
139
+ The exact JSON Schemas are served by `tools/list`. Inputs reject unknown properties. Every tool
140
+ accepts `root` and `outDir`; both are confined to the directories the server was started for.
141
+ `includeSensitiveFiles` is deliberately absent from every tool: a prompt cannot turn a read-only
142
+ server into an exfiltration primitive.
143
+
144
+ ## Removed tools and their replacements
145
+
146
+ | Removed | Use instead |
147
+ | :-- | :-- |
148
+ | `snapshot_status`, `snapshot_stats`, `snapshot_review` | `snapshot_validate({ mode: "status" })` |
149
+ | `snapshot_health` | `snapshot_validate({ mode: "audit", deep: true })` |
150
+ | `snapshot_plan` | `snapshot_generate({ dryRun: true })` |
151
+ | `snapshot_dependents`, `snapshot_neighbors`, `snapshot_tests`, `snapshot_diff_context`, `snapshot_cycles` | `snapshot_impact` |
152
+ | `snapshot_plan_for`, `snapshot_answer`, `snapshot_budget` | `snapshot_context` |
153
+ | `snapshot_search`, `snapshot_symbol`, `snapshot_query`, `snapshot_routes`, `snapshot_entrypoints` | `snapshot_locate` |
154
+ | `snapshot_history` | `snapshot://reports/log` resource |
155
+ | `snapshot_workspace` | `WORKSPACE.json` and the CLI |
156
+
157
+ ## See also
158
+
159
+ - [MCP server for a codebase](mcp-server-for-codebase.md) — setup, security and large-repo limits.
160
+ - [snapshot_context](answer.md) — the one-call context tool in practice.
161
+ - [All documentation](contents.md) — every guide and reference.