codebase-snapshot 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-D_mUjgXw.cjs';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-BK4uJx7Z.cjs';
2
2
  import { Readable, Writable } from 'node:stream';
3
3
 
4
4
  /**
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-D_mUjgXw.js';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-BK4uJx7Z.js';
2
2
  import { Readable, Writable } from 'node:stream';
3
3
 
4
4
  /**
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-4H7MSW64.js';
2
- export { generateInWorker } from './chunk-EP7OCPUM.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-5EYBTBFY.js';
2
+ export { generateInWorker } from './chunk-5AV7OR3J.js';
@@ -42,9 +42,11 @@ interface SourceSummary {
42
42
  /**
43
43
  * Which module system's exports are recorded here.
44
44
  *
45
- * Absent means the file had no exports at all. `cjs` means the names came from
46
- * `module.exports`/`exports.*` — a shape the ES-module walk used to miss entirely, leaving a
47
- * CommonJS module's public surface empty in the manifest.
45
+ * Absent means the file had no exports at all — no ES `export` and no
46
+ * `module.exports`/`exports.*`. `esm` means every name came from an ES `export`;
47
+ * `cjs` means they came from `module.exports`/`exports.*` — a shape the ES-module walk used to
48
+ * miss entirely, leaving a CommonJS module's public surface empty in the manifest; `mixed`
49
+ * means both kinds are present.
48
50
  */
49
51
  exportsKind?: "esm" | "cjs" | "mixed";
50
52
  }
@@ -325,10 +327,19 @@ interface ManifestIndexes {
325
327
  files: number;
326
328
  }>;
327
329
  imports: {
330
+ /**
331
+ * One entry per file whose import edges are known.
332
+ *
333
+ * A previewed or oversized file has no structural summary, but its import specifiers are
334
+ * still extracted — they are what makes it a dependent — so it appears here. Its
335
+ * `exports` list was never read, and `exportsOmitted` says so instead of leaving an empty
336
+ * array that reads as "this file exports nothing".
337
+ */
328
338
  byFile: Array<{
329
339
  path: string;
330
340
  imports: string[];
331
341
  exports: string[];
342
+ exportsOmitted?: true;
332
343
  }>;
333
344
  centralFiles: Array<{
334
345
  path: string;
@@ -387,12 +398,22 @@ type TruncationReason = "large-file-budget" | "part-budget" | "section-metadata"
387
398
  /** One file the snapshot does not contain in full, and what was left out of it. */
388
399
  interface IncompleteFile {
389
400
  relativePath: string;
401
+ /** The part this file was written to, so the omission can be found on disk. */
390
402
  part: string;
391
403
  reason: TruncationReason;
392
404
  /** 1-based, inclusive. Sorted and non-overlapping. */
393
405
  omittedRanges: Array<[number, number]>;
406
+ /** Source lines the ranges cover — the sum of their lengths. */
394
407
  omittedLines: number;
408
+ /**
409
+ * Lines in the emitted block, **including an omission notice line when one is written**.
410
+ *
411
+ * It counts what the fenced block holds, not the source lines that survived, so a preview
412
+ * records head + tail + the notice. `includedLines + omittedLines` is therefore not `lines`
413
+ * and no consumer should expect it to be.
414
+ */
395
415
  includedLines: number;
416
+ /** Lines in the source file. */
396
417
  lines: number;
397
418
  }
398
419
  interface Manifest {
@@ -549,8 +570,18 @@ interface SnapshotConfig {
549
570
  previewTailLines?: number;
550
571
  includeMonolith?: boolean;
551
572
  maxMonolithBytes?: ByteSize | null;
552
- /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/credential files. Default false. */
573
+ /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
553
574
  includeSensitiveFiles?: boolean;
575
+ /**
576
+ * How files are discovered; `auto` picks git when it can list files and walks the tree
577
+ * otherwise.
578
+ *
579
+ * Present here because this is the type a user writes against — `defineConfig` and
580
+ * `resolveConfig` both take it — and it was missing while `ResolvedSnapshotConfig`,
581
+ * `CliOptions` and `CONFIG_KEYS` all carried it. A TypeScript config containing
582
+ * `discovery: "walk"` was TS2353 in exactly the format `init` recommends.
583
+ */
584
+ discovery?: DiscoveryMode;
554
585
  /** Allow-list of globs. When non-empty, only matching files are included. */
555
586
  include?: string[];
556
587
  /** Force a preset by name instead of auto-detecting one. */
@@ -42,9 +42,11 @@ interface SourceSummary {
42
42
  /**
43
43
  * Which module system's exports are recorded here.
44
44
  *
45
- * Absent means the file had no exports at all. `cjs` means the names came from
46
- * `module.exports`/`exports.*` — a shape the ES-module walk used to miss entirely, leaving a
47
- * CommonJS module's public surface empty in the manifest.
45
+ * Absent means the file had no exports at all — no ES `export` and no
46
+ * `module.exports`/`exports.*`. `esm` means every name came from an ES `export`;
47
+ * `cjs` means they came from `module.exports`/`exports.*` — a shape the ES-module walk used to
48
+ * miss entirely, leaving a CommonJS module's public surface empty in the manifest; `mixed`
49
+ * means both kinds are present.
48
50
  */
49
51
  exportsKind?: "esm" | "cjs" | "mixed";
50
52
  }
@@ -325,10 +327,19 @@ interface ManifestIndexes {
325
327
  files: number;
326
328
  }>;
327
329
  imports: {
330
+ /**
331
+ * One entry per file whose import edges are known.
332
+ *
333
+ * A previewed or oversized file has no structural summary, but its import specifiers are
334
+ * still extracted — they are what makes it a dependent — so it appears here. Its
335
+ * `exports` list was never read, and `exportsOmitted` says so instead of leaving an empty
336
+ * array that reads as "this file exports nothing".
337
+ */
328
338
  byFile: Array<{
329
339
  path: string;
330
340
  imports: string[];
331
341
  exports: string[];
342
+ exportsOmitted?: true;
332
343
  }>;
333
344
  centralFiles: Array<{
334
345
  path: string;
@@ -387,12 +398,22 @@ type TruncationReason = "large-file-budget" | "part-budget" | "section-metadata"
387
398
  /** One file the snapshot does not contain in full, and what was left out of it. */
388
399
  interface IncompleteFile {
389
400
  relativePath: string;
401
+ /** The part this file was written to, so the omission can be found on disk. */
390
402
  part: string;
391
403
  reason: TruncationReason;
392
404
  /** 1-based, inclusive. Sorted and non-overlapping. */
393
405
  omittedRanges: Array<[number, number]>;
406
+ /** Source lines the ranges cover — the sum of their lengths. */
394
407
  omittedLines: number;
408
+ /**
409
+ * Lines in the emitted block, **including an omission notice line when one is written**.
410
+ *
411
+ * It counts what the fenced block holds, not the source lines that survived, so a preview
412
+ * records head + tail + the notice. `includedLines + omittedLines` is therefore not `lines`
413
+ * and no consumer should expect it to be.
414
+ */
395
415
  includedLines: number;
416
+ /** Lines in the source file. */
396
417
  lines: number;
397
418
  }
398
419
  interface Manifest {
@@ -549,8 +570,18 @@ interface SnapshotConfig {
549
570
  previewTailLines?: number;
550
571
  includeMonolith?: boolean;
551
572
  maxMonolithBytes?: ByteSize | null;
552
- /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/credential files. Default false. */
573
+ /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
553
574
  includeSensitiveFiles?: boolean;
575
+ /**
576
+ * How files are discovered; `auto` picks git when it can list files and walks the tree
577
+ * otherwise.
578
+ *
579
+ * Present here because this is the type a user writes against — `defineConfig` and
580
+ * `resolveConfig` both take it — and it was missing while `ResolvedSnapshotConfig`,
581
+ * `CliOptions` and `CONFIG_KEYS` all carried it. A TypeScript config containing
582
+ * `discovery: "walk"` was TS2353 in exactly the format `init` recommends.
583
+ */
584
+ discovery?: DiscoveryMode;
554
585
  /** Allow-list of globs. When non-empty, only matching files are included. */
555
586
  include?: string[];
556
587
  /** Force a preset by name instead of auto-detecting one. */
package/docs/cli.md CHANGED
@@ -97,10 +97,10 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
97
97
 
98
98
  ```
99
99
  📸 Generating snapshot for: /path/to/repo
100
- Branch: main | Part budget: 300 KB | Generator: 0.10.0 (project dependency ^0.10.0)
100
+ Branch: main | Part budget: 300 KB | Generator: 0.10.2 (project dependency ^0.10.2)
101
101
 
102
102
  ✅ Snapshot generated in 0.14s:
103
- - Tracked files: 121 included of 128 found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
103
+ - 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
104
104
  - Total lines: 9,431
105
105
  - Total size: 0.41 MB
106
106
  - Parts written: 3 under snapshot/parts/
@@ -141,6 +141,14 @@ filesystem-permission problem. It is a class of its own because the fix is diffe
141
141
  as "deleted" sent the reader looking for a file that is still there. Text mode lists each path
142
142
  as `unreadable: <path>`; `--format json` carries them in `drift.unreadable`.
143
143
 
144
+ It also verifies the **completeness contract**: `incomplete[]` is checked against `files[]` entry by
145
+ entry (same part, same reason, same ranges, same line counts), `counts.incompleteCount` against the
146
+ length of the list, and every `omittedRanges` pair against the file's own line count. A manifest is
147
+ an input — `generate` proves this contract when it writes one, but once the file is on disk nothing
148
+ else re-derives it — so a hand-edited or foreign `manifest.json` is refused here rather than
149
+ reported as current. The shape guard also confines `incomplete[].relativePath` to the repository,
150
+ like the two other path-bearing arrays.
151
+
144
152
  Exit `0` when the snapshot is current, `1` on any drift. It never writes anything.
145
153
 
146
154
  ### `report`
@@ -183,8 +191,8 @@ The whole first run in one command, with defaults and no prompts. This is the sa
183
191
  🚀 Setup for: /path/to/repo
184
192
  ✅ Created snapshot.config.ts (preset: nextjs)
185
193
  Added npm scripts: snapshot, snapshot:validate
186
- Added devDependency: codebase-snapshot ^0.10.0
187
- Added to .gitignore: snapshot/, snapshot.tmp/
194
+ Added devDependency: codebase-snapshot ^0.10.2
195
+ Added to .gitignore: /snapshot/, /snapshot.tmp/
188
196
  ⏳ Installing dependencies…
189
197
  ✅ Installed dependencies (npm install, 2.1s)
190
198
  ✅ Snapshot generated in 0.16s:
@@ -235,8 +243,8 @@ It also has three side effects on files you own, and it says so when it does the
235
243
  ```
236
244
  ✅ Created snapshot.config.ts (preset: node-lib)
237
245
  Added npm scripts: snapshot, snapshot:validate
238
- Added devDependency: codebase-snapshot ^0.10.0
239
- Added to .gitignore: snapshot/, snapshot.tmp/
246
+ Added devDependency: codebase-snapshot ^0.10.2
247
+ Added to .gitignore: /snapshot/, /snapshot.tmp/
240
248
  ```
241
249
 
242
250
  - `scripts.snapshot` and `scripts.snapshot:validate` are added to `package.json` if those keys
@@ -246,7 +254,9 @@ It also has three side effects on files you own, and it says so when it does the
246
254
  declares it yet. That is what puts a real copy in `node_modules` and stops `npm run
247
255
  snapshot` from resolving `@latest` out of the registry on every run. A range you already
248
256
  declared — including a pin to an older version — is never overwritten.
249
- - `snapshot/` and `snapshot.tmp/` are appended to `.gitignore` if they are not already listed;
257
+ - `/<outDir>/` and `/<tmpDir>/` are appended to `.gitignore` if they are not already listed —
258
+ anchored at the repository root, and naming the directories the config actually uses, so
259
+ `--out-dir .context` ignores `/.context/` rather than `/snapshot/`;
250
260
  the file is created if missing, and entries already present are not duplicated.
251
261
 
252
262
  ### Going back
@@ -322,7 +332,7 @@ With `--format json` the same answer is one object on stdout, with only the keys
322
332
  | `layerMatch`, `kindMatch` | Which rule chose the layer or kind. A glob is printed as written (`src/api/**`); a `RegExp` as its literal form (`/\.tsx$/i`); a function matcher, which is what the presets use, as `function (custom predicate)`. Absent when no rule matched and the `other` fallback was used. |
323
333
  | `bytes`, `lines` | Size of the file on disk. |
324
334
  | `encoding` | Present only when the file is not plain UTF-8 — `utf-16le`, `utf-16be` or `utf-8-lossy`. |
325
- | `secretCount`, `secrets` | How many secret rules fire, and the first 20 as `{ rule, line }` — never the matched text. |
335
+ | `secretCount`, `secrets` | How many secret rules fire, and the first 20 as `{ rules, line }` — `rules` is every rule that matched that line, never the matched text. |
326
336
  | `part` | The part filename from the last written manifest, or `null` when it is not in that snapshot. |
327
337
  | `inclusionMode` | `full` or `preview`, when a part entry exists. |
328
338
 
@@ -354,6 +364,17 @@ Manifests written before 4.0.5 have no `config.digest`. In that case `diff` comp
354
364
  content fingerprint and the part count only, and prints `configuration not compared: a
355
365
  manifest has no config digest (written before 4.0.5).` rather than implying the settings match.
356
366
 
367
+ In `--format json` each statement in `payload.reasons` has a stable `payload.codes` entry beside
368
+ it — `schema-version`, `config-digest`, `config-digest-missing`, `generator`, `fingerprint`,
369
+ `parts-count`, `layer-changed` — so a program can branch on what changed without matching English.
370
+
371
+ `diff` deliberately does **not** read the project configuration: it answers a question about two
372
+ files and importing a config would execute repository code to do it. The paths it prints are masked
373
+ with the built-in rules (the library form, `compareManifests(before, after, secretRules)`, takes
374
+ your resolved rules). A project-specific token that a manifest recorded *before* you declared it in
375
+ `secretRules` can therefore still appear in a comparison of that old manifest — regenerate it, and
376
+ every later manifest carries the masked path.
377
+
357
378
  ### `describe`
358
379
 
359
380
  ```bash
@@ -16,14 +16,17 @@ This repository, measured rather than estimated:
16
16
 
17
17
  | | |
18
18
  | :--- | ---: |
19
- | TypeScript files under `src/` | 57 |
20
- | Lines | 14,626 |
21
- | Bytes | 603,420 |
22
- | **Estimated tokens** | **≈ 165,000** |
23
-
24
- That single number decides the whole conversation. 165k tokens does not fit in an 8k window, it
25
- almost exactly fills a 200k window leaving nothing for the question or the answer, and it fits
26
- in a 1M window without effort.
19
+ | TypeScript files under `src/` | 88 |
20
+ | Lines | 28,992 |
21
+ | Bytes | 1,191,949 |
22
+ | **Estimated tokens** | **≈ 340,000** |
23
+
24
+ That single number decides the whole conversation. 340k tokens does not fit in an 8k window, it
25
+ does not fit a 200k window at all — it is the whole window and two thirds of another — and it fits
26
+ in a 1M window with room for the question. Measured on 2026-11-17 with `git ls-files src` plus the
27
+ tool's own `countLines`, over the files present that day. The count moves with every commit — the
28
+ order of magnitude does not, which is what the number is for; run `codebase-snapshot report` on a
29
+ snapshot of this repository to re-measure a checkout.
27
30
 
28
31
  ## What the default part budget means
29
32
 
@@ -61,7 +64,7 @@ budget of any single part.
61
64
 
62
65
  ## When the repository does not fit
63
66
 
64
- It usually does not. 165k tokens is a small library; a real application is five to twenty times
67
+ It usually does not. 340k tokens is a small library; a real application is five to twenty times
65
68
  that. In order of preference:
66
69
 
67
70
  1. **Scope the run, not the budget.** `include`/`exclude` patterns, or the wizard's "only
@@ -75,9 +78,10 @@ that. In order of preference:
75
78
  4. **Summarise once, in a separate session.** Ask the model for a map of the parts, then use that
76
79
  map to choose which parts to read in detail.
77
80
 
78
- What not to do: silently truncate. A snapshot never exceeds its budget — a file too large for
79
- the remaining space is cut with an explicit omission marker that names the budget, and above
80
- `largeFileBytes` it becomes a head/tail excerpt rather than a full body.
81
+ What not to do: silently truncate. A snapshot never exceeds its budget — a file that cannot fit
82
+ one part becomes a head/tail excerpt with an explicit omission marker, and above `largeFileBytes`
83
+ (which defaults to the budget and may not exceed it) that is the only route by which content is
84
+ dropped. `manifest.json` names every such file in `incomplete[]`.
81
85
 
82
86
  ## Checking your own number
83
87
 
@@ -277,7 +277,7 @@ makes an audit entry mean something.
277
277
  disable redaction itself, and it applies to **paths** as well as to content, so a
278
278
  credential-shaped file name is no longer skipped by a rule you switched off.
279
279
 
280
- Redaction is **fail-closed**, so a placeholder is indistinguishable from a secret: a
280
+ Redaction is **fail-closed**, so most placeholders are indistinguishable from secrets: a
281
281
  `.env.example` whose line reads `JWT_SECRET=replace-with-base64url-48-bytes` is masked like a
282
282
  live key would be, and a test fixture literal such as `process.env.X_SECRET = "test-value"` is
283
283
  masked too. That is the intended trade-off — the alternative is guessing which values are
@@ -285,7 +285,23 @@ throwaway — and it is worth knowing before you hand the snapshot to a model an
285
285
  less readable than the original. To narrow it, remove a rule by name with
286
286
  `disableDefaultPatterns: true` plus your own `customPatterns`.
287
287
 
288
- The one shape that is *not* masked is a value that is a single `${…}` reference and nothing else —
288
+ The exception is a **whole value** that is one of the conventional placeholder shapes. The list
289
+ is exhaustive and lives in `PLACEHOLDER_PATTERNS` in `src/security/redact.ts`:
290
+
291
+ | Value is exactly… | Example that survives |
292
+ | :--- | :--- |
293
+ | `replace-me` / `change-me`, optionally followed by more words | `replace-me-with-the-read-tier-key` |
294
+ | `your-…` / `your_…` | `your-api-key-here`, `your_api_key` |
295
+ | `example` / `sample`, optionally followed by more words | `example-token`, `sample-value` |
296
+ | a single `<…>` (the closing bracket may be missing) | `<fine-grained PAT>`, `<missing-bracket` |
297
+ | three or more dots | `...`, `sk-...` |
298
+ | four or more `x`, `X` or `*` | `xxxx`, `****` |
299
+
300
+ Everything else is masked, including `replace-with-…` — the rule keys on the `-me` — and any real
301
+ credential that merely contains the word "example". This list is the only exemption; there is no
302
+ entropy heuristic behind it.
303
+
304
+ A second shape that is *not* masked is a value that is a single `${…}` reference and nothing else —
289
305
  `password: "${DB_PASSWORD}"`, `` `${process.env.TOKEN}` `` — because that is an expression and
290
306
  masking it rewrites a program (or an assertion message) rather than hiding a credential. Anything
291
307
  inside the braces that is not a plain reference settles it the other way:
@@ -487,7 +503,7 @@ also what lets you reference the object (from a test, or from `--dry-run`) witho
487
503
  This is **not** byte-identical to a generated file. `codebase-snapshot init` starts from these
488
504
  values and substitutes two things: `preset` becomes the detected name (`node-lib` for a plain
489
505
  npm package), and `maxPartBytes` with `budgets.default` become that preset's
490
- `recommendedBudget` (`"120k"` in the same project). `generate` on its own applies no
506
+ `recommendedBudget` (`"300k"` for every preset). `generate` on its own applies no
491
507
  recommended budget — without a config it uses `--max-part-bytes`, default 307200 — so the
492
508
  preset's figure only takes effect once `init` has written it into a config.
493
509
 
@@ -23,6 +23,7 @@ window can take the largest.
23
23
  - **`maxPartBytes`** — the hard ceiling for one part. This is a promise, not an average: no part
24
24
  exceeds it. Set it to the destination's limit and stop worrying about the largest file.
25
25
  - **`largeFileBytes`** — above this, a file becomes a head/tail excerpt rather than its full body.
26
+ It defaults to `maxPartBytes` and may not be set above it.
26
27
  This is what stops one generated 40 MB file from consuming an entire snapshot.
27
28
  - **`budgets.byLayer`** — different ceilings per layer. Documentation is usually worth less per byte
28
29
  than source; `{ docs: 40_000 }` is a common shape.
@@ -72,7 +73,7 @@ before you spend it on a model call.
72
73
  1. Generate with a ceiling that matches the destination.
73
74
  2. Run `report`; look at the per-layer breakdown.
74
75
  3. Cut the largest layer that does not answer your question.
75
- 4. Re-generate and compare `manifest.totals.events` and the part count.
76
+ 4. Re-generate and compare `manifest.totals.emittedLines` and `manifest.counts.partsCount`.
76
77
  5. Keep the settings that produced a snapshot you actually used — the config is the durable artifact,
77
78
  not the output.
78
79
 
@@ -66,8 +66,9 @@ const config = {
66
66
  export default config;
67
67
  ```
68
68
 
69
- A file larger than the budget is not silently dropped: it is truncated with an explicit marker
70
- naming the budget, and files above `largeFileBytes` become a head/tail excerpt instead of a body.
69
+ A file is never cut down to make a part fit. A file above `largeFileBytes` — which defaults to the
70
+ budget — becomes a head/tail excerpt with an explicit marker, and `manifest.json` lists it in
71
+ `incomplete[]` with the line ranges it lost.
71
72
 
72
73
  ### 3. Tell the model what it is looking at
73
74
 
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.10.0 mcp
13
+ npx -y codebase-snapshot@0.10.2 mcp
14
14
  ```
15
15
 
16
16
  The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
25
25
  "mcpServers": {
26
26
  "codebase-snapshot": {
27
27
  "command": "npx",
28
- "args": ["-y", "codebase-snapshot@0.10.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.10.2", "mcp", "--cwd", "/absolute/path/to/repo"]
29
29
  }
30
30
  }
31
31
  }
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
34
34
  Claude Code registers the same thing from a shell:
35
35
 
36
36
  ```bash
37
- claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.10.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.10.2 mcp --cwd /absolute/path/to/repo
38
38
  ```
39
39
 
40
40
  On Windows, wrap the command as `cmd /c npx` with the same arguments — `npx` is a `.cmd` shim
@@ -101,7 +101,7 @@ Resources are the browse surface; tools are the act surface.
101
101
 
102
102
  | URI | Contents |
103
103
  | :-- | :-- |
104
- | `snapshot://manifest` | Every included file with layer, kind, part and hash, plus every skip reason |
104
+ | `snapshot://manifest` | Every included file with layer, kind, part and hash, every skip reason, and `incomplete[]` — the files whose body is not the whole file, with their missing line ranges |
105
105
  | `snapshot://parts/{index}` | One budgeted part, by 1-based index |
106
106
  | `snapshot://reports/audit` | Secret findings, large files, parse diagnostics |
107
107
  | `snapshot://reports/tree` | The directory tree of included files |
package/docs/output.md CHANGED
@@ -49,7 +49,7 @@ same persistently. The ownership marker is always written.
49
49
  ## Parts
50
50
 
51
51
  Each `part-NNN.md` holds whole files under the byte budget (`maxPartBytes`, default 300 KB).
52
- A file is never split mid-file, and a file is never cut down just to make the part fit:
52
+ A file is never split mid-file, and a complete file is never cut down just to make the part fit:
53
53
  `largeFileBytes` defaults to the part budget and may not exceed it, so a file too big for a part
54
54
  is also over the threshold, and the preview below applies.
55
55
 
@@ -112,7 +112,7 @@ diff the manifest only when you need to know that a run happened.
112
112
  | `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
113
113
  | `artifacts` | A digest of every artifact the run wrote: `readme`, `navigation`, `projectTree`, `audit`, `fullJson`, `fullMarkdown` and `sarif` when present, each `{ byteSize, sha256 }`. `validate` requires each recorded file to exist and match, so deleting the README or the navigation index is a failure rather than a silent omission. Monolith entries are `null` when the file was not written; a key absent for an older manifest is not drift. |
114
114
  | `layers`, `kinds` | File counts per layer and per kind. |
115
- | `indexes` | Cross-references: `routes`, `components`, `handlers`, `features`, `imports`, `directives`. |
115
+ | `indexes` | Cross-references: `routes`, `components`, `handlers`, `features`, `imports`, `directives`. `imports.byFile` holds one entry per file whose import edges are known — including a previewed or oversized file, whose specifiers are still extracted because they are what makes it a dependent. Such an entry has `exportsOmitted: true`: its `exports` list was never read, and an empty array there would claim "no exports". |
116
116
  | `parts` | One entry per part (below). |
117
117
  | `files` | One entry per included file (below). |
118
118
  | `skipped` | One entry per excluded file (below). Every scanned path appears in `files` or here: the generator asserts it, so a file cannot vanish between the two. |
@@ -186,10 +186,13 @@ has several at once, and "within budget" cannot be answered without knowing whic
186
186
  than inlined whole.
187
187
  - `isPreviewTruncated` is a fact about what was written: the body in this snapshot is **not**
188
188
  the whole file, because lines were dropped.
189
- - `includedLines` counts content lines after CRLF normalisation and without a trailing empty
190
- element, which is what the fenced block holds. An empty file therefore records `0` while the
191
- fence shows one empty line, and a file ending in a blank line records one fewer than a reader
192
- counts — the number describes content, not rendering.
189
+ - `includedLines` counts the lines of the fenced block: content lines after CRLF normalisation
190
+ and without a trailing empty element, **plus the omission notice when one is written**. An
191
+ empty file therefore records `0` while the fence shows one empty line, and a file ending in a
192
+ blank line records one fewer than a reader counts. A preview records head + tail + the notice
193
+ line — the block as written. It is not a count of surviving source content, which is why
194
+ `includedLines + omittedLines` is one more than `lines` for a preview and never a sum a reader
195
+ should reconcile.
193
196
  - `inclusionMode` is `preview` exactly when `isPreviewTruncated` is `true`. There used to be two
194
197
  routes to it, and the second — a file *under* `largeFileBytes` but too big for its part, cut
195
198
  by the partitioner with `isLarge: false` — is what made the manifest unreadable: it looked
@@ -49,12 +49,16 @@ codebase-snapshot validate
49
49
  ```
50
50
 
51
51
  ```text
52
- ✖ Snapshot does not match the repository:
53
- - modified: src/parser/partition.ts
54
- - added: src/presets/evidence.ts
55
- - removed: src/legacy/old-partitioner.ts
52
+ ❌ Snapshot validation failed:
53
+ - 1 file(s) have been modified since the snapshot was generated.
54
+ - modified: src/parser/partition.ts
55
+ - new file: src/presets/evidence.ts
56
+ - deleted: src/legacy/old-partitioner.ts
56
57
  ```
57
58
 
59
+ The first line is the count; the lines after it name each path. `new file` is a file on disk
60
+ the snapshot does not contain, and `deleted` is the opposite.
61
+
58
62
  That is the difference between a copy and an artefact. A copy is trusted; an artefact is
59
63
  checked.
60
64
 
@@ -75,6 +79,12 @@ checked.
75
79
  When an answer is wrong because the model never saw a file, this is the list that tells you
76
80
  whether the file was excluded on purpose or by accident.
77
81
 
82
+ The second half of the same question is a file that was included but not in full.
83
+ `manifest.incomplete[]` names every one of those with its `reason` — `large-file-budget`,
84
+ `part-budget` or `section-metadata` — and `omittedRanges`, the 1-based source lines that are
85
+ missing or partial. A server that only reports what it included is telling half the story; this
86
+ is the half that explains a confident answer about code the model never saw.
87
+
78
88
  ## Gate it
79
89
 
80
90
  The comparison is only a guard if something runs it. In CI, after whatever changes the tree:
@@ -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 | 31 defaults, value-span masking, audit table | Ignore rules |
33
+ | Secret handling | 32 defaults, value-span masking, audit table | Ignore rules |
34
34
 
35
35
  ## Where code2prompt is the better choice
36
36
 
@@ -42,8 +42,9 @@ If the prompt format is the thing you care about: **use code2prompt.**
42
42
 
43
43
  ## Where this is the better choice
44
44
 
45
- - **You need the output to fit a budget.** `maxPartBytes` is a ceiling: an oversized file is
46
- truncated with an omission marker naming the budget rather than silently blowing the limit.
45
+ - **You need the output to fit a budget.** `maxPartBytes` is a ceiling: a file that cannot fit one
46
+ part becomes a head/tail preview with an omission marker, listed in `incomplete[]` with the line
47
+ ranges it lost, rather than silently blowing the limit.
47
48
  - **You need to detect staleness.** `validate` compares every file hash plus a digest of the
48
49
  generation settings, so a changed budget counts as drift. Prompt generators generally have no
49
50
  concept of a snapshot that can expire.
@@ -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 | 31 default rules, value-span masking, audit table | Relies on ignore rules |
32
+ | Secret redaction | 32 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
 
@@ -50,9 +50,10 @@ If you want to paste a repo into a chat right now: **use gitingest.**
50
50
  `--no-update-check` or `CODEBASE_SNAPSHOT_NO_UPDATE_CHECK=1` disables it entirely (see
51
51
  [the update notice](cli.md#update-notice)). If the code is private enough that a hosted digest is
52
52
  not allowed, that settles it.
53
- - **You need a size guarantee.** A part either fits the budget or carries an explicit truncation
54
- marker naming the budget. A digest that grows with the repository eventually stops fitting, and
55
- discovering that at ingestion time is too late.
53
+ - **You need a size guarantee.** A part never exceeds the budget: a file that cannot fit one is a
54
+ head/tail preview with an explicit marker, listed in `incomplete[]` with its missing line ranges.
55
+ A digest that grows with the repository eventually stops fitting, and discovering that at
56
+ ingestion time is too late.
56
57
  - **You need to prove the context is current.** `validate` re-hashes the tree and compares a digest
57
58
  of the generation settings, so a stale snapshot fails instead of quietly misleading a model.
58
59
  - **You need the exclusions explained.** Every skipped path carries a reason — `binary`, `gitignore`,
@@ -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 | 31 default rules, value-span masking, per-line audit table | Secretlint integration |
33
+ | Secret handling | 32 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 |
@@ -57,8 +57,9 @@ If you want the most popular, most integrated tool: **use repomix.**
57
57
  ## Where this is the better choice
58
58
 
59
59
  - **You need a guarantee, not a best effort.** `maxPartBytes` promises no part exceeds the ceiling;
60
- a file too large is truncated with an explicit marker naming the budget. If a downstream system
61
- rejects payloads above a size, a warning is not enough.
60
+ a file that cannot fit one part is a head/tail preview with an explicit marker, and the manifest
61
+ lists it in `incomplete[]` with the line ranges it lost. If a downstream system rejects payloads
62
+ above a size, a warning is not enough.
62
63
  - **You need to know the snapshot still matches the code.** `validate` compares every file hash
63
64
  *and* a digest of the settings the snapshot was generated with, so a changed budget or secret
64
65
  pattern counts as drift. That makes "is my context current?" a CI-gateable question.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
5
5
  "keywords": [
6
6
  "codebase-snapshot",