codebase-snapshot 0.19.0 → 0.20.2

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.js CHANGED
@@ -1,2 +1,2 @@
1
- export { generateToken, startHttpTransport } from './chunk-TQXTKDFD.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-RTWSGQ3U.js';
1
+ export { generateToken, startHttpTransport } from './chunk-YL4VRORI.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-DUDF3CR5.js';
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.19.0 (project dependency ^0.19.0)
101
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.2 (project dependency ^0.20.2)
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
@@ -171,10 +171,14 @@ codebase-snapshot health [options]
171
171
  ```
172
172
 
173
173
  Audits the snapshot itself rather than the repository: every part hash, every artifact, every
174
- recorded claim, an unmasked-secret scan of every written text file, a byte comparison against the
175
- values of files that were excluded as sensitive, host paths, the token estimate and freshness.
174
+ summary claim against the body, every figure in the reports, every index entry, every pack body,
175
+ an unmasked-secret scan of every written text file, a byte comparison against the values of files
176
+ that were excluded as sensitive, host paths, the token estimate, context-window fit and freshness.
176
177
  It writes nothing and never prints a secret it finds.
177
178
 
179
+ `--deep` adds the one check that needs the repository: every full body is replayed from the bytes
180
+ on disk, with redaction as the only allowed difference. It costs one full read of the tree.
181
+
178
182
  Exit `0` when no check fails, `1` when a critical check fails, and `2` with `--strict` on a
179
183
  critical check (a warning also exits `1` under `--strict`). `--format json` emits the full report.
180
184
  See [the health service](health.md).
@@ -219,7 +223,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
219
223
  🚀 Setup for: /path/to/repo
220
224
  ✅ Created snapshot.config.ts (preset: nextjs)
221
225
  Added npm scripts: snapshot, snapshot:validate
222
- Added devDependency: codebase-snapshot ^0.19.0
226
+ Added devDependency: codebase-snapshot ^0.20.2
223
227
  Added to .gitignore: /snapshot/, /snapshot.tmp/
224
228
  ⏳ Installing dependencies…
225
229
  ✅ Installed dependencies (npm install, 2.1s)
@@ -271,7 +275,7 @@ It also has three side effects on files you own, and it says so when it does the
271
275
  ```
272
276
  ✅ Created snapshot.config.ts (preset: node-lib)
273
277
  Added npm scripts: snapshot, snapshot:validate
274
- Added devDependency: codebase-snapshot ^0.19.0
278
+ Added devDependency: codebase-snapshot ^0.20.2
275
279
  Added to .gitignore: /snapshot/, /snapshot.tmp/
276
280
  ```
277
281
 
@@ -421,8 +425,8 @@ agent](agent.md).
421
425
  Ask the npm registry whether a newer release exists, and print the version it compared against:
422
426
 
423
427
  ```bash
424
- npx codebase-snapshot@0.19.0 update # is 0.17.0 still current? print the answer
425
- npx codebase-snapshot@0.19.0 update --format json
428
+ npx codebase-snapshot@0.20.2 update # is 0.17.0 still current? print the answer
429
+ npx codebase-snapshot@0.20.2 update --format json
426
430
  ```
427
431
 
428
432
  ```text
@@ -512,6 +516,7 @@ for the two install flags, and the init-and-setup flags list both commands.
512
516
  | `--no-auth` | flag | off | mcp, serve | `mcp --http`: accept requests without `Authorization`. Refused on a non-loopback bind. |
513
517
  | `--allow-origin <list>` | list | unset | mcp | `mcp --http`: comma-separated extra CORS origins. Loopback origins are always allowed. |
514
518
  | `--all-members` | flag | off | health | Audit every snapshot a `--workspace` run wrote, not only the one at `outDir`. The combined score is the weakest member. |
519
+ | `--deep` | flag | off | health | Replay every full body from the source bytes on disk and compare it with the part. The only allowed difference is a redaction marker. Off by default because it re-reads the repository. |
515
520
  | `--strict` | flag | off | health | `health` only: exit 2 when a critical check fails, and 1 when a warning is the only thing left. Without it a critical check exits 1 and warnings exit 0. |
516
521
  | `--mode <command>` | string | unset | generate, validate, report, explain, init, setup, diff, describe, skill | Select the command when no command word is given. A command word and `--mode` must name the same command; a contradiction is a usage error (exit 2). |
517
522
  | `--no-update-check` | flag | off | all commands | Skip the check for a newer published version. Already skipped when stdout is not a terminal, in CI, in a JSON invocation, and in `mcp`, which makes no network requests. |
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.19.0 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.19.0 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.2 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.2 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
package/docs/health.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # Health: an audit of the snapshot itself
2
2
 
3
3
  `validate` answers one question: has the code moved since this snapshot was generated? That is
4
- necessary and not sufficient. Before a snapshot is pasted into a model you want to know four more
5
- things, and `snapshot health` answers them:
4
+ necessary and not sufficient. Before a snapshot is pasted into a model you want to know whether it
5
+ is internally honest, and `snapshot health` answers that:
6
6
 
7
7
  ```bash
8
8
  npx codebase-snapshot health # the snapshot in ./snapshot
9
9
  npx codebase-snapshot health --strict # exit 2 when a critical check fails
10
10
  npx codebase-snapshot health --format json # the report, for a dashboard
11
+ npx codebase-snapshot health --deep # also replay every full body from the source
11
12
  ```
12
13
 
13
14
  ## What it checks
@@ -20,15 +21,22 @@ npx codebase-snapshot health --format json # the report, for a dashboard
20
21
  | Every file in exactly one part | `parts.accounting` | critical | No file was silently dropped from the layout. |
21
22
  | Every recorded artifact present and unchanged | `artifacts` | critical | `README.md`, `PROMPT.md`, reports and monoliths still match their digests. |
22
23
  | Nothing unexpected in the directory | `artifacts.extra` | warning | No stale file from an earlier run is sitting in the payload. |
23
- | No unmasked secret in any artifact | `secrets.artifacts` | critical | Every written text file is re-scanned with the secret rules; a signature record is scanned without its random key material. |
24
- | No value from an excluded sensitive file appears | `secrets.skipped` | critical | Values from `.env`, keys and similar files are compared byte-for-byte against the artifacts. |
25
- | No host path or machine identity | `pii.paths` | warning | `/home/…`, `/Users/…`, `C:\Users\…` and the repository's absolute path are searched for. |
26
24
  | The manifest signature verifies | `signature` | critical | When `signature.json` exists: the manifest bytes match `manifestSha256` and the Ed25519 signature checks out. |
27
25
  | The counts equal the data | `bookkeeping` | critical | `totalFiles`, `partsCount`, `skippedCount`, `totalContentBytes` and the per-layer counts are recomputed from the arrays. |
26
+ | Every summary claim appears in the body | `summary.truth` | critical | Every export, function, class, import, route, JSON key and markdown heading a summary names is present in the part that holds the file. |
27
+ | The reports quote this run | `report.truth` | critical | The counts, sizes, part table, coverage line, redaction count and fingerprint in `README.md` and `PROMPT.md` equal the manifest. |
28
+ | Every index entry names a file | `indexes.consistent` | critical | Routes, components, handlers, import edges, central files and directives all point at a path in `files[]`, in the part the manifest records. |
28
29
  | Every file body matches the accounting | `pipeline.bodies` | critical | Each part section's bytes and lines equal the file's `includedBytes` and `includedLines`. |
30
+ | Every section sits where the manifest says | `markdown.structure` | critical | Section order, headings, inclusion mode, line count and part header numbers match `manifest.parts[]`. |
29
31
  | Every pack holds exactly the manifest's files | `pipeline.monolith` | critical | When `full-codebase.json`, `.xml` or `.md` is recorded, its file set is compared both ways. |
32
+ | Every pack body is the part body | `packs.bodies` | critical | For full files, the bytes in the pack equal the bytes in the part; previews and signatures are whole-file by design. |
33
+ | Every full body replays from the source | `fidelity.bodies` | critical | With `--deep`: each full body is rebuilt from the bytes on disk (redaction allowed) and compared. Skipped without `--deep`. |
30
34
  | A member matches its workspace index | `workspace.index` | warning | Fingerprint and file count equal `WORKSPACE.json`, and a member whose source directory is gone warns. |
35
+ | No unmasked secret in any artifact | `secrets.artifacts` | critical | Every written text file is re-scanned with the secret rules; a signature record is scanned without its random key material. |
36
+ | No value from an excluded sensitive file appears | `secrets.skipped` | critical | Values from `.env`, keys and similar files are compared byte-for-byte against the artifacts. |
37
+ | No host path or machine identity | `pii.paths` | warning | `/home/…`, `/Users/…`, `C:\Users\…` and the repository's absolute path are searched for. |
31
38
  | Token estimate is plausible | `tokens.count` | warning | The recorded estimate is compared with one recomputed from the parts. |
39
+ | The parts fit a context window | `tokens.fit` | warning | How many parts fit 32k, 128k and 200k tokens; the largest part and the largest single file are named. |
32
40
  | Every part honours the published budget | `tokens.budget` | warning | A part larger than the ceiling the manifest advertises is reported. |
33
41
  | Every excluded path has a reason | `skips` | critical | `skipped[]` is complete and the totals agree. |
34
42
  | The snapshot still describes the repository | `freshness` | warning | HEAD is compared with the recorded commit. |
@@ -37,7 +45,7 @@ npx codebase-snapshot health --format json # the report, for a dashboard
37
45
 
38
46
  ```text
39
47
  🩺 Snapshot health: 100/100
40
- 15 passed, 0 warning(s), 0 failed, 1 skipped
48
+ 20 passed, 0 warning(s), 0 failed, 2 skipped
41
49
  ```
42
50
 
43
51
  A **failed** check (critical) means the snapshot is not safe to hand to a model as it stands; the
@@ -47,36 +55,74 @@ secret, but you may not want it in the payload either.
47
55
  The score starts at 100; each failure costs 25 and each warning 5, with a floor of zero. It is a
48
56
  summary, not a substitute for the checks — the report always lists every one.
49
57
 
50
- ### A member whose source is gone
58
+ ### Every summary claim against the body
51
59
 
52
- `health --all-members` audits the written member snapshots. If a member's source directory has
53
- been deleted since the workspace was generated, the snapshot is still intact but no longer
54
- describes that workspace: the audit warns, names the missing path and says to regenerate.
55
- Before this it scored 100/100 for a member nobody could refresh.
60
+ A summary is generated from a separate parse. That is what makes it useful and what makes it able
61
+ to lie: an export can be renamed by a parser change, a stale manifest can keep a symbol the file no
62
+ longer has, and a masked name can disappear from the body. `summary.truth` checks every claim the
63
+ manifest records — imports, exports, functions, classes, interfaces, types, enums, variables,
64
+ components, hooks, route paths, JSON keys and markdown headings — against the part that carries the
65
+ file. Redacted claims are skipped, and a failing claim is named by path and field, never by value.
66
+
67
+ ### The reports quote this run
68
+
69
+ `README.md` and `PROMPT.md` restate the manifest in prose. A report copied from an earlier run, or
70
+ generated before the manifest was updated, describes a different snapshot while its digest still
71
+ proves the bytes are unchanged. `report.truth` parses the figures the current writer emits — file,
72
+ line, part and skip counts, the part table, the coverage sentence, the partial-file count, the
73
+ redaction count, the layer tally, the fingerprint, branch, commit and validation state — and
74
+ compares each with the manifest. A shape it does not recognise is not a failure; it is not counted.
56
75
 
57
- ### The JSON pack against the manifest
76
+ ### Every section where the manifest says
58
77
 
59
- When the run wrote `full-codebase.json`, the audit parses it and compares its file set with
60
- `manifest.files` in both directions. The artifact digest proves the pack is the file the manifest
61
- recorded; it does not prove the manifest recorded a pack holding every file. An entry removed and
62
- the digest updated would otherwise be invisible.
78
+ A part hash proves the bytes are the recorded bytes, not that the file body is under the right
79
+ heading. `markdown.structure` checks each part's own header (part number, file count, fingerprint,
80
+ token estimate), the number of sections against `part.fileCount`, the order of anchors against
81
+ `part.includedFiles`, every heading against the file's display path, and every `- Meta:` inclusion
82
+ and line count against the manifest entry. A duplicated, extra or misplaced section fails the audit.
63
83
 
64
- ### The counts against the data
84
+ ### Every pack body against its part
65
85
 
66
- A manifest edited to claim more files, parts, skips or content bytes than it holds used to pass
67
- every check: each part hashed correctly, the artifacts were present, and the numbers a summary
68
- quotes were never compared with the arrays they summarise. The audit now recomputes
69
- `counts.totalFiles`, `counts.partsCount`, `counts.skippedCount`, `totals.totalContentBytes` and the
70
- per-layer counts from the manifest's own arrays; any disagreement is a critical failure naming the
71
- field and both numbers.
86
+ The JSON, XML and markdown packs are a second copy of the same payload. Membership is checked by
87
+ `pipeline.monolith`; `packs.bodies` compares the bytes. For `full` and `comments-stripped` files the
88
+ pack body is normalised the way the part was and compared exactly. A preview's or skeleton's pack
89
+ deliberately carries the redacted whole file, so those bodies are counted as by-design rather than
90
+ compared.
72
91
 
73
- ### Every body against the accounting
92
+ ### Every index entry names a file
74
93
 
75
- The manifest says how many bytes and lines each file contributed. The audit now checks that
76
- claim against the part: each section is parsed out (by anchor, not by heading) and its body must
77
- match `includedBytes` and `includedLines` exactly. A truncated body, a missing section or a
78
- hand-edited part that still hashes correctly fails the audit, because the manifest would be
79
- describing a file the reader does not receive.
94
+ `manifest.indexes` is what the MCP tools answer from: routes, components, handlers, import edges,
95
+ central files and directives. An entry that names a path outside `files[]`, records a different
96
+ `part`, or lists the same import file twice is a promise the reader cannot keep.
97
+ `indexes.consistent` checks every entry against the file map, including the part the file ended up
98
+ in.
99
+
100
+ ### The parts against a context window
101
+
102
+ `tokens.fit` reports the largest part, the largest single file and how many parts fit a 32k, 128k
103
+ or 200k window. A part within the byte budget can still be unusable in a smaller window; this is
104
+ the number that says so, and it warns rather than fails because the destination is the user's
105
+ choice.
106
+
107
+ ### The deep replay
108
+
109
+ The cheap checks compare the snapshot with its own manifest. They cannot see a generator that read
110
+ the source incorrectly and then recorded the wrong bytes consistently. `--deep` closes that gap:
111
+ for every `full` file whose bytes still match the recorded `hashSha256`, it decodes the file again,
112
+ applies the emitted-body normalisation, and compares the result with the part. The only difference
113
+ allowed is a redaction marker replacing a span; a line that differs any other way is reported by
114
+ path and line number.
115
+
116
+ A file that has changed on disk since generation is not replayed — that is `validate`'s question,
117
+ and blaming the generator for a later edit would be the wrong finding. The check is off by default
118
+ because it re-reads the whole repository; on a large monorepo it costs one full read.
119
+
120
+ ### A member whose source is gone
121
+
122
+ `health --all-members` audits the written member snapshots. If a member's source directory has
123
+ been deleted since the workspace was generated, the snapshot is still intact but no longer
124
+ describes that workspace: the audit warns, names the missing path and says to regenerate.
125
+ Before this it scored 100/100 for a member nobody could refresh.
80
126
 
81
127
  ### A member of a workspace
82
128
 
@@ -100,17 +146,17 @@ codebase-snapshot health --all-members --cwd /repo
100
146
  ## What it never does
101
147
 
102
148
  - It does not regenerate, repair or delete anything. The report is evidence; evidence that mutates
103
- is not evidence.
149
+ is not evidence. `--deep` reads the repository; it still writes nothing.
104
150
  - It never prints a secret it found. Findings name the artifact and the line count, never the value.
105
151
  - It does not need the network. Everything it compares is on disk.
106
152
 
107
153
  ## In the MCP server
108
154
 
109
155
  `snapshot_health` returns the same report as structured output, so an agent can call it before
110
- trusting a snapshot it was handed:
156
+ trusting a snapshot it was handed. Pass `deep: true` for the source replay:
111
157
 
112
158
  ```json
113
- { "score": 100, "counts": { "pass": 15, "warn": 0, "fail": 0, "skip": 1 }, "checks": [ … ] }
159
+ { "score": 100, "counts": { "pass": 20, "warn": 0, "fail": 0, "skip": 2 }, "checks": [ … ] }
114
160
  ```
115
161
 
116
162
  The cheap subset — manifest, parts, artifacts, skips — also runs inside `validate`, so a normal
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.19.0 mcp
13
+ npx -y codebase-snapshot@0.20.2 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.19.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.20.2", "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.19.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.2 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.19.0 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.20.2 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
@@ -107,7 +107,7 @@ between them should not have to guess.
107
107
  | Tool | Answers | Writes |
108
108
  | :-- | :-- | :-- |
109
109
  | `snapshot_status` | Is there a snapshot, when was it built, what does it cover? | no |
110
- | `snapshot_health` | Does the written snapshot match its manifest, carry any secret or host path, and cost what it claims? `maxScanBytes` bounds the text scan. | no |
110
+ | `snapshot_health` | Does the written snapshot match its manifest, carry any secret or host path, and cost what it claims? `maxScanBytes` bounds the text scan; `deep: true` replays every full body from the source. | no |
111
111
  | `snapshot_query` | Filter the index by layer, kind, path pattern or symbol | no |
112
112
  | `snapshot_answer` | Question to cited, line-numbered windows within a budget | no |
113
113
  | `snapshot_budget` | Planner output at several budgets: what raising the budget would add | no |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.19.0",
3
+ "version": "0.20.2",
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",
@@ -110,7 +110,10 @@
110
110
  "seo-rank": "node scripts/seo-rank.mjs",
111
111
  "verify": "npm run check && npm run check:workflows && npm run sync-docs -- --check && npm run site && node scripts/check-site-links.mjs && npm run audit-site && npm run readme-lint && npm run pack-check",
112
112
  "snapshot": "node ./dist/bin.js generate",
113
- "snapshot:validate": "node ./dist/bin.js validate"
113
+ "snapshot:validate": "node ./dist/bin.js validate",
114
+ "coverage-diff": "node scripts/coverage-diff.mjs",
115
+ "reproducible": "node scripts/reproducible.mjs",
116
+ "verify:deep": "npm run verify && node scripts/verify-deep.mjs"
114
117
  },
115
118
  "dependencies": {
116
119
  "typescript": "^5.0.0"