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.
- package/CHANGELOG.md +44 -6
- package/README.md +46 -19
- package/SECURITY.md +2 -2
- package/dist/bin.js +12173 -9823
- package/dist/{chunk-TUKY6KLH.js → chunk-TDPYLX7X.js} +6312 -4472
- package/dist/cli.cjs +12074 -9744
- package/dist/cli.d.cts +76 -2
- package/dist/cli.d.ts +76 -2
- package/dist/cli.js +549 -14
- package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-D56JeXwx.d.cts} +2 -2
- package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-DakxZs-l.d.ts} +2 -2
- package/dist/index.cjs +6292 -4466
- package/dist/index.d.cts +281 -63
- package/dist/index.d.ts +281 -63
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +10486 -4393
- package/dist/mcp.d.cts +26 -11
- package/dist/mcp.d.ts +26 -11
- package/dist/mcp.js +1 -1
- package/dist/{types-C5ytHMYz.d.ts → types-D5XYzksd.d.cts} +50 -2
- package/dist/{types-C5ytHMYz.d.cts → types-D5XYzksd.d.ts} +50 -2
- package/docs/about.md +86 -0
- package/docs/agent.md +28 -6
- package/docs/answer.md +99 -48
- package/docs/benchmarks.md +34 -34
- package/docs/brief.md +80 -81
- package/docs/cli.md +103 -27
- package/docs/codebase-token-budget.md +14 -13
- package/docs/configuration.md +1 -1
- package/docs/contents.md +66 -0
- package/docs/deploy.md +2 -2
- package/docs/faq.md +112 -0
- package/docs/glossary.md +152 -0
- package/docs/health.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +6 -0
- package/docs/impact.md +102 -0
- package/docs/install.md +4 -3
- package/docs/llm-codebase-context.md +166 -0
- package/docs/mcp-server-for-codebase.md +155 -0
- package/docs/mcp.md +81 -82
- package/docs/migration.md +83 -85
- package/docs/output.md +1 -3
- package/docs/security-review.md +20 -9
- package/docs/slice.md +1 -1
- package/docs/tools.md +159 -185
- package/docs/troubleshooting.md +11 -11
- package/docs/vs-code2prompt.md +7 -0
- package/docs/vs-gitingest.md +7 -0
- package/docs/vs-repomix.md +10 -1
- package/docs/workspace.md +1 -1
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
50
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
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
|
|
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
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
`
|
|
161
|
-
|
|
162
|
-
`
|
|
163
|
-
|
|
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 "
|
|
175
|
-
|
|
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
|
|
179
|
-
|
|
180
|
-
|
|
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 `
|
|
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 `
|
|
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 `-
|
|
221
|
-
|
|
222
|
-
the
|
|
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
|
|
280
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
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
|
|
297
|
-
|
|
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. `
|
|
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 `
|
|
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.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
|
|
|
19
|
-
| :--- | :--- |
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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.
|
|
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
|
package/docs/security-review.md
CHANGED
|
@@ -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, `
|
|
39
|
-
`
|
|
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.** `
|
|
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.
|
|
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
|
-
- **`
|
|
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
|
|
131
|
-
|
|
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; `
|
|
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
|
-
[`
|
|
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
|