codebase-snapshot 0.10.1 → 0.11.0

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-WDJ3O3R4.js';
2
- export { generateInWorker } from './chunk-7DAW2LFZ.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-5ZOXHBTW.js';
2
+ export { generateInWorker } from './chunk-NJ75RVHO.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;
@@ -363,6 +374,17 @@ interface ManifestConfigSnapshot {
363
374
  */
364
375
  maxMonolithBytes?: number | null;
365
376
  includeSensitiveFiles: boolean;
377
+ /**
378
+ * The file-slot ceiling `PROMPT.md` was planned for; `0` for no limit.
379
+ *
380
+ * Recorded so the manifest states the destination the instructions were written for, and
381
+ * optional because a manifest written before this was recorded has no such key. It is not part
382
+ * of `configDigest`: the payload is identical either way, and a new delivery preference must not
383
+ * make an existing snapshot fail `validate` as configuration drift.
384
+ */
385
+ attachmentSlots?: number;
386
+ /** The part-count ceiling the run enforced, `null` when the experimental mode was off. */
387
+ maxParts?: number | null;
366
388
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
367
389
  discovery?: DiscoveryMode;
368
390
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -387,12 +409,22 @@ type TruncationReason = "large-file-budget" | "part-budget" | "section-metadata"
387
409
  /** One file the snapshot does not contain in full, and what was left out of it. */
388
410
  interface IncompleteFile {
389
411
  relativePath: string;
412
+ /** The part this file was written to, so the omission can be found on disk. */
390
413
  part: string;
391
414
  reason: TruncationReason;
392
415
  /** 1-based, inclusive. Sorted and non-overlapping. */
393
416
  omittedRanges: Array<[number, number]>;
417
+ /** Source lines the ranges cover — the sum of their lengths. */
394
418
  omittedLines: number;
419
+ /**
420
+ * Lines in the emitted block, **including an omission notice line when one is written**.
421
+ *
422
+ * It counts what the fenced block holds, not the source lines that survived, so a preview
423
+ * records head + tail + the notice. `includedLines + omittedLines` is therefore not `lines`
424
+ * and no consumer should expect it to be.
425
+ */
395
426
  includedLines: number;
427
+ /** Lines in the source file. */
396
428
  lines: number;
397
429
  }
398
430
  interface Manifest {
@@ -446,6 +478,7 @@ interface Manifest {
446
478
  * recorded has no key; a current manifest records every artifact it wrote.
447
479
  */
448
480
  readme?: ManifestArtifact;
481
+ prompt?: ManifestArtifact;
449
482
  navigation?: ManifestArtifact;
450
483
  projectTree?: ManifestArtifact;
451
484
  audit?: ManifestArtifact;
@@ -492,6 +525,8 @@ interface LayerRule {
492
525
  interface ArtifactSelection {
493
526
  /** `README.md` — the orientation page for humans and models. */
494
527
  readme?: boolean;
528
+ /** `PROMPT.md` — the instruction sheet a snapshot is pasted with. */
529
+ prompt?: boolean;
495
530
  /** `manifest.json` — the registry `validate` and `report` read. */
496
531
  manifest?: boolean;
497
532
  /** `parts/part-XXX.md` — the partitioned code payload. */
@@ -549,8 +584,36 @@ interface SnapshotConfig {
549
584
  previewTailLines?: number;
550
585
  includeMonolith?: boolean;
551
586
  maxMonolithBytes?: ByteSize | null;
552
- /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/credential files. Default false. */
587
+ /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
553
588
  includeSensitiveFiles?: boolean;
589
+ /**
590
+ * Files the destination accepts in one message; 10 by default, `0` for no limit.
591
+ *
592
+ * `PROMPT.md` plans the delivery to fit: which parts to attach, what to leave behind, and the
593
+ * part budget that would merge them. The payload is unchanged by this setting — only the
594
+ * instructions and the plan that ships with it.
595
+ */
596
+ attachmentSlots?: number;
597
+ /**
598
+ * Experimental: the most parts a snapshot may have.
599
+ *
600
+ * Off by default. When set, the partitioner grows the per-part budget until the run fits this
601
+ * many parts, which is how a repository that keeps growing keeps its shape instead of adding a
602
+ * twelfth file to a chat that takes ten. The budget it settles on is recorded in
603
+ * `manifest.budgets.maxPartBytes` and may exceed the configured `maxPartBytes`; a warning says
604
+ * so, because a larger part is more tokens for the destination to swallow at once.
605
+ */
606
+ maxParts?: number | null;
607
+ /**
608
+ * How files are discovered; `auto` picks git when it can list files and walks the tree
609
+ * otherwise.
610
+ *
611
+ * Present here because this is the type a user writes against — `defineConfig` and
612
+ * `resolveConfig` both take it — and it was missing while `ResolvedSnapshotConfig`,
613
+ * `CliOptions` and `CONFIG_KEYS` all carried it. A TypeScript config containing
614
+ * `discovery: "walk"` was TS2353 in exactly the format `init` recommends.
615
+ */
616
+ discovery?: DiscoveryMode;
554
617
  /** Allow-list of globs. When non-empty, only matching files are included. */
555
618
  include?: string[];
556
619
  /** Force a preset by name instead of auto-detecting one. */
@@ -613,6 +676,10 @@ interface ResolvedSnapshotConfig {
613
676
  includeMonolith: boolean;
614
677
  maxMonolithBytes: number | null;
615
678
  includeSensitiveFiles: boolean;
679
+ /** Files the destination accepts in one message; `0` means no limit. */
680
+ attachmentSlots: number;
681
+ /** The part-count ceiling, or `null` when the experimental mode is off. */
682
+ maxParts: number | null;
616
683
  /**
617
684
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
618
685
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -658,6 +725,10 @@ interface CliOptions {
658
725
  includeMonolith?: boolean;
659
726
  includeSensitiveFiles?: boolean;
660
727
  maxMonolithBytes?: number | null;
728
+ /** `--attachment-slots`: how many files the destination accepts. */
729
+ attachmentSlots?: number;
730
+ /** `--max-parts`: the experimental part-count ceiling. */
731
+ maxParts?: number | null;
661
732
  maxPartBytes?: number;
662
733
  maxPartTokens?: ByteSize | null;
663
734
  largeFileBytes?: number;
@@ -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;
@@ -363,6 +374,17 @@ interface ManifestConfigSnapshot {
363
374
  */
364
375
  maxMonolithBytes?: number | null;
365
376
  includeSensitiveFiles: boolean;
377
+ /**
378
+ * The file-slot ceiling `PROMPT.md` was planned for; `0` for no limit.
379
+ *
380
+ * Recorded so the manifest states the destination the instructions were written for, and
381
+ * optional because a manifest written before this was recorded has no such key. It is not part
382
+ * of `configDigest`: the payload is identical either way, and a new delivery preference must not
383
+ * make an existing snapshot fail `validate` as configuration drift.
384
+ */
385
+ attachmentSlots?: number;
386
+ /** The part-count ceiling the run enforced, `null` when the experimental mode was off. */
387
+ maxParts?: number | null;
366
388
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
367
389
  discovery?: DiscoveryMode;
368
390
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -387,12 +409,22 @@ type TruncationReason = "large-file-budget" | "part-budget" | "section-metadata"
387
409
  /** One file the snapshot does not contain in full, and what was left out of it. */
388
410
  interface IncompleteFile {
389
411
  relativePath: string;
412
+ /** The part this file was written to, so the omission can be found on disk. */
390
413
  part: string;
391
414
  reason: TruncationReason;
392
415
  /** 1-based, inclusive. Sorted and non-overlapping. */
393
416
  omittedRanges: Array<[number, number]>;
417
+ /** Source lines the ranges cover — the sum of their lengths. */
394
418
  omittedLines: number;
419
+ /**
420
+ * Lines in the emitted block, **including an omission notice line when one is written**.
421
+ *
422
+ * It counts what the fenced block holds, not the source lines that survived, so a preview
423
+ * records head + tail + the notice. `includedLines + omittedLines` is therefore not `lines`
424
+ * and no consumer should expect it to be.
425
+ */
395
426
  includedLines: number;
427
+ /** Lines in the source file. */
396
428
  lines: number;
397
429
  }
398
430
  interface Manifest {
@@ -446,6 +478,7 @@ interface Manifest {
446
478
  * recorded has no key; a current manifest records every artifact it wrote.
447
479
  */
448
480
  readme?: ManifestArtifact;
481
+ prompt?: ManifestArtifact;
449
482
  navigation?: ManifestArtifact;
450
483
  projectTree?: ManifestArtifact;
451
484
  audit?: ManifestArtifact;
@@ -492,6 +525,8 @@ interface LayerRule {
492
525
  interface ArtifactSelection {
493
526
  /** `README.md` — the orientation page for humans and models. */
494
527
  readme?: boolean;
528
+ /** `PROMPT.md` — the instruction sheet a snapshot is pasted with. */
529
+ prompt?: boolean;
495
530
  /** `manifest.json` — the registry `validate` and `report` read. */
496
531
  manifest?: boolean;
497
532
  /** `parts/part-XXX.md` — the partitioned code payload. */
@@ -549,8 +584,36 @@ interface SnapshotConfig {
549
584
  previewTailLines?: number;
550
585
  includeMonolith?: boolean;
551
586
  maxMonolithBytes?: ByteSize | null;
552
- /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/credential files. Default false. */
587
+ /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
553
588
  includeSensitiveFiles?: boolean;
589
+ /**
590
+ * Files the destination accepts in one message; 10 by default, `0` for no limit.
591
+ *
592
+ * `PROMPT.md` plans the delivery to fit: which parts to attach, what to leave behind, and the
593
+ * part budget that would merge them. The payload is unchanged by this setting — only the
594
+ * instructions and the plan that ships with it.
595
+ */
596
+ attachmentSlots?: number;
597
+ /**
598
+ * Experimental: the most parts a snapshot may have.
599
+ *
600
+ * Off by default. When set, the partitioner grows the per-part budget until the run fits this
601
+ * many parts, which is how a repository that keeps growing keeps its shape instead of adding a
602
+ * twelfth file to a chat that takes ten. The budget it settles on is recorded in
603
+ * `manifest.budgets.maxPartBytes` and may exceed the configured `maxPartBytes`; a warning says
604
+ * so, because a larger part is more tokens for the destination to swallow at once.
605
+ */
606
+ maxParts?: number | null;
607
+ /**
608
+ * How files are discovered; `auto` picks git when it can list files and walks the tree
609
+ * otherwise.
610
+ *
611
+ * Present here because this is the type a user writes against — `defineConfig` and
612
+ * `resolveConfig` both take it — and it was missing while `ResolvedSnapshotConfig`,
613
+ * `CliOptions` and `CONFIG_KEYS` all carried it. A TypeScript config containing
614
+ * `discovery: "walk"` was TS2353 in exactly the format `init` recommends.
615
+ */
616
+ discovery?: DiscoveryMode;
554
617
  /** Allow-list of globs. When non-empty, only matching files are included. */
555
618
  include?: string[];
556
619
  /** Force a preset by name instead of auto-detecting one. */
@@ -613,6 +676,10 @@ interface ResolvedSnapshotConfig {
613
676
  includeMonolith: boolean;
614
677
  maxMonolithBytes: number | null;
615
678
  includeSensitiveFiles: boolean;
679
+ /** Files the destination accepts in one message; `0` means no limit. */
680
+ attachmentSlots: number;
681
+ /** The part-count ceiling, or `null` when the experimental mode is off. */
682
+ maxParts: number | null;
616
683
  /**
617
684
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
618
685
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -658,6 +725,10 @@ interface CliOptions {
658
725
  includeMonolith?: boolean;
659
726
  includeSensitiveFiles?: boolean;
660
727
  maxMonolithBytes?: number | null;
728
+ /** `--attachment-slots`: how many files the destination accepts. */
729
+ attachmentSlots?: number;
730
+ /** `--max-parts`: the experimental part-count ceiling. */
731
+ maxParts?: number | null;
661
732
  maxPartBytes?: number;
662
733
  maxPartTokens?: ByteSize | null;
663
734
  largeFileBytes?: number;
package/docs/cli.md CHANGED
@@ -97,15 +97,16 @@ 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.1 (project dependency ^0.10.1)
100
+ Branch: main | Part budget: 300 KB | Generator: 0.11.0 (project dependency ^0.11.0)
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/
107
107
  - Reports: snapshot/reports/ (project-tree, navigation, audit)
108
108
  - Manifest: snapshot/manifest.json
109
+ - Orientation: snapshot/README.md, snapshot/PROMPT.md
109
110
  - Fingerprint: e4607b570268c8def0911babbace97e4a0196d9eaf2cac22c8847500883d70aa
110
111
  - Integrity: passed
111
112
  - Redacted: 2 line(s) — values masked; see snapshot/reports/audit.md
@@ -141,6 +142,14 @@ filesystem-permission problem. It is a class of its own because the fix is diffe
141
142
  as "deleted" sent the reader looking for a file that is still there. Text mode lists each path
142
143
  as `unreadable: <path>`; `--format json` carries them in `drift.unreadable`.
143
144
 
145
+ It also verifies the **completeness contract**: `incomplete[]` is checked against `files[]` entry by
146
+ entry (same part, same reason, same ranges, same line counts), `counts.incompleteCount` against the
147
+ length of the list, and every `omittedRanges` pair against the file's own line count. A manifest is
148
+ an input — `generate` proves this contract when it writes one, but once the file is on disk nothing
149
+ else re-derives it — so a hand-edited or foreign `manifest.json` is refused here rather than
150
+ reported as current. The shape guard also confines `incomplete[].relativePath` to the repository,
151
+ like the two other path-bearing arrays.
152
+
144
153
  Exit `0` when the snapshot is current, `1` on any drift. It never writes anything.
145
154
 
146
155
  ### `report`
@@ -183,8 +192,8 @@ The whole first run in one command, with defaults and no prompts. This is the sa
183
192
  🚀 Setup for: /path/to/repo
184
193
  ✅ Created snapshot.config.ts (preset: nextjs)
185
194
  Added npm scripts: snapshot, snapshot:validate
186
- Added devDependency: codebase-snapshot ^0.10.1
187
- Added to .gitignore: snapshot/, snapshot.tmp/
195
+ Added devDependency: codebase-snapshot ^0.11.0
196
+ Added to .gitignore: /snapshot/, /snapshot.tmp/
188
197
  ⏳ Installing dependencies…
189
198
  ✅ Installed dependencies (npm install, 2.1s)
190
199
  ✅ Snapshot generated in 0.16s:
@@ -235,8 +244,8 @@ It also has three side effects on files you own, and it says so when it does the
235
244
  ```
236
245
  ✅ Created snapshot.config.ts (preset: node-lib)
237
246
  Added npm scripts: snapshot, snapshot:validate
238
- Added devDependency: codebase-snapshot ^0.10.1
239
- Added to .gitignore: snapshot/, snapshot.tmp/
247
+ Added devDependency: codebase-snapshot ^0.11.0
248
+ Added to .gitignore: /snapshot/, /snapshot.tmp/
240
249
  ```
241
250
 
242
251
  - `scripts.snapshot` and `scripts.snapshot:validate` are added to `package.json` if those keys
@@ -246,7 +255,9 @@ It also has three side effects on files you own, and it says so when it does the
246
255
  declares it yet. That is what puts a real copy in `node_modules` and stops `npm run
247
256
  snapshot` from resolving `@latest` out of the registry on every run. A range you already
248
257
  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;
258
+ - `/<outDir>/` and `/<tmpDir>/` are appended to `.gitignore` if they are not already listed —
259
+ anchored at the repository root, and naming the directories the config actually uses, so
260
+ `--out-dir .context` ignores `/.context/` rather than `/snapshot/`;
250
261
  the file is created if missing, and entries already present are not duplicated.
251
262
 
252
263
  ### Going back
@@ -322,7 +333,7 @@ With `--format json` the same answer is one object on stdout, with only the keys
322
333
  | `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
334
  | `bytes`, `lines` | Size of the file on disk. |
324
335
  | `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. |
336
+ | `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
337
  | `part` | The part filename from the last written manifest, or `null` when it is not in that snapshot. |
327
338
  | `inclusionMode` | `full` or `preview`, when a part entry exists. |
328
339
 
@@ -354,6 +365,17 @@ Manifests written before 4.0.5 have no `config.digest`. In that case `diff` comp
354
365
  content fingerprint and the part count only, and prints `configuration not compared: a
355
366
  manifest has no config digest (written before 4.0.5).` rather than implying the settings match.
356
367
 
368
+ In `--format json` each statement in `payload.reasons` has a stable `payload.codes` entry beside
369
+ it — `schema-version`, `config-digest`, `config-digest-missing`, `generator`, `fingerprint`,
370
+ `parts-count`, `layer-changed` — so a program can branch on what changed without matching English.
371
+
372
+ `diff` deliberately does **not** read the project configuration: it answers a question about two
373
+ files and importing a config would execute repository code to do it. The paths it prints are masked
374
+ with the built-in rules (the library form, `compareManifests(before, after, secretRules)`, takes
375
+ your resolved rules). A project-specific token that a manifest recorded *before* you declared it in
376
+ `secretRules` can therefore still appear in a comparison of that old manifest — regenerate it, and
377
+ every later manifest carries the masked path.
378
+
357
379
  ### `describe`
358
380
 
359
381
  ```bash
@@ -428,6 +450,8 @@ for the two install flags, and the init-and-setup flags list both commands.
428
450
  | `--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. |
429
451
  | `--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. |
430
452
  | `--max-monolith-bytes <n>` | size | unset | generate, validate, setup | Skip the single-file monolith when it would exceed this. |
453
+ | `--max-parts <n>` | count | unset | generate, validate | **Experimental.** Grow the per-part budget until the snapshot has at most `n` parts, so the file count stays fixed as the code grows. The budget it settles on is recorded in `manifest.budgets.maxPartBytes` and may exceed `--max-part-bytes`; a warning says so. `0` is a usage error. |
454
+ | `--attachment-slots <n>` | count | `10` | generate | Files the destination accepts in one message; `0` means no limit. `PROMPT.md` plans the delivery against it — which parts to attach, what to leave behind, and the `--max-part-bytes` value that would merge them. It changes no part and no file, so it is recorded in the manifest but is not part of the config digest. |
431
455
  | `--include-monolith` | flag | off | generate, validate, setup | Also write `full-codebase.json` and `full-codebase.md`. |
432
456
  | `--include-sensitive-files` | flag | off | generate, validate, explain, init, setup | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
433
457
  | `--skip-artifacts <names>` | list | unset | generate, validate, init, setup | Comma-separated artifacts to omit. |
@@ -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
@@ -225,6 +225,7 @@ the manifest called it a preview by policy. That combination is a config error.
225
225
  export default {
226
226
  artifacts: {
227
227
  readme: true, // snapshot/README.md
228
+ prompt: true, // snapshot/PROMPT.md — the instruction sheet a model is given
228
229
  manifest: true, // snapshot/manifest.json
229
230
  parts: true, // snapshot/parts/*.md
230
231
  navigation: true, // snapshot/reports/navigation.md
@@ -246,6 +247,54 @@ on leaves links pointing at files that were never written. Both are allowed.
246
247
 
247
248
  The `.codebase-snapshot` ownership marker is always written, whatever the selection.
248
249
 
250
+ ## Delivering it: how many files the destination takes
251
+
252
+ ```js
253
+ export default {
254
+ attachmentSlots: 10, // files your chat accepts per message; 0 = no limit
255
+ };
256
+ ```
257
+
258
+ Hosted assistants take a fixed number of files per message — 10 is the common cap — and every part
259
+ is one of them. `PROMPT.md` plans the delivery against this number: which parts to attach, what to
260
+ leave behind when they do not all fit, and the `--max-part-bytes` value that would merge them.
261
+
262
+ - Default `10`; `0` means the destination imposes no limit and the plan says to attach everything.
263
+ - It changes **no part and no file**: the payload is byte-identical either way. Only the delivery
264
+ section of `PROMPT.md` moves, which is why it is recorded in `manifest.config` but is not part of
265
+ the config digest — a new delivery preference must not make an existing snapshot fail `validate`.
266
+ - Instructions are pasted as text and cost no slot, so the budget is always spent on files.
267
+
268
+ The one thing it cannot do is make a snapshot fit: a 12-part snapshot does not go into a 10-file
269
+ message at any setting. Raise `maxPartBytes` to merge the parts, or narrow the scope — the plan in
270
+ `PROMPT.md` names the number.
271
+
272
+ ### Experimental: a fixed number of parts
273
+
274
+ ```js
275
+ export default {
276
+ maxParts: 10, // grow the parts until the snapshot has at most ten; off by default
277
+ };
278
+ ```
279
+
280
+ The opposite trade to everything above: the **count** is fixed and the **size** gives way. As the
281
+ repository grows, `maxParts` grows the per-part budget instead of adding a part, which is what a
282
+ destination with a hard file limit wants — the snapshot keeps its shape instead of turning into
283
+ eleven parts next month.
284
+
285
+ - Off by default (`null`). Opt in per run with `--max-parts <n>`, or in the config.
286
+ - The budget it settles on is recorded in `manifest.budgets.maxPartBytes` — the number the parts
287
+ actually honour — while `manifest.config.maxPartBytes` keeps the configured value, so
288
+ `validate` still compares like with like.
289
+ - It may exceed `maxPartBytes`, and that is the point: a part bigger than the configured ceiling is
290
+ more tokens at once, and some destinations cap a single file. Both facts land in
291
+ `manifest.warnings`, so the run says what it did rather than quietly changing the shape.
292
+ - If it cannot converge, generation fails with the counts it tried rather than writing something
293
+ the setting did not ask for.
294
+
295
+ Treat it as experimental: `maxPartBytes` stays the honest control, and this is the knob for the
296
+ case where the file count, not the byte count, is the binding constraint.
297
+
249
298
  See [Snapshot output](output.md) for the layout and the manifest schema.
250
299
 
251
300
  ## Secrets: redaction
@@ -277,7 +326,7 @@ makes an audit entry mean something.
277
326
  disable redaction itself, and it applies to **paths** as well as to content, so a
278
327
  credential-shaped file name is no longer skipped by a rule you switched off.
279
328
 
280
- Redaction is **fail-closed**, so a placeholder is indistinguishable from a secret: a
329
+ Redaction is **fail-closed**, so most placeholders are indistinguishable from secrets: a
281
330
  `.env.example` whose line reads `JWT_SECRET=replace-with-base64url-48-bytes` is masked like a
282
331
  live key would be, and a test fixture literal such as `process.env.X_SECRET = "test-value"` is
283
332
  masked too. That is the intended trade-off — the alternative is guessing which values are
@@ -285,7 +334,23 @@ throwaway — and it is worth knowing before you hand the snapshot to a model an
285
334
  less readable than the original. To narrow it, remove a rule by name with
286
335
  `disableDefaultPatterns: true` plus your own `customPatterns`.
287
336
 
288
- The one shape that is *not* masked is a value that is a single `${…}` reference and nothing else —
337
+ The exception is a **whole value** that is one of the conventional placeholder shapes. The list
338
+ is exhaustive and lives in `PLACEHOLDER_PATTERNS` in `src/security/redact.ts`:
339
+
340
+ | Value is exactly… | Example that survives |
341
+ | :--- | :--- |
342
+ | `replace-me` / `change-me`, optionally followed by more words | `replace-me-with-the-read-tier-key` |
343
+ | `your-…` / `your_…` | `your-api-key-here`, `your_api_key` |
344
+ | `example` / `sample`, optionally followed by more words | `example-token`, `sample-value` |
345
+ | a single `<…>` (the closing bracket may be missing) | `<fine-grained PAT>`, `<missing-bracket` |
346
+ | three or more dots | `...`, `sk-...` |
347
+ | four or more `x`, `X` or `*` | `xxxx`, `****` |
348
+
349
+ Everything else is masked, including `replace-with-…` — the rule keys on the `-me` — and any real
350
+ credential that merely contains the word "example". This list is the only exemption; there is no
351
+ entropy heuristic behind it.
352
+
353
+ A second shape that is *not* masked is a value that is a single `${…}` reference and nothing else —
289
354
  `password: "${DB_PASSWORD}"`, `` `${process.env.TOKEN}` `` — because that is an expression and
290
355
  masking it rewrites a program (or an assertion message) rather than hiding a credential. Anything
291
356
  inside the braces that is not a plain reference settles it the other way:
@@ -448,6 +513,9 @@ const config = {
448
513
  excludePatterns: [],
449
514
  discovery: "auto", // "auto" | "git" | "walk"
450
515
 
516
+ // ── Delivery ─────────────────────────────────────────────
517
+ attachmentSlots: 10, // files your destination takes per message; 0 = no limit
518
+
451
519
  // ── Classification ───────────────────────────────────────
452
520
  layersMode: "merge",
453
521
  layers: [],
@@ -460,6 +528,7 @@ const config = {
460
528
  // ── Artifacts ────────────────────────────────────────────
461
529
  artifacts: {
462
530
  readme: true,
531
+ prompt: true,
463
532
  manifest: true,
464
533
  parts: true,
465
534
  navigation: true,
@@ -73,7 +73,7 @@ before you spend it on a model call.
73
73
  1. Generate with a ceiling that matches the destination.
74
74
  2. Run `report`; look at the per-layer breakdown.
75
75
  3. Cut the largest layer that does not answer your question.
76
- 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`.
77
77
  5. Keep the settings that produced a snapshot you actually used — the config is the durable artifact,
78
78
  not the output.
79
79