codebase-snapshot 0.10.1 → 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/CHANGELOG.md +70 -0
- package/README.md +1 -1
- package/dist/bin.js +595 -396
- package/dist/{chunk-7DAW2LFZ.js → chunk-5AV7OR3J.js} +371 -176
- package/dist/{chunk-WDJ3O3R4.js → chunk-5EYBTBFY.js} +24 -28
- package/dist/cli.cjs +595 -396
- package/dist/cli.d.cts +11 -9
- package/dist/cli.d.ts +11 -9
- package/dist/cli.js +14 -6
- package/dist/{generate-worker-D_mUjgXw.d.cts → generate-worker-BK4uJx7Z.d.cts} +17 -8
- package/dist/{generate-worker-D_mUjgXw.d.ts → generate-worker-BK4uJx7Z.d.ts} +17 -8
- package/dist/index.cjs +347 -169
- package/dist/index.d.cts +68 -23
- package/dist/index.d.ts +68 -23
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +453 -2694
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{types-Z471HW65.d.cts → types-BoWneA7n.d.cts} +35 -4
- package/dist/{types-Z471HW65.d.ts → types-BoWneA7n.d.ts} +35 -4
- package/docs/cli.md +29 -8
- package/docs/codebase-token-budget.md +12 -9
- package/docs/configuration.md +18 -2
- package/docs/how-to-context-budget.md +1 -1
- package/docs/mcp.md +3 -3
- package/docs/output.md +8 -5
- package/docs/stale-context-is-your-bug.md +8 -4
- package/docs/vs-code2prompt.md +1 -1
- package/docs/vs-gitingest.md +1 -1
- package/docs/vs-repomix.md +1 -1
- package/package.json +1 -1
package/dist/mcp.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-
|
|
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-
|
|
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-
|
|
2
|
-
export { generateInWorker } from './chunk-
|
|
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
|
|
46
|
-
* `module.exports`/`exports
|
|
47
|
-
*
|
|
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
|
|
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
|
|
46
|
-
* `module.exports`/`exports
|
|
47
|
-
*
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
-
|
|
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 `{
|
|
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/` |
|
|
20
|
-
| Lines |
|
|
21
|
-
| Bytes |
|
|
22
|
-
| **Estimated tokens** | **≈
|
|
23
|
-
|
|
24
|
-
That single number decides the whole conversation.
|
|
25
|
-
|
|
26
|
-
in a 1M window
|
|
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.
|
|
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
|
package/docs/configuration.md
CHANGED
|
@@ -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
|
|
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
|
|
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:
|
|
@@ -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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
package/docs/output.md
CHANGED
|
@@ -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
|
|
190
|
-
|
|
191
|
-
fence shows one empty line, and a file ending in a
|
|
192
|
-
counts
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
package/docs/vs-code2prompt.md
CHANGED
|
@@ -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 |
|
|
33
|
+
| Secret handling | 32 defaults, value-span masking, audit table | Ignore rules |
|
|
34
34
|
|
|
35
35
|
## Where code2prompt is the better choice
|
|
36
36
|
|
package/docs/vs-gitingest.md
CHANGED
|
@@ -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 |
|
|
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
|
|
package/docs/vs-repomix.md
CHANGED
|
@@ -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 |
|
|
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 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-snapshot",
|
|
3
|
-
"version": "0.10.
|
|
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",
|