codebase-snapshot 0.20.12 → 0.21.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 +44 -6
  2. package/README.md +46 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/bin.js +12173 -9823
  5. package/dist/{chunk-TUKY6KLH.js → chunk-TDPYLX7X.js} +6312 -4472
  6. package/dist/cli.cjs +12074 -9744
  7. package/dist/cli.d.cts +76 -2
  8. package/dist/cli.d.ts +76 -2
  9. package/dist/cli.js +549 -14
  10. package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-D56JeXwx.d.cts} +2 -2
  11. package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-DakxZs-l.d.ts} +2 -2
  12. package/dist/index.cjs +6292 -4466
  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 +10486 -4393
  17. package/dist/mcp.d.cts +26 -11
  18. package/dist/mcp.d.ts +26 -11
  19. package/dist/mcp.js +1 -1
  20. package/dist/{types-C5ytHMYz.d.ts → types-D5XYzksd.d.cts} +50 -2
  21. package/dist/{types-C5ytHMYz.d.cts → types-D5XYzksd.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 +103 -27
  28. package/docs/codebase-token-budget.md +14 -13
  29. package/docs/configuration.md +1 -1
  30. package/docs/contents.md +66 -0
  31. package/docs/deploy.md +2 -2
  32. package/docs/faq.md +112 -0
  33. package/docs/glossary.md +152 -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 +155 -0
  40. package/docs/mcp.md +81 -82
  41. package/docs/migration.md +83 -85
  42. package/docs/output.md +1 -3
  43. package/docs/security-review.md +20 -9
  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 +9 -2
package/docs/mcp.md CHANGED
@@ -10,7 +10,7 @@ walk — that the client sees.
10
10
  ## Start it
11
11
 
12
12
  ```bash
13
- npx -y codebase-snapshot@0.20.9 mcp
13
+ npx -y codebase-snapshot@0.21.0 mcp
14
14
  ```
15
15
 
16
16
  The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
25
25
  "mcpServers": {
26
26
  "codebase-snapshot": {
27
27
  "command": "npx",
28
- "args": ["-y", "codebase-snapshot@0.20.9", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.21.0", "mcp", "--cwd", "/absolute/path/to/repo"]
29
29
  }
30
30
  }
31
31
  }
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
34
34
  Claude Code registers the same thing from a shell:
35
35
 
36
36
  ```bash
37
- claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.9 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.21.0 mcp --cwd /absolute/path/to/repo
38
38
  ```
39
39
 
40
40
  On Windows, wrap the command as `cmd /c npx` with the same arguments — `npx` is a `.cmd` shim
@@ -43,11 +43,15 @@ there, and clients that spawn without a shell cannot execute it directly.
43
43
  ## Over HTTP, for clients that cannot spawn a process
44
44
 
45
45
  ```bash
46
- npx -y codebase-snapshot@0.20.9 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.21.0 mcp --http --port 4789
47
47
  ```
48
48
 
49
- This is the Streamable HTTP shape: POST one JSON-RPC message (or an array) to `/mcp` and read
50
- the JSON-RPC answer from the response body. `GET /healthz` answers
49
+ This is the Streamable HTTP shape: POST one JSON-RPC message to `/mcp` and read the JSON-RPC
50
+ answer from the response body. Modern (`2026-07-28`) requests must also carry
51
+ `MCP-Protocol-Version`, `Mcp-Method` and — for `tools/call`, `resources/read` and
52
+ `prompts/get` — `Mcp-Name`. A missing header, or one that disagrees with the body, is refused
53
+ with HTTP `400` and JSON-RPC `-32020` before dispatch; the CORS preflight allows all three
54
+ names. Legacy requests keep the session behaviour below. `GET /healthz` answers
51
55
  `{ ok, name, version, tools, uptimeSeconds }` without a token, and `GET /metrics` answers Prometheus
52
56
  text: `snapshot_requests_total`, `snapshot_requests_by_method_total{method="…"}` (fixed labels,
53
57
  never a path or a credential), `snapshot_requests_refused_total` (every 4xx except 429: an
@@ -78,14 +82,16 @@ reachable from the network must not be readable by any page that guesses the por
78
82
  CORS is granted to loopback origins (`localhost`, `127.0.0.1`, `[::1]`, any port) and to the
79
83
  origins you list. Any other `Origin` gets `403`.
80
84
 
81
- The first `initialize` response carries an `mcp-session-id` header. Send it on every later
82
- request: era and cancellation state belong to that session, so one client's
83
- `server/discover` cannot reject another client's legacy handshake. A client that ignores the
84
- header falls back to a per-address server; two such clients on one host with the same user agent
85
- share state, which is why forwarding the header matters. An unknown `mcp-session-id` is answered
86
- with `404`, never used to mint state; sessions expire after 30 minutes idle, the oldest is evicted
87
- when the table is full, and `DELETE /mcp` closes one explicitly. JSON-RPC batches are capped at
88
- 100 messages, and the body cap applies before parsing.
85
+ Modern requests are stateless: `mcp-session-id` is ignored, never minted and never echoed. The
86
+ legacy era still opens with `initialize`, whose response carries an `mcp-session-id` header;
87
+ send it on every later legacy request. Era and cancellation state belong to that session, so one
88
+ client's `server/discover` cannot reject another client's legacy handshake. A legacy client that
89
+ ignores the header falls back to a per-address server; two such clients on one host with the same
90
+ user agent share state, which is why forwarding the header matters. An unknown `mcp-session-id`
91
+ is answered with `404`, never used to mint state; sessions expire after 30 minutes idle, the
92
+ oldest is evicted when the table is full, and `DELETE /mcp` closes one explicitly. Legacy
93
+ JSON-RPC batches are capped at 100 messages; a modern request is one message, and a modern batch
94
+ is refused. The body cap applies before parsing.
89
95
 
90
96
  ### Legacy SSE, for clients that cannot send a header
91
97
 
@@ -104,52 +110,34 @@ into logs and is documented as such. A heartbeat every 15 s keeps the connection
104
110
  shutdown ends the streams rather than waiting on them. Request bodies are capped at 2 MB, the rate is
105
111
  capped at 60 requests per 10 seconds per address, and every response is one bounded JSON document.
106
112
 
107
- ## The 26 tools
113
+ ## The 7 tools
108
114
 
109
115
  Each tool has an entry with a ready-to-send call in the [tool reference](tools.md).
110
116
 
111
-
112
117
  Every tool states its cost class in `tools/list` as `_meta["codebase-snapshot/cost"]`: `cheap`
113
- reads the manifest, `medium` reads one or a few parts, `expensive` reads the repository or writes.
114
- Two tools that answer the same question can differ by an order of magnitude, and a client choosing
115
- between them should not have to guess.
118
+ reads the index, `medium` reads a few bounded bodies, `expensive` runs a compiler or writes.
116
119
 
117
120
  | Tool | Answers | Writes |
118
121
  | :-- | :-- | :-- |
119
- | `snapshot_status` | Is there a snapshot, when was it built, what does it cover? | no |
120
- | `snapshot_health` | Does the written snapshot match its manifest, carry any secret or host path, and cost what it claims? `maxScanBytes` bounds the text scan; `deep: true` replays every full body from the source. | no |
121
- | `snapshot_query` | Filter the index by layer, kind, path pattern or symbol | no |
122
- | `snapshot_answer` | Question to cited, line-numbered windows within a budget | no |
123
- | `snapshot_budget` | Planner output at several budgets: what raising the budget would add | no |
124
- | `snapshot_history` | The commits the snapshot was built from (reads `reports/log.md`) | no |
125
- | `snapshot_tests` | The tests that import a file (or every test and what it covers) | no |
126
- | `snapshot_workspace` | The members of a multi-repository workspace and the imports that cross between them | no |
127
- | `snapshot_entrypoints` | The files a reader should start from, manifests first | no |
128
- | `snapshot_neighbors` | Both import directions for one path | no |
129
- | `snapshot_routes` | Route handlers recorded by the summaries, with their files | no |
130
- | `snapshot_cycles` | Strongly connected components in the import graph | no |
131
- | `snapshot_stats` | Files by layer and kind, part sizes, token estimate, heaviest files | no |
132
- | `snapshot_search` | Case-insensitive text search across the emitted parts, bounded and redaction-safe | no |
133
- | `snapshot_review` | Currency, health and bounded bodies in one call, so a review can start | no |
134
- | `snapshot_symbol` | Where a function, class or constant is defined, with a window and a line number | no |
135
- | `snapshot_diff_context` | Bodies of the changed files plus the files that import them | no |
136
- | `snapshot_context` | One bounded context block from named files or symbols, read from the snapshot | no |
137
- | `snapshot_plan_for` | Given a question and a token budget, the smallest set of files that answer it, in reading order | no |
138
- | `snapshot_plan` | What would a generate at this budget include, and what would it leave out? | no |
139
- | `snapshot_generate` | Build it. Accepts `includeDiffs`, `includeLogs`, `tokenTree` and `stripComments`, so a client can ask for the opt-in reports the CLI has. | yes |
140
- | `snapshot_validate` | Is the context the agent was given still current? | no |
141
- | `snapshot_locate` | Which part holds this symbol, route or file? | no |
142
- | `snapshot_dependents` | What does this file import, and what imports it? | no |
143
- | `snapshot_read` | A window of one file, as the snapshot contains it. | no |
144
- | `snapshot_explain` | Why is this path not in the snapshot? | no |
145
-
146
- Twenty-five are declared `readOnlyHint`, which most clients use to run them without asking. Only
122
+ | `snapshot_impact` | What does this change reach? Symbol-pruned callers, routes, import cycles, candidate tests and optional snippets. Omitting `paths` and `base` compares the working tree with `HEAD`. | no |
123
+ | `snapshot_context` | The minimum redacted, line-numbered context for a question, files or symbols inside a hard token budget. `planOnly` returns the reading plan. | no |
124
+ | `snapshot_locate` | Paths, symbols, routes, entrypoints or bounded redacted text. Symbol mode can add compiler-resolved references. | no |
125
+ | `snapshot_read` | A bounded, redacted line window of one file. Sensitive paths are never readable. | no |
126
+ | `snapshot_validate` | `status` (presence, counts, fingerprint), `drift` (freshness), or `audit` (secret and integrity checks). Only drift claims `current`. | no |
127
+ | `snapshot_explain` | Why is this path included, excluded, sensitive, ignored, binary or truncated? | no |
128
+ | `snapshot_generate` | Write the snapshot, or preview it with `dryRun: true`. | yes |
129
+
130
+ Six tools are declared `readOnlyHint`, which most clients use to run them without asking. Only
147
131
  `snapshot_generate` writes.
148
132
 
149
- All 26 take `outDir`, so a snapshot generated into a directory other than the configured one is
150
- still reachable: pass the same value to the read side that you passed to `snapshot_generate`. Before
151
- that, only `snapshot_generate` honoured it and every other tool looked in the configured directory
152
- and reported "there is no snapshot manifest here".
133
+ **Live by default.** Read-only tools reuse a current `manifest.json`, overlay changed and new files
134
+ in memory when the tree has moved, or scan the confined working tree when no snapshot exists. They
135
+ never write into the repository. Pass `"live": false` to require the persisted snapshot. Every
136
+ structured response carries a `trust` envelope naming the index source, freshness, coverage,
137
+ redaction count and any reason coverage is partial.
138
+
139
+ All 7 take `outDir`, so a snapshot generated into a directory other than the configured one is
140
+ still reachable: pass the same value to the read side that you passed to `snapshot_generate`.
153
141
 
154
142
  An `outDir` **tool argument** must resolve inside the repository the server serves: a prompt cannot
155
143
  drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir`
@@ -157,32 +145,25 @@ and `tmpDir` are confined the same way. If either escapes, the tool refuses and
157
145
  to move the directory inside the served root, or start the server with `--cwd` at the parent
158
146
  repository.
159
147
 
160
- `snapshot_plan`, `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the
161
- **scope and compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`,
162
- `changedSince`, `staged` and `withDependents`. They have to: `manifest.config.digest` covers those
163
- settings, so a snapshot generated with `--skeleton` was not merely un-inspectable over MCP, it was
164
- reported as configuration drift on every `snapshot_validate`. Pass the same switches you generated
165
- with, exactly as you would on the command line. The other tools do not take them, because
166
- none of them re-derives the configuration and a flag that changes nothing is the command-line form
167
- of a silent fallback.
148
+ `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the **scope and
149
+ compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`, `changedSince`,
150
+ `staged` and `withDependents`. `manifest.config.digest` covers those settings, so a snapshot
151
+ generated with `--skeleton` must be validated with the same switch rather than reported as drift.
168
152
 
169
153
  `includeSensitiveFiles` is deliberately absent from every one of them. A prompt can ask for
170
154
  anything, and a tool that emits `.env` on request is a secret-exfiltration primitive with a
171
155
  friendly name.
172
156
 
173
157
  `snapshot_locate` is the one that makes the others usable: a twelve-part snapshot is hundreds of
174
- kilobytes, and asking "which part holds authentication?" is cheaper than reading all twelve. It
175
- searches the manifest's index — file paths, exported symbols, component names, routes, layers and
176
- kinds — and returns the part each match lives in.
158
+ kilobytes, and asking "where is authentication?" is cheaper than reading all twelve. It searches
159
+ the manifest's index and, for text mode, a bounded redacted body scan.
177
160
 
178
- `snapshot_read` is windowed on purpose. It defaults to 200 lines and reports `nextFromLine` when
179
- more remains, so an agent continues deliberately instead of pulling a whole part into a context
180
- window it has not budgeted. A single line longer than one result can carry is the exception: the
181
- page ends mid-line, `pageable` is `false` and `reason` says so, because advancing `fromLine` would
182
- silently skip the rest of that line.
161
+ `snapshot_read` is windowed on purpose. It defaults to 200 lines and reports where more remains,
162
+ so an agent continues deliberately instead of pulling a whole part into a context window it has
163
+ not budgeted. A response never exceeds 64 KiB.
183
164
 
184
165
  At most four requests run at once. A fifth gets a JSON-RPC `overloaded` error (`-32001`) naming
185
- the limit instead of being queued silently or dropped, so a client can retry and `snapshot_status`
166
+ the limit instead of being queued silently or dropped, so a client can retry and `snapshot_validate`
186
167
  stays responsive.
187
168
 
188
169
  ## Resources
@@ -210,16 +191,18 @@ publishes them separately as `reportResources`.
210
191
  A resource read is **all-or-nothing**. Above the 512 kB single-read limit the read fails with
211
192
  JSON-RPC error `-32000` (the implementation-defined server-error range) and
212
193
  `data: { uri, bytes, limit }`; the message says what to use instead — `snapshot_locate`,
213
- `snapshot_read` or `snapshot_status` for a manifest or part, the file on disk for a report, and
194
+ `snapshot_read` or `snapshot_validate` for a manifest or part, the file on disk for a report, and
214
195
  the CLI for the contract or the skill. It never returns a truncated document: half a JSON manifest
215
196
  does not parse, and half a part is a fragment that looks complete. The rule applies to every
216
197
  resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the report resources,
217
198
  `snapshot://prompt`, `snapshot://contract` and `snapshot://skill`.
218
199
 
219
200
  A URI this build serves but this snapshot does not contain — `snapshot://prompt` when the prompt
220
- artifact was disabled, a report when that artifact was — is answered with `-32002` (resource not
221
- found) and a message naming the artifact and the cause. An unknown URI is still "Unknown resource":
222
- the two are different mistakes and a client should be able to tell them apart.
201
+ artifact was disabled, a report when that artifact was — is answered with `-32602` (Invalid
202
+ Params) under the modern revision, and with the legacy `-32002` for a legacy client. The message
203
+ names the artifact and the cause. Modern clients also accept `-32002` from older servers, but this
204
+ server does not make a modern client guess. An unknown URI is still "Unknown resource": the two
205
+ are different mistakes and a client should be able to tell them apart.
223
206
 
224
207
  Part resources carry their size in the description, so a client choosing between them can see that
225
208
  one is 300 kB before attaching it; a part above the limit says in its description that it will be
@@ -276,25 +259,34 @@ says what happened rather than pretending the call never ran.
276
259
 
277
260
  ## Both protocol eras
278
261
 
279
- Revision `2026-07-28` removed the handshake that every client in use today still performs. The
280
- server speaks both and answers whichever arrives first.
262
+ Revision `2026-07-28` removed the handshake most deployed clients still perform. The server speaks
263
+ both and answers whichever arrives first.
281
264
 
282
265
  | Era | Revisions | Opening move |
283
266
  | :-- | :-- | :-- |
284
267
  | Legacy | `2025-11-25`, `2025-06-18` | `initialize`, then `notifications/initialized` |
285
268
  | Modern | `2026-07-28` | `server/discover`, or `_meta` on every request; a stateless request with valid `_meta` is complete on its own |
286
269
 
287
- The two disagree about an unsupported version, and the difference is observable: a legacy client is
288
- negotiated *down* to a revision the server speaks, while a modern client receives `-32022` with the
289
- list of supported revisions so it can retry.
270
+ A modern request over HTTP is complete only when its mirroring headers agree with its body, and its
271
+ cacheable results carry the fields the revision requires. Those rules are enforced in
272
+ `src/mcp/http-headers.ts` and `src/mcp/server.ts`, not just documented.
290
273
 
291
- ## Why there is no SDK
274
+ The two eras disagree about an unsupported version, and the difference is observable: a legacy
275
+ client is negotiated *down* to a revision the server speaks, while a modern client receives
276
+ `-32022` with the list of supported revisions so it can retry.
277
+
278
+ ## Why there is no runtime SDK
292
279
 
293
280
  `@modelcontextprotocol/sdk` is 4.5 MB unpacked and brings Express, Hono, Ajv, JOSE and Zod with it.
294
281
  The transport here is newline-delimited JSON-RPC, which is roughly 400 lines of readable code, and
295
282
  the package's only runtime dependency remains `typescript`. The parity test — a live `tools/list`
296
- compared against `describe --format json` — is what keeps the protocol implementation honest, not
297
- the presence of a library.
283
+ compared against `describe --format json` — is what keeps the protocol contract honest, not the
284
+ presence of a library.
285
+
286
+ The official v2 client (`@modelcontextprotocol/client`) is a **dev-only** dependency. Two
287
+ interoperability tests drive this server through it over modern stdio and modern HTTP, including
288
+ `server/discover`, `tools/list`, `tools/call`, `resources/read` and the cache fields. It is not
289
+ shipped, and it does not make the runtime depend on the SDK.
298
290
 
299
291
  ## Performance
300
292
 
@@ -309,7 +301,7 @@ the same repository. The numbers below are measured, not estimated:
309
301
  | A synthetic tree | 3,000 | 7.5 s |
310
302
 
311
303
  They describe how long the *write* takes, not how long the server is deaf — which is the
312
- distinction a client's request timeout actually cares about. `snapshot_plan` produces the same
304
+ distinction a client's request timeout actually cares about. `snapshot_generate` with `dryRun` produces the same
313
305
  numbers without writing anything.
314
306
 
315
307
  The worker re-reads the configuration and applies the same options this thread used, because a
@@ -327,7 +319,7 @@ to stderr. Check the client's server log — the first line says which directory
327
319
  version in the client arguments.
328
320
 
329
321
  **`Unknown resource` for a part.** Resources are computed from the manifest, so nothing but the
330
- static set exists before the first generate. Call `snapshot_status`, then `snapshot_generate`.
322
+ static set exists before the first generate. Call `snapshot_validate` with `mode: "status"`, then `snapshot_generate`.
331
323
 
332
324
  **A resource read fails with `-32000`.** The resource is larger than the 512 kB single-read limit;
333
325
  it was refused rather than truncated. `data.uri`, `data.bytes` and `data.limit` say which resource
@@ -336,3 +328,10 @@ from the snapshot directory for the manifest or a report.
336
328
 
337
329
  **A file is missing from `snapshot_locate`.** It is excluded, and `snapshot_explain` will name the
338
330
  reason — an ignore rule, the preset, a sensitive-file pattern, or your own config.
331
+
332
+
333
+ ## See also
334
+
335
+ - [MCP server for a codebase](mcp-server-for-codebase.md) — setup for Claude, Cursor and generic clients, the seven tools, security and limits.
336
+ - [MCP tools](tools.md) — every schema and an example call.
337
+ - [LLM codebase context](llm-codebase-context.md) — why a local server beats attaching a file for follow-up questions.
package/docs/migration.md CHANGED
@@ -1,86 +1,84 @@
1
- # Migrating to 0.20.12
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.12: 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
-
67
- ## Behaviour changes to know
68
-
69
- 1. **`validate` accepts `--include-diffs`, `--include-logs` and `--token-tree`** (0.12.28).
70
- Those flags change the artifact selection the manifest records, so pass the same flags to
71
- compare like with like.
72
- 2. **The 0.20 line is published in place.** Every 0.20.x patch is committed, tagged and may be
73
- published; earlier lines published only at `x.y.0`. Pin an exact version when the same build
74
- must run everywhere.
75
- 3. **The 0.20.12 HTTP/MCP limits are stricter.** Empty JSON-RPC batches are invalid, oversized
76
- bodies return 413 before the socket closes, and content tools refuse a part above 16 MiB.
77
-
78
- `validate` on a snapshot written by an older version still works: newer manifest keys are
79
- optional, and an artifact the manifest does not record is not required to exist.
80
-
81
- ## If you are on an older 0.12.x
82
-
83
- Upgrade to the latest 0.12.x first; every change since 0.12.14 is a patch on the same line, and
84
- the configuration file format has not changed. Run `snapshot health` after the first generate on
85
- the new version - it is the fastest way to see whether an old snapshot carries anything the
86
- 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
@@ -57,11 +57,16 @@ executable config in it is refused, because a fetched repository is not a truste
57
57
  `--no-auth` is refused on a non-loopback bind.
58
58
  - **Constant-time** token comparison; the token is generated with `crypto.randomBytes`.
59
59
  - **CORS only for loopback origins** and explicit `--allow-origin` values; everything else is 403.
60
+ The allowed request headers include `Mcp-Method` and `Mcp-Name` so a browser can send the
61
+ modern routing headers.
62
+ - **Header/body agreement.** A modern request is refused with HTTP 400 and `-32020` when
63
+ `MCP-Protocol-Version`, `Mcp-Method` or `Mcp-Name` is missing or disagrees with the parsed
64
+ body. Routing decisions cannot be made from a header the handler did not verify against the
65
+ value it executes.
60
66
  - **Bounded work**: 2 MiB bodies, 60 requests per 10 s per address, one JSON document per response,
61
67
  and at most four MCP tool calls in flight across all HTTP sessions. The session and rate maps are
62
68
  capped and evicted, so a client cannot grow either without bound.
63
- - **Untrusted regexes are bounded.** `snapshot_search`, `snapshot_routes` and `snapshot_query`
64
- 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
65
70
  backreferences before compiling; glob and gitignore patterns are bounded by wildcard, brace and
66
71
  alternative counts. JavaScript has no regex timeout, so the alternative is a main-thread stall.
67
72
  - **Errors are JSON-RPC error objects**, never stack traces.
@@ -114,7 +119,7 @@ to treat file content as data. This is a real, documented limitation, not a solv
114
119
 
115
120
  ## What changed since this review was written
116
121
 
117
- The review was written at 0.12.34. Between then and 0.20.12 the surfaces it covers grew; each
122
+ The review was written at 0.12.34. Between then and 0.20.13 the surfaces it covers grew; each
118
123
  addition was reviewed with the same question — what new input arrives, and what does it reach?
119
124
 
120
125
  - **`GET /metrics`** (0.13.3) publishes counters with a fixed label set. Repo paths, tokens and
@@ -125,10 +130,11 @@ addition was reviewed with the same question — what new input arrives, and wha
125
130
  - **The audit stopped trusting the manifest** (0.13.6-0.13.10): bodies, counts and pack membership
126
131
  are recomputed. An attacker who edits a part and updates its hash, or edits a manifest count,
127
132
  now fails the audit; before, both passed. This turns a tampered snapshot into a detected one.
128
- - **`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
129
134
  exclusions apply exactly as they do to `snapshot_read`; it adds no file-system surface.
130
- - **`--only`/`--ignore`** (0.14.6) widen nothing: `--ignore` adds excludes, and `--only` can only
131
- 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.
132
138
  - **The 0.20.5 second audit** closed the bypasses left by 0.20.4: symlink targets now have to be
133
139
  included under their own name, uppercase authorization headers are masked, C-quoted diff paths
134
140
  and gitignore/exclude targets are handled, resource/manifest/report reads are confined,
@@ -148,7 +154,7 @@ addition was reviewed with the same question — what new input arrives, and wha
148
154
  credentials and unterminated PEM bodies have no length/prefix blind spot; alternation and glob
149
155
  branch budgets bound the event loop; workspace members inherit every generation flag;
150
156
  `validate` agrees with `--skip-artifacts parts`; HTTP batches are charged per message and
151
- 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
152
158
  reach validation; `..notes.ts` is accepted at the segment boundary; `health --all-members`
153
159
  confines the index and members; `serve` rejects non-HTTP loopback origins and records nested
154
160
  repository roots; and report fences grow with their content.
@@ -158,6 +164,9 @@ addition was reviewed with the same question — what new input arrives, and wha
158
164
  for a missing local source and cleans an in-flight clone on close; IPv6 remote literals parse;
159
165
  `**` counts as one wildcard and brace products are bounded; and the describe contract, tool
160
166
  annotations and documentation statements were corrected where the source disagreed.
167
+ - **The 0.20.13 MCP conformance pass** checked the modern Streamable HTTP rules against the
168
+ published revision and the official v2 client: header/body agreement, cache fields and
169
+ resource errors.
161
170
 
162
171
  The residual risks below are unchanged, including the two that are deliberate rather than solved.
163
172
 
@@ -169,6 +178,8 @@ The residual risks below are unchanged, including the two that are deliberate ra
169
178
  | Redaction masks the span only | redaction suite (hundreds of cases) |
170
179
  | Health catches a leaked secret and never echoes it | `tests/health.test.js` |
171
180
  | HTTP: 401 without token, 403 cross-origin, 413 oversize, 400 bad JSON | `tests/mcp-http.test.js` |
181
+ | Modern HTTP: required headers, mismatch 400/-32020, cache fields, -32602, CORS | `tests/mcp-modern-http.test.js` |
182
+ | Official MCP v2 client: modern stdio and modern HTTP, discovery, tools, resources | `tests/mcp-sdk-interop.test.js` |
172
183
  | SSE: token required, unknown session 404, shutdown does not hang | `tests/mcp-http.test.js` |
173
184
  | Remote: private addresses refused, credentials in URL refused, `file:` gated | `tests/remote-source.test.js` |
174
185
  | Serve: page without token, API with token, zip restricted | `tests/web-serve.test.js` |
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