codebase-snapshot 0.9.18 → 0.10.1

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.
@@ -144,6 +144,23 @@ interface FileEntry {
144
144
  inclusionMode: InclusionMode;
145
145
  isLarge: boolean;
146
146
  isPreviewTruncated: boolean;
147
+ /**
148
+ * Why the emitted body is shorter than the file on disk. Absent when nothing was dropped.
149
+ *
150
+ * `inclusionMode: "preview"` alone could mean "this file is large, so a head/tail preview is
151
+ * the policy" or "the partitioner cut it to fit a part", and `isLarge: false` beside
152
+ * `isPreviewTruncated: true` told a reader neither — the manifest recorded a preview-by-policy
153
+ * for a file whose missing 57 % nobody could find.
154
+ */
155
+ truncationReason?: TruncationReason;
156
+ /**
157
+ * 1-based, inclusive source line ranges that are not in the snapshot **in full**.
158
+ *
159
+ * A byte cut can end inside a line, which leaves that one line partly present; it is named
160
+ * here rather than omitted, because a range list that stays empty while bytes are missing
161
+ * would be the same silence this field exists to end.
162
+ */
163
+ omittedRanges?: Array<[number, number]>;
147
164
  /** Line count of the file on disk. */
148
165
  originalLines: number;
149
166
  /** Lines actually emitted into the snapshot. */
@@ -153,8 +170,13 @@ interface FileEntry {
153
170
  summary?: SourceSummary | JsonSummary | MarkdownSummary;
154
171
  /** How the summary was produced. Absent when there is no summary. */
155
172
  summaryQuality?: SummaryQuality;
156
- /** True when the summary alone was too large for the part budget and was dropped. */
173
+ /**
174
+ * True when a summary was not emitted for a size reason, rather than being unavailable for a
175
+ * language with no profile.
176
+ */
157
177
  summaryOmitted?: boolean;
178
+ /** Which size rule removed it. Present exactly when `summaryOmitted` is true. */
179
+ summaryOmittedReason?: "oversize" | "preview" | "part-budget";
158
180
  /**
159
181
  * How the file's bytes were decoded. Absent means plain UTF-8. Present when the file was
160
182
  * transcoded from UTF-16, or when it was not valid UTF-8 and lost bytes to U+FFFD.
@@ -360,6 +382,19 @@ interface ManifestConfigSnapshot {
360
382
  layers: string[];
361
383
  kinds: string[];
362
384
  }
385
+ /** Why a file's emitted body is shorter than the file itself. */
386
+ type TruncationReason = "large-file-budget" | "part-budget" | "section-metadata";
387
+ /** One file the snapshot does not contain in full, and what was left out of it. */
388
+ interface IncompleteFile {
389
+ relativePath: string;
390
+ part: string;
391
+ reason: TruncationReason;
392
+ /** 1-based, inclusive. Sorted and non-overlapping. */
393
+ omittedRanges: Array<[number, number]>;
394
+ omittedLines: number;
395
+ includedLines: number;
396
+ lines: number;
397
+ }
363
398
  interface Manifest {
364
399
  schemaVersion: string;
365
400
  generatedAt: string;
@@ -393,6 +428,8 @@ interface Manifest {
393
428
  skippedCount: number;
394
429
  largeFileCount: number;
395
430
  truncatedPreviewCount: number;
431
+ /** Length of `incomplete`; the number a run summary has to be able to quote. */
432
+ incompleteCount: number;
396
433
  };
397
434
  totals: ManifestTotals;
398
435
  fingerprint: string;
@@ -429,6 +466,15 @@ interface Manifest {
429
466
  parts: PartMetadata[];
430
467
  files: FileEntry[];
431
468
  skipped: SkipRecord[];
469
+ /**
470
+ * Every included file whose emitted body is not the whole file.
471
+ *
472
+ * The same statement lives in `files[]`; this list exists so a consumer can ask "was anything
473
+ * lost?" without filtering four hundred entries, and so an omission cannot hide behind an
474
+ * `inclusionMode` that reads like policy. Empty is the normal case and is written as an empty
475
+ * array rather than omitted, because "no key" and "nothing lost" must not look alike.
476
+ */
477
+ incomplete: IncompleteFile[];
432
478
  warnings: string[];
433
479
  }
434
480
  interface LayerRule {
@@ -661,4 +707,4 @@ interface ValidationResult {
661
707
  warnings: string[];
662
708
  }
663
709
 
664
- export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SecretRule as S, TextEncoding as T, ValidationResult as V, SkipRecord as a, SourceSummary as b, SnapshotConfig as c, SecretFinding as d, Manifest as e, BudgetConfig as f, ManifestArtifact as g, ManifestConfigSnapshot as h, ManifestIndexes as i, ManifestTotals as j, Mode as k, PartFileEntry as l, ResolvedArtifacts as m, ResolvedBudgets as n, SecretRuleInput as o, SkipReason as p, SummaryQuality as q, ValidationDrift as r };
710
+ export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SecretRule as S, TextEncoding as T, ValidationResult as V, SkipRecord as a, SourceSummary as b, SnapshotConfig as c, SecretFinding as d, Manifest as e, BudgetConfig as f, IncompleteFile as g, ManifestArtifact as h, ManifestConfigSnapshot as i, ManifestIndexes as j, ManifestTotals as k, Mode as l, PartFileEntry as m, ResolvedArtifacts as n, ResolvedBudgets as o, SecretRuleInput as p, SkipReason as q, SummaryQuality as r, TruncationReason as s, ValidationDrift as t };
package/docs/agent.md CHANGED
@@ -166,6 +166,8 @@ When you parse the manifest, remember what is conditional: `manifest.files[]` ca
166
166
  `relativePath`, `layer`, `kind`, `language`, `part`, `inclusionMode` and `hashSha256` for
167
167
  every included file, but `summary` and `summaryQuality` only for a language the tool can
168
168
  analyse. A `.gitignore` or plain-text entry has neither key, and a file whose summary was too
169
- large for its part carries `summaryOmitted: true` instead of a `summary`. `encoding` appears only
169
+ large for its part carries `summaryOmitted: true` (with `summaryOmittedReason`) instead of a
170
+ `summary`. `manifest.incomplete[]` is the list of files whose body is not the whole file, with
171
+ `truncationReason` and `omittedRanges`; `files[]` carries the same two fields. `encoding` appears only
170
172
  when a file was not plain UTF-8: `utf-16le`/`utf-16be` were transcoded, and `utf-8-lossy` means
171
173
  the body you are reading contains `U+FFFD` where undecodable bytes were.
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
100
+ Branch: main | Part budget: 300 KB | Generator: 0.10.1 (project dependency ^0.10.1)
101
101
 
102
102
  ✅ Snapshot generated in 0.14s:
103
- - Tracked files: 128
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
104
104
  - Total lines: 9,431
105
105
  - Total size: 0.41 MB
106
106
  - Parts written: 3 under snapshot/parts/
@@ -183,18 +183,21 @@ The whole first run in one command, with defaults and no prompts. This is the sa
183
183
  🚀 Setup for: /path/to/repo
184
184
  ✅ Created snapshot.config.ts (preset: nextjs)
185
185
  Added npm scripts: snapshot, snapshot:validate
186
- Added devDependency: codebase-snapshot ^0.9.18
186
+ Added devDependency: codebase-snapshot ^0.10.1
187
187
  Added to .gitignore: snapshot/, snapshot.tmp/
188
188
  ⏳ Installing dependencies…
189
189
  ✅ Installed dependencies (npm install, 2.1s)
190
190
  ✅ Snapshot generated in 0.16s:
191
- - Tracked files: 128
191
+ - Tracked files: 121 included of 128 found — 7 skipped (binary 6, sensitive-file 1)
192
192
  …
193
193
  Next: npm run snapshot
194
194
  ```
195
195
 
196
196
  - `--no-install` skips step 4 — CI, an offline machine, or a lockfile you would rather no package
197
197
  manager touched.
198
+ - A directory with no `package.json` is not a package, so step 4 is skipped there too and says
199
+ so. There is no dependency to add, and running the package manager anyway used to leave an
200
+ empty `package-lock.json` at the repository root.
198
201
  - `--dry-run` prints the plan and the config it would write, and writes nothing — including the
199
202
  `.git/hooks/pre-commit` that `--install-hook` would otherwise install.
200
203
  - `--force` rewrites an existing config; `--preset`, `--include`, `--exclude`, `--out-dir`,
@@ -232,7 +235,7 @@ It also has three side effects on files you own, and it says so when it does the
232
235
  ```
233
236
  ✅ Created snapshot.config.ts (preset: node-lib)
234
237
  Added npm scripts: snapshot, snapshot:validate
235
- Added devDependency: codebase-snapshot ^0.9.18
238
+ Added devDependency: codebase-snapshot ^0.10.1
236
239
  Added to .gitignore: snapshot/, snapshot.tmp/
237
240
  ```
238
241
 
@@ -423,7 +426,7 @@ for the two install flags, and the init-and-setup flags list both commands.
423
426
  | `--out-dir <path>` | path | `snapshot` | generate, validate, report, explain, init, setup | Where the snapshot is written or read. May be absolute. |
424
427
  | `--max-part-bytes <n>` | size | `307200` (300 KB) | generate, validate, init, setup | Hard ceiling per markdown part. Accepts `120k`, `1.5mb`. Minimum 4096. |
425
428
  | `--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. The byte ceiling is what is enforced: `estimatedTokens` is an estimate, and a part whose estimate exceeds the token ceiling is named in a warning rather than silently accepted. |
426
- | `--large-file-bytes <n>` | size | `204800` (200 KB) | generate, validate, explain, setup | Above this, a file becomes a head/tail preview. |
429
+ | `--large-file-bytes <n>` | size | the part budget (307200) | generate, validate, explain, setup | Above this, a file becomes a head/tail preview. It may not exceed `--max-part-bytes`: a file between the two could not fit a part. |
427
430
  | `--max-monolith-bytes <n>` | size | unset | generate, validate, setup | Skip the single-file monolith when it would exceed this. |
428
431
  | `--include-monolith` | flag | off | generate, validate, setup | Also write `full-codebase.json` and `full-codebase.md`. |
429
432
  | `--include-sensitive-files` | flag | off | generate, validate, explain, init, setup | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
@@ -75,9 +75,10 @@ that. In order of preference:
75
75
  4. **Summarise once, in a separate session.** Ask the model for a map of the parts, then use that
76
76
  map to choose which parts to read in detail.
77
77
 
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.
78
+ What not to do: silently truncate. A snapshot never exceeds its budget — a file that cannot fit
79
+ one part becomes a head/tail excerpt with an explicit omission marker, and above `largeFileBytes`
80
+ (which defaults to the budget and may not exceed it) that is the only route by which content is
81
+ dropped. `manifest.json` names every such file in `incomplete[]`.
81
82
 
82
83
  ## Checking your own number
83
84
 
@@ -114,30 +114,30 @@ not mistaken for a Node library.
114
114
  | Preset | Priority | Detected from | Budget | Ecosystem ignores |
115
115
  | :--- | ---: | :--- | :--- | :--- |
116
116
  | `nextjs` | 100 | `next.config.*`, or `next` | 300k | `.svelte-kit`, `.astro`, `.vite`, `.output` |
117
- | `nuxt` | 98 | `nuxt.config.*`, or `nuxt` | 200k | `.nuxt`, `.output` |
118
- | `sveltekit` | 96 | `svelte.config.*`, `@sveltejs/kit` | 200k | `.svelte-kit`, `.vercel` |
119
- | `remix` | 94 | `@remix-run/*` | 200k | `.cache`, `public/build` |
120
- | `astro` | 92 | `astro.config.*`, `astro` | 150k | `.astro`, `dist` |
121
- | `angular` | 90 | `angular.json`, `@angular/core` | 200k | `.angular`, `dist` |
122
- | `solid` | 88 | `solid-js`, `solid-start` | 120k | `.solid`, `dist` |
123
- | `vue-vite` | 86 | `vue` + `vite`/`vite.config.*` | 120k | `.vite`, `dist` |
124
- | `react-vite` | 84 | `react` + `vite`/`vite.config.*` | 120k | `.vite`, `dist` |
125
- | `nest` | 80 | `@nestjs/core` | 200k | `dist`, `node_modules` |
126
- | `node-express` | 78 | `express`, `fastify`, `koa`, `@hapi/hapi` | 200k | `dist` |
127
- | `monorepo` | 70 | `pnpm-workspace.yaml`, `nx.json`, `turbo.json`, `lerna.json`, `"workspaces"` | 200k | `.turbo`, `.nx` |
128
- | `python-django` | 56 | `manage.py`, django in `pyproject.toml`/`requirements.txt` | 150k | `__pycache__`, `.venv`, `venv`, `.mypy_cache`, `.pytest_cache`, `.tox`, `.eggs`, `staticfiles`, `media` |
129
- | `python-fastapi` | 54 | fastapi or flask in `pyproject.toml`/`requirements.txt` | 150k | `__pycache__`, `.venv`, `venv`, `.mypy_cache`, `.pytest_cache`, `.tox`, `.eggs` |
130
- | `go` | 50 | `go.mod` | 200k | `vendor`, `testdata` |
131
- | `rust` | 48 | `Cargo.toml` | 200k | `target` |
132
- | `java-spring` | 46 | `pom.xml`, `build.gradle`, `build.gradle.kts` | 200k | `.gradle`, `out`, `target` |
133
- | `node-lib` | 45 | any `package.json` | 120k | `dist` |
134
- | `dotnet` | 44 | `*.csproj`, `*.sln`, `global.json` | 200k | `bin`, `obj`, `.vs` |
135
- | `php-laravel` | 42 | `artisan`, laravel in `composer.json`, `composer.json` | 150k | `vendor`, `storage`, `bootstrap/cache`, `public/build` |
136
- | `ruby-rails` | 40 | `Gemfile`, `config.ru`, `Rakefile` | 150k | `.bundle`, `log`, `tmp`, `vendor/bundle`, `public/assets` |
137
- | `python-lib` | 30 | `pyproject.toml`, `setup.py`, `requirements.txt`, `.py` files | 120k | `__pycache__`, `.venv`, `venv`, `.mypy_cache`, `.pytest_cache`, `.tox`, `.eggs` |
138
- | `infra` | 24 | `*.tf`, `Chart.yaml`, `kustomization.yaml`, `docker-compose.yml` | 100k | `.terraform`, `.terragrunt-cache` |
139
- | `docs` | 22 | ≥ 3 markdown files and no `package.json` | 100k | `.docusaurus`, `.vitepress/dist`, `site` |
140
- | `generic` | 0 | anything else | 120k | — |
117
+ | `nuxt` | 98 | `nuxt.config.*`, or `nuxt` | 300k | `.nuxt`, `.output` |
118
+ | `sveltekit` | 96 | `svelte.config.*`, `@sveltejs/kit` | 300k | `.svelte-kit`, `.vercel` |
119
+ | `remix` | 94 | `@remix-run/*` | 300k | `.cache`, `public/build` |
120
+ | `astro` | 92 | `astro.config.*`, `astro` | 300k | `.astro`, `dist` |
121
+ | `angular` | 90 | `angular.json`, `@angular/core` | 300k | `.angular`, `dist` |
122
+ | `solid` | 88 | `solid-js`, `solid-start` | 300k | `.solid`, `dist` |
123
+ | `vue-vite` | 86 | `vue` + `vite`/`vite.config.*` | 300k | `.vite`, `dist` |
124
+ | `react-vite` | 84 | `react` + `vite`/`vite.config.*` | 300k | `.vite`, `dist` |
125
+ | `nest` | 80 | `@nestjs/core` | 300k | `dist`, `node_modules` |
126
+ | `node-express` | 78 | `express`, `fastify`, `koa`, `@hapi/hapi` | 300k | `dist` |
127
+ | `monorepo` | 70 | `pnpm-workspace.yaml`, `nx.json`, `turbo.json`, `lerna.json`, `"workspaces"` | 300k | `.turbo`, `.nx` |
128
+ | `python-django` | 56 | `manage.py`, django in `pyproject.toml`/`requirements.txt` | 300k | `__pycache__`, `.venv`, `venv`, `.mypy_cache`, `.pytest_cache`, `.tox`, `.eggs`, `staticfiles`, `media` |
129
+ | `python-fastapi` | 54 | fastapi or flask in `pyproject.toml`/`requirements.txt` | 300k | `__pycache__`, `.venv`, `venv`, `.mypy_cache`, `.pytest_cache`, `.tox`, `.eggs` |
130
+ | `go` | 50 | `go.mod` | 300k | `vendor`, `testdata` |
131
+ | `rust` | 48 | `Cargo.toml` | 300k | `target` |
132
+ | `java-spring` | 46 | `pom.xml`, `build.gradle`, `build.gradle.kts` | 300k | `.gradle`, `out`, `target` |
133
+ | `node-lib` | 45 | any `package.json` | 300k | `dist` |
134
+ | `dotnet` | 44 | `*.csproj`, `*.sln`, `global.json` | 300k | `bin`, `obj`, `.vs` |
135
+ | `php-laravel` | 42 | `artisan`, laravel in `composer.json`, `composer.json` | 300k | `vendor`, `storage`, `bootstrap/cache`, `public/build` |
136
+ | `ruby-rails` | 40 | `Gemfile`, `config.ru`, `Rakefile` | 300k | `.bundle`, `log`, `tmp`, `vendor/bundle`, `public/assets` |
137
+ | `python-lib` | 30 | `pyproject.toml`, `setup.py`, `requirements.txt`, `.py` files | 300k | `__pycache__`, `.venv`, `venv`, `.mypy_cache`, `.pytest_cache`, `.tox`, `.eggs` |
138
+ | `infra` | 24 | `*.tf`, `Chart.yaml`, `kustomization.yaml`, `docker-compose.yml` | 300k | `.terraform`, `.terragrunt-cache` |
139
+ | `docs` | 22 | ≥ 3 markdown files and no `package.json` | 300k | `.docusaurus`, `.vitepress/dist`, `site` |
140
+ | `generic` | 0 | anything else | 300k | — |
141
141
 
142
142
  Each detector reports **the signal that fired**, not just a verdict: `next.config.ts`, `depends on
143
143
  express`, `django in pyproject.toml`. The first run prints it — `Detected nextjs` / `Because
@@ -194,7 +194,8 @@ export default {
194
194
  // staged: true, // only files staged for the next commit
195
195
  // withDependents: true, // ...and the files that import them
196
196
  // skeleton: true, // signatures instead of bodies (--skeleton); TS, JS, TSX and JSX
197
- largeFileBytes: "200k", // above this a file becomes a head/tail preview
197
+ largeFileBytes: "300k", // above this a file becomes a head/tail preview; defaults to
198
+ // maxPartBytes, and may not exceed it
198
199
  previewHeadLines: 80,
199
200
  previewTailLines: 40,
200
201
  budgets: { // optional per-layer overrides
@@ -209,7 +210,12 @@ values are errors; so is anything below 4096 — a part budget that small cannot
209
210
  let alone code.
210
211
 
211
212
  The budget is a hard ceiling: a part never exceeds it. A single file larger than the budget is
212
- not split mid-file — it becomes a head/tail preview, marked `isPreviewTruncated`.
213
+ not split mid-file — it becomes a head/tail preview, marked `isPreviewTruncated`, and listed in
214
+ `manifest.incomplete[]` with the line ranges it lost.
215
+
216
+ `largeFileBytes` is the size at which that happens. It defaults to the part budget and may not
217
+ be set above it: a file between the two could not fit a part, so it would be cut to fit while
218
+ the manifest called it a preview by policy. That combination is a config error.
213
219
 
214
220
  `budgets.byLayer` lets expensive layers get more room than generated docs, for example.
215
221
 
@@ -422,7 +428,10 @@ const config = {
422
428
  // ── Size ─────────────────────────────────────────────────
423
429
  maxPartBytes: "300k",
424
430
  maxPartTokens: null, // the same ceiling in tokens; narrows maxPartBytes
425
- largeFileBytes: "200k",
431
+ largeFileBytes: "300k",
432
+ // ^ defaults to maxPartBytes. A threshold above the part budget is a config error: a file
433
+ // between the two cannot fit a part, so it would be cut while the manifest called it a
434
+ // preview by policy. Previewing exists for files that cannot be emitted whole.
426
435
  previewHeadLines: 80,
427
436
  previewTailLines: 40,
428
437
  budgets: { default: "300k", byLayer: {} },
@@ -478,7 +487,7 @@ also what lets you reference the object (from a test, or from `--dry-run`) witho
478
487
  This is **not** byte-identical to a generated file. `codebase-snapshot init` starts from these
479
488
  values and substitutes two things: `preset` becomes the detected name (`node-lib` for a plain
480
489
  npm package), and `maxPartBytes` with `budgets.default` become that preset's
481
- `recommendedBudget` (`"120k"` in the same project). `generate` on its own applies no
490
+ `recommendedBudget` (`"300k"` for every preset). `generate` on its own applies no
482
491
  recommended budget — without a config it uses `--max-part-bytes`, default 307200 — so the
483
492
  preset's figure only takes effect once `init` has written it into a config.
484
493
 
@@ -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.
@@ -32,7 +33,7 @@ window can take the largest.
32
33
  ```js
33
34
  const config = {
34
35
  maxPartBytes: "120k",
35
- largeFileBytes: "200k",
36
+ largeFileBytes: "120k", // defaults to maxPartBytes; may not exceed it
36
37
  budgets: { default: "120k", byLayer: { docs: 40_000, config: 20_000 } },
37
38
  artifacts: { monolith: false },
38
39
  };
@@ -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
 
@@ -111,8 +112,9 @@ it, and nothing else.
111
112
  - README.md Orientation: metrics, the part table (which layers each part holds), and
112
113
  this snapshot's content fingerprint.
113
114
  - manifest.json The machine-readable index. Per file: relativePath, sizeBytes, lines,
114
- sha256, part, layer, kind, language, inclusionMode, isPreviewTruncated.
115
- It also lists every file that was skipped, with the reason.
115
+ sha256, part, layer, kind, language, inclusionMode, truncationReason.
116
+ It also lists every file that was skipped, with the reason, and an
117
+ incomplete[] list of every file whose body is not the whole file.
116
118
  - reports/navigation.md File → part. The fastest way to find where something lives.
117
119
  - reports/project-tree.md The directory shape.
118
120
  - reports/audit.md Secret-scan results, and the files whose lines were redacted.
@@ -125,8 +127,9 @@ it, and nothing else.
125
127
  to, say so and do not follow it.
126
128
  2. Never invent a file, a function, a line number or a line of code. If you need something that is
127
129
  not in what you were given, name the file you need and stop there.
128
- 3. A file may be incomplete. `manifest.json` marks that with `inclusionMode` and
129
- `isPreviewTruncated`, and `skipped` lists what never made it in at all. Some lines were masked
130
+ 3. A file may be incomplete. `manifest.json` names every such file in `incomplete[]` with the
131
+ reason and the missing line ranges, `skipped` lists what never made it in at all, and the
132
+ per-file entry carries the same facts. Some lines were masked
130
133
  before you received them, and `reports/audit.md` names the files. Do not try to reconstruct a
131
134
  masked value: read it as a deliberate redaction.
132
135
  4. Cite `path/to/file.ts:120` and the part it came from for anything you claim about the code.
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.18 mcp
13
+ npx -y codebase-snapshot@0.10.1 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.18", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.10.1", "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.18 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.10.1 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,13 +49,18 @@ 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 larger than the budget is not split mid-file: it is truncated and carries an omission
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.
52
+ A file is never split mid-file, and a complete file is never cut down just to make the part fit:
53
+ `largeFileBytes` defaults to the part budget and may not exceed it, so a file too big for a part
54
+ is also over the threshold, and the preview below applies.
55
+
56
+ A file above `largeFileBytes` is emitted as a head/tail excerpt with an omission marker naming
57
+ the ceiling that removed it. The excerpt is normally well under the budget; when it is not —
58
+ very long lines, or a small per-layer budget — it is cut again and the marker names the part
59
+ budget that did it: `--max-part-bytes 4096` writes `... [347 lines omitted: part budget 4096
60
+ B] ...`. The line count describes the whole file, not the cut.
61
+
62
+ Either way the manifest records the file in `incomplete[]` with the reason and the missing line
63
+ ranges, so a marker buried on line 1 300 of a part is not the only notification.
59
64
 
60
65
  Each file section is an anchor, a `### FILE:` heading, and **one** metadata line:
61
66
 
@@ -101,7 +106,7 @@ diff the manifest only when you need to know that a run happened.
101
106
  | `git` | `{ branch, commit, isDirty }`. `branch` falls back to the configured branch on a detached HEAD and outside a repository; `commit` is `"unknown"` and `isDirty` is `false` when git cannot report. A `false` there means "not known to be dirty", not "clean tree" — check `commit` to tell the two apart. |
102
107
  | `budgets` | The effective byte limits for the run: `{ maxPartBytes, largeFileBytes }`. The per-layer overrides live at `config.budgets`, which is `{ default, byLayer }`. |
103
108
  | `config` | The resolved configuration actually used (preset, artifacts, sizing, scoping). |
104
- | `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount }`. |
109
+ | `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount, incompleteCount }`. |
105
110
  | `totals` | Bookkeeping: `{ candidateFiles, includedFiles, fullFiles, previewFiles, skippedFiles, totalSourceBytes, totalContentBytes, sourceLines, emittedLines, estimatedTokens, partCount, warningCount, redactedLines }`. `sourceLines` is the source line count before previews and part budgets; `emittedLines` is what the parts actually carry. `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. |
106
111
  | `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. It is recomputed by `validate` from `files[]` and `config.digest`, so an edited file list cannot keep the recorded value — and because the partitioner may change a file's `inclusionMode` after the fingerprint is taken, the mode is not part of the hash. |
107
112
  | `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
@@ -110,7 +115,8 @@ diff the manifest only when you need to know that a run happened.
110
115
  | `indexes` | Cross-references: `routes`, `components`, `handlers`, `features`, `imports`, `directives`. |
111
116
  | `parts` | One entry per part (below). |
112
117
  | `files` | One entry per included file (below). |
113
- | `skipped` | One entry per excluded file (below). |
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. |
119
+ | `incomplete` | One entry per included file whose body is **not the whole file**: `{ relativePath, part, reason, omittedRanges, omittedLines, includedLines, lines }`. `reason` is `large-file-budget`, `part-budget` or `section-metadata`; `omittedRanges` are 1-based inclusive line ranges that are missing or partial. Empty is the normal case and is written as an empty array — a consumer asks "was anything lost?" without reading four hundred file entries. |
114
120
  | `warnings` | Non-fatal observations that may change how you read the snapshot — a disabled artifact, a file too large to parse, a transcoded file, a throwing `hooks.afterGenerate`. Masked values are **not** warnings: they are counted in `totals.redactedLines` and listed per line in `reports/audit.md`. |
115
121
 
116
122
  ### `parts[]`
@@ -175,24 +181,32 @@ has several at once, and "within budget" cannot be answered without knowing whic
175
181
  }
176
182
  ```
177
183
 
178
- - `isLarge` is a fact about the file: it is bigger than `largeFileBytes` (default 200 KB).
179
- A large file is emitted as a head/tail excerpt rather than inlined whole.
184
+ - `isLarge` is a fact about the file: it is bigger than `largeFileBytes`, which defaults to
185
+ `maxPartBytes` and may not exceed it. A large file is emitted as a head/tail excerpt rather
186
+ than inlined whole.
180
187
  - `isPreviewTruncated` is a fact about what was written: the body in this snapshot is **not**
181
188
  the whole file, because lines were dropped.
182
189
  - `includedLines` counts content lines after CRLF normalisation and without a trailing empty
183
190
  element, which is what the fenced block holds. An empty file therefore records `0` while the
184
191
  fence shows one empty line, and a file ending in a blank line records one fewer than a reader
185
192
  counts — the number describes content, not rendering.
186
- - `inclusionMode` is `preview` exactly when `isPreviewTruncated` is `true`, and there are two
187
- routes to it:
188
- - **Over `largeFileBytes`** — the head/tail excerpt drops the middle, so
189
- `isLarge: true`, `isPreviewTruncated: true`. If the head and tail happen to cover every
190
- line, nothing is dropped and the entry stays `isLarge: true`, `inclusionMode: "full"`.
191
- - **Under `largeFileBytes` but too big for its part** — the partitioner byte-truncates the
192
- section to keep the part inside its budget, so `isLarge: false`,
193
- `isPreviewTruncated: true`. This is the one that surprises people: the file is not "large"
194
- by the configured threshold, yet its body is incomplete.
195
- - Only `isPreviewTruncated` tells you content is missing; `isLarge` alone does not.
193
+ - `inclusionMode` is `preview` exactly when `isPreviewTruncated` is `true`. There used to be two
194
+ routes to it, and the second — a file *under* `largeFileBytes` but too big for its part, cut
195
+ by the partitioner with `isLarge: false` — is what made the manifest unreadable: it looked
196
+ like a preview chosen by policy while 57 % of the file was gone. That configuration is now a
197
+ hard error (`largeFileBytes` above `maxPartBytes`), so `preview` now means one thing: the file
198
+ is over the threshold and cannot be emitted whole.
199
+ - The head/tail excerpt drops the middle, so `isLarge: true`, `isPreviewTruncated: true`. If
200
+ the head and tail happen to cover every line, nothing is dropped and the entry stays
201
+ `isLarge: true`, `inclusionMode: "full"`.
202
+ - A preview that is still too large for its part is cut again, and `truncationReason` becomes
203
+ `part-budget` instead of `large-file-budget`.
204
+ - `truncationReason` says which rule produced the omission: `large-file-budget`, `part-budget`
205
+ or `section-metadata`. It is present exactly when something was dropped.
206
+ - `omittedRanges` are the 1-based, inclusive source lines that are missing or partial. A byte
207
+ cut can end inside a line, and that line is named rather than the list staying empty.
208
+ - The same facts are collected in the manifest's top-level `incomplete[]`, which is what to ask
209
+ when the question is "was anything left out?" rather than "what is in this file?".
196
210
  - `hashSha256` is the hash of the source file on disk — `validate` recomputes it to detect
197
211
  drift. It is the full 64-character digest.
198
212
  - `encoding` is present **only** when the file is not plain UTF-8; its absence means clean UTF-8.
@@ -219,9 +233,11 @@ has several at once, and "within budget" cannot be answered without knowing whic
219
233
  not parse. `headings` skips headings inside fenced code and inside YAML front matter, and a
220
234
  document that *opens* with a `---` horizontal rule keeps its headings: the block has to look like
221
235
  YAML before it counts as front matter.
222
- - `summaryOmitted: true` means the file's summary was dropped because the summary alone would
223
- not fit the part budget. The entry then has `summaryQuality` but no `summary`, and the
224
- file's body is still emitted in full. It is only ever present when `true`.
236
+ - `summaryOmitted: true` means a summary was not emitted for a size reason, and
237
+ `summaryOmittedReason` says which: `oversize` (the file is too large to parse), `preview` (the
238
+ body is a head/tail excerpt, so a whole-file summary would describe lines the snapshot does not
239
+ contain) or `part-budget` (the summary alone would not fit the part). The entry then has no
240
+ `summary`. It is only ever present when `true`.
225
241
  - `summaryQuality` is `ast` (parsed by the TypeScript compiler), `structural` (JSON or
226
242
  Markdown shape) or `heuristic` (pattern-matched). It tells you how much to trust the
227
243
  summary: `heuristic` means a line scan, not a parse.
@@ -75,6 +75,12 @@ checked.
75
75
  When an answer is wrong because the model never saw a file, this is the list that tells you
76
76
  whether the file was excluded on purpose or by accident.
77
77
 
78
+ The second half of the same question is a file that was included but not in full.
79
+ `manifest.incomplete[]` names every one of those with its `reason` — `large-file-budget`,
80
+ `part-budget` or `section-metadata` — and `omittedRanges`, the 1-based source lines that are
81
+ missing or partial. A server that only reports what it included is telling half the story; this
82
+ is the half that explains a confident answer about code the model never saw.
83
+
78
84
  ## Gate it
79
85
 
80
86
  The comparison is only a guard if something runs it. In CI, after whatever changes the tree:
@@ -228,11 +228,36 @@ followed by the usage text:
228
228
  name, and their minimum is 1 rather than 4096:
229
229
  `--large-file-bytes must be at least 1, received "0".`
230
230
 
231
+ ### `largeFileBytes (…) is larger than maxPartBytes (…)`
232
+
233
+ The two ceilings answer one question — *can this file be emitted whole?* — and they disagree.
234
+ A part cannot hold more than its budget, so a file between the two numbers cannot fit a part;
235
+ it would be cut to fit while the manifest called it a preview by policy. That is exactly the
236
+ silent truncation this check exists to prevent, so it is refused **before anything is written**.
237
+
238
+ Raise `maxPartBytes` to at least `largeFileBytes`, or lower `largeFileBytes`. Leaving
239
+ `largeFileBytes` unset is the usual answer: it then follows the budget.
240
+
241
+ A config written by an older `setup` may set `largeFileBytes: "200k"` beside a smaller budget;
242
+ delete that line and it follows the budget again.
243
+
231
244
  ### `Cannot write the snapshot: permission denied under …`
232
245
 
233
246
  The output directory is not writable (or a parent is not readable). The previous snapshot is
234
247
  left intact. Fix the permissions, or choose another `--out-dir`.
235
248
 
249
+ ### `EPERM: rename 'snapshot' -> 'snapshot.backup-…'` (Windows, OneDrive)
250
+
251
+ Something holds a handle *inside* the previous snapshot — a sync client, an antivirus, an
252
+ editor with one of those files open — and Windows will not rename a directory while any handle
253
+ in it is open. The swap retries for three seconds and then, because the ownership guard has
254
+ already proved the directory holds nothing but a snapshot this tool wrote, removes it and
255
+ places the new one in the same path. You will see a `could not be moved aside … replaced in
256
+ place` note when that happens.
257
+
258
+ If it still fails, close whatever is holding the old snapshot and run again. The new snapshot
259
+ is complete in the staging directory (`snapshot.tmp` by default) and its path is printed.
260
+
236
261
  ### `Snapshot validation failed` (from `validate`)
237
262
 
238
263
  Exit `1` with one line per class of drift:
@@ -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.
@@ -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`,
@@ -25,7 +25,7 @@ If you want the most popular, most integrated tool: **use repomix.**
25
25
  | | codebase-snapshot | repomix |
26
26
  | :--- | :--- | :--- |
27
27
  | Output shape | Multiple parts, each under a hard byte budget, plus a JSON manifest | One packed file (XML, Markdown or JSON), or several with `--split-output <size>` |
28
- | Size control | **Yes** — `maxPartBytes` is a per-part byte ceiling; a file too large for one part is truncated with a marker naming the budget | `--split-output <size>` splits by output size, and `--token-budget <n>` exits non-zero above a token count |
28
+ | Size control | **Yes** — `maxPartBytes` is a per-part byte ceiling; a file that cannot fit one part becomes a head/tail preview listed in `incomplete[]` | `--split-output <size>` splits by output size, and `--token-budget <n>` exits non-zero above a token count |
29
29
  | Reproducible output | Parts are byte-identical across runs; a fingerprint covers them | Content is stable; no published determinism guarantee |
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 |
@@ -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.9.18",
3
+ "version": "0.10.1",
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",