codebase-snapshot 0.20.9 → 0.20.13
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 +64 -6
- package/README.md +20 -17
- package/SECURITY.md +0 -1
- package/dist/bin.js +5982 -4752
- package/dist/{chunk-SU6YGIQT.js → chunk-GNVRD7XS.js} +8256 -7065
- package/dist/cli.cjs +8099 -6875
- package/dist/cli.d.cts +2 -2
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +51 -18
- package/dist/{generate-worker--m4IM5zj.d.ts → generate-worker-CRMESc0b.d.ts} +9 -9
- package/dist/{generate-worker-DfNd8f67.d.cts → generate-worker-DMzNbsAW.d.cts} +9 -9
- package/dist/index.cjs +8665 -7466
- package/dist/index.d.cts +56 -40
- package/dist/index.d.ts +56 -40
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +2249 -7440
- package/dist/mcp.d.cts +17 -8
- package/dist/mcp.d.ts +17 -8
- package/dist/mcp.js +1 -1
- package/dist/{types-D2_K7jfI.d.ts → types-C5ytHMYz.d.cts} +2 -0
- package/dist/{types-D2_K7jfI.d.cts → types-C5ytHMYz.d.ts} +2 -0
- package/docs/benchmarks.md +9 -6
- package/docs/budget.md +3 -2
- package/docs/cli.md +24 -22
- package/docs/configuration.md +18 -17
- package/docs/deploy.md +2 -2
- package/docs/health.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +8 -11
- package/docs/mcp.md +55 -33
- package/docs/migration.md +47 -43
- package/docs/output.md +2 -1
- package/docs/security-review.md +46 -8
- package/docs/vs-gitingest.md +2 -2
- package/docs/vs-repomix.md +7 -6
- package/docs/workspace.md +4 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,13 +10,14 @@ This package started its public life as `@ankurhalder/codebase-snapshot`, which
|
|
|
10
10
|
moved to the unscoped name and **restarted at 0.9.0**, so the numbers below are not a continuation of
|
|
11
11
|
the old line — `0.9.0` is newer than `4.4.1`, not older.
|
|
12
12
|
|
|
13
|
-
The line
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
The current line is **`0.20.x`, with literal sub-bumps**: every change ships as its own version,
|
|
14
|
+
`0.20.12`, `0.20.13`, and so on. The number is not the promise; the entry below is. `1.0.0` is never
|
|
15
|
+
released.
|
|
16
16
|
|
|
17
|
-
GitHub carries a tag for every version and `main` carries every commit. **npm
|
|
18
|
-
only at `x.y.0`** (`0.13.0`, `0.14.0`, …)
|
|
19
|
-
|
|
17
|
+
GitHub carries a tag for every version and `main` carries every commit. For earlier lines, **npm
|
|
18
|
+
publication happens only at `x.y.0`** (`0.13.0`, `0.14.0`, …). **The 0.20 line is the deliberate
|
|
19
|
+
exception:** patches may be published and pinned, so the registry stays current without leaving
|
|
20
|
+
0.20.
|
|
20
21
|
|
|
21
22
|
Two versions exist on the registry that are not releases, and both are deprecated:
|
|
22
23
|
|
|
@@ -30,6 +31,63 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
34
|
+
## 0.20.13
|
|
35
|
+
|
|
36
|
+
**MCP 2026-07-28 conformance: the modern HTTP headers, cache metadata and resource error code now match the revision, and an independent client drives both modern transports.**
|
|
37
|
+
|
|
38
|
+
- Streamable HTTP validates `MCP-Protocol-Version`, `Mcp-Method` and `Mcp-Name` against the parsed body before dispatch, returns HTTP `400` with `-32020` for a missing or mismatched header, decodes the Base64 sentinel, and allows the headers in CORS preflights.
|
|
39
|
+
- `server/discover`, `tools/list`, `prompts/list`, `resources/list`, `resources/read` and `resources/templates/list` carry the required `ttlMs` and `cacheScope` fields in the modern era. `ttlMs` is `0` and the scope is `private`: a regenerated snapshot must not be served from a stale cache.
|
|
40
|
+
- A missing modern resource returns `-32602` (Invalid Params); legacy clients keep `-32002`. Unknown methods and unsupported versions use the modern HTTP statuses (404 and 400).
|
|
41
|
+
- Modern requests are stateless: an `mcp-session-id` is ignored rather than looked up, and a modern request never mints or echoes one.
|
|
42
|
+
- New tests drive the server through the official MCP v2 client over modern stdio and modern HTTP (`server/discover`, `tools/list`, `tools/call`, `resources/read`), and a Windows CI job builds and runs the transport suites. The client is a dev-only dependency; the runtime still depends only on `typescript`.
|
|
43
|
+
- The docs now state the modern header, caching and error rules, and the security review names the header/body agreement check.
|
|
44
|
+
|
|
45
|
+
## 0.20.12
|
|
46
|
+
|
|
47
|
+
**Live execution of the fourth audit's hypotheses: every claim was reproduced against the built CLI before it was fixed, and each class has a regression test.**
|
|
48
|
+
|
|
49
|
+
- MCP HTTP `POST /mcp` charges the envelope before reading the body. An empty batch is rejected with JSON-RPC `-32600` instead of an endless 202, malformed JSON and oversized bodies consume the rate window, and a batch is charged per JSON-RPC message. Oversized bodies flush the documented 413 before the socket closes.
|
|
50
|
+
- Dockerfile/Containerfile `ENV` and `ARG` line continuations are masked as one value before the per-line rules run. Quoted literals and `KEY=` continuations are covered; `$VAR` references and placeholders stay readable, and a second scan is idempotent.
|
|
51
|
+
- `snapshot_read`, `snapshot_context`, `snapshot_diff_context`, `snapshot_review` and `snapshot_answer` refuse parts above 16 MiB before `readFileSync`, instead of blocking the JSON-RPC event loop on a hand-crafted part.
|
|
52
|
+
- `serve` answers 404 for a missing local source and 403 only for a path outside the served root. An in-flight remote clone is tracked before its first await and removed when the server closes.
|
|
53
|
+
- IPv6 literals parse as `--remote` sources again, including `[::1]` with `--allow-private` and public literals; the DNS check strips the brackets before lookup.
|
|
54
|
+
- A run of `*` characters counts as one wildcard expression, so `**/a/**/b/*` is accepted by git and walk discovery alike. Brace alternatives are multiplied across groups, so eight five-way groups are refused rather than compiled into 312,500 regex paths.
|
|
55
|
+
- `describe` reports the real `diff`/`log`/`tokenTree` defaults and the real types for `--attachment-slots` and `--max-parts`; the `--skip-artifacts` summary lists every artifact.
|
|
56
|
+
- Documentation now matches the code for the read-only tool count, configured `outDir` confinement, `init`'s JSON default and `--force`, remote support in the comparison pages, and the difference between the structural manifest token estimate and the byte-ratio budget estimate.
|
|
57
|
+
- Removed the retired 0.10.1 audit tree and the stale `GOAL.md`/`ROADMAP.md` planning files, with their scanner and snapshot exclusions; the migration guide now covers 0.12.14 to 0.20.12.
|
|
58
|
+
|
|
59
|
+
## 0.20.11
|
|
60
|
+
|
|
61
|
+
**A second, deeper review found that several guards were true in one path but not its twin. This pass closes those edge cases and makes every omission visible.**
|
|
62
|
+
|
|
63
|
+
- A repository-controlled `.codebase-snapshot` marker can no longer erase a subtree from both `files[]` and `skipped[]`. Only the configured output/staging paths are silent; any other complete marker is recorded with reason `tool-output` and not treated as source.
|
|
64
|
+
- Dockerfile `ENV`/`ARG` redaction is idempotent: health no longer re-finds its own marker, and placeholder or `$VAR` values are exempt.
|
|
65
|
+
- The quoted-credential bound and the unquoted assignment bounds were removed entirely, so a long value under a credential-shaped key has no length cliff at which every rule stops matching.
|
|
66
|
+
- Unterminated PEM keys are detected through comment prefixes, quoted array elements and escaped `\n` sequences, not only bare indented body lines.
|
|
67
|
+
- `unsafeRegExpReason` charges alternation branches, so a chain of unquantified groups such as `(\w|\S|.)` repeated is refused instead of backtracking on the event loop. Glob wildcard chains are capped at four.
|
|
68
|
+
- `generate --workspace` now resolves the caller's generation flags for every member instead of silently dropping budgets, compression, scoping and report options.
|
|
69
|
+
- `validate` agrees with `generate --skip-artifacts parts`: a navigation link to a deliberately absent part is expected, not drift.
|
|
70
|
+
- MCP HTTP rate limiting counts JSON-RPC messages, not HTTP envelopes; a batched `initialize` is rejected unless it is alone, and a one-message batch mints an `mcp-session-id`.
|
|
71
|
+
- `snapshot_symbol` bounds `lines`/`maxFiles`/`maxReferences` and caps the whole response, clearing the duplicated structured bodies when clipped.
|
|
72
|
+
- `snapshot_validate` honors explicit `false` overrides for compression, scope, artifacts and other boolean settings instead of falling back to the recorded manifest.
|
|
73
|
+
- Path containment checks now use a segment boundary, so a legitimate file such as `..notes.ts` is inside the repository and replays under `health --deep`.
|
|
74
|
+
- `health --all-members` reads `WORKSPACE.json` through the confined reader, refuses a symlinked member or index, and never echoes parser snippets.
|
|
75
|
+
- `serve` accepts only HTTP(S) loopback origins, drops evicted clone roots, and records the repository root for a nested `outDir` so `GET /api/health` audits the right tree.
|
|
76
|
+
- Diff and log reports choose an adaptive code fence, and `snapshot_history` parses it, so a commit subject containing backticks cannot break the report.
|
|
77
|
+
|
|
78
|
+
## 0.20.10
|
|
79
|
+
|
|
80
|
+
**Security hardening from a three-pass audit: snapshot confinement, redaction, validation, MCP protocol and serve boundaries. Every finding was reproduced before its fix, and each class has a regression test.**
|
|
81
|
+
|
|
82
|
+
- **Confinement.** A committed `snapshot/parts` junction/symlink can no longer read a host file through `snapshot://parts/{n}`; a repository's `snapshot.config.json` may not place `outDir` or `tmpDir` outside the served root; `WORKSPACE.json` and `signature.json` are read through the confined reader, and a member path is never stat'ed until it resolves inside the repository.
|
|
83
|
+
- **Redaction.** PEM blocks are masked structurally instead of trusting a cross-line quote state, so a preceding comment, regex literal or Python `b"..."` prefix cannot leak the base64 body. Multi-line JS/TS template literals, Python/Ruby/JS quoted assignments, YAML list-item block scalars, `Dockerfile.prod`/`Containerfile` ENV lines, backup spellings such as `.kube/config.bak`, and credentials beside a redaction marker are masked. Diff reports scan the logical file without the `+`/`-`/` ` prefix, then restore it.
|
|
84
|
+
- **ReDoS.** `unsafeRegExpReason` counts optional quantifiers (`?`, `{0,1}`) and refuses backreferences; `globToRegExp` and `compileGitignorePattern` refuse globs whose brace groups or wildcard chains exceed a bounded branch budget. A custom-secret-rule list is capped at 64 in MCP and serve.
|
|
85
|
+
- **MCP protocol.** A metadata-less `server/discover` and a pre-initialize `ping` no longer commit the connection's era; a modern stateless HTTP request gets its own dispatcher instead of sharing the legacy anonymous pool; `Access-Control-Expose-Headers: mcp-session-id` lets browser clients read the session they were given; `snapshot_answer`, `snapshot_context` and `snapshot_diff_context` cap the whole response at 64 KiB; explicit `false` boolean arguments are honored; `snapshot_read` stays paginated when the first line is empty.
|
|
86
|
+
- **Validation.** A snapshotted file replaced by a directory or symlink, or dropped from the current ignore/filter selection, is drift rather than "valid"; `git rm --cached` with `--staged` no longer fails immediately after a correct generate; raising `maxPartBytes` in the config is detected instead of clamped to the old manifest value.
|
|
87
|
+
- **Serve.** `/api/snapshot.zip` zips only the files the manifest declares and refuses a directory that merely contains a PWA `manifest.json`; the remote clone is asynchronous, so one slow URL cannot freeze `/healthz`, `/mcp` or SSE; concurrent generations and temporary clones are bounded and keep-alive connections are closed on shutdown.
|
|
88
|
+
- **Agent onboarding.** `init` writes a data-only `snapshot.config.json` by default, which the CLI, MCP and `serve` can all load without executing repository code. An existing executable config is preserved by `--force`; this repository's own config is now JSON.
|
|
89
|
+
- Smaller fixes: `verifySnapshotSignature` confines both reads and no longer echoes parser snippets; `slice` questions are masked before reaching the manifest; the graph tools use maps and an iterative Tarjan pass; a monolith body transformed by comment stripping is labelled `comments-stripped`, not `full`.
|
|
90
|
+
|
|
33
91
|
## 0.20.9
|
|
34
92
|
|
|
35
93
|
**MCP hardening: a regex denial of service, a session-table wedge, stateless modern clients, config compatibility and transport drift are fixed together, with a regression for each.**
|
package/README.md
CHANGED
|
@@ -212,7 +212,7 @@ Everything an agent needs is available as data, and the tool can install its own
|
|
|
212
212
|
```bash
|
|
213
213
|
npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
|
|
214
214
|
npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
|
|
215
|
-
npx -y codebase-snapshot@0.20.
|
|
215
|
+
npx -y codebase-snapshot@0.20.12 mcp # or serve it over MCP
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
|
|
@@ -224,24 +224,27 @@ tree, so an excluded file stays excluded and a redacted value stays redacted, an
|
|
|
224
224
|
`snapshot_validate` answers the question an agent otherwise cannot ask: is the context I was given
|
|
225
225
|
still true?
|
|
226
226
|
|
|
227
|
+
It speaks both protocol eras, including the `2026-07-28` revision: stateless `server/discover`,
|
|
228
|
+
required `MCP-Protocol-Version`/`Mcp-Method`/`Mcp-Name` HTTP headers, cache hints on every
|
|
229
|
+
cacheable result, and the modern resource-not-found code. The suite drives it through the official
|
|
230
|
+
MCP v2 client over both modern stdio and modern HTTP.
|
|
231
|
+
|
|
227
232
|
→ [Using this with an AI agent](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/agent.md) · [MCP server](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp.md) · [AGENTS.md](https://github.com/ankurhalder/codebase-snapshot/blob/main/AGENTS.md) · [llms.txt](https://github.com/ankurhalder/codebase-snapshot/blob/main/llms.txt)
|
|
228
233
|
|
|
229
234
|
## Configuration
|
|
230
235
|
|
|
231
|
-
`snapshot.config.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
maxPartBytes: "120k",
|
|
238
|
-
excludePatterns: ["vendor/**", "**/*.min.js"],
|
|
239
|
-
artifacts: { monolith: false },
|
|
240
|
-
budgets: { default: "120k", byLayer: { docs:
|
|
241
|
-
includeSensitiveFiles: false
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export default config;
|
|
236
|
+
`snapshot.config.json` is written by `init` with **every** setting at its current value, so it
|
|
237
|
+
doubles as the reference. Deleting any line is safe: the defaults are real. JSON is deliberate:
|
|
238
|
+
the MCP server and `serve` refuse executable repository configs.
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"maxPartBytes": "120k",
|
|
243
|
+
"excludePatterns": ["vendor/**", "**/*.min.js"],
|
|
244
|
+
"artifacts": { "monolith": false },
|
|
245
|
+
"budgets": { "default": "120k", "byLayer": { "docs": 40000 } },
|
|
246
|
+
"includeSensitiveFiles": false
|
|
247
|
+
}
|
|
245
248
|
```
|
|
246
249
|
|
|
247
250
|
→ [Configuration reference](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/configuration.md)
|
|
@@ -280,12 +283,12 @@ others.
|
|
|
280
283
|
| [Benchmarks](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/benchmarks.md) | Reproducible token and time numbers for the three modes |
|
|
281
284
|
| [Security review](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/security-review.md) | Threat model, controls, tests and residual risks |
|
|
282
285
|
| [Deploy](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/deploy.md) | Container, compose and systemd, with the token requirement |
|
|
283
|
-
| [Migrating](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/migration.md) | What changed from 0.12.14 to 0.
|
|
286
|
+
| [Migrating](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/migration.md) | What changed from 0.12.14 to 0.20.13, and the behaviour changes that matter |
|
|
284
287
|
| [Workspaces](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/workspace.md) | `--workspace`: one snapshot per member, plus the index |
|
|
285
288
|
| [Token budget](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/budget.md) | `--budget-tokens`: whole files chosen to fit a limit, not torn to fit a part |
|
|
286
289
|
| [The brief](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/brief.md) | The half of PROMPT.md only you can write, and what is refused |
|
|
287
290
|
| [AI agents](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/agent.md) | The contract, the skill, what an agent should avoid |
|
|
288
|
-
| [MCP server](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp.md) | 26 tools, resources, both protocol eras |
|
|
291
|
+
| [MCP server](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp.md) | 26 tools, resources, both protocol eras, modern HTTP conformance |
|
|
289
292
|
| [Troubleshooting](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/troubleshooting.md) | Every message and what to do about it |
|
|
290
293
|
| [Changelog](https://github.com/ankurhalder/codebase-snapshot/blob/main/CHANGELOG.md) | Release history and breaking changes |
|
|
291
294
|
|
package/SECURITY.md
CHANGED
|
@@ -85,7 +85,6 @@ construction, instead of asking a human to dismiss the same alert on every push:
|
|
|
85
85
|
| Surface | Why it is excluded |
|
|
86
86
|
| :--- | :--- |
|
|
87
87
|
| `tests/**` | the fixtures assert that detection fires |
|
|
88
|
-
| `audit/**` | verification reports quote the probes they describe |
|
|
89
88
|
| `src/security/patterns.ts`, `src/security/redact.ts` | the rule definitions and their worked examples |
|
|
90
89
|
| `package-lock.json` | integrity digests are not credentials |
|
|
91
90
|
|