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/CHANGELOG.md +130 -0
- package/README.md +9 -1
- package/SECURITY.md +2 -2
- package/dist/bin.js +1247 -413
- package/dist/{chunk-WDJ3O3R4.js → chunk-5ZOXHBTW.js} +53 -30
- package/dist/{chunk-7DAW2LFZ.js → chunk-NJ75RVHO.js} +939 -180
- package/dist/cli.cjs +1246 -411
- package/dist/cli.d.cts +36 -11
- package/dist/cli.d.ts +36 -11
- package/dist/cli.js +60 -8
- 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 +915 -173
- package/dist/index.d.cts +69 -24
- package/dist/index.d.ts +69 -24
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +745 -2923
- 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-DGWw3SH2.d.cts} +75 -4
- package/dist/{types-Z471HW65.d.ts → types-DGWw3SH2.d.ts} +75 -4
- package/docs/cli.md +32 -8
- package/docs/codebase-token-budget.md +12 -9
- package/docs/configuration.md +71 -2
- package/docs/how-to-context-budget.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +40 -9
- package/docs/mcp.md +3 -3
- package/docs/output.md +60 -7
- 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
|
@@ -70,17 +70,36 @@ A file is never cut down to make a part fit. A file above `largeFileBytes` — w
|
|
|
70
70
|
budget — becomes a head/tail excerpt with an explicit marker, and `manifest.json` lists it in
|
|
71
71
|
`incomplete[]` with the line ranges it lost.
|
|
72
72
|
|
|
73
|
+
### 2b. Count the attachment slots, not just the bytes
|
|
74
|
+
|
|
75
|
+
Hosted chats take a fixed number of files per message — 10 is the common cap — and every part is
|
|
76
|
+
one file. A 12-part snapshot cannot be delivered to a 10-file chat at all, and no amount of
|
|
77
|
+
compression changes that: the payload is twelve files.
|
|
78
|
+
|
|
79
|
+
Three things follow:
|
|
80
|
+
|
|
81
|
+
- **Instructions are text, not a file.** Paste `PROMPT.md` into the message and attach only code.
|
|
82
|
+
A prompt that costs a slot is a part you do not get.
|
|
83
|
+
- **Parts before reports.** When the parts leave no room, skip `manifest.json` and `reports/`:
|
|
84
|
+
`PROMPT.md` already names the parts, the counts and the omissions.
|
|
85
|
+
- **Fewer parts, or fewer files.** Raise `maxPartBytes` to merge the parts into fewer, larger
|
|
86
|
+
files, or narrow the scope with `--include` and `excludePatterns` so the code that matters fits.
|
|
87
|
+
|
|
88
|
+
`PROMPT.md` does this arithmetic for the snapshot you have: how many parts fit, which to leave out
|
|
89
|
+
when they do not, and the `--max-part-bytes` value that would fit the whole repository.
|
|
90
|
+
|
|
73
91
|
### 3. Tell the model what it is looking at
|
|
74
92
|
|
|
75
|
-
|
|
93
|
+
`generate` writes `snapshot/PROMPT.md` for exactly this. Paste it before the parts.
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
It is rendered from the manifest rather than written once, so it is about *this* snapshot: the
|
|
96
|
+
parts by name, every file that is only partly present with the line ranges it lost, the skip
|
|
97
|
+
reasons with counts, the fingerprint to quote back, and the commit it was taken from. Regenerate
|
|
98
|
+
the snapshot and those numbers move with the code.
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
The sentence it exists to say is the one models otherwise fill by invention — *a file may be
|
|
101
|
+
missing, and the reason is recorded, so ask instead of assuming*. That is what turns a
|
|
102
|
+
hallucination into a question you can answer with `explain <path>`.
|
|
84
103
|
|
|
85
104
|
### 4. Include the index, always
|
|
86
105
|
|
|
@@ -98,10 +117,22 @@ npm run snapshot:validate || npm run snapshot
|
|
|
98
117
|
changed budget, layer rule or secret pattern is drift, not silence — so the check catches both code
|
|
99
118
|
changes and configuration changes.
|
|
100
119
|
|
|
101
|
-
## The prompt
|
|
120
|
+
## The prompt
|
|
102
121
|
|
|
103
122
|
Everything above is about producing the snapshot. This is the other half: what to say to the model
|
|
104
|
-
that receives it.
|
|
123
|
+
that receives it.
|
|
124
|
+
|
|
125
|
+
You do not have to write it. `snapshot/PROMPT.md` is the prompt, and being generated is what makes
|
|
126
|
+
it worth pasting: it describes the snapshot you are actually sending. It is a brief, not a packing
|
|
127
|
+
slip — the job, the system map the manifest can prove (layers, the modules with the most
|
|
128
|
+
importers, entry points, which surfaces were indexed), the last ten commit subjects as claims to
|
|
129
|
+
verify rather than rediscover, the evidence bar, the coverage owed, and calibration examples of
|
|
130
|
+
the defects that do not crash. Then the per-run apparatus: fingerprint, part inventory, partial
|
|
131
|
+
files, skip tallies and the attachment arithmetic.
|
|
132
|
+
|
|
133
|
+
If you are assembling the message by hand instead — a chat window that takes one file at a time, a
|
|
134
|
+
wrapper that cannot include a directory — this is the minimum that keeps the properties. Replace
|
|
135
|
+
the task section with your question.
|
|
105
136
|
|
|
106
137
|
```text
|
|
107
138
|
You are working on a codebase you cannot clone, run or grep. What you have is a generated snapshot of
|
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.
|
|
13
|
+
npx -y codebase-snapshot@0.11.0 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.
|
|
28
|
+
"args": ["-y", "codebase-snapshot@0.11.0", "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.
|
|
37
|
+
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.11.0 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
|
@@ -10,6 +10,7 @@ explains everything they omit.
|
|
|
10
10
|
snapshot/
|
|
11
11
|
├── .codebase-snapshot ownership marker (see Safety)
|
|
12
12
|
├── README.md human summary of this snapshot
|
|
13
|
+
├── PROMPT.md the instruction sheet to paste with it
|
|
13
14
|
├── manifest.json machine index: files, parts, config, hashes, skips
|
|
14
15
|
├── parts/
|
|
15
16
|
│ ├── part-001.md the code, grouped and size-budgeted
|
|
@@ -42,6 +43,55 @@ impossible field: a file cannot record its own sha256, so `artifacts.fullJson` i
|
|
|
42
43
|
embedded copy and a `selfReference` sentence points at `manifest.json`, which carries the real
|
|
43
44
|
`byteSize` and `sha256` for that file.
|
|
44
45
|
|
|
46
|
+
## PROMPT.md
|
|
47
|
+
|
|
48
|
+
The one artifact written for the model rather than for you, and the only one that is a *brief*
|
|
49
|
+
rather than an index. Paste it with the payload. It has two halves:
|
|
50
|
+
|
|
51
|
+
**The brief** — what to do and how to be believed:
|
|
52
|
+
|
|
53
|
+
- **The job**: find what is still wrong or will break, with the method left to the reader and an
|
|
54
|
+
honest account of coverage owed in return. A narrower task in the closing slot wins, and the
|
|
55
|
+
standard still applies to it.
|
|
56
|
+
- **The system**, from the manifest: layers and their file counts, the modules with the most
|
|
57
|
+
importers (so a reader knows what a change reaches), entry points by convention, the routes,
|
|
58
|
+
handlers and components the index found — or a plain statement that none were recorded, so a
|
|
59
|
+
model does not go looking for a surface that is not there — the largest files, and the share of
|
|
60
|
+
bytes that is tests.
|
|
61
|
+
- **What came before**: the last ten commit subjects, labelled as claims rather than evidence,
|
|
62
|
+
with the instruction to verify a recorded fix holds instead of rediscovering it. When git
|
|
63
|
+
cannot be read the section says so; it is never invented.
|
|
64
|
+
- **The bar**: quoted lines, the state that reaches them, why the apparent guard does not stop it;
|
|
65
|
+
no style findings, no invented findings, a clean surface proven by quoting the guard.
|
|
66
|
+
- **Coverage**: paths found, included and skipped with reasons, partial files with their missing
|
|
67
|
+
line ranges, redactions, and "everything unseen is unread, never clean".
|
|
68
|
+
- **Calibration**: the classes of defect that do not crash — a guard at one call site and not its
|
|
69
|
+
twin, a budget shorter than the work it guards, a success flag that means the call returned.
|
|
70
|
+
|
|
71
|
+
**The apparatus** — this run only:
|
|
72
|
+
|
|
73
|
+
- the fingerprint to quote back, the timestamp, the commit, whether the tree was dirty, and the
|
|
74
|
+
validation status with the warning that it describes the run and not the tree now;
|
|
75
|
+
- every part by name, and every file not present in full with its reason and missing ranges;
|
|
76
|
+
- the delivery arithmetic below.
|
|
77
|
+
|
|
78
|
+
Everything factual is rendered from the manifest and the repository, so the brief cannot describe
|
|
79
|
+
a different run. It only names artifacts that were actually written: `--skip-artifacts
|
|
80
|
+
parts,audit` produces a brief that does not tell a model to read parts, and says the per-file
|
|
81
|
+
redaction detail is unavailable rather than pointing at a file that is not there.
|
|
82
|
+
|
|
83
|
+
It also does the arithmetic of sending it. Hosted chats take a fixed number of files — 10 is the
|
|
84
|
+
common cap — and every part is one file, so a 12-part snapshot cannot be delivered whole. The
|
|
85
|
+
`## Attaching this` section states which files fit, what to leave behind, and the `--max-part-bytes`
|
|
86
|
+
value that would merge the parts into a number the destination accepts. The instructions themselves
|
|
87
|
+
are pasted as text, so they cost no attachment slot.
|
|
88
|
+
|
|
89
|
+
It only names artifacts that were actually written: `--skip-artifacts parts,audit` produces a
|
|
90
|
+
prompt that does not tell a model to read parts, and says the per-file redaction detail is
|
|
91
|
+
unavailable rather than pointing at a file that is not there. Its digest is recorded under
|
|
92
|
+
`artifacts.prompt`, so editing it by hand makes `validate` fail — a prompt that names a previous
|
|
93
|
+
run's parts is worse than no prompt, because it reads as current.
|
|
94
|
+
|
|
45
95
|
Every artifact can be turned off. `--skip-artifacts parts` omits the parts,
|
|
46
96
|
`--only-artifacts manifest` writes nothing but the manifest, and `config.artifacts` does the
|
|
47
97
|
same persistently. The ownership marker is always written.
|
|
@@ -104,15 +154,15 @@ diff the manifest only when you need to know that a run happened.
|
|
|
104
154
|
| `generatedAt` | ISO timestamp of the run. |
|
|
105
155
|
| `generator` | `{ name, version }` of the tool that wrote it. |
|
|
106
156
|
| `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. |
|
|
107
|
-
| `budgets` | The effective byte limits for the run: `{ maxPartBytes, largeFileBytes }`. The per-layer overrides live at `config.budgets`, which is `{ default, byLayer }`. |
|
|
157
|
+
| `budgets` | The effective byte limits for the run: `{ maxPartBytes, largeFileBytes }`. The per-layer overrides live at `config.budgets`, which is `{ default, byLayer }`. With the experimental `maxParts`, `maxPartBytes` here is the budget the run grew to and `config.maxPartBytes` keeps the configured ceiling. |
|
|
108
158
|
| `config` | The resolved configuration actually used (preset, artifacts, sizing, scoping). |
|
|
109
159
|
| `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount, incompleteCount }`. |
|
|
110
160
|
| `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. |
|
|
111
161
|
| `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. |
|
|
112
162
|
| `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
|
|
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. |
|
|
163
|
+
| `artifacts` | A digest of every artifact the run wrote: `readme`, `prompt`, `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
164
|
| `layers`, `kinds` | File counts per layer and per kind. |
|
|
115
|
-
| `indexes` | Cross-references: `routes`, `components`, `handlers`, `features`, `imports`, `directives`. |
|
|
165
|
+
| `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
166
|
| `parts` | One entry per part (below). |
|
|
117
167
|
| `files` | One entry per included file (below). |
|
|
118
168
|
| `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 +236,13 @@ has several at once, and "within budget" cannot be answered without knowing whic
|
|
|
186
236
|
than inlined whole.
|
|
187
237
|
- `isPreviewTruncated` is a fact about what was written: the body in this snapshot is **not**
|
|
188
238
|
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
|
|
239
|
+
- `includedLines` counts the lines of the fenced block: content lines after CRLF normalisation
|
|
240
|
+
and without a trailing empty element, **plus the omission notice when one is written**. An
|
|
241
|
+
empty file therefore records `0` while the fence shows one empty line, and a file ending in a
|
|
242
|
+
blank line records one fewer than a reader counts. A preview records head + tail + the notice
|
|
243
|
+
line — the block as written. It is not a count of surviving source content, which is why
|
|
244
|
+
`includedLines + omittedLines` is one more than `lines` for a preview and never a sum a reader
|
|
245
|
+
should reconcile.
|
|
193
246
|
- `inclusionMode` is `preview` exactly when `isPreviewTruncated` is `true`. There used to be two
|
|
194
247
|
routes to it, and the second — a file *under* `largeFileBytes` but too big for its part, cut
|
|
195
248
|
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.
|
|
3
|
+
"version": "0.11.0",
|
|
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",
|