codebase-snapshot 0.20.8 → 0.20.12

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 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 now runs **`0.12.x` to `0.17.0`, with literal sub-bumps**: every change ships as its
14
- own version, `0.12.15` through `0.12.99`, then `0.13.0` and the same ladder again. The number is not
15
- the promise; the entry below is. `1.0.0` is never released.
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 publication happens
18
- only at `x.y.0`** (`0.13.0`, `0.14.0`, …), so the registry stays clean while the repository keeps a
19
- complete, buildable history.
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,66 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
30
31
 
31
32
  ---
32
33
 
34
+ ## 0.20.12
35
+
36
+ **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.**
37
+
38
+ - 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.
39
+ - 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.
40
+ - `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.
41
+ - `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.
42
+ - IPv6 literals parse as `--remote` sources again, including `[::1]` with `--allow-private` and public literals; the DNS check strips the brackets before lookup.
43
+ - 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.
44
+ - `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.
45
+ - 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.
46
+ - 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.
47
+
48
+ ## 0.20.11
49
+
50
+ **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.**
51
+
52
+ - 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.
53
+ - Dockerfile `ENV`/`ARG` redaction is idempotent: health no longer re-finds its own marker, and placeholder or `$VAR` values are exempt.
54
+ - 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.
55
+ - Unterminated PEM keys are detected through comment prefixes, quoted array elements and escaped `\n` sequences, not only bare indented body lines.
56
+ - `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.
57
+ - `generate --workspace` now resolves the caller's generation flags for every member instead of silently dropping budgets, compression, scoping and report options.
58
+ - `validate` agrees with `generate --skip-artifacts parts`: a navigation link to a deliberately absent part is expected, not drift.
59
+ - 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`.
60
+ - `snapshot_symbol` bounds `lines`/`maxFiles`/`maxReferences` and caps the whole response, clearing the duplicated structured bodies when clipped.
61
+ - `snapshot_validate` honors explicit `false` overrides for compression, scope, artifacts and other boolean settings instead of falling back to the recorded manifest.
62
+ - 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`.
63
+ - `health --all-members` reads `WORKSPACE.json` through the confined reader, refuses a symlinked member or index, and never echoes parser snippets.
64
+ - `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.
65
+ - Diff and log reports choose an adaptive code fence, and `snapshot_history` parses it, so a commit subject containing backticks cannot break the report.
66
+
67
+ ## 0.20.10
68
+
69
+ **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.**
70
+
71
+ - **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.
72
+ - **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.
73
+ - **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.
74
+ - **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.
75
+ - **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.
76
+ - **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.
77
+ - **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.
78
+ - 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`.
79
+
80
+ ## 0.20.9
81
+
82
+ **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.**
83
+
84
+ - `unsafeRegExpReason` no longer skips the interior of an invalid `{...}` (JavaScript parses it literally without the `u` flag), caps a bounded repetition at 200, and refuses a pattern that chains more than two repeating quantifiers. `snapshot_search`, `snapshot_routes` and `snapshot_query` cannot be made to freeze the event loop with those shapes.
85
+ - Streamable HTTP accepts a session id only after `initialize`; an unknown `mcp-session-id` is a 404, sessions expire after 30 minutes idle, the oldest is evicted instead of silently dropping a new one, and `DELETE /mcp` closes a session.
86
+ - A modern `2026-07-28` request with valid `_meta` is complete without `server/discover`, as the stateless revision requires.
87
+ - `mcp` accepts `--no-config`, and a JSON config beside an executable config is loaded without running the executable one. A repository created by `init` can therefore be served with the documented JSON export or with `--no-config`; it still cannot execute its own TypeScript config inside the server.
88
+ - MCP and `serve` refuse a repository config that enables sensitive-file emission, disables the default secret patterns, or contains a custom regex that can consume the event loop. The CLI keeps honoring those settings; a server does not.
89
+ - `snapshot_health` and `snapshot_review` pass a project's `secrets.customPatterns` to the audit instead of reporting a clean secret check without them.
90
+ - `snapshot serve` mounts the same MCP HTTP/SSE handler as `mcp --http`: session ids, CORS and the documented `/sse` and `/messages` endpoints no longer differ between the two commands.
91
+ - `snapshot_read` omits `nextFromLine` when the file is complete instead of emitting a null for an integer field; `snapshot_review` caps its response at 64 KiB and bounds `linesPerFile`; known-but-absent resources answer `-32002`; `snapshot_plan` and `snapshot_generate` accept numeric byte/token budgets; a token-budget snapshot validates against the narrowed byte budget it actually used.
92
+ - `snapshot_generate` reports a failed in-memory integrity check as a tool error, cancellation is registered before the config await, progress notifications are serialized with responses, and `snapshot_explain` and `snapshot_validate` are labelled expensive rather than cheap or medium.
93
+
33
94
  ## 0.20.8
34
95
 
35
96
  **Security hardening from the first CodeQL pass. The public API and artifact shape are unchanged; hostile names, headers and truncated keys are handled without backtracking or table escape.**
package/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  <a href="#license"><img alt="license: MIT" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
14
14
  <a href="https://nodejs.org"><img alt="node: 18 or newer" src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg"></a>
15
15
  <a href="https://ankurhalder.github.io/codebase-snapshot/"><img alt="documentation" src="https://img.shields.io/badge/docs-read-1a7f37"></a>
16
+ <a href="https://m8ven.ai/mcp/ankurhalder-codebase-snapshot-9hzkhs?s=readme"><img alt="M8ven Live: continuously verified" src="https://m8ven.ai/badge/mcp/ankurhalder-codebase-snapshot-9hzkhs?variant=verified"></a>
16
17
  </p>
17
18
  </div>
18
19
 
@@ -211,7 +212,7 @@ Everything an agent needs is available as data, and the tool can install its own
211
212
  ```bash
212
213
  npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
213
214
  npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
214
- npx -y codebase-snapshot@0.20.8 mcp # or serve it over MCP
215
+ npx -y codebase-snapshot@0.20.9 mcp # or serve it over MCP
215
216
  ```
216
217
 
217
218
  An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
@@ -227,20 +228,18 @@ still true?
227
228
 
228
229
  ## Configuration
229
230
 
230
- `snapshot.config.ts` (or `.mjs`) is written by `init` with **every** setting at its current value,
231
- commented and grouped, so it doubles as the reference. Deleting any line is safe: the defaults are
232
- real.
233
-
234
- ```js
235
- const config = {
236
- maxPartBytes: "120k", // hard budget per part
237
- excludePatterns: ["vendor/**", "**/*.min.js"],
238
- artifacts: { monolith: false }, // single-file output stays off
239
- budgets: { default: "120k", byLayer: { docs: 40_000 } },
240
- includeSensitiveFiles: false, // .env, *.pem … stay out
241
- };
242
-
243
- export default config;
231
+ `snapshot.config.json` is written by `init` with **every** setting at its current value, so it
232
+ doubles as the reference. Deleting any line is safe: the defaults are real. JSON is deliberate:
233
+ the MCP server and `serve` refuse executable repository configs.
234
+
235
+ ```json
236
+ {
237
+ "maxPartBytes": "120k",
238
+ "excludePatterns": ["vendor/**", "**/*.min.js"],
239
+ "artifacts": { "monolith": false },
240
+ "budgets": { "default": "120k", "byLayer": { "docs": 40000 } },
241
+ "includeSensitiveFiles": false
242
+ }
244
243
  ```
245
244
 
246
245
  → [Configuration reference](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/configuration.md)
@@ -279,7 +278,7 @@ others.
279
278
  | [Benchmarks](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/benchmarks.md) | Reproducible token and time numbers for the three modes |
280
279
  | [Security review](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/security-review.md) | Threat model, controls, tests and residual risks |
281
280
  | [Deploy](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/deploy.md) | Container, compose and systemd, with the token requirement |
282
- | [Migrating](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/migration.md) | What changed from 0.12.14 to 0.17.0, and the two behaviour changes |
281
+ | [Migrating](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/migration.md) | What changed from 0.12.14 to 0.20.12, and the behaviour changes that matter |
283
282
  | [Workspaces](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/workspace.md) | `--workspace`: one snapshot per member, plus the index |
284
283
  | [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 |
285
284
  | [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 |
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