codebase-snapshot 0.20.3 → 0.20.4
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 +63 -0
- package/README.md +1 -1
- package/dist/bin.js +897 -419
- package/dist/{chunk-7JQRJBMP.js → chunk-AQZNT3QL.js} +657 -256
- package/dist/{chunk-TUL3I7O6.js → chunk-QB5TNXMZ.js} +90 -14
- package/dist/cli.cjs +808 -329
- package/dist/cli.d.cts +14 -2
- package/dist/cli.d.ts +14 -2
- package/dist/cli.js +72 -73
- package/dist/{generate-worker-C6Z1I0XS.d.cts → generate-worker-CNRsO_z7.d.cts} +4 -0
- package/dist/{generate-worker-C6Z1I0XS.d.ts → generate-worker-CNRsO_z7.d.ts} +4 -0
- package/dist/index.cjs +660 -232
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +672 -306
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +2 -2
- package/docs/brief.md +5 -0
- package/docs/cli.md +5 -5
- package/docs/configuration.md +5 -0
- package/docs/deploy.md +2 -2
- package/docs/mcp.md +11 -4
- package/docs/security-review.md +16 -3
- package/docs/serve.md +8 -4
- package/package.json +1 -1
package/dist/mcp.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-
|
|
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-
|
|
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-
|
|
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-
|
|
1
|
+
export { generateToken, startHttpTransport } from './chunk-QB5TNXMZ.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-AQZNT3QL.js';
|
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.
|
|
101
|
+
Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.4 (project dependency ^0.20.4)
|
|
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.
|
|
226
|
+
Added devDependency: codebase-snapshot ^0.20.4
|
|
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.
|
|
278
|
+
Added devDependency: codebase-snapshot ^0.20.4
|
|
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.
|
|
429
|
-
npx codebase-snapshot@0.20.
|
|
428
|
+
npx codebase-snapshot@0.20.4 update # is 0.17.0 still current? print the answer
|
|
429
|
+
npx codebase-snapshot@0.20.4 update --format json
|
|
430
430
|
```
|
|
431
431
|
|
|
432
432
|
```text
|
package/docs/configuration.md
CHANGED
|
@@ -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.
|
|
65
|
-
ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.
|
|
64
|
+
ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.4 generate --cwd /srv/app
|
|
65
|
+
ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.4 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.
|
|
13
|
+
npx -y codebase-snapshot@0.20.4 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.
|
|
28
|
+
"args": ["-y", "codebase-snapshot@0.20.4", "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.
|
|
37
|
+
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.4 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.
|
|
46
|
+
npx -y codebase-snapshot@0.20.4 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:
|
package/docs/security-review.md
CHANGED
|
@@ -53,20 +53,33 @@ executable config in it is refused, because a fetched repository is not a truste
|
|
|
53
53
|
baked into the HTML, so serving `/` cannot leak it.
|
|
54
54
|
- A request with a cross-origin `Origin` is refused before any auth check.
|
|
55
55
|
- `api/snapshot.zip` only zips a directory that contains a manifest or an ownership marker.
|
|
56
|
+
- Every path is resolved with `realpath` before the allowed-root check, so a symlink inside the
|
|
57
|
+
served directory cannot read or zip a target outside it. `POST /api/generate` applies the same
|
|
58
|
+
check to its local source and to the `outDir` it is about to write; a remote clone's
|
|
59
|
+
`outDir`/`tmpDir` are forced to the clone.
|
|
60
|
+
- The page renders manifest fields with text nodes, never `innerHTML`, so a crafted manifest is
|
|
61
|
+
data rather than script.
|
|
56
62
|
|
|
57
63
|
### Remote ingestion
|
|
58
64
|
|
|
59
65
|
- **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
|
|
61
|
-
unless `--allow-private` is given.
|
|
66
|
+
RFC1918, link-local (including `169.254.169.254`), CGNAT, multicast, IPv4-mapped IPv6, NAT64/6to4
|
|
67
|
+
forms and their v6 equivalents are refused unless `--allow-private` is given.
|
|
62
68
|
- **Checked twice**: the literal host before DNS, and every resolved address after.
|
|
63
|
-
- **
|
|
69
|
+
- **No redirects**: git is passed `http.followRedirects=false` and a protocol allow-list, so a
|
|
70
|
+
public host cannot answer `302` into the local network after the host check.
|
|
71
|
+
- **The ambient token is host-scoped**: `GITHUB_TOKEN`/`GH_TOKEN` is attached only for
|
|
72
|
+
`github.com` or hosts named in `CODEBASE_SNAPSHOT_GITHUB_HOSTS`; it is never sent to an
|
|
73
|
+
arbitrary `--remote` host.
|
|
74
|
+
- **Shallow clone** into a temp directory removed on exit; the token reaches git through the
|
|
64
75
|
environment (`http.extraheader` via `GIT_CONFIG_*`), never argv, and never enters the manifest.
|
|
65
76
|
- A clone larger than 1 GB is refused before scanning.
|
|
66
77
|
|
|
67
78
|
### Signing
|
|
68
79
|
|
|
69
80
|
- Ed25519 over the exact manifest bytes; the record carries the public key and the manifest sha256.
|
|
81
|
+
- Signing happens inside staging, before the ownership marker. The signature is therefore part of
|
|
82
|
+
the atomic swap and the marker's inventory; a later `generate --sign` can replace its own output.
|
|
70
83
|
- `health` fails when the manifest changed after signing; an unsigned snapshot is a skip, because
|
|
71
84
|
absence is not tampering.
|
|
72
85
|
- The private key never reaches an artifact. `SNAPSHOT_SIGNING_KEY` is read from the environment.
|
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
|
|
39
|
-
|
|
40
|
-
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-snapshot",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.4",
|
|
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",
|