codebase-snapshot 0.20.8 → 0.20.12
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 +67 -6
- package/README.md +15 -16
- package/SECURITY.md +0 -1
- package/dist/bin.js +8200 -6854
- package/dist/{chunk-RVWDPCJ6.js → chunk-TUKY6KLH.js} +8707 -6963
- package/dist/chunk-WMEZFLUT.js +1 -0
- package/dist/cli.cjs +10993 -9653
- package/dist/cli.d.cts +2 -2
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +68 -19
- package/dist/{generate-worker-CkWFKtf0.d.ts → generate-worker-CRMESc0b.d.ts} +24 -11
- package/dist/{generate-worker-Wne8FzN5.d.cts → generate-worker-DMzNbsAW.d.cts} +24 -11
- package/dist/index.cjs +8334 -6753
- package/dist/index.d.cts +66 -40
- package/dist/index.d.ts +66 -40
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +5026 -10058
- package/dist/mcp.d.cts +17 -5
- package/dist/mcp.d.ts +17 -5
- package/dist/mcp.js +2 -2
- package/dist/{types-CykWdR6V.d.cts → types-C5ytHMYz.d.cts} +10 -0
- package/dist/{types-CykWdR6V.d.ts → types-C5ytHMYz.d.ts} +10 -0
- package/docs/benchmarks.md +9 -6
- package/docs/budget.md +3 -2
- package/docs/cli.md +22 -21
- package/docs/configuration.md +17 -16
- package/docs/deploy.md +2 -2
- package/docs/health.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +8 -11
- package/docs/mcp.md +22 -16
- package/docs/migration.md +42 -43
- package/docs/output.md +2 -1
- package/docs/security-review.md +35 -8
- package/docs/tools.md +4 -3
- package/docs/vs-gitingest.md +2 -2
- package/docs/vs-repomix.md +7 -6
- package/docs/workspace.md +4 -2
- package/package.json +1 -1
- package/dist/chunk-STWEFBES.js +0 -459
package/dist/mcp.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-DMzNbsAW.cjs';
|
|
2
2
|
import { Readable, Writable } from 'node:stream';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-C5ytHMYz.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* JSON-RPC 2.0 envelopes and the Model Context Protocol revisions this server speaks.
|
|
@@ -107,8 +107,14 @@ declare const METHOD: {
|
|
|
107
107
|
* Deliberately not `unknown`: the tool table is authored by hand, and the compiler catching a
|
|
108
108
|
* misspelled keyword is worth more than accepting every dialect feature we never emit.
|
|
109
109
|
*/
|
|
110
|
+
type JsonSchemaType = "object" | "string" | "number" | "integer" | "boolean" | "array";
|
|
110
111
|
interface JsonSchema {
|
|
111
|
-
|
|
112
|
+
/**
|
|
113
|
+
* A single type, or the union a human-facing byte budget needs: `maxPartBytes` accepts both
|
|
114
|
+
* `307200` and `"300k"`, and the generated JSON Schema should say so rather than document one
|
|
115
|
+
* shape and reject it.
|
|
116
|
+
*/
|
|
117
|
+
type?: JsonSchemaType | readonly JsonSchemaType[];
|
|
112
118
|
description?: string;
|
|
113
119
|
properties?: Record<string, JsonSchema>;
|
|
114
120
|
required?: string[];
|
|
@@ -141,6 +147,8 @@ interface ToolContext {
|
|
|
141
147
|
cwd: string;
|
|
142
148
|
/** Absolute directories a `root` argument is allowed to resolve into. */
|
|
143
149
|
roots: string[];
|
|
150
|
+
/** True when `mcp --no-config` asked to ignore every configuration file. */
|
|
151
|
+
noConfig?: boolean;
|
|
144
152
|
/** Writes one line to stderr. Never stdout, which carries protocol messages only. */
|
|
145
153
|
log: (line: string) => void;
|
|
146
154
|
/**
|
|
@@ -167,8 +175,8 @@ interface ToolContext {
|
|
|
167
175
|
* Client-facing hints.
|
|
168
176
|
*
|
|
169
177
|
* `readOnlyHint` is the one that changes behaviour rather than appearance: clients use it to
|
|
170
|
-
* auto-approve a call.
|
|
171
|
-
*
|
|
178
|
+
* auto-approve a call. Twenty-five of the 26 tools never write, so they are marked read-only;
|
|
179
|
+
* only `snapshot_generate` writes.
|
|
172
180
|
*/
|
|
173
181
|
interface ToolAnnotations {
|
|
174
182
|
readOnlyHint: boolean;
|
|
@@ -451,6 +459,8 @@ interface ServerOptions {
|
|
|
451
459
|
notify?: (message: JsonObject) => void;
|
|
452
460
|
/** Additional directories callers may name as `root`. Defaults to `cwd` alone. */
|
|
453
461
|
roots?: string[];
|
|
462
|
+
/** True when `--no-config` asked to ignore every configuration file. */
|
|
463
|
+
noConfig?: boolean;
|
|
454
464
|
/** Where operational notes go. Never stdout, which carries protocol messages only. */
|
|
455
465
|
log?: (line: string) => void;
|
|
456
466
|
}
|
|
@@ -495,6 +505,8 @@ interface HttpTransportOptions {
|
|
|
495
505
|
/** Extra origins, beyond loopback. */
|
|
496
506
|
allowedOrigins?: readonly string[];
|
|
497
507
|
maxBodyBytes?: number;
|
|
508
|
+
/** True when `mcp --no-config` asked to ignore every config file. */
|
|
509
|
+
noConfig?: boolean;
|
|
498
510
|
log?: (line: string) => void;
|
|
499
511
|
}
|
|
500
512
|
interface HttpTransport {
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-CRMESc0b.js';
|
|
2
2
|
import { Readable, Writable } from 'node:stream';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-C5ytHMYz.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* JSON-RPC 2.0 envelopes and the Model Context Protocol revisions this server speaks.
|
|
@@ -107,8 +107,14 @@ declare const METHOD: {
|
|
|
107
107
|
* Deliberately not `unknown`: the tool table is authored by hand, and the compiler catching a
|
|
108
108
|
* misspelled keyword is worth more than accepting every dialect feature we never emit.
|
|
109
109
|
*/
|
|
110
|
+
type JsonSchemaType = "object" | "string" | "number" | "integer" | "boolean" | "array";
|
|
110
111
|
interface JsonSchema {
|
|
111
|
-
|
|
112
|
+
/**
|
|
113
|
+
* A single type, or the union a human-facing byte budget needs: `maxPartBytes` accepts both
|
|
114
|
+
* `307200` and `"300k"`, and the generated JSON Schema should say so rather than document one
|
|
115
|
+
* shape and reject it.
|
|
116
|
+
*/
|
|
117
|
+
type?: JsonSchemaType | readonly JsonSchemaType[];
|
|
112
118
|
description?: string;
|
|
113
119
|
properties?: Record<string, JsonSchema>;
|
|
114
120
|
required?: string[];
|
|
@@ -141,6 +147,8 @@ interface ToolContext {
|
|
|
141
147
|
cwd: string;
|
|
142
148
|
/** Absolute directories a `root` argument is allowed to resolve into. */
|
|
143
149
|
roots: string[];
|
|
150
|
+
/** True when `mcp --no-config` asked to ignore every configuration file. */
|
|
151
|
+
noConfig?: boolean;
|
|
144
152
|
/** Writes one line to stderr. Never stdout, which carries protocol messages only. */
|
|
145
153
|
log: (line: string) => void;
|
|
146
154
|
/**
|
|
@@ -167,8 +175,8 @@ interface ToolContext {
|
|
|
167
175
|
* Client-facing hints.
|
|
168
176
|
*
|
|
169
177
|
* `readOnlyHint` is the one that changes behaviour rather than appearance: clients use it to
|
|
170
|
-
* auto-approve a call.
|
|
171
|
-
*
|
|
178
|
+
* auto-approve a call. Twenty-five of the 26 tools never write, so they are marked read-only;
|
|
179
|
+
* only `snapshot_generate` writes.
|
|
172
180
|
*/
|
|
173
181
|
interface ToolAnnotations {
|
|
174
182
|
readOnlyHint: boolean;
|
|
@@ -451,6 +459,8 @@ interface ServerOptions {
|
|
|
451
459
|
notify?: (message: JsonObject) => void;
|
|
452
460
|
/** Additional directories callers may name as `root`. Defaults to `cwd` alone. */
|
|
453
461
|
roots?: string[];
|
|
462
|
+
/** True when `--no-config` asked to ignore every configuration file. */
|
|
463
|
+
noConfig?: boolean;
|
|
454
464
|
/** Where operational notes go. Never stdout, which carries protocol messages only. */
|
|
455
465
|
log?: (line: string) => void;
|
|
456
466
|
}
|
|
@@ -495,6 +505,8 @@ interface HttpTransportOptions {
|
|
|
495
505
|
/** Extra origins, beyond loopback. */
|
|
496
506
|
allowedOrigins?: readonly string[];
|
|
497
507
|
maxBodyBytes?: number;
|
|
508
|
+
/** True when `mcp --no-config` asked to ignore every config file. */
|
|
509
|
+
noConfig?: boolean;
|
|
498
510
|
log?: (line: string) => void;
|
|
499
511
|
}
|
|
500
512
|
interface HttpTransport {
|
package/dist/mcp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-
|
|
1
|
+
import './chunk-WMEZFLUT.js';
|
|
2
|
+
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText } from './chunk-TUKY6KLH.js';
|
|
@@ -99,6 +99,8 @@ type SkipReason = "binary" | "read-error" | "not-file"
|
|
|
99
99
|
| "gitignore"
|
|
100
100
|
/** Excluded by a built-in rule: the ignore list, a preset, or an output dir. */
|
|
101
101
|
| "default-ignore"
|
|
102
|
+
/** A directory with a .codebase-snapshot marker, recorded instead of silently dropped. */
|
|
103
|
+
| "tool-output"
|
|
102
104
|
/** Excluded by the user's own `excludePatterns` or `include` allow-list. */
|
|
103
105
|
| "excluded"
|
|
104
106
|
/**
|
|
@@ -918,6 +920,14 @@ interface ResolvedSnapshotConfig {
|
|
|
918
920
|
kinds: KindRule[];
|
|
919
921
|
excludePatterns: string[];
|
|
920
922
|
secretRules: SecretRule[];
|
|
923
|
+
/**
|
|
924
|
+
* The custom rules only, separated from the built-ins.
|
|
925
|
+
*
|
|
926
|
+
* Health and review already add the default rules themselves. Passing the full `secretRules`
|
|
927
|
+
* list made every built-in rule run twice, and omitting the custom rules entirely let a project's
|
|
928
|
+
* own token shape pass a clean audit. This is the half they need.
|
|
929
|
+
*/
|
|
930
|
+
customSecretRules?: SecretRule[];
|
|
921
931
|
}
|
|
922
932
|
interface CliOptions {
|
|
923
933
|
mode: Mode;
|
|
@@ -99,6 +99,8 @@ type SkipReason = "binary" | "read-error" | "not-file"
|
|
|
99
99
|
| "gitignore"
|
|
100
100
|
/** Excluded by a built-in rule: the ignore list, a preset, or an output dir. */
|
|
101
101
|
| "default-ignore"
|
|
102
|
+
/** A directory with a .codebase-snapshot marker, recorded instead of silently dropped. */
|
|
103
|
+
| "tool-output"
|
|
102
104
|
/** Excluded by the user's own `excludePatterns` or `include` allow-list. */
|
|
103
105
|
| "excluded"
|
|
104
106
|
/**
|
|
@@ -918,6 +920,14 @@ interface ResolvedSnapshotConfig {
|
|
|
918
920
|
kinds: KindRule[];
|
|
919
921
|
excludePatterns: string[];
|
|
920
922
|
secretRules: SecretRule[];
|
|
923
|
+
/**
|
|
924
|
+
* The custom rules only, separated from the built-ins.
|
|
925
|
+
*
|
|
926
|
+
* Health and review already add the default rules themselves. Passing the full `secretRules`
|
|
927
|
+
* list made every built-in rule run twice, and omitting the custom rules entirely let a project's
|
|
928
|
+
* own token shape pass a clean audit. This is the half they need.
|
|
929
|
+
*/
|
|
930
|
+
customSecretRules?: SecretRule[];
|
|
921
931
|
}
|
|
922
932
|
interface CliOptions {
|
|
923
933
|
mode: Mode;
|
package/docs/benchmarks.md
CHANGED
|
@@ -21,8 +21,9 @@ tokens in full.
|
|
|
21
21
|
|
|
22
22
|
- **Files** — entries in `manifest.files`, i.e. what the parts actually carry.
|
|
23
23
|
- **Parts** — part files written. A budget/slice snapshot tends to be one part because it fits.
|
|
24
|
-
- **Tokens** — `manifest.totals.estimatedTokens`, the
|
|
25
|
-
|
|
24
|
+
- **Tokens** — `manifest.totals.estimatedTokens`, the structural estimate the product reports.
|
|
25
|
+
`estimateTokens` counts word runs, punctuation and newline runs; it is neither bytes/4 nor a
|
|
26
|
+
tokenizer count, and every model tokenizes differently.
|
|
26
27
|
- **vs full** — token share of the full snapshot.
|
|
27
28
|
- **Time** — wall clock for the whole `generate` process, including scan, parse, partition and write.
|
|
28
29
|
|
|
@@ -66,9 +67,10 @@ identical, which is what a deterministic scanner should do.
|
|
|
66
67
|
|
|
67
68
|
Read it carefully:
|
|
68
69
|
|
|
69
|
-
- **The ratio is not a contest.** Our estimate
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
- **The ratio is not a contest.** Our manifest estimate weighs word runs, punctuation and
|
|
71
|
+
newlines; the byte-based budget planner uses one token per four bytes; repomix uses a tokenizer.
|
|
72
|
+
Across nine repositories the two land within about plus or minus 30%, which is what two
|
|
73
|
+
reasonable estimates of the same text do.
|
|
72
74
|
- **minimatch is the exception, and it is a policy difference, not an estimate.** That repository
|
|
73
75
|
carries five benchmark fixtures of 20 to 25 MB of JSON. repomix emits them (64.8M tokens); our
|
|
74
76
|
large-file rule emits a bounded preview and records the omission, so the pack stays 319,879 tokens.
|
|
@@ -110,7 +112,8 @@ gitingest from PyPI, same machine:
|
|
|
110
112
|
Read that honestly:
|
|
111
113
|
|
|
112
114
|
- **repomix reports fewer tokens for a similar pack** (854k against our 1.03M, 83%). The cause is
|
|
113
|
-
the estimator, not the content:
|
|
115
|
+
the estimator, not the content: our manifest counts word runs, punctuation and newlines (the
|
|
116
|
+
budget planner uses bytes/4), while repomix uses a tokenizer.
|
|
114
117
|
Our number is conservative, which is the right direction for a budget — a plan that fits
|
|
115
118
|
1,027,911 tokens fits a tokenizer count of 854,178 far more often than the reverse.
|
|
116
119
|
- **Our pack is smaller in bytes** (3.20 MB of file content against repomix's 3.39 MB of output,
|
package/docs/budget.md
CHANGED
|
@@ -22,8 +22,9 @@ Every scanned file is scored once:
|
|
|
22
22
|
| Cost | up to −40 | A cheap file that matters beats an expensive one that barely does. |
|
|
23
23
|
|
|
24
24
|
Files are taken in score order while the running token estimate fits; a file that would exceed the
|
|
25
|
-
budget is skipped whole, not cut.
|
|
26
|
-
|
|
25
|
+
budget is skipped whole, not cut. This planner uses one token per four bytes of emitted body. The
|
|
26
|
+
manifest's `estimatedTokens` is the structural `estimateTokens` result instead, so the two differ
|
|
27
|
+
by construction and neither is a tokenizer count.
|
|
27
28
|
|
|
28
29
|
## What it records
|
|
29
30
|
|
package/docs/cli.md
CHANGED
|
@@ -98,7 +98,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
|
|
|
98
98
|
|
|
99
99
|
```
|
|
100
100
|
📸 Generating snapshot for: /path/to/repo
|
|
101
|
-
Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.
|
|
101
|
+
Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.12 (project dependency ^0.20.12)
|
|
102
102
|
|
|
103
103
|
✅ Snapshot generated in 0.14s:
|
|
104
104
|
- 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
|
|
@@ -209,8 +209,9 @@ The whole first run in one command, with defaults and no prompts. This is the sa
|
|
|
209
209
|
`--autopilot` uses, spelled as a command word:
|
|
210
210
|
|
|
211
211
|
1. Detects the project preset.
|
|
212
|
-
2. Writes `snapshot.config.
|
|
213
|
-
|
|
212
|
+
2. Writes `snapshot.config.json` — **only when the repository has none**. An existing config is
|
|
213
|
+
kept byte for byte and the output says `Keeping …`. A data-only config is intentional: the MCP
|
|
214
|
+
server and `serve` refuse executable repository code.
|
|
214
215
|
3. Adds `scripts.snapshot`, `scripts.snapshot:validate`, the `devDependencies` entry and the
|
|
215
216
|
`.gitignore` entries, exactly as `init` does.
|
|
216
217
|
4. Installs dependencies with the package manager the repository already uses — a lockfile
|
|
@@ -221,9 +222,9 @@ The whole first run in one command, with defaults and no prompts. This is the sa
|
|
|
221
222
|
|
|
222
223
|
```
|
|
223
224
|
🚀 Setup for: /path/to/repo
|
|
224
|
-
✅ Created snapshot.config.
|
|
225
|
+
✅ Created snapshot.config.json (preset: nextjs)
|
|
225
226
|
Added npm scripts: snapshot, snapshot:validate
|
|
226
|
-
Added devDependency: codebase-snapshot ^0.20.
|
|
227
|
+
Added devDependency: codebase-snapshot ^0.20.12
|
|
227
228
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
228
229
|
⏳ Installing dependencies…
|
|
229
230
|
✅ Installed dependencies (npm install, 2.1s)
|
|
@@ -265,17 +266,17 @@ The whole first run in one command, with defaults and no prompts. This is the sa
|
|
|
265
266
|
codebase-snapshot init [options]
|
|
266
267
|
```
|
|
267
268
|
|
|
268
|
-
Detects the project and writes `snapshot.config.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
Detects the project and writes `snapshot.config.json` containing **every** setting at its
|
|
270
|
+
current value. It is a reference you can keep, not just a diff — there is no shorter variant,
|
|
271
|
+
because the file that documents the settings is the file you edit. JSON is deliberate: the MCP
|
|
272
|
+
server and `serve` refuse executable repository configs, so `init` never writes one.
|
|
272
273
|
|
|
273
274
|
It also has three side effects on files you own, and it says so when it does them:
|
|
274
275
|
|
|
275
276
|
```
|
|
276
|
-
✅ Created snapshot.config.
|
|
277
|
+
✅ Created snapshot.config.json (preset: node-lib)
|
|
277
278
|
Added npm scripts: snapshot, snapshot:validate
|
|
278
|
-
Added devDependency: codebase-snapshot ^0.20.
|
|
279
|
+
Added devDependency: codebase-snapshot ^0.20.12
|
|
279
280
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
280
281
|
```
|
|
281
282
|
|
|
@@ -308,10 +309,10 @@ file.
|
|
|
308
309
|
Interactive by default; with `--yes` it accepts every default and never prompts, which is
|
|
309
310
|
what agents and release checks should use.
|
|
310
311
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
run through `npx` and never installed.
|
|
312
|
+
A new configuration is always `snapshot.config.json`, a plain JSON object with no imports. JSON
|
|
313
|
+
is the shape `mcp` and `serve` accept without executing repository code; request an executable
|
|
314
|
+
`.ts`/`.js`/`.mjs` file yourself only if you need function matchers. The file works even when
|
|
315
|
+
the package is only run through `npx` and never installed.
|
|
315
316
|
|
|
316
317
|
Related options: `--preset`, `--include`, `--exclude`, `--yes` and `--force`
|
|
317
318
|
apply to `init` and `setup` only. `init` also accepts `--dry-run`, `--max-part-bytes`, `--out-dir`,
|
|
@@ -425,12 +426,12 @@ agent](agent.md).
|
|
|
425
426
|
Ask the npm registry whether a newer release exists, and print the version it compared against:
|
|
426
427
|
|
|
427
428
|
```bash
|
|
428
|
-
npx codebase-snapshot@0.20.
|
|
429
|
-
npx codebase-snapshot@0.20.
|
|
429
|
+
npx codebase-snapshot@0.20.9 update # is 0.20.12 current? print the answer
|
|
430
|
+
npx codebase-snapshot@0.20.9 update --format json
|
|
430
431
|
```
|
|
431
432
|
|
|
432
433
|
```text
|
|
433
|
-
↑ codebase-snapshot 0.
|
|
434
|
+
↑ codebase-snapshot 0.20.12 is available — you have 0.20.9.
|
|
434
435
|
npm install -g codebase-snapshot
|
|
435
436
|
```
|
|
436
437
|
|
|
@@ -519,7 +520,7 @@ for the two install flags, and the init-and-setup flags list both commands.
|
|
|
519
520
|
| `--deep` | flag | off | health | Replay every full body from the source bytes on disk and compare it with the part. The only allowed difference is a redaction marker. Off by default because it re-reads the repository. |
|
|
520
521
|
| `--strict` | flag | off | health | `health` only: exit 2 when a critical check fails, and 1 when a warning is the only thing left. Without it a critical check exits 1 and warnings exit 0. |
|
|
521
522
|
| `--mode <command>` | string | unset | generate, validate, report, explain, init, setup, diff, describe, skill | Select the command when no command word is given. A command word and `--mode` must name the same command; a contradiction is a usage error (exit 2). |
|
|
522
|
-
| `--no-update-check` | flag | off | all commands | Skip the check for a newer published version. Already skipped when stdout is not a terminal, in CI, in a JSON invocation, and in `mcp`, which makes no network requests. |
|
|
523
|
+
| `--no-update-check` | flag | off | all commands except `update` | Skip the check for a newer published version. Already skipped when stdout is not a terminal, in CI, in a JSON invocation, and in `mcp`, which makes no network requests. `update` exists to contact the registry, so it has no check to skip. |
|
|
523
524
|
| `--prompt-task <task>` | string | `audit` | generate, validate | `audit`, `review` or `explain` — which job the brief is written for. Changes the opening section, not the standard. |
|
|
524
525
|
| `--budget-tokens <n>` | count | unset | generate | Fit the snapshot into n tokens by selecting whole files (entry points, then the most-imported). Records a `budget` block; the rest are `not-selected`. See [budget](budget.md). |
|
|
525
526
|
| `--sign` | flag | off | generate | Sign `manifest.json` with Ed25519 and write `signature.json`. Key from `SNAPSHOT_SIGNING_KEY`, else generated (trust on first use). See [signing](signing.md). |
|
|
@@ -552,13 +553,13 @@ for the two install flags, and the init-and-setup flags list both commands.
|
|
|
552
553
|
| `--watch` | flag | off | generate | Regenerate on every change until interrupted. Redaction and parsing are cached per file across runs in the same process, keyed on the content hash, so a one-file edit regenerates from that one file instead of from the whole repository. The cache is memory only and is dropped when the process exits. |
|
|
553
554
|
| `--autopilot` | flag | off | generate | Set the project up without asking — config, `.gitignore`, npm scripts, devDependency, install — then generate. Never overwrites an existing config; refuses an empty directory (exit `1`); contradicts `--no-config` (exit `2`). |
|
|
554
555
|
| `--no-install` | flag | off | setup, generate `--autopilot` | Skip the dependency install. Anywhere else it is a usage error, because it would change nothing. |
|
|
555
|
-
| `--no-config` | flag | off | generate, validate, report, explain, diff | Ignore every `snapshot.config.*` file and run on the built-in defaults. `diff` never loads a config anyway and accepts the flag for consistency. |
|
|
556
|
+
| `--no-config` | flag | off | generate, validate, report, explain, diff, mcp | Ignore every `snapshot.config.*` file and run on the built-in defaults. `diff` never loads a config anyway and accepts the flag for consistency; `mcp` uses it when a repository config cannot be read or should not be trusted. |
|
|
556
557
|
| `--discovery <mode>` | enum | `auto` | generate, validate, explain, setup | How files are found: `auto` lists through git when git works and refuses when a `.git` directory cannot be listed; `git` requires git; `walk` scans the tree and reads `.gitignore` files directly. The escape hatch for a broken `.git`. |
|
|
557
558
|
| `--preset <name>` | name | detected | init, setup | Force a preset instead of detecting one. |
|
|
558
559
|
| `--include <globs>` | list | unset | init, setup | Allow-list recorded in the generated config. |
|
|
559
560
|
| `--exclude <globs>` | list | unset | init, setup | Exclude globs recorded in the generated config. |
|
|
560
561
|
| `--yes` | flag | off | init, setup | Never prompt; accept every default. |
|
|
561
|
-
| `--force` | flag | off | init, setup | Replace an existing
|
|
562
|
+
| `--force` | flag | off | init, setup | Replace an existing JSON-family config in place. An executable `.ts`/`.js`/`.mjs` config is refused, naming the file to remove. |
|
|
562
563
|
| `--install` | flag | off | *skill only* | Write the skill into the repository instead of printing it. |
|
|
563
564
|
| `--target <name>` | enum | `all` | *skill only* | `claude`, `cursor` or `all`. |
|
|
564
565
|
| `-h`, `--help` | flag | — | every command | Print usage. |
|
package/docs/configuration.md
CHANGED
|
@@ -49,14 +49,15 @@ A config file that exists but cannot be parsed is a **hard error** (exit `1`, no
|
|
|
49
49
|
written). Silently ignoring it would produce a snapshot with none of your settings.
|
|
50
50
|
|
|
51
51
|
A `.ts` config needs Node ≥ 22.6 **and** an ES-module project, because Node applies the
|
|
52
|
-
package's `type` field to a `.ts` file. `codebase-snapshot init`
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
package's `type` field to a `.ts` file. `codebase-snapshot init` writes `snapshot.config.json`
|
|
53
|
+
for a new project: data only, no imports, and accepted by `mcp` and `serve` without executing
|
|
54
|
+
repository code. An executable `.ts`/`.js`/`.mjs` config is something you create yourself and
|
|
55
|
+
can use with the CLI; those surfaces refuse to run it.
|
|
55
56
|
|
|
56
|
-
The snippets below show an `export default { … }` object
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
The snippets below show an `export default { … }` object because that is the executable form.
|
|
58
|
+
A JSON config uses the same keys without the export wrapper. Both load identically for the CLI.
|
|
59
|
+
For an executable config, prefer `const config = { … }; export default config;` over the
|
|
60
|
+
anonymous form, which `eslint-config-next` reports via `import/no-anonymous-default-export`.
|
|
60
61
|
|
|
61
62
|
CLI flags override the config for a single run (`--max-part-bytes`, `--out-dir`, …).
|
|
62
63
|
`--no-config` goes further and ignores every config file, so the run uses the built-in
|
|
@@ -674,13 +675,13 @@ npx codebase-snapshot init --preset go --max-part-bytes 200k \
|
|
|
674
675
|
--include "cmd/**,internal/**" --exclude "**/*_test.go" --yes
|
|
675
676
|
```
|
|
676
677
|
|
|
677
|
-
`--dry-run` prints the config and writes nothing.
|
|
678
|
-
config
|
|
679
|
-
|
|
678
|
+
`--dry-run` prints the config and writes nothing. A new configuration is
|
|
679
|
+
`snapshot.config.json`, the data-only form MCP and serve accept. `--force` rewrites an existing
|
|
680
|
+
configuration in place: a JSON-family file keeps JSON; an ES-module `.ts`, ESM `.js`, or `.mjs`
|
|
681
|
+
file keeps its executable format. A CommonJS `.js` or `.cjs` file is refused, because this
|
|
682
|
+
wizard cannot write that format, and a new file beside it would silently shadow the old one.
|
|
683
|
+
Without `--force`, an existing config is left alone and the command exits `1`.
|
|
680
684
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
with a message naming the file to delete or rename. Note that this means `--force` writing
|
|
685
|
-
`snapshot.config.ts` does shadow a `"snapshot"` key in `package.json`, since a dedicated config
|
|
686
|
-
file always wins.
|
|
685
|
+
A `"snapshot"` key in `package.json` is handled the same way: without `--force` the command
|
|
686
|
+
exits `1` and names the key; with `--force` it writes `snapshot.config.json`, and that file then
|
|
687
|
+
takes precedence over the key. The key itself is not edited.
|
package/docs/deploy.md
CHANGED
|
@@ -61,8 +61,8 @@ After=network.target
|
|
|
61
61
|
Type=oneshot
|
|
62
62
|
User=deploy
|
|
63
63
|
WorkingDirectory=/srv/app
|
|
64
|
-
ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.
|
|
65
|
-
ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.
|
|
64
|
+
ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.9 generate --cwd /srv/app
|
|
65
|
+
ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.9 validate --cwd /srv/app
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
```ini
|
package/docs/health.md
CHANGED
|
@@ -32,7 +32,7 @@ npx codebase-snapshot health --deep # also replay every full body from t
|
|
|
32
32
|
| Every pack body is the part body | `packs.bodies` | critical | For full files, the bytes in the pack equal the bytes in the part; previews and signatures are whole-file by design. |
|
|
33
33
|
| Every full body replays from the source | `fidelity.bodies` | critical | With `--deep`: each full body is rebuilt from the bytes on disk (redaction allowed) and compared. Skipped without `--deep`. |
|
|
34
34
|
| A member matches its workspace index | `workspace.index` | warning | Fingerprint and file count equal `WORKSPACE.json`, and a member whose source directory is gone warns. |
|
|
35
|
-
| No unmasked secret in any artifact | `secrets.artifacts` | critical | Every written text file is re-scanned with the secret rules; a signature record is scanned without its random key material. |
|
|
35
|
+
| No unmasked secret in any artifact | `secrets.artifacts` | critical | Every written text file is re-scanned with the secret rules; a signature record is scanned without its random key material. If `maxScanBytes` truncates the scan, the check is a warning, never a pass. |
|
|
36
36
|
| No value from an excluded sensitive file appears | `secrets.skipped` | critical | Values from `.env`, keys and similar files are compared byte-for-byte against the artifacts. |
|
|
37
37
|
| No host path or machine identity | `pii.paths` | warning | `/home/…`, `/Users/…`, `C:\Users\…` and the repository's absolute path are searched for. |
|
|
38
38
|
| Token estimate is plausible | `tokens.count` | warning | The recorded estimate is compared with one recomputed from the parts. |
|
|
@@ -31,9 +31,9 @@ snapshot # installed globally: one word, and it asks once
|
|
|
31
31
|
npx codebase-snapshot setup # or from a checkout with no global install
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
`setup` detects the project type from the repository, writes a
|
|
35
|
-
the npm scripts and the devDependency, installs it, and generates. It does not overwrite a
|
|
36
|
-
already have. Use `--no-install` if you would rather not touch the lockfile. `npx codebase-snapshot
|
|
34
|
+
`setup` detects the project type from the repository, writes a data-only `snapshot.config.json`,
|
|
35
|
+
adds the npm scripts and the devDependency, installs it, and generates. It does not overwrite a
|
|
36
|
+
config you already have. Use `--no-install` if you would rather not touch the lockfile. `npx codebase-snapshot
|
|
37
37
|
--autopilot` does the same thing with no questions at all, which is what you want in CI.
|
|
38
38
|
|
|
39
39
|
If you prefer to see each stage:
|
|
@@ -56,14 +56,11 @@ destination, not from taste:
|
|
|
56
56
|
| A RAG index | 120–300 KB per part, chunked by heading |
|
|
57
57
|
| An agent's context | 60–150 KB; smaller parts leave room to reason |
|
|
58
58
|
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
budgets: { default: "120k", byLayer: { docs: 40_000 } },
|
|
65
|
-
};
|
|
66
|
-
export default config;
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"maxPartBytes": "120k",
|
|
62
|
+
"budgets": { "default": "120k", "byLayer": { "docs": 40000 } }
|
|
63
|
+
}
|
|
67
64
|
```
|
|
68
65
|
|
|
69
66
|
A file is never cut down to make a part fit. A file above `largeFileBytes` — which defaults to the
|
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.20.
|
|
13
|
+
npx -y codebase-snapshot@0.20.9 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.20.
|
|
28
|
+
"args": ["-y", "codebase-snapshot@0.20.9", "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.20.
|
|
37
|
+
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.9 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
|
|
@@ -43,7 +43,7 @@ there, and clients that spawn without a shell cannot execute it directly.
|
|
|
43
43
|
## Over HTTP, for clients that cannot spawn a process
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
npx -y codebase-snapshot@0.20.
|
|
46
|
+
npx -y codebase-snapshot@0.20.9 mcp --http --port 4789
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
This is the Streamable HTTP shape: POST one JSON-RPC message (or an array) to `/mcp` and read
|
|
@@ -73,6 +73,7 @@ reachable from the network must not be readable by any page that guesses the por
|
|
|
73
73
|
| `--token <value>` | generated | Bearer token |
|
|
74
74
|
| `--no-auth` | off | Unauthenticated; loopback only |
|
|
75
75
|
| `--allow-origin <list>` | unset | Extra CORS origins, comma separated |
|
|
76
|
+
| `--no-config` | off | Ignore every config file and use the detected preset plus defaults |
|
|
76
77
|
|
|
77
78
|
CORS is granted to loopback origins (`localhost`, `127.0.0.1`, `[::1]`, any port) and to the
|
|
78
79
|
origins you list. Any other `Origin` gets `403`.
|
|
@@ -81,8 +82,10 @@ The first `initialize` response carries an `mcp-session-id` header. Send it on e
|
|
|
81
82
|
request: era and cancellation state belong to that session, so one client's
|
|
82
83
|
`server/discover` cannot reject another client's legacy handshake. A client that ignores the
|
|
83
84
|
header falls back to a per-address server; two such clients on one host with the same user agent
|
|
84
|
-
share state, which is why forwarding the header matters.
|
|
85
|
-
|
|
85
|
+
share state, which is why forwarding the header matters. An unknown `mcp-session-id` is answered
|
|
86
|
+
with `404`, never used to mint state; sessions expire after 30 minutes idle, the oldest is evicted
|
|
87
|
+
when the table is full, and `DELETE /mcp` closes one explicitly. JSON-RPC batches are capped at
|
|
88
|
+
100 messages, and the body cap applies before parsing.
|
|
86
89
|
|
|
87
90
|
### Legacy SSE, for clients that cannot send a header
|
|
88
91
|
|
|
@@ -140,26 +143,26 @@ between them should not have to guess.
|
|
|
140
143
|
| `snapshot_read` | A window of one file, as the snapshot contains it. | no |
|
|
141
144
|
| `snapshot_explain` | Why is this path not in the snapshot? | no |
|
|
142
145
|
|
|
143
|
-
|
|
144
|
-
`snapshot_generate`
|
|
146
|
+
Twenty-five are declared `readOnlyHint`, which most clients use to run them without asking. Only
|
|
147
|
+
`snapshot_generate` writes.
|
|
145
148
|
|
|
146
|
-
All
|
|
149
|
+
All 26 take `outDir`, so a snapshot generated into a directory other than the configured one is
|
|
147
150
|
still reachable: pass the same value to the read side that you passed to `snapshot_generate`. Before
|
|
148
151
|
that, only `snapshot_generate` honoured it and every other tool looked in the configured directory
|
|
149
152
|
and reported "there is no snapshot manifest here".
|
|
150
153
|
|
|
151
154
|
An `outDir` **tool argument** must resolve inside the repository the server serves: a prompt cannot
|
|
152
|
-
drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir`
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
drop a snapshot tree anywhere the process is able to write. The project's *configured* `outDir`
|
|
156
|
+
and `tmpDir` are confined the same way. If either escapes, the tool refuses and the message says
|
|
157
|
+
to move the directory inside the served root, or start the server with `--cwd` at the parent
|
|
158
|
+
repository.
|
|
156
159
|
|
|
157
160
|
`snapshot_plan`, `snapshot_generate`, `snapshot_validate` and `snapshot_explain` also take the
|
|
158
161
|
**scope and compression** switches `generate` accepts: `maxPartTokens`, `skeleton`, `sarif`,
|
|
159
162
|
`changedSince`, `staged` and `withDependents`. They have to: `manifest.config.digest` covers those
|
|
160
163
|
settings, so a snapshot generated with `--skeleton` was not merely un-inspectable over MCP, it was
|
|
161
164
|
reported as configuration drift on every `snapshot_validate`. Pass the same switches you generated
|
|
162
|
-
with, exactly as you would on the command line. The
|
|
165
|
+
with, exactly as you would on the command line. The other tools do not take them, because
|
|
163
166
|
none of them re-derives the configuration and a flag that changes nothing is the command-line form
|
|
164
167
|
of a silent fallback.
|
|
165
168
|
|
|
@@ -260,7 +263,10 @@ says what happened rather than pretending the call never ran.
|
|
|
260
263
|
before the check.
|
|
261
264
|
- **Emit a sensitive file.** `.env`, `*.pem` and the rest stay out, and `includeSensitiveFiles` is
|
|
262
265
|
not a tool argument — a prompt cannot ask for it. Reads come from the emitted snapshot, so
|
|
263
|
-
redaction applies to everything the client sees.
|
|
266
|
+
redaction applies to everything the client sees. A repository config that enables
|
|
267
|
+
`includeSensitiveFiles`, disables the default secret patterns, or supplies a custom regex that
|
|
268
|
+
can consume the event loop is refused with a clear error instead of being silently overridden.
|
|
269
|
+
The CLI still honors those settings because the user invoked it directly.
|
|
264
270
|
- **Install or configure.** `snapshot_generate` writes the snapshot directory and nothing else. It
|
|
265
271
|
never runs a package manager and never writes a config file.
|
|
266
272
|
- **Touch the network.** The stdio server makes no outbound connection. `--http` binds a loopback
|
|
@@ -276,7 +282,7 @@ server speaks both and answers whichever arrives first.
|
|
|
276
282
|
| Era | Revisions | Opening move |
|
|
277
283
|
| :-- | :-- | :-- |
|
|
278
284
|
| Legacy | `2025-11-25`, `2025-06-18` | `initialize`, then `notifications/initialized` |
|
|
279
|
-
| Modern | `2026-07-28` | `server/discover`, or `_meta` on every request |
|
|
285
|
+
| Modern | `2026-07-28` | `server/discover`, or `_meta` on every request; a stateless request with valid `_meta` is complete on its own |
|
|
280
286
|
|
|
281
287
|
The two disagree about an unsupported version, and the difference is observable: a legacy client is
|
|
282
288
|
negotiated *down* to a revision the server speaks, while a modern client receives `-32022` with the
|