codebase-snapshot 0.20.9 → 0.20.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-DfNd8f67.cjs';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-DMzNbsAW.cjs';
2
2
  import { Readable, Writable } from 'node:stream';
3
- import './types-D2_K7jfI.cjs';
3
+ import './types-C5ytHMYz.cjs';
4
4
 
5
5
  /**
6
6
  * JSON-RPC 2.0 envelopes and the Model Context Protocol revisions this server speaks.
@@ -175,8 +175,8 @@ interface ToolContext {
175
175
  * Client-facing hints.
176
176
  *
177
177
  * `readOnlyHint` is the one that changes behaviour rather than appearance: clients use it to
178
- * auto-approve a call. Seven of the 26 tools never touch the filesystem, so they are marked
179
- * read-only and only `snapshot_generate` prompts.
178
+ * auto-approve a call. Twenty-five of the 26 tools never write, so they are marked read-only;
179
+ * only `snapshot_generate` writes.
180
180
  */
181
181
  interface ToolAnnotations {
182
182
  readOnlyHint: boolean;
package/dist/mcp.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker--m4IM5zj.js';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-CRMESc0b.js';
2
2
  import { Readable, Writable } from 'node:stream';
3
- import './types-D2_K7jfI.js';
3
+ import './types-C5ytHMYz.js';
4
4
 
5
5
  /**
6
6
  * JSON-RPC 2.0 envelopes and the Model Context Protocol revisions this server speaks.
@@ -175,8 +175,8 @@ interface ToolContext {
175
175
  * Client-facing hints.
176
176
  *
177
177
  * `readOnlyHint` is the one that changes behaviour rather than appearance: clients use it to
178
- * auto-approve a call. Seven of the 26 tools never touch the filesystem, so they are marked
179
- * read-only and only `snapshot_generate` prompts.
178
+ * auto-approve a call. Twenty-five of the 26 tools never write, so they are marked read-only;
179
+ * only `snapshot_generate` writes.
180
180
  */
181
181
  interface ToolAnnotations {
182
182
  readOnlyHint: boolean;
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import './chunk-WMEZFLUT.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, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText } from './chunk-SU6YGIQT.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, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText } from './chunk-TUKY6KLH.js';
@@ -99,6 +99,8 @@ type SkipReason = "binary" | "read-error" | "not-file"
99
99
  | "gitignore"
100
100
  /** Excluded by a built-in rule: the ignore list, a preset, or an output dir. */
101
101
  | "default-ignore"
102
+ /** A directory with a .codebase-snapshot marker, recorded instead of silently dropped. */
103
+ | "tool-output"
102
104
  /** Excluded by the user's own `excludePatterns` or `include` allow-list. */
103
105
  | "excluded"
104
106
  /**
@@ -99,6 +99,8 @@ type SkipReason = "binary" | "read-error" | "not-file"
99
99
  | "gitignore"
100
100
  /** Excluded by a built-in rule: the ignore list, a preset, or an output dir. */
101
101
  | "default-ignore"
102
+ /** A directory with a .codebase-snapshot marker, recorded instead of silently dropped. */
103
+ | "tool-output"
102
104
  /** Excluded by the user's own `excludePatterns` or `include` allow-list. */
103
105
  | "excluded"
104
106
  /**
@@ -21,8 +21,9 @@ tokens in full.
21
21
 
22
22
  - **Files** — entries in `manifest.files`, i.e. what the parts actually carry.
23
23
  - **Parts** — part files written. A budget/slice snapshot tends to be one part because it fits.
24
- - **Tokens** — `manifest.totals.estimatedTokens`, the same estimate the product reports. It is one
25
- token per four bytes of emitted body, not a tokenizer count; every model tokenizes differently.
24
+ - **Tokens** — `manifest.totals.estimatedTokens`, the structural estimate the product reports.
25
+ `estimateTokens` counts word runs, punctuation and newline runs; it is neither bytes/4 nor a
26
+ tokenizer count, and every model tokenizes differently.
26
27
  - **vs full** — token share of the full snapshot.
27
28
  - **Time** — wall clock for the whole `generate` process, including scan, parse, partition and write.
28
29
 
@@ -66,9 +67,10 @@ identical, which is what a deterministic scanner should do.
66
67
 
67
68
  Read it carefully:
68
69
 
69
- - **The ratio is not a contest.** Our estimate is one token per four bytes of emitted body; repomix
70
- uses a tokenizer. Across nine repositories the two land within about plus or minus 30%, which is
71
- what two reasonable estimates of the same text do.
70
+ - **The ratio is not a contest.** Our manifest estimate weighs word runs, punctuation and
71
+ newlines; the byte-based budget planner uses one token per four bytes; repomix uses a tokenizer.
72
+ Across nine repositories the two land within about plus or minus 30%, which is what two
73
+ reasonable estimates of the same text do.
72
74
  - **minimatch is the exception, and it is a policy difference, not an estimate.** That repository
73
75
  carries five benchmark fixtures of 20 to 25 MB of JSON. repomix emits them (64.8M tokens); our
74
76
  large-file rule emits a bounded preview and records the omission, so the pack stays 319,879 tokens.
@@ -110,7 +112,8 @@ gitingest from PyPI, same machine:
110
112
  Read that honestly:
111
113
 
112
114
  - **repomix reports fewer tokens for a similar pack** (854k against our 1.03M, 83%). The cause is
113
- the estimator, not the content: we count one token per four bytes, repomix uses a tokenizer.
115
+ the estimator, not the content: our manifest counts word runs, punctuation and newlines (the
116
+ budget planner uses bytes/4), while repomix uses a tokenizer.
114
117
  Our number is conservative, which is the right direction for a budget — a plan that fits
115
118
  1,027,911 tokens fits a tokenizer count of 854,178 far more often than the reverse.
116
119
  - **Our pack is smaller in bytes** (3.20 MB of file content against repomix's 3.39 MB of output,
package/docs/budget.md CHANGED
@@ -22,8 +22,9 @@ Every scanned file is scored once:
22
22
  | Cost | up to −40 | A cheap file that matters beats an expensive one that barely does. |
23
23
 
24
24
  Files are taken in score order while the running token estimate fits; a file that would exceed the
25
- budget is skipped whole, not cut. The estimate is one token per four bytes of emitted body — the
26
- same estimate the manifest reports.
25
+ budget is skipped whole, not cut. This planner uses one token per four bytes of emitted body. The
26
+ manifest's `estimatedTokens` is the structural `estimateTokens` result instead, so the two differ
27
+ by construction and neither is a tokenizer count.
27
28
 
28
29
  ## What it records
29
30
 
package/docs/cli.md CHANGED
@@ -98,7 +98,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
98
98
 
99
99
  ```
100
100
  📸 Generating snapshot for: /path/to/repo
101
- Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.9 (project dependency ^0.20.9)
101
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.12 (project dependency ^0.20.12)
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
@@ -209,8 +209,9 @@ The whole first run in one command, with defaults and no prompts. This is the sa
209
209
  `--autopilot` uses, spelled as a command word:
210
210
 
211
211
  1. Detects the project preset.
212
- 2. Writes `snapshot.config.ts` (or `.mjs`) — **only when the repository has none**. An existing
213
- config is kept byte for byte and the output says `Keeping …`.
212
+ 2. Writes `snapshot.config.json` — **only when the repository has none**. An existing config is
213
+ kept byte for byte and the output says `Keeping …`. A data-only config is intentional: the MCP
214
+ server and `serve` refuse executable repository code.
214
215
  3. Adds `scripts.snapshot`, `scripts.snapshot:validate`, the `devDependencies` entry and the
215
216
  `.gitignore` entries, exactly as `init` does.
216
217
  4. Installs dependencies with the package manager the repository already uses — a lockfile
@@ -221,9 +222,9 @@ The whole first run in one command, with defaults and no prompts. This is the sa
221
222
 
222
223
  ```
223
224
  🚀 Setup for: /path/to/repo
224
- ✅ Created snapshot.config.ts (preset: nextjs)
225
+ ✅ Created snapshot.config.json (preset: nextjs)
225
226
  Added npm scripts: snapshot, snapshot:validate
226
- Added devDependency: codebase-snapshot ^0.20.9
227
+ Added devDependency: codebase-snapshot ^0.20.12
227
228
  Added to .gitignore: /snapshot/, /snapshot.tmp/
228
229
  ⏳ Installing dependencies…
229
230
  ✅ Installed dependencies (npm install, 2.1s)
@@ -265,17 +266,17 @@ The whole first run in one command, with defaults and no prompts. This is the sa
265
266
  codebase-snapshot init [options]
266
267
  ```
267
268
 
268
- Detects the project and writes `snapshot.config.ts` (or `.mjs`, see below) containing
269
- **every** setting at its current value, commented and grouped. It is a reference you can
270
- keep, not just a diff — there is no shorter variant, because the file that documents the
271
- settings is the file you edit.
269
+ Detects the project and writes `snapshot.config.json` containing **every** setting at its
270
+ current value. It is a reference you can keep, not just a diff — there is no shorter variant,
271
+ because the file that documents the settings is the file you edit. JSON is deliberate: the MCP
272
+ server and `serve` refuse executable repository configs, so `init` never writes one.
272
273
 
273
274
  It also has three side effects on files you own, and it says so when it does them:
274
275
 
275
276
  ```
276
- ✅ Created snapshot.config.ts (preset: node-lib)
277
+ ✅ Created snapshot.config.json (preset: node-lib)
277
278
  Added npm scripts: snapshot, snapshot:validate
278
- Added devDependency: codebase-snapshot ^0.20.9
279
+ Added devDependency: codebase-snapshot ^0.20.12
279
280
  Added to .gitignore: /snapshot/, /snapshot.tmp/
280
281
  ```
281
282
 
@@ -308,10 +309,10 @@ file.
308
309
  Interactive by default; with `--yes` it accepts every default and never prompts, which is
309
310
  what agents and release checks should use.
310
311
 
311
- The filename adapts to the project: `.ts` only when the running Node can strip types
312
- (≥ 22.6) **and** the project is an ES module; otherwise `.mjs`, which loads everywhere. The
313
- generated file is a plain object with no imports, so it works even when the package is only
314
- run through `npx` and never installed.
312
+ A new configuration is always `snapshot.config.json`, a plain JSON object with no imports. JSON
313
+ is the shape `mcp` and `serve` accept without executing repository code; request an executable
314
+ `.ts`/`.js`/`.mjs` file yourself only if you need function matchers. The file works even when
315
+ the package is only run through `npx` and never installed.
315
316
 
316
317
  Related options: `--preset`, `--include`, `--exclude`, `--yes` and `--force`
317
318
  apply to `init` and `setup` only. `init` also accepts `--dry-run`, `--max-part-bytes`, `--out-dir`,
@@ -425,12 +426,12 @@ agent](agent.md).
425
426
  Ask the npm registry whether a newer release exists, and print the version it compared against:
426
427
 
427
428
  ```bash
428
- npx codebase-snapshot@0.20.9 update # is 0.17.0 still current? print the answer
429
+ npx codebase-snapshot@0.20.9 update # is 0.20.12 current? print the answer
429
430
  npx codebase-snapshot@0.20.9 update --format json
430
431
  ```
431
432
 
432
433
  ```text
433
- ↑ codebase-snapshot 0.18.0 is available — you have 0.17.0.
434
+ ↑ codebase-snapshot 0.20.12 is available — you have 0.20.9.
434
435
  npm install -g codebase-snapshot
435
436
  ```
436
437
 
@@ -519,7 +520,7 @@ for the two install flags, and the init-and-setup flags list both commands.
519
520
  | `--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. |
520
521
  | `--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. |
521
522
  | `--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). |
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. |
523
+ | `--no-update-check` | flag | off | all commands except `update` | 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. `update` exists to contact the registry, so it has no check to skip. |
523
524
  | `--prompt-task <task>` | string | `audit` | generate, validate | `audit`, `review` or `explain` — which job the brief is written for. Changes the opening section, not the standard. |
524
525
  | `--budget-tokens <n>` | count | unset | generate | Fit the snapshot into n tokens by selecting whole files (entry points, then the most-imported). Records a `budget` block; the rest are `not-selected`. See [budget](budget.md). |
525
526
  | `--sign` | flag | off | generate | Sign `manifest.json` with Ed25519 and write `signature.json`. Key from `SNAPSHOT_SIGNING_KEY`, else generated (trust on first use). See [signing](signing.md). |
@@ -558,7 +559,7 @@ for the two install flags, and the init-and-setup flags list both commands.
558
559
  | `--include <globs>` | list | unset | init, setup | Allow-list recorded in the generated config. |
559
560
  | `--exclude <globs>` | list | unset | init, setup | Exclude globs recorded in the generated config. |
560
561
  | `--yes` | flag | off | init, setup | Never prompt; accept every default. |
561
- | `--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. |
562
+ | `--force` | flag | off | init, setup | Replace an existing JSON-family config in place. An executable `.ts`/`.js`/`.mjs` config is refused, naming the file to remove. |
562
563
  | `--install` | flag | off | *skill only* | Write the skill into the repository instead of printing it. |
563
564
  | `--target <name>` | enum | `all` | *skill only* | `claude`, `cursor` or `all`. |
564
565
  | `-h`, `--help` | flag | — | every command | Print usage. |
@@ -49,14 +49,15 @@ A config file that exists but cannot be parsed is a **hard error** (exit `1`, no
49
49
  written). Silently ignoring it would produce a snapshot with none of your settings.
50
50
 
51
51
  A `.ts` config needs Node ≥ 22.6 **and** an ES-module project, because Node applies the
52
- package's `type` field to a `.ts` file. `codebase-snapshot init` picks the right filename for
53
- the project — `.ts` when both conditions hold, `.mjs` otherwise — and writes a plain object
54
- with no imports so it loads even when the package is only used through `npx`.
52
+ package's `type` field to a `.ts` file. `codebase-snapshot init` writes `snapshot.config.json`
53
+ for a new project: data only, no imports, and accepted by `mcp` and `serve` without executing
54
+ repository code. An executable `.ts`/`.js`/`.mjs` config is something you create yourself and
55
+ can use with the CLI; those surfaces refuse to run it.
55
56
 
56
- The snippets below show an `export default { … }` object for brevity. `init` writes it as
57
- `const config = { … }; export default config;` because the anonymous form is reported by
58
- `import/no-anonymous-default-export`, which `eslint-config-next` enables by default — both load
59
- identically, so use whichever keeps your linter quiet.
57
+ The snippets below show an `export default { … }` object because that is the executable form.
58
+ A JSON config uses the same keys without the export wrapper. Both load identically for the CLI.
59
+ For an executable config, prefer `const config = { … }; export default config;` over the
60
+ anonymous form, which `eslint-config-next` reports via `import/no-anonymous-default-export`.
60
61
 
61
62
  CLI flags override the config for a single run (`--max-part-bytes`, `--out-dir`, …).
62
63
  `--no-config` goes further and ignores every config file, so the run uses the built-in
@@ -674,13 +675,13 @@ npx codebase-snapshot init --preset go --max-part-bytes 200k \
674
675
  --include "cmd/**,internal/**" --exclude "**/*_test.go" --yes
675
676
  ```
676
677
 
677
- `--dry-run` prints the config and writes nothing. `--force` replaces an existing ES-module
678
- config (`.ts`, `.js`, `.mjs`) in place; without it, an existing config is left alone and the
679
- command exits `1`.
678
+ `--dry-run` prints the config and writes nothing. A new configuration is
679
+ `snapshot.config.json`, the data-only form MCP and serve accept. `--force` rewrites an existing
680
+ configuration in place: a JSON-family file keeps JSON; an ES-module `.ts`, ESM `.js`, or `.mjs`
681
+ file keeps its executable format. A CommonJS `.js` or `.cjs` file is refused, because this
682
+ wizard cannot write that format, and a new file beside it would silently shadow the old one.
683
+ Without `--force`, an existing config is left alone and the command exits `1`.
680
684
 
681
- It will not replace a JSON-family config — `snapshot.config.json`, `.snapshotrc`,
682
- `.snapshotrc.json`, or the `"snapshot"` key in `package.json` — because this wizard writes an
683
- ES-module file and a new file beside the old one would silently shadow it. Those cases exit `1`
684
- with a message naming the file to delete or rename. Note that this means `--force` writing
685
- `snapshot.config.ts` does shadow a `"snapshot"` key in `package.json`, since a dedicated config
686
- file always wins.
685
+ A `"snapshot"` key in `package.json` is handled the same way: without `--force` the command
686
+ exits `1` and names the key; with `--force` it writes `snapshot.config.json`, and that file then
687
+ takes precedence over the key. The key itself is not edited.
package/docs/health.md CHANGED
@@ -32,7 +32,7 @@ npx codebase-snapshot health --deep # also replay every full body from t
32
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
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`. |
34
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. |
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. If `maxScanBytes` truncates the scan, the check is a warning, never a pass. |
36
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
37
  | No host path or machine identity | `pii.paths` | warning | `/home/…`, `/Users/…`, `C:\Users\…` and the repository's absolute path are searched for. |
38
38
  | Token estimate is plausible | `tokens.count` | warning | The recorded estimate is compared with one recomputed from the parts. |
@@ -31,9 +31,9 @@ snapshot # installed globally: one word, and it asks once
31
31
  npx codebase-snapshot setup # or from a checkout with no global install
32
32
  ```
33
33
 
34
- `setup` detects the project type from the repository, writes a commented `snapshot.config.mjs`, adds
35
- the npm scripts and the devDependency, installs it, and generates. It does not overwrite a config you
36
- already have. Use `--no-install` if you would rather not touch the lockfile. `npx codebase-snapshot
34
+ `setup` detects the project type from the repository, writes a data-only `snapshot.config.json`,
35
+ adds the npm scripts and the devDependency, installs it, and generates. It does not overwrite a
36
+ config you already have. Use `--no-install` if you would rather not touch the lockfile. `npx codebase-snapshot
37
37
  --autopilot` does the same thing with no questions at all, which is what you want in CI.
38
38
 
39
39
  If you prefer to see each stage:
@@ -56,14 +56,11 @@ destination, not from taste:
56
56
  | A RAG index | 120–300 KB per part, chunked by heading |
57
57
  | An agent's context | 60–150 KB; smaller parts leave room to reason |
58
58
 
59
- ```js
60
- // snapshot.config.mjs
61
- const config = {
62
- maxPartBytes: "120k",
63
- // Per-layer ceilings, when docs and code deserve different treatment.
64
- budgets: { default: "120k", byLayer: { docs: 40_000 } },
65
- };
66
- export default config;
59
+ ```json
60
+ {
61
+ "maxPartBytes": "120k",
62
+ "budgets": { "default": "120k", "byLayer": { "docs": 40000 } }
63
+ }
67
64
  ```
68
65
 
69
66
  A file is never cut down to make a part fit. A file above `largeFileBytes` — which defaults to the
package/docs/mcp.md CHANGED
@@ -143,26 +143,26 @@ between them should not have to guess.
143
143
  | `snapshot_read` | A window of one file, as the snapshot contains it. | no |
144
144
  | `snapshot_explain` | Why is this path not in the snapshot? | no |
145
145
 
146
- Seven are declared `readOnlyHint`, which most clients use to run them without asking. Only
147
- `snapshot_generate` prompts.
146
+ Twenty-five are declared `readOnlyHint`, which most clients use to run them without asking. Only
147
+ `snapshot_generate` writes.
148
148
 
149
- All eight take `outDir`, so a snapshot generated into a directory other than the configured one is
149
+ All 26 take `outDir`, so a snapshot generated into a directory other than the configured one is
150
150
  still reachable: pass the same value to the read side that you passed to `snapshot_generate`. Before
151
151
  that, only `snapshot_generate` honoured it and every other tool looked in the configured directory
152
152
  and reported "there is no snapshot manifest here".
153
153
 
154
154
  An `outDir` **tool argument** must resolve inside the repository the server serves: a prompt cannot
155
- drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir` is
156
- not confined the same way — that is the repository's own decision, and a config may legitimately
157
- point one directory up. If the argument escapes, the tool refuses and the message says to restart
158
- the server with `--cwd` pointing at the repository you want to write.
155
+ drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir`
156
+ and `tmpDir` are confined the same way. If either escapes, the tool refuses and the message says
157
+ to move the directory inside the served root, or start the server with `--cwd` at the parent
158
+ repository.
159
159
 
160
160
  `snapshot_plan`, `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the
161
161
  **scope and compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`,
162
162
  `changedSince`, `staged` and `withDependents`. They have to: `manifest.config.digest` covers those
163
163
  settings, so a snapshot generated with `--skeleton` was not merely un-inspectable over MCP, it was
164
164
  reported as configuration drift on every `snapshot_validate`. Pass the same switches you generated
165
- with, exactly as you would on the command line. The four remaining tools do not take them, because
165
+ with, exactly as you would on the command line. The other tools do not take them, because
166
166
  none of them re-derives the configuration and a flag that changes nothing is the command-line form
167
167
  of a silent fallback.
168
168
 
package/docs/migration.md CHANGED
@@ -1,16 +1,17 @@
1
- # Migrating from 0.12.14 to 0.17.0
1
+ # Migrating to 0.20.12
2
2
 
3
3
  Nothing was removed. Every command, flag, config key and MCP tool that existed in 0.12.14 still
4
- works, with two deliberate behaviour changes listed at the bottom. This page is the map of what was
5
- added, so a reader can find the feature they need without reading a hundred changelog entries.
4
+ works. This page maps what was added and the behaviour changes that matter when upgrading an old
5
+ checkout, config or snapshot.
6
6
 
7
7
  ## New commands
8
8
 
9
9
  | Command | Since | What it does |
10
10
  | :--- | :--- | :--- |
11
- | `snapshot health` | 0.12.15 | Audits the written snapshot: hashes, artifacts, secrets, host paths, tokens, freshness, signature. `--strict`, `--format json`. |
11
+ | `snapshot health` | 0.12.15 | Audits the written snapshot: hashes, artifacts, secrets, host paths, tokens, freshness, signature. `--strict`, `--format json`, `--deep`, `--all-members`. |
12
12
  | `snapshot serve` | 0.12.19 | A browser page to generate, preview and download a snapshot; MCP on the same port. |
13
13
  | `snapshot mcp --http` | 0.12.18 | MCP over Streamable HTTP instead of stdio; `GET /sse` for legacy clients since 0.12.29. |
14
+ | `snapshot update` | 0.18.0 | Bypasses the update cache, prints the registry answer, exits 0 current / 1 newer / 2 unreachable. |
14
15
 
15
16
  ## New `generate` flags
16
17
 
@@ -18,7 +19,7 @@ added, so a reader can find the feature they need without reading a hundred chan
18
19
  | :--- | :--- | :--- |
19
20
  | `--remote <url>` | 0.12.20 | Shallow, SSRF-safe clone of a public repository; provenance in the manifest. |
20
21
  | `--ref <branch>` | 0.12.20 | Branch or tag for `--remote`. |
21
- | `--allow-private` | 0.12.20 | The explicit override for private addresses and `file:` URLs. |
22
+ | `--allow-private` | 0.12.20 | Explicit override for private addresses and `file:` URLs. |
22
23
  | `--keep-clone` | 0.12.20 | Keep the temporary clone. |
23
24
  | `--include-diffs` | 0.12.24 | `reports/diff.md` from the uncommitted diff. |
24
25
  | `--include-logs <n>` | 0.12.24 | `reports/log.md` with the last n commits. |
@@ -26,7 +27,7 @@ added, so a reader can find the feature they need without reading a hundred chan
26
27
  | `--delta <path>` | 0.12.25 | Only what changed since a base snapshot, plus its importers. |
27
28
  | `--slice "<question>"` | 0.12.26 | Only what the retrieval planner picks for a question. |
28
29
  | `--slice-tokens <n>` | 0.12.26 | The slice budget (default 30000). |
29
- | `--pack single\|xml\|json` | 0.12.31 | One full-repository file in the chosen shape. |
30
+ | `--pack single|xml|json` | 0.12.31 | One full-repository file in the chosen shape. |
30
31
  | `--sign` | 0.12.32 | Ed25519 signature over the manifest. |
31
32
  | `--budget-tokens <n>` | 0.12.33 | Fit the repository into a token budget by selecting whole files. |
32
33
 
@@ -35,53 +36,51 @@ added, so a reader can find the feature they need without reading a hundred chan
35
36
  | Key | Since | Notes |
36
37
  | :--- | :--- | :--- |
37
38
  | `artifacts.diff`, `artifacts.log`, `artifacts.tokenTree` | 0.12.24 | Default `false`. `--skip-artifacts` still wins. |
38
- | `logCount` | 0.12.24 | 1–500, default 20. |
39
+ | `logCount` | 0.12.24 | 1-500, default 20. |
39
40
  | `pack` | 0.12.31 | `single`, `xml` or `json`; unset keeps the monolith pair. |
41
+ | `discovery` | 0.13.x | `auto`, `git` or `walk`; recorded in the config digest. |
42
+ | `maxParts` | 0.16.x | Grow the part budget until the snapshot has at most this many parts. |
40
43
 
41
44
  ## MCP
42
45
 
43
- Tools went from eight to fifteen: `snapshot_health`, `snapshot_plan_for`, `snapshot_query`,
44
- `snapshot_context`, `snapshot_symbol`, `snapshot_diff_context`, `snapshot_review` joined the original
45
- eight. Prompts went from two (`orient`, `keep-current`) to seven (`audit`, `review`, `explain`,
46
- `onboard`, `security-review` were added). Resources gained `snapshot://prompt` and the three opt-in
47
- reports.
46
+ Tools went from eight to **26**: health, budget, history, tests, workspace, entrypoints,
47
+ neighbors, routes, cycles, search, stats, review, diff_context, symbol, context, query,
48
+ plan_for, answer, plan, generate, validate, locate, dependents, read, explain and status.
49
+ Prompts went from two (`orient`, `keep-current`) to seven (`audit`, `review`, `explain`,
50
+ `onboard`, `security-review` were added). Resources gained `snapshot://prompt` and the three
51
+ opt-in reports.
48
52
 
49
- Transports: stdio is still the default. `--http` adds Streamable HTTP with a bearer token and a
50
- loopback bind; `--no-auth` is refused on a non-loopback bind. The page and the MCP endpoint can share
53
+ stdio is still the default. `--http` adds Streamable HTTP with a bearer token and a loopback
54
+ bind; `--no-auth` is refused on a non-loopback bind. The page and the MCP endpoint can share
51
55
  one port with `serve`.
52
56
 
53
- ## Two behaviour changes
57
+ ## 0.18.0 to 0.20.12: what changed
54
58
 
55
- 1. **`validate` accepts `--include-diffs`, `--include-logs` and `--token-tree`** (0.12.28). Those
56
- flags change the artifact selection the manifest records, so passing them is required to compare
57
- like with like. Before, a snapshot generated with one of them reported a selection mismatch.
58
- 2. **npm publishes only at `x.y.0`** (0.12.16 onward). Every patch is committed, tagged and pushed;
59
- the registry carries `0.13.0`, `0.14.0`, … so `latest` stays a milestone rather than a patch. If
60
- you pin an exact patch version, install from the git tag or build from source until the next
61
- minor.
62
-
63
- ## What changed after 0.12.x
64
-
65
- The line from `0.13.0` to `0.17.0` added checks and two tools; it removed nothing. What a reader
66
- upgrading across those milestones should know:
67
-
68
- | Change | Since | Why it matters to you |
59
+ | Change | Since | Why it matters |
69
60
  | :--- | :--- | :--- |
70
- | The audit verifies bodies and counts | 0.13.6-0.13.7 | A snapshot whose parts disagree with its manifest now scores below 100 — correctly. Regenerate if a hand-edited snapshot fails. |
71
- | Single-file packs are audited | 0.13.9-0.13.10 | JSON, XML and markdown packs must hold exactly the manifest's files. |
72
- | `GET /metrics` on the HTTP transport | 0.13.3 | Prometheus text: request totals, per-method counts, refusals, rate limits. No path or credential is a label. |
73
- | `--only` / `--ignore` | 0.14.6 | One-run narrowing without editing a config. Both enter the digest, so `validate` takes them too. |
74
- | `reports/selection.md` | 0.15.3 | Written for `--slice` and `--budget-tokens`; it is a recorded artifact, so editing it is drift. |
75
- | `snapshot_budget` | 0.15.2 | The planner at several budgets; the manifest also records `headroomTokens` and `nextInLine`. |
76
- | `snapshot_answer` | 0.15.5 | Question to cited, line-numbered windows in one call. |
77
- | 26 MCP tools | 0.15.5 | The tool count is documented and tested; a client that hard-coded 15 should read `tools/list`. |
78
-
79
- `validate` on a snapshot written by an older version still works: the new manifest keys are
61
+ | `snapshot update` and a corrected update cache | 0.18.0, 0.20.0 | The command bypasses the cache; a failed check is remembered for five minutes, not an hour. |
62
+ | `health` recognises its own redaction marker and scans parts per section | 0.18.2, 0.19.0 | A clean snapshot no longer scores 70 for leaks that do not exist. The remaining host-path warning is documentation examples, not a credential. |
63
+ | The audit verifies snapshot claims, not only hashes | 0.20.1, 0.20.2 | Artifact counts, bodies, packs and workspace indexes are recomputed; a hand-edited snapshot fails. |
64
+ | `health` skips a secret check in linear time | 0.20.3 | A large skipped-secret set no longer re-reads the snapshot per token. |
65
+ | Security hardening across CLI, scanner, redaction, MCP, serve and remote | 0.20.4-0.20.12 | CodeQL, audit and live-verdict findings: path confinement, redaction continuations, rate limiting, 413 flushing, part-size caps, IPv6 remote parsing, git/walk parity and clone cleanup. |
66
+
67
+ ## Behaviour changes to know
68
+
69
+ 1. **`validate` accepts `--include-diffs`, `--include-logs` and `--token-tree`** (0.12.28).
70
+ Those flags change the artifact selection the manifest records, so pass the same flags to
71
+ compare like with like.
72
+ 2. **The 0.20 line is published in place.** Every 0.20.x patch is committed, tagged and may be
73
+ published; earlier lines published only at `x.y.0`. Pin an exact version when the same build
74
+ must run everywhere.
75
+ 3. **The 0.20.12 HTTP/MCP limits are stricter.** Empty JSON-RPC batches are invalid, oversized
76
+ bodies return 413 before the socket closes, and content tools refuse a part above 16 MiB.
77
+
78
+ `validate` on a snapshot written by an older version still works: newer manifest keys are
80
79
  optional, and an artifact the manifest does not record is not required to exist.
81
80
 
82
81
  ## If you are on an older 0.12.x
83
82
 
84
- Upgrade to the latest 0.12.x first; every change since 0.12.14 is a patch on the same line, and the
85
- configuration file format has not changed. Run `snapshot health` after the first generate on the new
86
- version — it is the fastest way to see whether an old snapshot carries anything the newer checks
87
- would refuse.
83
+ Upgrade to the latest 0.12.x first; every change since 0.12.14 is a patch on the same line, and
84
+ the configuration file format has not changed. Run `snapshot health` after the first generate on
85
+ the new version - it is the fastest way to see whether an old snapshot carries anything the
86
+ newer checks would refuse.
package/docs/output.md CHANGED
@@ -335,7 +335,8 @@ Reasons, and what each one means:
335
335
  | `reason` | The file was dropped because |
336
336
  | :--- | :--- |
337
337
  | `excluded` | It matched your own `excludePatterns`, or fell outside a non-empty `include` allow-list. |
338
- | `default-ignore` | A built-in rule caught it, the preset's ecosystem ignores did (`node_modules`, `__pycache__`, `target`, …), or it sat inside an output directory. |
338
+ | `default-ignore` | A built-in rule caught it, or the preset's ecosystem ignores did (`node_modules`, `__pycache__`, `target`, …). |
339
+ | `tool-output` | The path sits under a directory carrying a complete .codebase-snapshot marker. It is a prior snapshot, recorded rather than silently dropped; the configured outDir/tmpDir for this run is silent bookkeeping and never appears here. |
339
340
  | `sensitive-file` | Its name is credential-bearing (`.env`, `*.pem`, `.npmrc`, …). |
340
341
  | `sensitive-path` | The path itself matched a secret rule. The file is skipped and the path is masked in every artifact. |
341
342
  | `binary` | It is not text: it holds a NUL byte outside a UTF-16 stream, or more than 1% control characters (a 4 KB blob of `0x07` is valid UTF-8 but is not text). `detail` carries the size and, when there is one to give, the reason: the control-byte count (`Size: 13 B; 5 control byte(s)`), or the offset of a NUL found past the 8 MB head scan (`Size: 9000010 B; NUL byte at offset 9000000`). A NUL inside the head scan is caught by the cheap extension-and-prefix check, so its `detail` is the size alone. |
@@ -33,10 +33,11 @@ untrusted input can arrive.
33
33
  - **A symlink is only a second name for included content.** The target must survive the same
34
34
  include/exclude/ignore filters as the link alias; `.git/config` cannot be reached through a
35
35
  tracked `notes.txt`.
36
- - **Every snapshot file read is confined.** PROMPT.md, reports, the manifest and WORKSPACE.json
37
- are opened through one reader that refuses a symlink and requires the canonical target inside
38
- the snapshot directory. The MCP resources, `snapshot_history`, `snapshot_workspace` and
39
- `serve` use it; the part reader keeps its older equivalent.
36
+ - **Every snapshot file read is confined.** PROMPT.md, reports, the manifest, WORKSPACE.json and
37
+ signature.json are opened through one reader that refuses a symlink and requires the canonical
38
+ target inside the snapshot directory. The MCP resources, `snapshot_history`,
39
+ `snapshot_workspace`, signing verification and `serve` use it; a part lookup also requires its
40
+ `parts/` directory and the resolved part to stay inside the snapshot.
40
41
  - **The diff report fails closed.** Git is forced to emit unquoted ASCII prefixes, a section that
41
42
  cannot be attributed to a path is omitted rather than trusted, redaction runs before truncation
42
43
  with the diffed file's extension, and `--only` applies to the diff too.
@@ -60,8 +61,9 @@ executable config in it is refused, because a fetched repository is not a truste
60
61
  and at most four MCP tool calls in flight across all HTTP sessions. The session and rate maps are
61
62
  capped and evicted, so a client cannot grow either without bound.
62
63
  - **Untrusted regexes are bounded.** `snapshot_search`, `snapshot_routes` and `snapshot_query`
63
- reject nested quantifiers, more than one unbounded repetition and oversized repetition bounds
64
- before compiling; JavaScript has no regex timeout, so the alternative is a main-thread stall.
64
+ reject nested quantifiers, more than one unbounded repetition, optional-chain blowups and
65
+ backreferences before compiling; glob and gitignore patterns are bounded by wildcard, brace and
66
+ alternative counts. JavaScript has no regex timeout, so the alternative is a main-thread stall.
65
67
  - **Errors are JSON-RPC error objects**, never stack traces.
66
68
 
67
69
  ### The browser page
@@ -69,7 +71,8 @@ executable config in it is refused, because a fetched repository is not a truste
69
71
  - The page is HTML and is served without a token; **every API call requires one**. The token is not
70
72
  baked into the HTML, so serving `/` cannot leak it.
71
73
  - A request with a cross-origin `Origin` is refused before any auth check.
72
- - `api/snapshot.zip` only zips a directory that contains a manifest or an ownership marker.
74
+ - `api/snapshot.zip` zips only the parts, artifacts and signature the manifest declares; a
75
+ directory with a PWA `manifest.json` and an arbitrary file is refused.
73
76
  - Every path is resolved with `realpath` before the allowed-root check, so a symlink inside the
74
77
  served directory cannot read or zip a target outside it. `POST /api/generate` applies the same
75
78
  check to its local source and to the `outDir` it is about to write; a remote clone's
@@ -111,7 +114,7 @@ to treat file content as data. This is a real, documented limitation, not a solv
111
114
 
112
115
  ## What changed since this review was written
113
116
 
114
- The review was written at 0.12.34. Between then and 0.17.0 the surfaces it covers grew; each
117
+ The review was written at 0.12.34. Between then and 0.20.12 the surfaces it covers grew; each
115
118
  addition was reviewed with the same question — what new input arrives, and what does it reach?
116
119
 
117
120
  - **`GET /metrics`** (0.13.3) publishes counters with a fixed label set. Repo paths, tokens and
@@ -132,6 +135,29 @@ addition was reviewed with the same question — what new input arrives, and wha
132
135
  catastrophic MCP regexes are refused before compilation, HTTP tool concurrency is bounded,
133
136
  failed clones are removed, workspace dry runs write nothing, staged validation reads the index,
134
137
  and hook installation refuses a symlink or hard link.
138
+ - **The 0.20.10 third audit** closed the remaining gaps: parts-directory and configured
139
+ `outDir`/`tmpDir` escapes are refused; WORKSPACE/signature reads are confined; PEM quote
140
+ tracking, template literals, YAML block scalars, Dockerfile variants and diff prefixes are
141
+ redacted; optional-quantifier and backreference ReDoS and exponential globs are refused;
142
+ MCP era probes, CORS session exposure, whole-response caps, explicit false overrides and an
143
+ empty-first-line read are fixed; validation distinguishes replaced files and skipped paths from
144
+ drift; MCP runs health/validate/review/explain in a worker, and `serve` zips only manifest
145
+ inventory and runs its health audit and remote clone without blocking request handling.
146
+ - **The 0.20.11 fourth audit** closed cross-path twins: a nested ownership marker is recorded
147
+ as `tool-output` instead of vanishing; Dockerfile redaction is re-scan idempotent; quoted
148
+ credentials and unterminated PEM bodies have no length/prefix blind spot; alternation and glob
149
+ branch budgets bound the event loop; workspace members inherit every generation flag;
150
+ `validate` agrees with `--skip-artifacts parts`; HTTP batches are charged per message and
151
+ batched `initialize` mints a session; `snapshot_symbol` is bounded; explicit false overrides
152
+ reach validation; `..notes.ts` is accepted at the segment boundary; `health --all-members`
153
+ confines the index and members; `serve` rejects non-HTTP loopback origins and records nested
154
+ repository roots; and report fences grow with their content.
155
+ - **The 0.20.12 live verdict** executed the fourth audit's hypotheses against the built CLI: HTTP
156
+ envelopes are charged before parsing and empty batches are invalid; Dockerfile continuations
157
+ are masked before per-line rules; content tools refuse parts above 16 MiB; `serve` answers 404
158
+ for a missing local source and cleans an in-flight clone on close; IPv6 remote literals parse;
159
+ `**` counts as one wildcard and brace products are bounded; and the describe contract, tool
160
+ annotations and documentation statements were corrected where the source disagreed.
135
161
 
136
162
  The residual risks below are unchanged, including the two that are deliberate rather than solved.
137
163
 
@@ -148,6 +174,7 @@ The residual risks below are unchanged, including the two that are deliberate ra
148
174
  | Serve: page without token, API with token, zip restricted | `tests/web-serve.test.js` |
149
175
  | Signature: tamper detected | `tests/signing.test.js` |
150
176
  | Second 0.20 audit: symlink targets, auth case, diff quoting, brief headings, ReDoS, HTTP cap, workspace dry run, staged validation, hook links | `tests/audit-0-20-5-ultimate.test.js` |
177
+ | Fourth 0.20 audit: marker visibility, Dockerfile re-scan, long quoted secrets, unterminated PEM, alternation/glob budgets, workspace flags, skip-parts validation, HTTP batching, symbol cap, false overrides, `..notes.ts`, CLI workspace confinement, serve origin/fences | `tests/audit-0-20-11-followup.test.js` |
151
178
 
152
179
  ## Residual risks, stated
153
180
 
@@ -31,11 +31,11 @@ If you want to paste a repo into a chat right now: **use gitingest.**
31
31
  | Excluded-file accounting | Every skipped path recorded with a reason | Ignore rules applied |
32
32
  | Secret redaction | 32 default rules, value-span masking, audit table | Relies on ignore rules |
33
33
  | Runtime | Node.js | Python |
34
- | Repo URL input | No — needs a checkout | **Yes** |
34
+ | Repo URL input | **Yes** — `generate --remote` (Node + git; `file://` needs `--allow-private`) | **Yes** — zero install |
35
35
 
36
36
  ## Where gitingest is the better choice
37
37
 
38
- - **You have not installed anything and do not want to.** Nothing here competes with a URL box.
38
+ - **You have not installed anything and do not want to.** This tool needs Node and git, so a hosted URL box is still the shortest path.
39
39
  - **You want one digest, not parts.** If the destination is a chat window, one blob is the right
40
40
  shape.
41
41
  - **You are in Python.** `pip install gitingest` fits an existing pipeline without adding a Node