codebase-snapshot 0.9.12 → 0.9.15

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.
@@ -192,7 +192,7 @@ export default {
192
192
  // changedSince: "main", // only files changed since this git ref
193
193
  // staged: true, // only files staged for the next commit
194
194
  // withDependents: true, // ...and the files that import them
195
- // skeleton: true, // TypeScript signatures instead of bodies (--skeleton)
195
+ // skeleton: true, // signatures instead of bodies (--skeleton); TS, JS, TSX and JSX
196
196
  largeFileBytes: "200k", // above this a file becomes a head/tail preview
197
197
  previewHeadLines: 80,
198
198
  previewTailLines: 40,
@@ -229,8 +229,9 @@ export default {
229
229
  ```
230
230
 
231
231
  Everything except `monolith` is on by default; `monolith` follows `includeMonolith`. Turn
232
- artifacts off with the config, `--skip-artifacts a,b`, or `--only-artifacts a,b` (the two
233
- cannot be combined).
232
+ artifacts off with the config or `--skip-artifacts a,b`. `--only-artifacts a,b` is different: it
233
+ *writes only* those and turns each named artifact **on**, so `--only-artifacts audit` still produces
234
+ `reports/audit.md` in a project whose config says `audit: false`. The two flags cannot be combined.
234
235
 
235
236
  Two combinations warn because they produce a snapshot that contradicts itself: `manifest` off
236
237
  means `validate` and `report` cannot inspect the snapshot, and `parts` off with `navigation`
@@ -266,19 +267,69 @@ makes an audit entry mean something.
266
267
  matched span is masked, never the whole line, and no excerpt of a matched line reaches any
267
268
  artifact. Multi-line PEM keys are masked as a block.
268
269
  - `customPatterns` add rules; `disableDefaultPatterns` removes the built-in set — it does not
269
- disable redaction itself.
270
+ disable redaction itself, and it applies to **paths** as well as to content, so a
271
+ credential-shaped file name is no longer skipped by a rule you switched off.
270
272
 
271
273
  Redaction is **fail-closed**, so a placeholder is indistinguishable from a secret: a
272
274
  `.env.example` whose line reads `JWT_SECRET=replace-with-base64url-48-bytes` is masked like a
273
275
  live key would be, and a test fixture literal such as `process.env.X_SECRET = "test-value"` is
274
- masked too. The same holds for an environment reference written as a quoted value —
275
- `password: "${DB_PASSWORD}"` is masked exactly like a literal password, because the rule sees a
276
- credential-shaped key followed by a string and a `${…}` reference cannot be told apart from a
277
- secret by shape alone. That is the intended trade-off — the alternative is guessing which values
278
- are throwaway — and it is worth knowing before you hand the snapshot to a model and find the
279
- template less readable than the original. To narrow it, remove a rule by name with
276
+ masked too. That is the intended trade-off — the alternative is guessing which values are
277
+ throwaway — and it is worth knowing before you hand the snapshot to a model and find the template
278
+ less readable than the original. To narrow it, remove a rule by name with
280
279
  `disableDefaultPatterns: true` plus your own `customPatterns`.
281
280
 
281
+ The one shape that is *not* masked is a value that is a single `${…}` reference and nothing else —
282
+ `password: "${DB_PASSWORD}"`, `` `${process.env.TOKEN}` `` — because that is an expression and
283
+ masking it rewrites a program (or an assertion message) rather than hiding a credential. Anything
284
+ inside the braces that is not a plain reference settles it the other way:
285
+ `password: "${DB_PASSWORD:-hunter2}"` is masked, because the shell and Compose idiom for a default
286
+ puts a **hardcoded credential** in the fallback position. So does a second interpolation, or any
287
+ quote inside the braces.
288
+
289
+ The same default is masked when it is not quoted, which is how it is usually written:
290
+
291
+ ```bash
292
+ # .env, docker-compose.yml, a workflow, a shell script — all of these are masked
293
+ POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-MyProdPassword123!}
294
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-MyProdPassword123!}
295
+ ```
296
+
297
+ The fallback is what gets replaced; the variable name stays, exactly as `POSTGRES_PASSWORD:` does.
298
+ `${PORT:-3000}` is untouched: the name is not a credential name, and a port number is not one
299
+ either.
300
+
301
+ A credential assigned to a name inside a string is also masked — a connection string is a string:
302
+
303
+ ```js
304
+ const dsn = "password=MySuperSecret123;host=db.internal";
305
+ ```
306
+
307
+ What is left alone is a credential *name* in a literal, with nothing assigned to it:
308
+ `["awsSecret:", "apiKey:"]` is a list of keys, not two credentials, and a documentation line showing
309
+ `password: "…"` inside a code span is showing an example. The difference is whether the literal
310
+ closes between the name and the value.
311
+
312
+ `readonly` and `declare` are shell assignments in a shell file and declarations in a source file, and
313
+ the file decides: `readonly api_key=hunter2` in `.envrc`, `.sh`, `.zsh`, a YAML or an INI file is
314
+ masked, while `private readonly apiKey = someValue` in TypeScript is left alone.
315
+
316
+ The file type decides how an **unquoted** value is read too. In a source file (`.ts`, `.js`, `.tsx`,
317
+ …) a bare value after a credential name is an expression, and expressions are left as written:
318
+ `opts.token: (value)` and `password: getPassword() & 0xff` are untouched. In a data or shell file
319
+ (`.yaml`, `.yml`, `.toml`, `.ini`, `.conf`, `.cfg`, `.properties`, `.tf`, `.tfvars`, `.sh`,
320
+ `.env` and the `.envrc` family) the same line is an assignment: a **strong** credential name in
321
+ colon form (`password:`, `token:`, `api_key:`) masks the value whatever symbols it holds — a
322
+ `password` value such as `pa&ss`, or an expression like `getPassword() & 0xff`, in a `.yaml` is
323
+ masked whole, running to the end of the line (a trailing `#` comment is kept, and the match is
324
+ capped at 300 characters).
325
+ A value that cannot be bounded is handled by file type: in a data or shell file a colon-form
326
+ assignment still masks the value whole, while in source code the unbounded match is dropped rather
327
+ than emitted as a marker in front of an expression. The `=` form follows the same file-type rule:
328
+ in a data or shell file a key ending in a credential word (`password`, `client_secret`, `access_key`,
329
+ `apiKey`, upper or lower case) masks the whole value whatever symbols it contains, while the same
330
+ line in source code is left alone unless it matches an existing source rule. A key that merely
331
+ contains a credential word (`tokenCount`, `secretary`) is not a credential and is untouched.
332
+
282
333
  Findings are summarised in `reports/audit.md` (one row per line, naming every rule that matched
283
334
  it), counted in `manifest.totals.redactedLines`, and shown in the `generate` summary as a
284
335
  `Redacted:` line separate from `Warnings:`.
@@ -355,16 +406,33 @@ const config = {
355
406
 
356
407
  // ── Size ─────────────────────────────────────────────────
357
408
  maxPartBytes: "300k",
409
+ maxPartTokens: null, // the same ceiling in tokens; narrows maxPartBytes
358
410
  largeFileBytes: "200k",
359
411
  previewHeadLines: 80,
360
412
  previewTailLines: 40,
361
413
  budgets: { default: "300k", byLayer: {} },
362
414
 
363
- // ── Scope ────────────────────────────────────────────────
415
+ // ── Scope and compression ────────────────────────────────
416
+ skeleton: false, // replace function bodies with { /* ... */ }
417
+ sarif: false, // also write reports/audit.sarif (SARIF 2.1.0)
418
+ changedSince: null, // only files changed since this git ref
419
+ staged: false, // only what is staged in the index
420
+ withDependents: false, // with a scope, also include one-hop importers
421
+
422
+ // ── What goes in ─────────────────────────────────────────
364
423
  include: [],
365
424
  excludePatterns: [],
366
425
  discovery: "auto", // "auto" | "git" | "walk"
367
426
 
427
+ // ── Classification ───────────────────────────────────────
428
+ layersMode: "merge",
429
+ layers: [],
430
+ kinds: [],
431
+
432
+ // ── Safety ───────────────────────────────────────────────
433
+ includeSensitiveFiles: false,
434
+ secrets: { customPatterns: [], disableDefaultPatterns: false },
435
+
368
436
  // ── Artifacts ────────────────────────────────────────────
369
437
  artifacts: {
370
438
  readme: true,
@@ -375,19 +443,10 @@ const config = {
375
443
  audit: true,
376
444
  monolith: false,
377
445
  },
378
-
379
- // ── Safety ───────────────────────────────────────────────
380
- includeSensitiveFiles: false,
381
- secrets: { customPatterns: [], disableDefaultPatterns: false },
382
-
383
- // ── Classification ───────────────────────────────────────
384
- layersMode: "merge",
385
- layers: [],
386
- kinds: [],
446
+ maxMonolithBytes: null, // skip the monolith above this size
447
+ includeMonolith: false, // top-level switch; the artifacts entry wins
387
448
 
388
449
  // ── Advanced ─────────────────────────────────────────────
389
- includeMonolith: false,
390
- maxMonolithBytes: null,
391
450
  hooks: {},
392
451
  };
393
452
 
package/docs/install.md CHANGED
@@ -124,9 +124,10 @@ contract. To put the skill there, print it and paste it —
124
124
 
125
125
  ## Verified clients
126
126
 
127
- Every client below installs the published package and runs it successfully; the release check
128
- enforces this on every pull request, so a change that breaks one fails the build rather than
129
- a user's terminal.
127
+ Every client below installs the published package and runs it successfully. The automated gate
128
+ does not reinstall the package under any of these runners — it runs the test suite with npm on
129
+ Node 18, 20 and 22 — so a break specific to yarn, pnpm or bun can reach a release. The table
130
+ records what has been verified, not a CI result.
130
131
 
131
132
  | Client | Run installed binary with |
132
133
  | :--- | :--- |
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.9.12 mcp
13
+ npx -y codebase-snapshot@0.9.15 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.9.12", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.9.15", "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.9.12 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.9.15 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
@@ -61,6 +61,25 @@ still reachable: pass the same value to the read side that you passed to `snapsh
61
61
  that, only `snapshot_generate` honoured it and every other tool looked in the configured directory
62
62
  and reported "there is no snapshot manifest here".
63
63
 
64
+ An `outDir` **tool argument** must resolve inside the repository the server serves: a prompt cannot
65
+ drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir` is
66
+ not confined the same way — that is the repository's own decision, and a config may legitimately
67
+ point one directory up. If the argument escapes, the tool refuses and the message says to restart
68
+ the server with `--cwd` pointing at the repository you want to write.
69
+
70
+ `snapshot_plan`, `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the
71
+ **scope and compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`,
72
+ `changedSince`, `staged` and `withDependents`. They have to: `manifest.config.digest` covers those
73
+ settings, so a snapshot generated with `--skeleton` was not merely un-inspectable over MCP, it was
74
+ reported as configuration drift on every `snapshot_validate`. Pass the same switches you generated
75
+ with, exactly as you would on the command line. The four remaining tools do not take them, because
76
+ none of them re-derives the configuration and a flag that changes nothing is the command-line form
77
+ of a silent fallback.
78
+
79
+ `includeSensitiveFiles` is deliberately absent from every one of them. A prompt can ask for
80
+ anything, and a tool that emits `.env` on request is a secret-exfiltration primitive with a
81
+ friendly name.
82
+
64
83
  `snapshot_locate` is the one that makes the others usable: a twelve-part snapshot is hundreds of
65
84
  kilobytes, and asking "which part holds authentication?" is cheaper than reading all twelve. It
66
85
  searches the manifest's index — file paths, exported symbols, component names, routes, layers and
@@ -84,8 +103,18 @@ Resources are the browse surface; tools are the act surface.
84
103
  | `snapshot://contract` | The machine-readable CLI contract |
85
104
  | `snapshot://skill` | The agent skill, as one read |
86
105
 
106
+ A resource read is **all-or-nothing**. Above the 512 kB single-read limit the read fails with
107
+ JSON-RPC error `-32000` (the implementation-defined server-error range) and
108
+ `data: { uri, bytes, limit }`; the message says what to use instead — `snapshot_locate`,
109
+ `snapshot_read` or `snapshot_status` for a manifest or part, the file on disk for a report, and
110
+ the CLI for the contract or the skill. It never returns a truncated document: half a JSON manifest
111
+ does not parse, and half a part is a fragment that looks complete. The rule applies to every
112
+ resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the three reports,
113
+ `snapshot://contract` and `snapshot://skill`.
114
+
87
115
  Part resources carry their size in the description, so a client choosing between them can see that
88
- one is 300 kB before attaching it.
116
+ one is 300 kB before attaching it; a part above the limit says in its description that it will be
117
+ refused rather than truncated.
89
118
 
90
119
  ## Prompts
91
120
 
@@ -95,8 +124,11 @@ making changes.
95
124
 
96
125
  ## What it will not do
97
126
 
98
- - **Read outside its root.** `--cwd` is the only directory that is readable. A `root` argument can
99
- name a sub-directory of it and nothing else; symlinks are resolved before the check.
127
+ - **Read outside its root.** `--cwd` is the only directory that is readable, and it is the only
128
+ knob that changes it — the command has no `--root` option, only the `root` tool argument. A
129
+ `root` argument may name the served directory or a sub-directory of it; anything else is refused
130
+ with a message saying to restart the server with `--cwd <directory>`. Symlinks are resolved
131
+ before the check.
100
132
  - **Emit a sensitive file.** `.env`, `*.pem` and the rest stay out, and `includeSensitiveFiles` is
101
133
  not a tool argument — a prompt cannot ask for it. Reads come from the emitted snapshot, so
102
134
  redaction applies to everything the client sees.
@@ -158,5 +190,10 @@ version in the client arguments.
158
190
  **`Unknown resource` for a part.** Resources are computed from the manifest, so nothing but the
159
191
  static set exists before the first generate. Call `snapshot_status`, then `snapshot_generate`.
160
192
 
193
+ **A resource read fails with `-32000`.** The resource is larger than the 512 kB single-read limit;
194
+ it was refused rather than truncated. `data.uri`, `data.bytes` and `data.limit` say which resource
195
+ and by how much. Use `snapshot_locate` then `snapshot_read` for a part, or read the file straight
196
+ from the snapshot directory for the manifest or a report.
197
+
161
198
  **A file is missing from `snapshot_locate`.** It is excluded, and `snapshot_explain` will name the
162
199
  reason — an ignore rule, the preset, a sensitive-file pattern, or your own config.
package/docs/output.md CHANGED
@@ -31,6 +31,12 @@ fields in `manifest.json` for the same file. `manifest.json` reports what the pa
31
31
  (CRLF normalised, the trailing newline not counted); the monolith reports the content it
32
32
  embedded. Compare a file's fields within one artifact, not across the two.
33
33
 
34
+ "CRLF normalised" covers all three line endings a file can have. A CR-only file — an old Mac file,
35
+ or anything written by a tool that predates LF on that platform — is written to a part with LF too,
36
+ and its `lines` count is the real one: the preview budget and the line counts used to split on `\n`
37
+ alone, so such a file was one line, `largeFileBytes` never applied, and the whole file went into a
38
+ part with its carriage returns intact.
39
+
34
40
  The manifest embedded in `full-codebase.json` is otherwise identical to `manifest.json` with one
35
41
  impossible field: a file cannot record its own sha256, so `artifacts.fullJson` is `null` in the
36
42
  embedded copy and a `selfReference` sentence points at `manifest.json`, which carries the real
@@ -44,8 +50,12 @@ same persistently. The ownership marker is always written.
44
50
 
45
51
  Each `part-NNN.md` holds whole files under the byte budget (`maxPartBytes`, default 300 KB).
46
52
  A file larger than the budget is not split mid-file: it is truncated and carries an omission
47
- marker naming the budget that cut it (`... [347 lines omitted: part budget 1887 B] ...`). A file
48
- above `largeFileBytes` is emitted as a head/tail excerpt instead, with the same marker.
53
+ marker naming the budget that cut it — the part budget the run was given, `maxPartBytes` or a
54
+ per-layer override, never the smaller allowance left for the body after the section header.
55
+ `--max-part-bytes 4096` writes `... [347 lines omitted: part budget 4096 B] ...`, for example.
56
+ The line count describes the whole file, not the cut: a large file that arrived as a head/tail
57
+ preview still reports how many source lines are missing. A file above `largeFileBytes` is
58
+ emitted as a head/tail excerpt instead, with the same marker.
49
59
 
50
60
  Each file section is an anchor, a `### FILE:` heading, and **one** metadata line:
51
61
 
@@ -93,7 +103,7 @@ diff the manifest only when you need to know that a run happened.
93
103
  | `config` | The resolved configuration actually used (preset, artifacts, sizing, scoping). |
94
104
  | `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount }`. |
95
105
  | `totals` | Bookkeeping: `{ candidateFiles, includedFiles, fullFiles, previewFiles, skippedFiles, totalSourceBytes, totalContentBytes, estimatedTokens, partCount, warningCount, redactedLines }`. `redactedLines` counts the lines whose values were masked — one per line, not one per matching rule — and is what the summary's `Redacted:` line prints. |
96
- | `fingerprint` | Stable hash of the snapshot content. Two runs over unchanged input produce the same value. |
106
+ | `fingerprint` | Stable hash of the snapshot content **and** the settings that shaped it. Two runs over unchanged input and unchanged settings produce the same value; changing the budget, a preset, a layer rule or the secret rules moves it, because the parts move too. |
97
107
  | `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
98
108
  | `artifacts` | The optional monolith files: `{ fullJson, fullMarkdown }`. Each value is `null` when that file was not written, otherwise `{ byteSize, sha256 }`. The object itself is always present. |
99
109
  | `layers`, `kinds` | File counts per layer and per kind. |
@@ -202,6 +212,13 @@ has several at once, and "within budget" cannot be answered without knowing whic
202
212
  `variables`, `reactComponents`, `hooks`, `routeHandlers`), plus `parseErrors` when the parser
203
213
  reported syntax errors. JSON gets `{ shape, itemCount, keys, sampleKeys }` and Markdown gets
204
214
  `{ headings, frontmatterKeys }` — a shape description rather than a code summary.
215
+ `imports` covers `import` declarations, named and star re-exports, `require("…")`, `import("…")`
216
+ and `import x = require("…")`; a computed specifier is an expression and is not recorded, because
217
+ a wrong edge in the import graph is worse than a missing one. The JSON reader follows JSONC —
218
+ comments, trailing commas and a BOM — and reports `invalid-json` only for a file that still does
219
+ not parse. `headings` skips headings inside fenced code and inside YAML front matter, and a
220
+ document that *opens* with a `---` horizontal rule keeps its headings: the block has to look like
221
+ YAML before it counts as front matter.
205
222
  - `summaryOmitted: true` means the file's summary was dropped because the summary alone would
206
223
  not fit the part budget. The entry then has `summaryQuality` but no `summary`, and the
207
224
  file's body is still emitted in full. It is only ever present when `true`.
@@ -272,20 +289,45 @@ omission: the directory and its files are all accounted for, just not at the sam
272
289
  - **The tool refuses to replace a directory it did not write.** Pointing `--out-dir` at
273
290
  `src/` is refused with exit `1` and the directory is left untouched — a mistyped output
274
291
  path cannot delete source code. Empty directories, directories that hold nothing but
275
- `.DS_Store`, and directories holding a complete snapshot this build wrote are accepted.
292
+ `.DS_Store`, and a complete snapshot whose recorded evidence still matches the directory are
293
+ accepted.
276
294
  A `.gitkeep` or `.gitignore` inside the directory is not accepted, because the generator never
277
295
  writes either into an output directory: a directory that holds one is somebody's data, so the
278
296
  run refuses instead of deleting it.
279
297
  - **Ownership is the marker, not a filename.** `.codebase-snapshot` is a JSON record carrying
280
298
  this generator's name and `version`, the marker's `schemaVersion`, a `createdAt` timestamp,
281
299
  a `pid`, a per-snapshot `id`, the run `state` (`staging` while it is being written, `complete`
282
- once it is whole), the `manifestSha256` digest of the manifest it shipped, and `entries` — the
283
- inventory of everything it wrote. `pid` is what lets a later run tell a crashed run's staging
284
- directory and lock from a live one. A zero-byte marker, a marker that is not JSON, a marker
285
- written by 3.0.0 (no `id`), a bare `manifest.json`, and a directory with files you added
286
- after the run are all refused.
300
+ once it is whole), the `manifestSha256` digest of the manifest it shipped when one was written,
301
+ `entries` — every path it wrote, directories included — and `files`, the digest inventory that
302
+ turns a filename into evidence. `pid` is what lets a later run tell a crashed run's staging
303
+ directory and lock from a live one.
287
304
  See [Troubleshooting](troubleshooting.md#refusing-to-replace-outdir-).
288
305
 
306
+ The record has this shape:
307
+
308
+ ```text
309
+ generator, version, schemaVersion, createdAt, state, id, pid
310
+ manifestSha256 sha256 of manifest.json, when one was written
311
+ entries[] every path written, directories included
312
+ files[] { path, bytes, sha256 } for every regular file written
313
+ ```
314
+
315
+ The marker cannot record its own digest, and Finder's `.DS_Store` is ignored by the ownership
316
+ check: a marker that carries `files` is verified file by file, so every other regular file in the
317
+ directory must appear with its recorded byte length and sha256, every recorded path must still
318
+ exist, and every entry in the directory must be one the run recorded. A marker written before
319
+ `files` existed is accepted on its `manifestSha256` instead, provided `manifest.json` is there and
320
+ the digest matches — that keeps an upgraded user's snapshot replaceable, while a legacy snapshot
321
+ generated with the manifest artifact disabled cannot prove itself and has to be removed once.
322
+
323
+ Refused: a zero-byte marker, a marker that is not JSON, is not an object or whose `files`
324
+ inventory is malformed, a marker naming another generator or an unknown `schemaVersion`, one with
325
+ no snapshot `id` or run `state`, one that
326
+ records no contents, a bare `manifest.json` with no marker, a directory holding a path the marker
327
+ did not record, and a recorded file whose byte length or sha256 no longer matches. A hand-written
328
+ marker whose recorded digests do not match the directory is therefore not evidence: passing the
329
+ check means reproducing the digests of a completed run, not copying a filename.
330
+
289
331
  The marker also makes hook-written artifacts safe: the entries a `hooks.afterGenerate` adds to
290
332
  the output are recorded in the marker, so they do not make the next run refuse the directory.
291
333
 
@@ -26,9 +26,10 @@ What you need is not more discipline. It is a comparison that can fail.
26
26
 
27
27
  ### 1. An identity for the copy
28
28
 
29
- Every run writes `manifest.fingerprint`, a hash of what was included, derived from the content
30
- of every file. Two repositories that differ by one byte have different fingerprints; two runs
31
- over the same tree on different machines have the same one.
29
+ Every run writes `manifest.fingerprint`, a hash of what was included — derived from the content
30
+ of every file and from the settings that shaped the output. Two repositories that differ by one
31
+ byte have different fingerprints, and so do two runs of the same tree with a different budget;
32
+ two runs over the same tree with the same settings, on different machines, have the same one.
32
33
 
33
34
  ```bash
34
35
  codebase-snapshot report --format json | jq -r .manifest.fingerprint
@@ -40,19 +40,29 @@ problem, and for an option the command does not take it also names the commands
40
40
 
41
41
  ```
42
42
  ❌ --watch does not apply to `report` and was not applied. It is accepted by: `generate`.
43
- ❌ --cwd does not apply to `describe` and was not applied. It is accepted by: `generate`, `validate`, `report`, `init`, `explain`, `skill`.
43
+ ❌ --cwd does not apply to `describe` and was not applied. It is accepted by: `generate`, `validate`, `report`, `explain`, `init`, `setup`, `skill`, `mcp`.
44
+ ❌ --max-part-bytes does not apply to `report` and was not applied. It is accepted by: `generate`, `validate`, `explain`, `init`, `setup`.
45
+ ❌ Unknown --mode "bogus". Expected one of: generate, validate, check, report, init, setup, explain, diff, describe, skill, mcp.
44
46
  ```
45
47
 
46
48
  Nothing is silently ignored — that is the point of the message. The per-option `Applies to`
47
49
  column is in the [CLI reference](cli.md#options).
48
50
 
51
+ `report` takes no generation settings: it reads the manifest and prints it, so for example
52
+ `--max-part-bytes`, `--large-file-bytes`, `--max-monolith-bytes`, `--include-monolith`,
53
+ `--include-sensitive-files`, `--skip-artifacts` and `--only-artifacts` are all usage errors
54
+ there, as are `--skeleton`, `--sarif` and `--max-part-tokens`. `--mode` names the same commands from the other side, `mcp` included, and
55
+ `--mode explain <path>` / `--mode diff <a> <b>` take their positionals like the command does.
56
+
49
57
  | Message | Fix |
50
58
  | :--- | :--- |
51
59
  | `Unknown command "frobnicate". Expected one of: …` | Use one of the commands in the [CLI reference](cli.md). |
52
60
  | `No configuration found in … and this session is not interactive, so nothing was generated.` | A first run and no terminal to ask its question. Nothing is wrong with the repository: say which setup you want — `--autopilot` for the full setup, `init --yes` then `generate` for the steps, or `generate` for the documented defaults. See [the first run](cli.md#the-first-run). |
53
61
  | `--autopilot sets a project up and writes a config; --no-config ignores config files. Pass one or the other.` | The two flags contradict each other. Drop one. |
54
62
  | `--no-install only applies to \`setup\`, or to \`generate --autopilot\`.` | The install only happens during a setup. Drop the flag, or add `--autopilot`. |
55
- | `--preset does not apply to \`generate\` and was not applied. It is accepted by: \`init\`. To scope a run, set include/excludePatterns/preset in snapshot.config.ts (or run \`codebase-snapshot init\` to generate one).` | `--preset`, `--include`, `--exclude`, `--yes` and `--force` configure `init`, which writes them into the config. Set them at generation time in `snapshot.config.ts` instead. |
63
+ | `--preset does not apply to \`generate\` and was not applied. It is accepted by: \`init\`, \`setup\`. To scope a run, set include/excludePatterns/preset in snapshot.config.ts (or run \`codebase-snapshot init\` to generate one).` | `--preset`, `--include`, `--exclude`, `--yes` and `--force` configure `init` and `setup`, which write them into the config. Set them at generation time in `snapshot.config.ts` instead. |
64
+ | `--skip-artifacts does not apply to \`report\` and was not applied. It is accepted by: \`generate\`, \`validate\`, \`explain\`, \`init\`, \`setup\`.` | `report` reads the manifest and prints it, so the generation settings are rejected there. Run `generate` with the artifact selection you want. |
65
+ | `Unknown --mode "bogus". Expected one of: generate, validate, check, report, init, setup, explain, diff, describe, skill, mcp.` | `--mode` names the command the run uses; `mcp` is one of the accepted names. Pass the command positionally unless a wrapper builds the argument list. |
56
66
  | `--install does not apply to \`generate\` and was not applied. It is accepted by: \`skill\`.` | `--install` and `--target` configure `skill` only. |
57
67
  | `--cwd directory does not exist: …` / `--cwd is not a directory: …` | Point `--cwd` at an existing repository directory. |
58
68
  | `--out-dir requires a value (received an empty string).` | An unset shell variable expanded to nothing. Quote it or drop the flag. Every string option rejects `""` rather than silently using the default. |
@@ -79,8 +89,9 @@ it wrote them. This guard exists because a mistyped `outDir` used to replace the
79
89
  `outDir: "src"` deleted source code while reporting success.
80
90
 
81
91
  Ownership is proved by a `.codebase-snapshot` marker that parses as ours — a JSON object
82
- naming this generator, carrying a schema version this build understands, a per-snapshot `id`
83
- and the digest of the manifest it shipped. A file with the right name is not enough:
92
+ naming this generator, carrying a schema version this build understands, a per-snapshot `id`,
93
+ the digest of the manifest it shipped and, in current markers, the size and sha256 of every file
94
+ it wrote. A file with the right name is not enough:
84
95
 
85
96
  | The directory | What the tool says |
86
97
  | :--- | :--- |
@@ -89,10 +100,21 @@ and the digest of the manifest it shipped. A file with the right name is not eno
89
100
  | has a marker that is not JSON | `its .codebase-snapshot marker is not valid JSON (found .codebase-snapshot, app.ts)` |
90
101
  | was written by 3.0.0 | `its .codebase-snapshot marker carries no snapshot id (found .codebase-snapshot, manifest.json)` |
91
102
  | carries our marker but you added files | `it carries this generator's ownership marker, but these entries are not part of the snapshot it recorded: custom.txt. Remove them yourself, or point outDir at a new or empty directory.` |
103
+ | has a marker whose recorded per-file digests no longer match the directory | `its .codebase-snapshot inventory's digest for parts/part-001.md does not match the file (found .codebase-snapshot, manifest.json, parts, reports, README.md)`, or `its .codebase-snapshot inventory records notes.txt as 12 B, but it is 20 B` |
104
+ | is a real snapshot and you edited a part by hand | the same digest refusal: the run stops before writing, so the edited snapshot is **not** overwritten. Delete the directory and generate again. |
105
+ | has a marker that records neither per-file digests nor a manifest digest | `its .codebase-snapshot marker records neither per-file digests nor a manifest digest, so it cannot prove this generator wrote the directory (found .codebase-snapshot, notes.txt)` |
106
+
107
+ Two evidence shapes are accepted. A marker with a per-file inventory is checked file by file:
108
+ every regular file's byte length and sha256 must match, every recorded path must still exist, and
109
+ every entry in the directory must be one the run recorded. A **legacy** marker (written before
110
+ that inventory existed) is accepted on its `manifestSha256` when `manifest.json` is present and
111
+ the digest matches — the upgrade path, so a snapshot from an earlier release stays replaceable. A
112
+ legacy snapshot generated with the manifest artifact disabled cannot prove itself and is refused
113
+ once; delete it and generate again.
92
114
 
93
115
  **Fix** — point `--out-dir` somewhere new, or delete the directory yourself. Do not delete
94
116
  your source. Accepted without complaint: a missing directory, an empty directory, one holding
95
- nothing but `.DS_Store`, and a complete snapshot this build wrote.
117
+ nothing but `.DS_Store`, and a complete snapshot whose marker evidence still matches.
96
118
 
97
119
  `.gitkeep` and `.gitignore` are **not** accepted, even in a directory that holds nothing else.
98
120
  Both are files you create — the generator never writes either into an output directory — so a
@@ -100,7 +122,7 @@ directory holding one is somebody's data and is refused rather than replaced. Mo
100
122
  or point `--out-dir` somewhere new.
101
123
 
102
124
  A snapshot written by 3.0.0 or earlier is **not** upgraded in place: its marker has three keys
103
- and no `id`, so the new build cannot prove it wrote the directory and refuses. Delete the old
125
+ and no `id`, so this build cannot prove it wrote the directory and refuses. Delete the old
104
126
  snapshot directory and generate again.
105
127
 
106
128
  ### `Refusing to write into outDir …: it exists but is not a directory.`
@@ -220,13 +242,15 @@ Exit `1` with one line per class of drift:
220
242
  | `- modified: path` | The file changed since the snapshot. |
221
243
  | `- deleted: path` | The file is in the snapshot but no longer on disk. |
222
244
  | `- new file: path` | The file exists on disk and is not in the snapshot. |
245
+ | `- unreadable: path` | The file exists but this process may not read or stat it — usually a permissions problem. It is not a deleted file. |
223
246
  | `- part: part-001.md (missing from snapshot/parts)` | The part file was deleted or renamed. |
224
247
  | `- part: … (size mismatch …)` | The part was edited by hand. |
225
248
  | `- config: …` | A setting differs from the one recorded in the manifest. |
226
249
  | `- counts: …` | The manifest's own bookkeeping disagrees with its contents. |
227
250
 
228
- **Fix** — re-run `generate`. If it persists, the snapshot directory is being modified by
229
- something else.
251
+ **Fix** — re-run `generate` for drift. For `unreadable`, fix the file's permissions first:
252
+ re-generating cannot read it either. If anything persists, the snapshot directory is being
253
+ modified by something else.
230
254
 
231
255
  ### `report` exits 1 (only when it cannot read the snapshot)
232
256
 
@@ -30,7 +30,7 @@ If the prompt format is the thing you care about: **use code2prompt.**
30
30
  | Distribution | Node.js, npm | Single Rust binary, no runtime |
31
31
  | Machine index | `manifest.json` with hashes and skip reasons | Template output only |
32
32
  | Language awareness | 25 presets, AST/structural/heuristic summaries | Template access to file contents |
33
- | Secret handling | 30 defaults, value-span masking, audit table | Ignore rules |
33
+ | Secret handling | 31 defaults, value-span masking, audit table | Ignore rules |
34
34
 
35
35
  ## Where code2prompt is the better choice
36
36
 
@@ -29,7 +29,7 @@ If you want to paste a repo into a chat right now: **use gitingest.**
29
29
  | Staleness check | `validate` exits non-zero on drift | Not a feature |
30
30
  | Reproducible output | Byte-identical parts across runs, with a fingerprint | Not a published guarantee |
31
31
  | Excluded-file accounting | Every skipped path recorded with a reason | Ignore rules applied |
32
- | Secret redaction | 30 default rules, value-span masking, audit table | Relies on ignore rules |
32
+ | Secret redaction | 31 default rules, value-span masking, audit table | Relies on ignore rules |
33
33
  | Runtime | Node.js | Python |
34
34
  | Repo URL input | No — needs a checkout | **Yes** |
35
35
 
@@ -30,7 +30,7 @@ If you want the most popular, most integrated tool: **use repomix.**
30
30
  | Staleness check | `validate` re-hashes the repository and exits non-zero on drift | Not a feature |
31
31
  | Remote repositories | No — operates on a local checkout | **Yes** — packs a GitHub URL directly |
32
32
  | MCP server | **Yes** — eight tools over stdio, and it serves the validated snapshot rather than the working tree | **Yes** — packs a repository, including by URL |
33
- | Secret handling | 30 default rules, value-span masking, per-line audit table | Secretlint integration |
33
+ | Secret handling | 31 default rules, value-span masking, per-line audit table | Secretlint integration |
34
34
  | Language awareness | 25 presets, AST or structural summaries labelled by confidence | Tree-sitter parsing with a compression mode |
35
35
  | Adoption | New | **Mature** — large user base, many integrations |
36
36
  | Runtime | Node.js ≥ 18, one dependency | Node.js, npm package |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.9.12",
3
+ "version": "0.9.15",
4
4
  "description": "Pack a codebase for an LLM into budgeted Markdown parts, with a manifest of every file and skip, and validate to prove the snapshot is current.",
5
5
  "keywords": [
6
6
  "codebase",
@@ -102,7 +102,6 @@
102
102
  "pretest": "npm run build",
103
103
  "test": "node --test tests/*.test.js",
104
104
  "test:coverage": "node --test --experimental-test-coverage tests/*.test.js",
105
- "prepublishOnly": "npm run build",
106
105
  "publish:create": "npm publish ./packages/create --access public",
107
106
  "prepack": "npm run sync-docs && npm run build",
108
107
  "pack-check": "node scripts/pack-check.mjs",