codebase-snapshot 0.9.14 → 0.9.16

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
@@ -58,6 +58,16 @@ declare const ERROR_CODES: {
58
58
  readonly methodNotFound: -32601;
59
59
  readonly invalidParams: -32602;
60
60
  readonly internalError: -32603;
61
+ /**
62
+ * A resource whose complete text is larger than one read may return.
63
+ *
64
+ * `-32000` is JSON-RPC's range for implementation-defined server errors, which is what this is:
65
+ * there is no standard code for "the document is too large", and answering with -32602 would tell
66
+ * a client its request was malformed when it was not. The message names the size, the limit and
67
+ * the tool to use instead, because a resource read that cannot return the whole resource must not
68
+ * invent a partial one.
69
+ */
70
+ readonly resourceTooLarge: -32000;
61
71
  readonly unsupportedProtocolVersion: -32022;
62
72
  };
63
73
  /** Method names, kept as constants so a typo is a compile error rather than a `-32601`. */
package/dist/mcp.d.ts CHANGED
@@ -58,6 +58,16 @@ declare const ERROR_CODES: {
58
58
  readonly methodNotFound: -32601;
59
59
  readonly invalidParams: -32602;
60
60
  readonly internalError: -32603;
61
+ /**
62
+ * A resource whose complete text is larger than one read may return.
63
+ *
64
+ * `-32000` is JSON-RPC's range for implementation-defined server errors, which is what this is:
65
+ * there is no standard code for "the document is too large", and answering with -32602 would tell
66
+ * a client its request was malformed when it was not. The message names the size, the limit and
67
+ * the tool to use instead, because a resource read that cannot return the whole resource must not
68
+ * invent a partial one.
69
+ */
70
+ readonly resourceTooLarge: -32000;
61
71
  readonly unsupportedProtocolVersion: -32022;
62
72
  };
63
73
  /** Method names, kept as constants so a typo is a compile error rather than a `-32601`. */
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
- export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-J4W74N4Y.js';
2
- export { generateInWorker } from './chunk-DUZK5VL2.js';
1
+ export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-WIL536QD.js';
2
+ export { generateInWorker } from './chunk-6TRFLA7N.js';
package/docs/cli.md CHANGED
@@ -132,9 +132,14 @@ says `… and N more in manifest.warnings[]`; nothing is dropped silently.
132
132
  codebase-snapshot validate [options]
133
133
  ```
134
134
 
135
- Compares the snapshot on disk with the repository. Reports five classes of drift — modified
136
- files, deleted files, files added since the snapshot, damaged or missing parts, and config
137
- changes — plus bookkeeping mismatches in the manifest.
135
+ Compares the snapshot on disk with the repository. Reports six classes of drift — modified
136
+ files, deleted files, files added since the snapshot, damaged or missing parts, unreadable
137
+ files, and config changes — plus bookkeeping mismatches in the manifest.
138
+
139
+ An **unreadable** file is one that exists but that this process may not read or stat, usually a
140
+ filesystem-permission problem. It is a class of its own because the fix is different: filing it
141
+ as "deleted" sent the reader looking for a file that is still there. Text mode lists each path
142
+ as `unreadable: <path>`; `--format json` carries them in `drift.unreadable`.
138
143
 
139
144
  Exit `0` when the snapshot is current, `1` on any drift. It never writes anything.
140
145
 
@@ -150,6 +155,10 @@ snapshot reports in about half a second. Requires an existing `manifest.json` (e
150
155
  missing); exits `0` otherwise. It does **not** check whether the snapshot is still true — that
151
156
  is `validate`, which re-reads the repository and exits `1` on drift.
152
157
 
158
+ It takes `--cwd`, `--out-dir`, `--no-config`, `--format` and `--no-update-check`. The
159
+ generation settings are rejected, not ignored: `report --max-part-bytes 120k` exits `2` with a
160
+ message naming the commands that do accept it.
161
+
153
162
  ### `setup`
154
163
 
155
164
  ```bash
@@ -174,7 +183,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
174
183
  🚀 Setup for: /path/to/repo
175
184
  ✅ Created snapshot.config.ts (preset: nextjs)
176
185
  Added npm scripts: snapshot, snapshot:validate
177
- Added devDependency: codebase-snapshot ^0.9.14
186
+ Added devDependency: codebase-snapshot ^0.9.16
178
187
  Added to .gitignore: snapshot/, snapshot.tmp/
179
188
  ⏳ Installing dependencies…
180
189
  ✅ Installed dependencies (npm install, 2.1s)
@@ -186,15 +195,25 @@ The whole first run in one command, with defaults and no prompts. This is the sa
186
195
 
187
196
  - `--no-install` skips step 4 — CI, an offline machine, or a lockfile you would rather no package
188
197
  manager touched.
189
- - `--dry-run` prints the plan and the config it would write, and writes nothing.
198
+ - `--dry-run` prints the plan and the config it would write, and writes nothing — including the
199
+ `.git/hooks/pre-commit` that `--install-hook` would otherwise install.
190
200
  - `--force` rewrites an existing config; `--preset`, `--include`, `--exclude`, `--out-dir`,
191
201
  `--max-part-bytes`, `--include-sensitive-files` and `--skip-artifacts` behave as they do for
192
- `generate` and `init`.
202
+ `generate` and `init`. `--only-artifacts` reaches the generation as itself rather than as a
203
+ derived suppression list, so it can switch an artifact back on even when the kept config
204
+ disables it.
205
+ - On a **kept** config, `--preset` cannot be applied: the file belongs to the repository and this
206
+ run does not rewrite it. The run still exits `0`; text mode prints
207
+ `⚠ --preset <name> was not applied: the existing config is kept.` and the setup document
208
+ reports `"preset": null` with the same explanation in `setup.notes[]`. Edit the config, or run
209
+ `init --force`, to change it.
193
210
  - `--format json` emits **one** document:
194
- `{ "setup": { configPath, configReused, preset, scripts, dependency, gitignoreEntries, install, notes }, "manifest": { … } }`,
195
- where `manifest` is the same object `generate --format json` writes. If that generate fails, the
196
- document is `{ "error": { … }, "setup": { … }, "manifest": null }` and the exit code is the
197
- generate's: one document per invocation, a payload or an error, never a payload holding an error.
211
+ `{ "setup": { configPath, configReused, preset, scripts, dependency, gitignoreEntries, install, notes, hook }, "manifest": { … } }`,
212
+ where `manifest` is the same object `generate --format json` writes. With `--dry-run` the
213
+ document is the plan instead — `{ "dryRun": true, configPath, configReused, preset, install, configText }` —
214
+ because nothing was written. If the generate fails, the document is
215
+ `{ "error": { … }, "setup": { … }, "manifest": null }` and the exit code is the generate's: one
216
+ document per invocation, a payload or an error, never a payload holding an error.
198
217
  - If `outDir` holds files this tool did not write, `setup` still refuses to replace it (exit 1,
199
218
  naming the entries) after writing the config — the guard is not weakened by the convenience.
200
219
  ### `init`
@@ -213,7 +232,7 @@ It also has three side effects on files you own, and it says so when it does the
213
232
  ```
214
233
  ✅ Created snapshot.config.ts (preset: node-lib)
215
234
  Added npm scripts: snapshot, snapshot:validate
216
- Added devDependency: codebase-snapshot ^0.9.14
235
+ Added devDependency: codebase-snapshot ^0.9.16
217
236
  Added to .gitignore: snapshot/, snapshot.tmp/
218
237
  ```
219
238
 
@@ -250,7 +269,7 @@ generated file is a plain object with no imports, so it works even when the pack
250
269
  run through `npx` and never installed.
251
270
 
252
271
  Related options: `--preset`, `--include`, `--exclude`, `--yes` and `--force`
253
- apply to `init` only. `init` also accepts `--dry-run`, `--max-part-bytes`, `--out-dir`,
272
+ apply to `init` and `setup` only. `init` also accepts `--dry-run`, `--max-part-bytes`, `--out-dir`,
254
273
  `--include-sensitive-files`, `--skip-artifacts` and `--only-artifacts`, which it shares with
255
274
  the commands that re-read a snapshot, and records their effect in the generated file. The
256
275
  `Applies to` column is in the [options table](#options).
@@ -395,22 +414,22 @@ URIs and protocol versions appear in [the MCP server guide](mcp.md) and in
395
414
  ## Options
396
415
 
397
416
  An option a command does not accept is **rejected**, not ignored: exit `2` and a message
398
- naming the commands that do accept it. Options marked *init only* or *skill only* are the
399
- narrowest cases of the same rule.
417
+ naming the commands that do accept it. The narrowest scopes say so in the table: *skill only*
418
+ for the two install flags, and the init-and-setup flags list both commands.
400
419
 
401
420
  | Option | Type | Default | Applies to | Meaning |
402
421
  | :--- | :--- | :--- | :--- | :--- |
403
- | `--cwd <path>` | path | current directory | generate, validate, report, explain, init, skill | Repository to operate on. Must exist and be a directory. `diff` and `describe` take no `--cwd`. |
404
- | `--out-dir <path>` | path | `snapshot` | generate, validate, report, explain, init | Where the snapshot is written or read. May be absolute. |
405
- | `--max-part-bytes <n>` | size | `307200` (300 KB) | generate, validate, report, explain, init | Hard ceiling per markdown part. Accepts `120k`, `1.5mb`. Minimum 4096. |
422
+ | `--cwd <path>` | path | current directory | generate, validate, report, explain, init, setup, skill, mcp | Repository to operate on. Must exist and be a directory. `diff` and `describe` take no `--cwd`; for `mcp` it chooses the one repository the server serves. |
423
+ | `--out-dir <path>` | path | `snapshot` | generate, validate, report, explain, init, setup | Where the snapshot is written or read. May be absolute. |
424
+ | `--max-part-bytes <n>` | size | `307200` (300 KB) | generate, validate, explain, init, setup | Hard ceiling per markdown part. Accepts `120k`, `1.5mb`. Minimum 4096. |
406
425
  | `--max-part-tokens <n>` | size | unset | generate, validate, setup | A per-part ceiling in **tokens**, for a context window rather than a disk. Narrows `--max-part-bytes` to the equivalent byte count (`tokens × 4`); the smaller of the two ceilings always wins, and both are recorded in the manifest. Accepts `32k`. Minimum 1024 — below that it is a usage error, not a value quietly raised to the floor. |
407
- | `--large-file-bytes <n>` | size | `204800` (200 KB) | generate, validate, report, explain | Above this, a file becomes a head/tail preview. |
408
- | `--max-monolith-bytes <n>` | size | unset | generate, validate, report, explain | Skip the single-file monolith when it would exceed this. |
409
- | `--include-monolith` | flag | off | generate, validate, report, explain | Also write `full-codebase.json` and `full-codebase.md`. |
410
- | `--include-sensitive-files` | flag | off | generate, validate, report, explain, init | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
411
- | `--skip-artifacts <names>` | list | unset | generate, validate, report, explain, init | Comma-separated artifacts to omit. |
412
- | `--only-artifacts <names>` | list | unset | generate, validate, report, explain, init | Write *only* these, and **turn on** any this names: a config with `artifacts: { audit: false }` still gets `reports/audit.md` from `--only-artifacts audit`, because "only these" is a statement about the whole selection rather than a suppression list. Cannot be combined with `--skip-artifacts`. |
413
- | `--format <text\|json>` | enum | `text` | generate, validate, report, explain, init, setup, diff, describe, skill | `json` writes a pure JSON payload to stdout. Every command honours it, and `describe` reports the same nine-command list. |
426
+ | `--large-file-bytes <n>` | size | `204800` (200 KB) | generate, validate, explain, setup | Above this, a file becomes a head/tail preview. |
427
+ | `--max-monolith-bytes <n>` | size | unset | generate, validate, explain, setup | Skip the single-file monolith when it would exceed this. |
428
+ | `--include-monolith` | flag | off | generate, validate, explain, setup | Also write `full-codebase.json` and `full-codebase.md`. |
429
+ | `--include-sensitive-files` | flag | off | generate, validate, explain, init, setup | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
430
+ | `--skip-artifacts <names>` | list | unset | generate, validate, explain, init, setup | Comma-separated artifacts to omit. |
431
+ | `--only-artifacts <names>` | list | unset | generate, validate, explain, init, setup | Write *only* these, and **turn on** any this names: a config with `artifacts: { audit: false }` still gets `reports/audit.md` from `--only-artifacts audit`, because "only these" is a statement about the whole selection rather than a suppression list. Cannot be combined with `--skip-artifacts`. |
432
+ | `--format <text\|json>` | enum | `text` | generate, validate, report, explain, init, setup, diff, describe, skill | `json` writes a pure JSON payload to stdout. Every command except `mcp` honours it — stdout there is the JSON-RPC protocol stream — and `describe` reports the same nine-command list. |
414
433
  | `--sarif` | flag | off | generate, validate, setup | Also write `reports/audit.sarif`: the redaction findings as SARIF 2.1.0, for upload to GitHub Code Scanning. The artefact carries the path, the line and the rule — never the value. Works with `--skip-artifacts audit`, because a CI gate does not read markdown. Rule ids are fixed per rule name, so adding a custom rule never re-points an existing alert. |
415
434
  | `--skeleton` | flag | off | generate, validate, setup | Emit signatures instead of bodies: each function or method body becomes `{ /* ... */ }` in place, so formatting and comments around it are untouched. Covers `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs` and `.cjs`; `.d.ts` files are left alone because they are already declarations. The summary still describes the whole file, and affected entries carry `inclusionMode: "signatures"`. `--include-monolith` still writes the whole body, so the monolith's `inclusionMode: "full"` stays true. |
416
435
  | `--changed-since <ref>` | git ref | unset | generate, validate, explain | Include only files changed since this ref, plus untracked ones. Every other file is recorded in `manifest.skipped[]` with reason `unchanged` and is never opened. `validate` re-resolves the scope: a skipped file that has changed since is reported as drift, and one that has not is left alone — and with `--with-dependents`, so is a file that now imports one that changed. `explain` answers with the same rule. A ref beginning with `-` is refused. |
@@ -422,22 +441,21 @@ narrowest cases of the same rule.
422
441
  | `--autopilot` | flag | off | generate | Set the project up without asking — config, `.gitignore`, npm scripts, devDependency, install — then generate. Never overwrites an existing config; refuses an empty directory (exit `1`); contradicts `--no-config` (exit `2`). |
423
442
  | `--no-install` | flag | off | setup, generate `--autopilot` | Skip the dependency install. Anywhere else it is a usage error, because it would change nothing. |
424
443
  | `--no-config` | flag | off | generate, validate, report, explain, diff | Ignore every `snapshot.config.*` file and run on the built-in defaults. `diff` never loads a config anyway and accepts the flag for consistency. |
425
- | `--discovery <mode>` | enum | `auto` | generate, validate, explain | How files are found: `auto` lists through git when git works and refuses when a `.git` directory cannot be listed; `git` requires git; `walk` scans the tree and reads `.gitignore` files directly. The escape hatch for a broken `.git`. |
426
- | `--preset <name>` | name | detected | *init only* | Force a preset instead of detecting one. |
427
- | `--include <globs>` | list | unset | *init only* | Allow-list recorded in the generated config. |
428
- | `--exclude <globs>` | list | unset | *init only* | Exclude globs recorded in the generated config. |
429
- | `--yes` | flag | off | *init only* | Never prompt; accept every default. |
430
- | `--force` | flag | off | *init only* | Replace an existing `.ts`/`.js`/`.mjs` config in place. A JSON-family config is refused, naming the file to remove. |
444
+ | `--discovery <mode>` | enum | `auto` | generate, validate, explain, setup | How files are found: `auto` lists through git when git works and refuses when a `.git` directory cannot be listed; `git` requires git; `walk` scans the tree and reads `.gitignore` files directly. The escape hatch for a broken `.git`. |
445
+ | `--preset <name>` | name | detected | init, setup | Force a preset instead of detecting one. |
446
+ | `--include <globs>` | list | unset | init, setup | Allow-list recorded in the generated config. |
447
+ | `--exclude <globs>` | list | unset | init, setup | Exclude globs recorded in the generated config. |
448
+ | `--yes` | flag | off | init, setup | Never prompt; accept every default. |
449
+ | `--force` | flag | off | init, setup | Replace an existing `.ts`/`.js`/`.mjs` config in place. A JSON-family config is refused, naming the file to remove. |
431
450
  | `--install` | flag | off | *skill only* | Write the skill into the repository instead of printing it. |
432
451
  | `--target <name>` | enum | `all` | *skill only* | `claude`, `cursor` or `all`. |
433
452
  | `-h`, `--help` | flag | — | every command | Print usage. |
434
453
  | `-v`, `--version` | flag | — | every command | Print the version on stdout: a bare `v`-prefixed semver (for example `v1.2.3`), with no package name. |
435
454
 
436
- The artifact and size options apply to `validate`, `report` and `explain` as well as
437
- `generate` because those commands re-read the snapshot: pass the selection you generated
438
- with and the comparison is like for like. `validate --skip-artifacts parts` on a snapshot
439
- built without parts therefore agrees, while the same flag on a full snapshot reports a
440
- config mismatch.
455
+ The artifact and size options apply to `validate` and `explain` as well as `generate` because
456
+ those commands re-derive the configuration: pass the selection you generated with and the
457
+ comparison is like for like. `validate --skip-artifacts parts` on a snapshot built without parts
458
+ therefore agrees, while the same flag on a full snapshot reports a config mismatch.
441
459
 
442
460
  The same rule applies to the compression and scope options. `--skeleton`, `--sarif` and
443
461
  `--max-part-tokens` are recorded in `manifest.config.digest`, so `validate` accepts them too —
@@ -446,9 +464,11 @@ the flag to `validate` was rejected as a flag that "does not apply to validate".
446
464
  `--staged` and `--with-dependents` are accepted by `validate` and `explain` because they decide
447
465
  which recorded `unchanged` skips are re-checked and what `explain` answers about one file.
448
466
 
449
- `report` does not take any of them: it reads the manifest and prints what is there, so a
450
- generation setting would change nothing. A flag that parses and does nothing is the silent
451
- fallback this table exists to prevent.
467
+ `report` takes none of the generation settings: it reads the manifest and prints what is there,
468
+ so a generation setting would change nothing — which is why it no longer accepts them as silent
469
+ no-ops. `report --max-part-bytes 120k` exits `2` with a message naming the commands that do
470
+ accept it. A flag that parses and does nothing is the silent fallback this table exists to
471
+ prevent.
452
472
 
453
473
  Every option also accepts the `--option=value` form. That form is required for negative
454
474
  numbers, which otherwise look like flags.
@@ -457,16 +477,21 @@ numbers, which otherwise look like flags.
457
477
 
458
478
  `--mode <command>` names the command instead of passing it positionally, which is handy when
459
479
  a wrapper builds the argument list. `--mode validate` and `codebase-snapshot validate` are the
460
- same run. It accepts the nine command names, and it is deliberately strict: asking for two
461
- different commands is an error rather than a silent winner.
480
+ same run. With `--mode`, the remaining positionals are that command's arguments, so
481
+ `--mode explain src/server.ts` and `--mode diff old-snapshot snapshot` work the same way the
482
+ positional form does.
483
+
484
+ It accepts the ten commands plus the `check` alias — the eleven names the error lists — and it is
485
+ deliberately strict: asking for two different commands is an error rather than a silent winner.
462
486
 
463
487
  ```
464
488
  ❌ --mode validate contradicts the command "generate". Pass one or the other.
465
- ❌ Unknown --mode "bogus". Expected one of: generate, validate, check, report, init, explain, diff, describe, skill.
489
+ ❌ Unknown --mode "bogus". Expected one of: generate, validate, check, report, init, setup, explain, diff, describe, skill, mcp.
466
490
  ```
467
491
 
468
- `--mode` is not listed in `describe`'s option table or `--help`, on purpose: an agent has no
469
- reason to use it, and the positional form is the documented one.
492
+ `describe` does list `--mode` in its option table (`appliesTo` names the ten canonical commands),
493
+ but `--help` does not: the positional form is the documented one for people, and the flag exists
494
+ for wrappers and for the contract.
470
495
 
471
496
  ## Exit codes
472
497
 
@@ -485,11 +510,12 @@ wrong and retrying it unchanged will fail the same way.
485
510
  - **stdout** carries the payload. With `--format json` it is pure JSON, safe to pipe into
486
511
  `jq` or `JSON.parse`.
487
512
  - **stderr** carries progress, the human summary, warnings and errors.
488
- - **In text mode the human result is on stderr, and stdout is empty.** That holds for every
489
- command: `report`, `explain`, `diff` and `validate` print their answer — tables, verdicts,
490
- drift lines — to stderr, and `generate` prints its summary there too. Redirecting
491
- `command > file.txt` therefore writes an empty file in text mode; use `--format json` when
492
- you want the output on stdout.
513
+ - **In text mode the human result is on stderr, and stdout is empty** — for every command
514
+ except `skill`. `report`, `explain`, `diff`, `validate`, `describe`, `setup` and
515
+ `generate` print their answer and progress to stderr, so redirecting `command > file.txt`
516
+ writes an empty file in text mode; use `--format json` when you want the output on stdout.
517
+ `skill` without `--install` prints the skill to stdout so it can be redirected, and the
518
+ `--help` / `--version` print paths do the same. `mcp` uses stdout for the JSON-RPC protocol.
493
519
 
494
520
  A failing invocation still writes one JSON document to stdout, so an agent never has to parse an
495
521
  empty string:
@@ -313,6 +313,23 @@ closes between the name and the value.
313
313
  the file decides: `readonly api_key=hunter2` in `.envrc`, `.sh`, `.zsh`, a YAML or an INI file is
314
314
  masked, while `private readonly apiKey = someValue` in TypeScript is left alone.
315
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
+
316
333
  Findings are summarised in `reports/audit.md` (one row per line, naming every rule that matched
317
334
  it), counted in `manifest.totals.redactedLines`, and shown in the `generate` summary as a
318
335
  `Redacted:` line separate from `Warnings:`.
@@ -389,16 +406,33 @@ const config = {
389
406
 
390
407
  // ── Size ─────────────────────────────────────────────────
391
408
  maxPartBytes: "300k",
409
+ maxPartTokens: null, // the same ceiling in tokens; narrows maxPartBytes
392
410
  largeFileBytes: "200k",
393
411
  previewHeadLines: 80,
394
412
  previewTailLines: 40,
395
413
  budgets: { default: "300k", byLayer: {} },
396
414
 
397
- // ── 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 ─────────────────────────────────────────
398
423
  include: [],
399
424
  excludePatterns: [],
400
425
  discovery: "auto", // "auto" | "git" | "walk"
401
426
 
427
+ // ── Classification ───────────────────────────────────────
428
+ layersMode: "merge",
429
+ layers: [],
430
+ kinds: [],
431
+
432
+ // ── Safety ───────────────────────────────────────────────
433
+ includeSensitiveFiles: false,
434
+ secrets: { customPatterns: [], disableDefaultPatterns: false },
435
+
402
436
  // ── Artifacts ────────────────────────────────────────────
403
437
  artifacts: {
404
438
  readme: true,
@@ -409,19 +443,10 @@ const config = {
409
443
  audit: true,
410
444
  monolith: false,
411
445
  },
412
-
413
- // ── Safety ───────────────────────────────────────────────
414
- includeSensitiveFiles: false,
415
- secrets: { customPatterns: [], disableDefaultPatterns: false },
416
-
417
- // ── Classification ───────────────────────────────────────
418
- layersMode: "merge",
419
- layers: [],
420
- kinds: [],
446
+ maxMonolithBytes: null, // skip the monolith above this size
447
+ includeMonolith: false, // top-level switch; the artifacts entry wins
421
448
 
422
449
  // ── Advanced ─────────────────────────────────────────────
423
- includeMonolith: false,
424
- maxMonolithBytes: null,
425
450
  hooks: {},
426
451
  };
427
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.14 mcp
13
+ npx -y codebase-snapshot@0.9.16 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.14", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.9.16", "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.14 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.9.16 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,12 @@ 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
+
64
70
  `snapshot_plan`, `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the
65
71
  **scope and compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`,
66
72
  `changedSince`, `staged` and `withDependents`. They have to: `manifest.config.digest` covers those
@@ -97,8 +103,18 @@ Resources are the browse surface; tools are the act surface.
97
103
  | `snapshot://contract` | The machine-readable CLI contract |
98
104
  | `snapshot://skill` | The agent skill, as one read |
99
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
+
100
115
  Part resources carry their size in the description, so a client choosing between them can see that
101
- 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.
102
118
 
103
119
  ## Prompts
104
120
 
@@ -108,8 +124,11 @@ making changes.
108
124
 
109
125
  ## What it will not do
110
126
 
111
- - **Read outside its root.** `--cwd` is the only directory that is readable. A `root` argument can
112
- 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.
113
132
  - **Emit a sensitive file.** `.env`, `*.pem` and the rest stay out, and `includeSensitiveFiles` is
114
133
  not a tool argument — a prompt cannot ask for it. Reads come from the emitted snapshot, so
115
134
  redaction applies to everything the client sees.
@@ -171,5 +190,10 @@ version in the client arguments.
171
190
  **`Unknown resource` for a part.** Resources are computed from the manifest, so nothing but the
172
191
  static set exists before the first generate. Call `snapshot_status`, then `snapshot_generate`.
173
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
+
174
198
  **A file is missing from `snapshot_locate`.** It is excluded, and `snapshot_explain` will name the
175
199
  reason — an ignore rule, the preset, a sensitive-file pattern, or your own config.
package/docs/output.md CHANGED
@@ -50,8 +50,12 @@ same persistently. The ownership marker is always written.
50
50
 
51
51
  Each `part-NNN.md` holds whole files under the byte budget (`maxPartBytes`, default 300 KB).
52
52
  A file larger than the budget is not split mid-file: it is truncated and carries an omission
53
- marker naming the budget that cut it (`... [347 lines omitted: part budget 1887 B] ...`). A file
54
- 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.
55
59
 
56
60
  Each file section is an anchor, a `### FILE:` heading, and **one** metadata line:
57
61
 
@@ -99,7 +103,7 @@ diff the manifest only when you need to know that a run happened.
99
103
  | `config` | The resolved configuration actually used (preset, artifacts, sizing, scoping). |
100
104
  | `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount }`. |
101
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. |
102
- | `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. |
103
107
  | `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
104
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. |
105
109
  | `layers`, `kinds` | File counts per layer and per kind. |
@@ -285,20 +289,45 @@ omission: the directory and its files are all accounted for, just not at the sam
285
289
  - **The tool refuses to replace a directory it did not write.** Pointing `--out-dir` at
286
290
  `src/` is refused with exit `1` and the directory is left untouched — a mistyped output
287
291
  path cannot delete source code. Empty directories, directories that hold nothing but
288
- `.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.
289
294
  A `.gitkeep` or `.gitignore` inside the directory is not accepted, because the generator never
290
295
  writes either into an output directory: a directory that holds one is somebody's data, so the
291
296
  run refuses instead of deleting it.
292
297
  - **Ownership is the marker, not a filename.** `.codebase-snapshot` is a JSON record carrying
293
298
  this generator's name and `version`, the marker's `schemaVersion`, a `createdAt` timestamp,
294
299
  a `pid`, a per-snapshot `id`, the run `state` (`staging` while it is being written, `complete`
295
- once it is whole), the `manifestSha256` digest of the manifest it shipped, and `entries` — the
296
- inventory of everything it wrote. `pid` is what lets a later run tell a crashed run's staging
297
- directory and lock from a live one. A zero-byte marker, a marker that is not JSON, a marker
298
- written by 3.0.0 (no `id`), a bare `manifest.json`, and a directory with files you added
299
- 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.
300
304
  See [Troubleshooting](troubleshooting.md#refusing-to-replace-outdir-).
301
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
+
302
331
  The marker also makes hook-written artifacts safe: the entries a `hooks.afterGenerate` adds to
303
332
  the output are recorded in the marker, so they do not make the next run refuse the directory.
304
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