codebase-snapshot 0.20.3 → 0.20.5

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/dist/mcp.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-C6Z1I0XS.cjs';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-CNRsO_z7.cjs';
2
2
  import { Readable, Writable } from 'node:stream';
3
3
 
4
4
  /**
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-C6Z1I0XS.js';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-CNRsO_z7.js';
2
2
  import { Readable, Writable } from 'node:stream';
3
3
 
4
4
  /**
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
- export { generateToken, startHttpTransport } from './chunk-TUL3I7O6.js';
2
- export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-7JQRJBMP.js';
1
+ export { generateToken, startHttpTransport } from './chunk-HYTY6T7P.js';
2
+ export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-C3WVC4FV.js';
@@ -843,6 +843,10 @@ interface SnapshotConfig {
843
843
  layers?: LayerRule[];
844
844
  kinds?: KindRule[];
845
845
  excludePatterns?: string[];
846
+ /** Alias of `excludePatterns`, accepted because `--exclude` is the flag spelling. */
847
+ exclude?: string[];
848
+ /** Library spelling of `secrets.customPatterns`; the loader compiles either form. */
849
+ secretRules?: SecretRuleInput[];
846
850
  secrets?: {
847
851
  customPatterns?: SecretRuleInput[];
848
852
  disableDefaultPatterns?: boolean;
@@ -843,6 +843,10 @@ interface SnapshotConfig {
843
843
  layers?: LayerRule[];
844
844
  kinds?: KindRule[];
845
845
  excludePatterns?: string[];
846
+ /** Alias of `excludePatterns`, accepted because `--exclude` is the flag spelling. */
847
+ exclude?: string[];
848
+ /** Library spelling of `secrets.customPatterns`; the loader compiles either form. */
849
+ secretRules?: SecretRuleInput[];
846
850
  secrets?: {
847
851
  customPatterns?: SecretRuleInput[];
848
852
  disableDefaultPatterns?: boolean;
package/docs/brief.md CHANGED
@@ -70,6 +70,11 @@ Three things are errors rather than overrides, because each would make the docum
70
70
  - **an edited brief after generating.** Its digest is recorded, so `validate` reports
71
71
  `brief: docs/brief.md changed since this snapshot was generated`.
72
72
 
73
+ A brief must also stay inside the repository and must not be a credential-bearing file; a path
74
+ that escapes the repository is refused, because an untrusted `snapshot.config.json` must not turn
75
+ the brief into a host-file read. Its prose is redacted with the full content scanner, so a PEM
76
+ private key pasted into the text is masked as a block.
77
+
73
78
  Two smaller ones: a heading defined twice is ambiguous and refused, and a file over 64 KiB is
74
79
  refused with its size — past that it is a second codebase rather than instruction.
75
80
 
package/docs/cli.md CHANGED
@@ -98,7 +98,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
98
98
 
99
99
  ```
100
100
  📸 Generating snapshot for: /path/to/repo
101
- Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.3 (project dependency ^0.20.3)
101
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.5 (project dependency ^0.20.5)
102
102
 
103
103
  ✅ Snapshot generated in 0.14s:
104
104
  - Tracked files: 121 included of 128 paths found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
@@ -223,7 +223,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
223
223
  🚀 Setup for: /path/to/repo
224
224
  ✅ Created snapshot.config.ts (preset: nextjs)
225
225
  Added npm scripts: snapshot, snapshot:validate
226
- Added devDependency: codebase-snapshot ^0.20.3
226
+ Added devDependency: codebase-snapshot ^0.20.5
227
227
  Added to .gitignore: /snapshot/, /snapshot.tmp/
228
228
  ⏳ Installing dependencies…
229
229
  ✅ Installed dependencies (npm install, 2.1s)
@@ -275,7 +275,7 @@ It also has three side effects on files you own, and it says so when it does the
275
275
  ```
276
276
  ✅ Created snapshot.config.ts (preset: node-lib)
277
277
  Added npm scripts: snapshot, snapshot:validate
278
- Added devDependency: codebase-snapshot ^0.20.3
278
+ Added devDependency: codebase-snapshot ^0.20.5
279
279
  Added to .gitignore: /snapshot/, /snapshot.tmp/
280
280
  ```
281
281
 
@@ -425,8 +425,8 @@ agent](agent.md).
425
425
  Ask the npm registry whether a newer release exists, and print the version it compared against:
426
426
 
427
427
  ```bash
428
- npx codebase-snapshot@0.20.3 update # is 0.17.0 still current? print the answer
429
- npx codebase-snapshot@0.20.3 update --format json
428
+ npx codebase-snapshot@0.20.5 update # is 0.17.0 still current? print the answer
429
+ npx codebase-snapshot@0.20.5 update --format json
430
430
  ```
431
431
 
432
432
  ```text
@@ -378,9 +378,14 @@ Three things are refused because they would make the document lie:
378
378
  error, not an override;
379
379
  - a `brief` path that cannot be read is an error — a snapshot must not silently ship without the
380
380
  half you wrote;
381
+ - a `brief` that resolves outside the repository, or that names a credential-bearing file, is
382
+ refused. An untrusted `snapshot.config.json` must not turn the brief into a host-file read;
381
383
  - and the file is digested into the config digest, so editing the brief after generating makes
382
384
  `validate` report drift. A stale brief is the same failure as a stale snapshot.
383
385
 
386
+ The brief is redacted with the full content scanner, not only the path rules: a token or a PEM
387
+ private key pasted into prose is masked before it reaches `PROMPT.md`.
388
+
384
389
  `promptTask` changes only the opening section: `audit` (the default) asks for what is wrong or
385
390
  will break, `review` for what a change breaks, `explain` for how a subsystem works. The standard
386
391
  and the coverage duty are the same in all three.
package/docs/deploy.md CHANGED
@@ -61,8 +61,8 @@ After=network.target
61
61
  Type=oneshot
62
62
  User=deploy
63
63
  WorkingDirectory=/srv/app
64
- ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.3 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.3 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.5 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.5 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
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.3 mcp
13
+ npx -y codebase-snapshot@0.20.5 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.3", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.20.5", "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.3 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.5 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,7 +43,7 @@ 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.3 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.20.5 mcp --http --port 4789
47
47
  ```
48
48
 
49
49
  This is the Streamable HTTP shape: POST one JSON-RPC message (or an array) to `/mcp` and read
@@ -77,6 +77,13 @@ reachable from the network must not be readable by any page that guesses the por
77
77
  CORS is granted to loopback origins (`localhost`, `127.0.0.1`, `[::1]`, any port) and to the
78
78
  origins you list. Any other `Origin` gets `403`.
79
79
 
80
+ The first `initialize` response carries an `mcp-session-id` header. Send it on every later
81
+ request: era and cancellation state belong to that session, so one client's
82
+ `server/discover` cannot reject another client's legacy handshake. A client that ignores the
83
+ header falls back to a per-address server; two such clients on one host with the same user agent
84
+ share state, which is why forwarding the header matters. JSON-RPC batches are capped at 100
85
+ messages, and the body cap applies before parsing.
86
+
80
87
  ### Legacy SSE, for clients that cannot send a header
81
88
 
82
89
  `GET /sse` opens an event stream and announces its message endpoint:
@@ -30,6 +30,18 @@ untrusted input can arrive.
30
30
  - **Paths are masked too.** A path that itself matches a secret rule is recorded masked.
31
31
  - **The health audit re-scans every written text file** for unmasked secrets and compares values
32
32
  from excluded sensitive files byte for byte against the artifacts (`snapshot health`).
33
+ - **A symlink is only a second name for included content.** The target must survive the same
34
+ include/exclude/ignore filters as the link alias; `.git/config` cannot be reached through a
35
+ tracked `notes.txt`.
36
+ - **Every snapshot file read is confined.** PROMPT.md, reports, the manifest and WORKSPACE.json
37
+ are opened through one reader that refuses a symlink and requires the canonical target inside
38
+ the snapshot directory. The MCP resources, `snapshot_history`, `snapshot_workspace` and
39
+ `serve` use it; the part reader keeps its older equivalent.
40
+ - **The diff report fails closed.** Git is forced to emit unquoted ASCII prefixes, a section that
41
+ cannot be attributed to a path is omitted rather than trusted, redaction runs before truncation
42
+ with the diffed file's extension, and `--only` applies to the diff too.
43
+ - **Owner prose is content.** A token in a brief heading, a project-overview line or a commit
44
+ subject goes through the full scanner, not only the path rules.
33
45
 
34
46
  ### Executable configuration
35
47
 
@@ -44,7 +56,12 @@ executable config in it is refused, because a fetched repository is not a truste
44
56
  `--no-auth` is refused on a non-loopback bind.
45
57
  - **Constant-time** token comparison; the token is generated with `crypto.randomBytes`.
46
58
  - **CORS only for loopback origins** and explicit `--allow-origin` values; everything else is 403.
47
- - **Bounded work**: 2 MiB bodies, 60 requests per 10 s per address, one JSON document per response.
59
+ - **Bounded work**: 2 MiB bodies, 60 requests per 10 s per address, one JSON document per response,
60
+ and at most four MCP tool calls in flight across all HTTP sessions. The session and rate maps are
61
+ capped and evicted, so a client cannot grow either without bound.
62
+ - **Untrusted regexes are bounded.** `snapshot_search`, `snapshot_routes` and `snapshot_query`
63
+ reject nested quantifiers, more than one unbounded repetition and oversized repetition bounds
64
+ before compiling; JavaScript has no regex timeout, so the alternative is a main-thread stall.
48
65
  - **Errors are JSON-RPC error objects**, never stack traces.
49
66
 
50
67
  ### The browser page
@@ -53,20 +70,34 @@ executable config in it is refused, because a fetched repository is not a truste
53
70
  baked into the HTML, so serving `/` cannot leak it.
54
71
  - A request with a cross-origin `Origin` is refused before any auth check.
55
72
  - `api/snapshot.zip` only zips a directory that contains a manifest or an ownership marker.
73
+ - Every path is resolved with `realpath` before the allowed-root check, so a symlink inside the
74
+ served directory cannot read or zip a target outside it. `POST /api/generate` applies the same
75
+ check to its local source and to the `outDir` it is about to write; a remote clone's
76
+ `outDir`/`tmpDir` are forced to the clone.
77
+ - The page renders manifest fields with text nodes, never `innerHTML`, so a crafted manifest is
78
+ data rather than script.
56
79
 
57
80
  ### Remote ingestion
58
81
 
59
82
  - **https only**, no credentials in the URL, and the host must resolve to public addresses. Loopback,
60
- RFC1918, link-local (including `169.254.169.254`), CGNAT and their v6 equivalents are refused
61
- unless `--allow-private` is given.
83
+ RFC1918, link-local (including `169.254.169.254`), CGNAT, multicast, IPv4-mapped IPv6, NAT64/6to4
84
+ forms and their v6 equivalents are refused unless `--allow-private` is given.
62
85
  - **Checked twice**: the literal host before DNS, and every resolved address after.
63
- - **Shallow clone** into a temp directory removed on exit; `GITHUB_TOKEN` reaches git through the
86
+ - **No redirects**: git is passed `http.followRedirects=false` and a protocol allow-list, so a
87
+ public host cannot answer `302` into the local network after the host check.
88
+ - **The ambient token is host-scoped**: `GITHUB_TOKEN`/`GH_TOKEN` is attached only for
89
+ `github.com` or hosts named in `CODEBASE_SNAPSHOT_GITHUB_HOSTS`; it is never sent to an
90
+ arbitrary `--remote` host.
91
+ - **Shallow clone** into a temp directory removed on exit; the token reaches git through the
64
92
  environment (`http.extraheader` via `GIT_CONFIG_*`), never argv, and never enters the manifest.
93
+ A clone that fails or exceeds 1 GB is removed before the error is rethrown.
65
94
  - A clone larger than 1 GB is refused before scanning.
66
95
 
67
96
  ### Signing
68
97
 
69
98
  - Ed25519 over the exact manifest bytes; the record carries the public key and the manifest sha256.
99
+ - Signing happens inside staging, before the ownership marker. The signature is therefore part of
100
+ the atomic swap and the marker's inventory; a later `generate --sign` can replace its own output.
70
101
  - `health` fails when the manifest changed after signing; an unsigned snapshot is a skip, because
71
102
  absence is not tampering.
72
103
  - The private key never reaches an artifact. `SNAPSHOT_SIGNING_KEY` is read from the environment.
@@ -95,6 +126,12 @@ addition was reviewed with the same question — what new input arrives, and wha
95
126
  exclusions apply exactly as they do to `snapshot_read`; it adds no file-system surface.
96
127
  - **`--only`/`--ignore`** (0.14.6) widen nothing: `--ignore` adds excludes, and `--only` can only
97
128
  narrow the allow-list the config already permits. Sensitive files stay excluded by default.
129
+ - **The 0.20.5 second audit** closed the bypasses left by 0.20.4: symlink targets now have to be
130
+ included under their own name, uppercase authorization headers are masked, C-quoted diff paths
131
+ and gitignore/exclude targets are handled, resource/manifest/report reads are confined,
132
+ catastrophic MCP regexes are refused before compilation, HTTP tool concurrency is bounded,
133
+ failed clones are removed, workspace dry runs write nothing, staged validation reads the index,
134
+ and hook installation refuses a symlink or hard link.
98
135
 
99
136
  The residual risks below are unchanged, including the two that are deliberate rather than solved.
100
137
 
@@ -110,6 +147,7 @@ The residual risks below are unchanged, including the two that are deliberate ra
110
147
  | Remote: private addresses refused, credentials in URL refused, `file:` gated | `tests/remote-source.test.js` |
111
148
  | Serve: page without token, API with token, zip restricted | `tests/web-serve.test.js` |
112
149
  | Signature: tamper detected | `tests/signing.test.js` |
150
+ | Second 0.20 audit: symlink targets, auth case, diff quoting, brief headings, ReDoS, HTTP cap, workspace dry run, staged validation, hook links | `tests/audit-0-20-5-ultimate.test.js` |
113
151
 
114
152
  ## Residual risks, stated
115
153
 
package/docs/serve.md CHANGED
@@ -24,7 +24,9 @@ Serving http://127.0.0.1:4788/
24
24
  provenance record the CLI writes. The page calls the same `generateSnapshot` the CLI calls,
25
25
  with the repository's `snapshot.config.json` (or the `snapshot` key of `package.json`) applied, so
26
26
  the browser and the terminal produce the same snapshot. An executable config is refused rather
27
- than run: this process does not execute repository code on a page's request.
27
+ than run: this process does not execute repository code on a page's request. A remote clone's
28
+ `outDir` and `tmpDir` are forced to the clone, and its hooks are stripped, so repository data
29
+ cannot choose a path on the host.
28
30
  3. **Preview.** The brief (`PROMPT.md`) and the file list come back from the written snapshot, not
29
31
  from the working tree. If the snapshot is wrong, the page shows the wrongness.
30
32
  4. **See the health score.** The page audits what it just wrote and shows the score, with the
@@ -35,9 +37,11 @@ Serving http://127.0.0.1:4788/
35
37
  ## What the API may read
36
38
 
37
39
  `/api/snapshot`, `/api/snapshot.zip` and `/api/health` take a `path`. The server answers `403` for
38
- a path outside the directory it was started for, or outside a clone it created itself. The token
39
- decides who may ask; this decides what may be asked about — otherwise a leaked token would be an
40
- arbitrary-file-read primitive over the whole disk.
40
+ a path outside the directory it was started for, or outside a clone it created itself. The check
41
+ uses the resolved real path, so a symlink inside the directory cannot point at an outside target.
42
+ `POST /api/generate` applies the same check to its local source, and the token decides who may ask;
43
+ this decides what may be asked about — otherwise a leaked token would be an arbitrary-file-read
44
+ primitive over the whole disk.
41
45
 
42
46
  ## The repository's configuration
43
47
 
package/docs/workspace.md CHANGED
@@ -78,6 +78,9 @@ directory configured if the member should be served on its own.
78
78
  - **No combination.** `--workspace` is refused with `--remote`, `--delta`, `--slice`,
79
79
  `--budget-tokens` and `--sign`: each of those narrows or signs *one* snapshot, and a workspace is
80
80
  several.
81
+ - **Dry run means nothing is written.** `--dry-run` returns the member plans and the index shape but
82
+ creates no member snapshot and no `WORKSPACE.json`. The workspace output root may be inside the
83
+ working directory; it may not be the working directory or one of its ancestors.
81
84
  - **Names come from the directories.** `--workspace a/api,b/api` would collide; use paths whose last
82
85
  segment is unique.
83
86
  - **Cross-member imports are recorded, not judged.** A relative import in one member that resolves
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.20.3",
3
+ "version": "0.20.5",
4
4
  "description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
5
5
  "keywords": [
6
6
  "codebase-snapshot",