codebase-snapshot 0.9.16 → 0.9.17
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 +64 -0
- package/README.md +1 -1
- package/SECURITY.md +18 -6
- package/dist/bin.js +2019 -619
- package/dist/{chunk-6TRFLA7N.js → chunk-IIP43I7C.js} +1755 -443
- package/dist/{chunk-WIL536QD.js → chunk-S4367K5X.js} +97 -24
- package/dist/cli.cjs +2001 -605
- package/dist/cli.d.cts +1 -11
- package/dist/cli.d.ts +1 -11
- package/dist/cli.js +16 -5
- package/dist/index.cjs +1748 -437
- package/dist/index.d.cts +97 -8
- package/dist/index.d.ts +97 -8
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +1760 -340
- package/dist/mcp.d.cts +7 -0
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.js +2 -2
- package/dist/{types-DIX6zWSt.d.cts → types-KbJvBjmV.d.cts} +46 -1
- package/dist/{types-DIX6zWSt.d.ts → types-KbJvBjmV.d.ts} +46 -1
- package/docs/cli.md +14 -9
- package/docs/configuration.md +16 -1
- package/docs/mcp.md +17 -7
- package/docs/output.md +3 -3
- package/docs/vs-gitingest.md +6 -2
- package/package.json +3 -2
package/dist/mcp.d.cts
CHANGED
|
@@ -68,6 +68,13 @@ declare const ERROR_CODES: {
|
|
|
68
68
|
* invent a partial one.
|
|
69
69
|
*/
|
|
70
70
|
readonly resourceTooLarge: -32000;
|
|
71
|
+
/**
|
|
72
|
+
* The server is at its concurrency limit.
|
|
73
|
+
*
|
|
74
|
+
* Implementation-defined range, like `resourceTooLarge`. A typed error rather than silent
|
|
75
|
+
* queueing or a dropped request: the caller can retry, and knows why.
|
|
76
|
+
*/
|
|
77
|
+
readonly overloaded: -32001;
|
|
71
78
|
readonly unsupportedProtocolVersion: -32022;
|
|
72
79
|
};
|
|
73
80
|
/** Method names, kept as constants so a typo is a compile error rather than a `-32601`. */
|
package/dist/mcp.d.ts
CHANGED
|
@@ -68,6 +68,13 @@ declare const ERROR_CODES: {
|
|
|
68
68
|
* invent a partial one.
|
|
69
69
|
*/
|
|
70
70
|
readonly resourceTooLarge: -32000;
|
|
71
|
+
/**
|
|
72
|
+
* The server is at its concurrency limit.
|
|
73
|
+
*
|
|
74
|
+
* Implementation-defined range, like `resourceTooLarge`. A typed error rather than silent
|
|
75
|
+
* queueing or a dropped request: the caller can retry, and knows why.
|
|
76
|
+
*/
|
|
77
|
+
readonly overloaded: -32001;
|
|
71
78
|
readonly unsupportedProtocolVersion: -32022;
|
|
72
79
|
};
|
|
73
80
|
/** Method names, kept as constants so a typo is a compile error rather than a `-32601`. */
|
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-S4367K5X.js';
|
|
2
|
+
export { generateInWorker } from './chunk-IIP43I7C.js';
|
|
@@ -39,6 +39,14 @@ interface SourceSummary {
|
|
|
39
39
|
routeHandlers: string[];
|
|
40
40
|
/** Number of parser diagnostics, present only when the file has syntax errors. */
|
|
41
41
|
parseErrors?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Which module system's exports are recorded here.
|
|
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.
|
|
48
|
+
*/
|
|
49
|
+
exportsKind?: "esm" | "cjs" | "mixed";
|
|
42
50
|
}
|
|
43
51
|
interface JsonSummary {
|
|
44
52
|
shape: string;
|
|
@@ -75,6 +83,14 @@ type SkipReason = "binary" | "read-error" | "not-file"
|
|
|
75
83
|
| "symlink"
|
|
76
84
|
/** A file link whose target resolves outside the scanned root. */
|
|
77
85
|
| "outside-root"
|
|
86
|
+
/**
|
|
87
|
+
* A tracked path that is absent from disk — deleted without staging.
|
|
88
|
+
*
|
|
89
|
+
* Distinct from `read-error`, which means the path exists but could not be read (EACCES, a
|
|
90
|
+
* sharing violation). Conflating the two left an operator unable to tell a missing file from an
|
|
91
|
+
* unreadable one, because neither record carried a detail.
|
|
92
|
+
*/
|
|
93
|
+
| "missing"
|
|
78
94
|
/** Excluded by a `.gitignore` in a scan without git. */
|
|
79
95
|
| "gitignore"
|
|
80
96
|
/** Excluded by a built-in rule: the ignore list, a preset, or an output dir. */
|
|
@@ -96,7 +112,15 @@ type SkipReason = "binary" | "read-error" | "not-file"
|
|
|
96
112
|
* Here the file is perfectly includable and simply did not change; reporting it as
|
|
97
113
|
* `excluded` would send a reader looking for an exclude pattern they never wrote.
|
|
98
114
|
*/
|
|
99
|
-
| "unchanged"
|
|
115
|
+
| "unchanged"
|
|
116
|
+
/**
|
|
117
|
+
* Staged for deletion: the path is in the next commit's parent, not in the next commit.
|
|
118
|
+
*
|
|
119
|
+
* With `--staged` the scope is the index, and a deletion has no blob to read. Recording it is
|
|
120
|
+
* the point: the alternative was to drop it silently and describe a commit that deletes a file
|
|
121
|
+
* as though the file never existed.
|
|
122
|
+
*/
|
|
123
|
+
| "deleted";
|
|
100
124
|
interface SkipRecord {
|
|
101
125
|
/** Path as it may be shown in an artifact: secret spans are masked. */
|
|
102
126
|
path: string;
|
|
@@ -223,6 +247,16 @@ interface ManifestTotals {
|
|
|
223
247
|
skippedFiles: number;
|
|
224
248
|
totalSourceBytes: number;
|
|
225
249
|
totalContentBytes: number;
|
|
250
|
+
/**
|
|
251
|
+
* Lines the source files contain, after redaction, before previews and part budgets.
|
|
252
|
+
*
|
|
253
|
+
* `counts.totalLines` is the same number. `emittedLines` below is the one a reader of the parts
|
|
254
|
+
* actually sees; the two differ whenever a preview or a byte-budget cut removed lines, and the
|
|
255
|
+
* README used to print only the first under the label "Total Code Lines".
|
|
256
|
+
*/
|
|
257
|
+
sourceLines?: number;
|
|
258
|
+
/** Lines carried by the emitted parts. Optional for manifests written before it was recorded. */
|
|
259
|
+
emittedLines?: number;
|
|
226
260
|
/**
|
|
227
261
|
* Estimated tokens in the emitted parts.
|
|
228
262
|
*
|
|
@@ -367,6 +401,17 @@ interface Manifest {
|
|
|
367
401
|
errors: string[];
|
|
368
402
|
};
|
|
369
403
|
artifacts: {
|
|
404
|
+
/**
|
|
405
|
+
* The human-facing artifacts, recorded in the same shape as the monoliths.
|
|
406
|
+
*
|
|
407
|
+
* `validate` used to verify only parts, monoliths and SARIF, so deleting the README or the
|
|
408
|
+
* navigation index left it green. Optional because a manifest written before these were
|
|
409
|
+
* recorded has no key; a current manifest records every artifact it wrote.
|
|
410
|
+
*/
|
|
411
|
+
readme?: ManifestArtifact;
|
|
412
|
+
navigation?: ManifestArtifact;
|
|
413
|
+
projectTree?: ManifestArtifact;
|
|
414
|
+
audit?: ManifestArtifact;
|
|
370
415
|
fullJson: ManifestArtifact | null;
|
|
371
416
|
fullMarkdown: ManifestArtifact | null;
|
|
372
417
|
/**
|
|
@@ -39,6 +39,14 @@ interface SourceSummary {
|
|
|
39
39
|
routeHandlers: string[];
|
|
40
40
|
/** Number of parser diagnostics, present only when the file has syntax errors. */
|
|
41
41
|
parseErrors?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Which module system's exports are recorded here.
|
|
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.
|
|
48
|
+
*/
|
|
49
|
+
exportsKind?: "esm" | "cjs" | "mixed";
|
|
42
50
|
}
|
|
43
51
|
interface JsonSummary {
|
|
44
52
|
shape: string;
|
|
@@ -75,6 +83,14 @@ type SkipReason = "binary" | "read-error" | "not-file"
|
|
|
75
83
|
| "symlink"
|
|
76
84
|
/** A file link whose target resolves outside the scanned root. */
|
|
77
85
|
| "outside-root"
|
|
86
|
+
/**
|
|
87
|
+
* A tracked path that is absent from disk — deleted without staging.
|
|
88
|
+
*
|
|
89
|
+
* Distinct from `read-error`, which means the path exists but could not be read (EACCES, a
|
|
90
|
+
* sharing violation). Conflating the two left an operator unable to tell a missing file from an
|
|
91
|
+
* unreadable one, because neither record carried a detail.
|
|
92
|
+
*/
|
|
93
|
+
| "missing"
|
|
78
94
|
/** Excluded by a `.gitignore` in a scan without git. */
|
|
79
95
|
| "gitignore"
|
|
80
96
|
/** Excluded by a built-in rule: the ignore list, a preset, or an output dir. */
|
|
@@ -96,7 +112,15 @@ type SkipReason = "binary" | "read-error" | "not-file"
|
|
|
96
112
|
* Here the file is perfectly includable and simply did not change; reporting it as
|
|
97
113
|
* `excluded` would send a reader looking for an exclude pattern they never wrote.
|
|
98
114
|
*/
|
|
99
|
-
| "unchanged"
|
|
115
|
+
| "unchanged"
|
|
116
|
+
/**
|
|
117
|
+
* Staged for deletion: the path is in the next commit's parent, not in the next commit.
|
|
118
|
+
*
|
|
119
|
+
* With `--staged` the scope is the index, and a deletion has no blob to read. Recording it is
|
|
120
|
+
* the point: the alternative was to drop it silently and describe a commit that deletes a file
|
|
121
|
+
* as though the file never existed.
|
|
122
|
+
*/
|
|
123
|
+
| "deleted";
|
|
100
124
|
interface SkipRecord {
|
|
101
125
|
/** Path as it may be shown in an artifact: secret spans are masked. */
|
|
102
126
|
path: string;
|
|
@@ -223,6 +247,16 @@ interface ManifestTotals {
|
|
|
223
247
|
skippedFiles: number;
|
|
224
248
|
totalSourceBytes: number;
|
|
225
249
|
totalContentBytes: number;
|
|
250
|
+
/**
|
|
251
|
+
* Lines the source files contain, after redaction, before previews and part budgets.
|
|
252
|
+
*
|
|
253
|
+
* `counts.totalLines` is the same number. `emittedLines` below is the one a reader of the parts
|
|
254
|
+
* actually sees; the two differ whenever a preview or a byte-budget cut removed lines, and the
|
|
255
|
+
* README used to print only the first under the label "Total Code Lines".
|
|
256
|
+
*/
|
|
257
|
+
sourceLines?: number;
|
|
258
|
+
/** Lines carried by the emitted parts. Optional for manifests written before it was recorded. */
|
|
259
|
+
emittedLines?: number;
|
|
226
260
|
/**
|
|
227
261
|
* Estimated tokens in the emitted parts.
|
|
228
262
|
*
|
|
@@ -367,6 +401,17 @@ interface Manifest {
|
|
|
367
401
|
errors: string[];
|
|
368
402
|
};
|
|
369
403
|
artifacts: {
|
|
404
|
+
/**
|
|
405
|
+
* The human-facing artifacts, recorded in the same shape as the monoliths.
|
|
406
|
+
*
|
|
407
|
+
* `validate` used to verify only parts, monoliths and SARIF, so deleting the README or the
|
|
408
|
+
* navigation index left it green. Optional because a manifest written before these were
|
|
409
|
+
* recorded has no key; a current manifest records every artifact it wrote.
|
|
410
|
+
*/
|
|
411
|
+
readme?: ManifestArtifact;
|
|
412
|
+
navigation?: ManifestArtifact;
|
|
413
|
+
projectTree?: ManifestArtifact;
|
|
414
|
+
audit?: ManifestArtifact;
|
|
370
415
|
fullJson: ManifestArtifact | null;
|
|
371
416
|
fullMarkdown: ManifestArtifact | null;
|
|
372
417
|
/**
|
package/docs/cli.md
CHANGED
|
@@ -183,7 +183,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
|
|
|
183
183
|
🚀 Setup for: /path/to/repo
|
|
184
184
|
✅ Created snapshot.config.ts (preset: nextjs)
|
|
185
185
|
Added npm scripts: snapshot, snapshot:validate
|
|
186
|
-
Added devDependency: codebase-snapshot ^0.9.
|
|
186
|
+
Added devDependency: codebase-snapshot ^0.9.17
|
|
187
187
|
Added to .gitignore: snapshot/, snapshot.tmp/
|
|
188
188
|
⏳ Installing dependencies…
|
|
189
189
|
✅ Installed dependencies (npm install, 2.1s)
|
|
@@ -232,7 +232,7 @@ It also has three side effects on files you own, and it says so when it does the
|
|
|
232
232
|
```
|
|
233
233
|
✅ Created snapshot.config.ts (preset: node-lib)
|
|
234
234
|
Added npm scripts: snapshot, snapshot:validate
|
|
235
|
-
Added devDependency: codebase-snapshot ^0.9.
|
|
235
|
+
Added devDependency: codebase-snapshot ^0.9.17
|
|
236
236
|
Added to .gitignore: snapshot/, snapshot.tmp/
|
|
237
237
|
```
|
|
238
238
|
|
|
@@ -421,19 +421,19 @@ for the two install flags, and the init-and-setup flags list both commands.
|
|
|
421
421
|
| :--- | :--- | :--- | :--- | :--- |
|
|
422
422
|
| `--cwd <path>` | path | current directory | generate, validate, report, explain, init, setup, skill, mcp | Repository to operate on. Must exist and be a directory. `diff` and `describe` take no `--cwd`; for `mcp` it chooses the one repository the server serves. |
|
|
423
423
|
| `--out-dir <path>` | path | `snapshot` | generate, validate, report, explain, init, setup | Where the snapshot is written or read. May be absolute. |
|
|
424
|
-
| `--max-part-bytes <n>` | size | `307200` (300 KB) | generate, validate,
|
|
425
|
-
| `--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. |
|
|
424
|
+
| `--max-part-bytes <n>` | size | `307200` (300 KB) | generate, validate, init, setup | Hard ceiling per markdown part. Accepts `120k`, `1.5mb`. Minimum 4096. |
|
|
425
|
+
| `--max-part-tokens <n>` | size | unset | generate, validate, setup | A per-part ceiling in **tokens**, for a context window rather than a disk. Narrows `--max-part-bytes` to the equivalent byte count (`tokens × 4`); the smaller of the two ceilings always wins, and both are recorded in the manifest. Accepts `32k`. Minimum 1024 — below that it is a usage error, not a value quietly raised to the floor. The byte ceiling is what is enforced: `estimatedTokens` is an estimate, and a part whose estimate exceeds the token ceiling is named in a warning rather than silently accepted. |
|
|
426
426
|
| `--large-file-bytes <n>` | size | `204800` (200 KB) | generate, validate, explain, setup | Above this, a file becomes a head/tail preview. |
|
|
427
|
-
| `--max-monolith-bytes <n>` | size | unset | generate, validate,
|
|
428
|
-
| `--include-monolith` | flag | off | generate, validate,
|
|
427
|
+
| `--max-monolith-bytes <n>` | size | unset | generate, validate, setup | Skip the single-file monolith when it would exceed this. |
|
|
428
|
+
| `--include-monolith` | flag | off | generate, validate, setup | Also write `full-codebase.json` and `full-codebase.md`. |
|
|
429
429
|
| `--include-sensitive-files` | flag | off | generate, validate, explain, init, setup | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
|
|
430
|
-
| `--skip-artifacts <names>` | list | unset | generate, validate,
|
|
431
|
-
| `--only-artifacts <names>` | list | unset | generate, validate,
|
|
430
|
+
| `--skip-artifacts <names>` | list | unset | generate, validate, init, setup | Comma-separated artifacts to omit. |
|
|
431
|
+
| `--only-artifacts <names>` | list | unset | generate, validate, init, setup | Write *only* these, and **turn on** any this names: a config with `artifacts: { audit: false }` still gets `reports/audit.md` from `--only-artifacts audit`, because "only these" is a statement about the whole selection rather than a suppression list. Cannot be combined with `--skip-artifacts`. |
|
|
432
432
|
| `--format <text\|json>` | enum | `text` | generate, validate, report, explain, init, setup, diff, describe, skill | `json` writes a pure JSON payload to stdout. Every command except `mcp` honours it — stdout there is the JSON-RPC protocol stream — and `describe` reports the same nine-command list. |
|
|
433
433
|
| `--sarif` | flag | off | generate, validate, setup | Also write `reports/audit.sarif`: the redaction findings as SARIF 2.1.0, for upload to GitHub Code Scanning. The artefact carries the path, the line and the rule — never the value. Works with `--skip-artifacts audit`, because a CI gate does not read markdown. Rule ids are fixed per rule name, so adding a custom rule never re-points an existing alert. |
|
|
434
434
|
| `--skeleton` | flag | off | generate, validate, setup | Emit signatures instead of bodies: each function or method body becomes `{ /* ... */ }` in place, so formatting and comments around it are untouched. Covers `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs` and `.cjs`; `.d.ts` files are left alone because they are already declarations. The summary still describes the whole file, and affected entries carry `inclusionMode: "signatures"`. `--include-monolith` still writes the whole body, so the monolith's `inclusionMode: "full"` stays true. |
|
|
435
435
|
| `--changed-since <ref>` | git ref | unset | generate, validate, explain | Include only files changed since this ref, plus untracked ones. Every other file is recorded in `manifest.skipped[]` with reason `unchanged` and is never opened. `validate` re-resolves the scope: a skipped file that has changed since is reported as drift, and one that has not is left alone — and with `--with-dependents`, so is a file that now imports one that changed. `explain` answers with the same rule. A ref beginning with `-` is refused. |
|
|
436
|
-
| `--staged` | flag | off | generate, validate, explain | Include only files staged for the next commit. |
|
|
436
|
+
| `--staged` | flag | off | generate, validate, explain | Include only files staged for the next commit. The bytes are read from the **index**, not the working tree, so a file with staged changes plus later unstaged edits is snapshotted at what `git commit` will write; a staged deletion is recorded in `manifest.skipped[]` with reason `deleted`. |
|
|
437
437
|
| `--with-dependents` | flag | off | generate, validate, explain | With either of the two above, also include the files that import a changed one — a one-hop closure, not a transitive walk. Needs a scope; alone it is a usage error. |
|
|
438
438
|
| `--install-hook` | flag | off | init, setup | Write `.git/hooks/pre-commit` so a commit is refused while the snapshot is out of date. The hook checks the `outDir` the config names, so it works for a project that does not use `snapshot/`. An existing hook is never replaced; the note says what to add to it instead. |
|
|
439
439
|
| `--dry-run` | flag | off | generate, init, setup | Compute everything, print it, write nothing. |
|
|
@@ -461,6 +461,11 @@ The same rule applies to the compression and scope options. `--skeleton`, `--sar
|
|
|
461
461
|
`--max-part-tokens` are recorded in `manifest.config.digest`, so `validate` accepts them too —
|
|
462
462
|
without that, a snapshot generated with `--skeleton` could not be validated at all, and passing
|
|
463
463
|
the flag to `validate` was rejected as a flag that "does not apply to validate". `--changed-since`,
|
|
464
|
+
`explain` accepts only flags that can change a per-file answer: the scope flags, `--out-dir`,
|
|
465
|
+
`--large-file-bytes` (it reports the inclusion mode `generate` would choose), and the
|
|
466
|
+
discovery/sensitive-file settings. Partitioning and artifact-selection flags are rejected rather
|
|
467
|
+
than accepted as no-ops.
|
|
468
|
+
|
|
464
469
|
`--staged` and `--with-dependents` are accepted by `validate` and `explain` because they decide
|
|
465
470
|
which recorded `unchanged` skips are re-checked and what `explain` answers about one file.
|
|
466
471
|
|
package/docs/configuration.md
CHANGED
|
@@ -188,7 +188,8 @@ Classification drives per-layer budgets and the `Layers:` breakdown in `report`.
|
|
|
188
188
|
```js
|
|
189
189
|
export default {
|
|
190
190
|
maxPartBytes: "300k", // hard ceiling per part; default 307200, minimum 4096
|
|
191
|
-
// maxPartTokens: 32000, // a per-part ceiling in tokens; narrows maxPartBytes (tokens x 4
|
|
191
|
+
// maxPartTokens: 32000, // a per-part ceiling in tokens; narrows maxPartBytes (tokens x 4,
|
|
192
|
+
// // and the byte ceiling is what is enforced — see docs/cli.md)
|
|
192
193
|
// changedSince: "main", // only files changed since this git ref
|
|
193
194
|
// staged: true, // only files staged for the next commit
|
|
194
195
|
// withDependents: true, // ...and the files that import them
|
|
@@ -389,6 +390,20 @@ A hook runs in the **process** working directory, so with `--cwd elsewhere` a re
|
|
|
389
390
|
resolves against your shell, not the target repository. Use the absolute paths on `manifest`
|
|
390
391
|
(or resolve against `outDir` yourself) when passing `--cwd`.
|
|
391
392
|
|
|
393
|
+
While an **async** hook is still running, the run keeps both locks (the staging root and the
|
|
394
|
+
output directory) until it settles. A second `generate` for the same output is refused with
|
|
395
|
+
"Another generate run is already using…" instead of publishing over the hook's writes; the lock's
|
|
396
|
+
heartbeat means a hook that never settles cannot wedge the directory forever.
|
|
397
|
+
|
|
398
|
+
A module config is re-evaluated only when its own bytes change. A helper module it imports stays
|
|
399
|
+
cached under its own stable URL, so editing only the helper is picked up on the next process start
|
|
400
|
+
— edit the config file itself if a running `--watch` must see the change.
|
|
401
|
+
|
|
402
|
+
A `match` **function** in a layer or kind rule is executable code, and `manifest.config.digest`
|
|
403
|
+
can only cover its source text, not the values its closure captures. `validate` says so in a
|
|
404
|
+
warning rather than claiming that the classification is unchanged; use a string or `RegExp`
|
|
405
|
+
matcher if the digest's answer matters to you.
|
|
406
|
+
|
|
392
407
|
## Complete example
|
|
393
408
|
|
|
394
409
|
Every setting at its built-in default. Nothing here has to be written — the tool runs on these
|
package/docs/mcp.md
CHANGED
|
@@ -10,7 +10,7 @@ walk — that the client sees.
|
|
|
10
10
|
## Start it
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npx -y codebase-snapshot@0.9.
|
|
13
|
+
npx -y codebase-snapshot@0.9.17 mcp
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
|
|
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
|
|
|
25
25
|
"mcpServers": {
|
|
26
26
|
"codebase-snapshot": {
|
|
27
27
|
"command": "npx",
|
|
28
|
-
"args": ["-y", "codebase-snapshot@0.9.
|
|
28
|
+
"args": ["-y", "codebase-snapshot@0.9.17", "mcp", "--cwd", "/absolute/path/to/repo"]
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
|
|
|
34
34
|
Claude Code registers the same thing from a shell:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.9.
|
|
37
|
+
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.9.17 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
|
|
@@ -87,7 +87,13 @@ kinds — and returns the part each match lives in.
|
|
|
87
87
|
|
|
88
88
|
`snapshot_read` is windowed on purpose. It defaults to 200 lines and reports `nextFromLine` when
|
|
89
89
|
more remains, so an agent continues deliberately instead of pulling a whole part into a context
|
|
90
|
-
window it has not budgeted.
|
|
90
|
+
window it has not budgeted. A single line longer than one result can carry is the exception: the
|
|
91
|
+
page ends mid-line, `pageable` is `false` and `reason` says so, because advancing `fromLine` would
|
|
92
|
+
silently skip the rest of that line.
|
|
93
|
+
|
|
94
|
+
At most four requests run at once. A fifth gets a JSON-RPC `overloaded` error (`-32001`) naming
|
|
95
|
+
the limit instead of being queued silently or dropped, so a client can retry and `snapshot_status`
|
|
96
|
+
stays responsive.
|
|
91
97
|
|
|
92
98
|
## Resources
|
|
93
99
|
|
|
@@ -134,7 +140,10 @@ making changes.
|
|
|
134
140
|
redaction applies to everything the client sees.
|
|
135
141
|
- **Install or configure.** `snapshot_generate` writes the snapshot directory and nothing else. It
|
|
136
142
|
never runs a package manager and never writes a config file.
|
|
137
|
-
- **Touch the network.** The server makes no outbound
|
|
143
|
+
- **Touch the network.** The server itself makes no outbound connection, and there is no HTTP
|
|
144
|
+
transport. Module configs (`.mjs`, `.cjs`, `.ts`) are refused: importing one would run repository
|
|
145
|
+
code with the user's privileges, so the server accepts only JSON configuration. The CLI still
|
|
146
|
+
loads a module config, because there the user invoked the repository's own command.
|
|
138
147
|
|
|
139
148
|
## Both protocol eras
|
|
140
149
|
|
|
@@ -161,8 +170,9 @@ the presence of a library.
|
|
|
161
170
|
## Performance
|
|
162
171
|
|
|
163
172
|
Generation runs in a worker thread, so the server keeps answering `ping` and acknowledging
|
|
164
|
-
`notifications/cancelled` while the snapshot is written.
|
|
165
|
-
|
|
173
|
+
`notifications/cancelled` while the snapshot is written. Admission is bounded to four concurrent
|
|
174
|
+
requests, so a flood of `snapshot_generate` calls cannot spawn an unbounded number of workers over
|
|
175
|
+
the same repository. The numbers below are measured, not estimated:
|
|
166
176
|
|
|
167
177
|
| Repository | Files | `snapshot_generate` |
|
|
168
178
|
| :-- | --: | --: |
|
package/docs/output.md
CHANGED
|
@@ -102,10 +102,10 @@ diff the manifest only when you need to know that a run happened.
|
|
|
102
102
|
| `budgets` | The effective byte limits for the run: `{ maxPartBytes, largeFileBytes }`. The per-layer overrides live at `config.budgets`, which is `{ default, byLayer }`. |
|
|
103
103
|
| `config` | The resolved configuration actually used (preset, artifacts, sizing, scoping). |
|
|
104
104
|
| `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount }`. |
|
|
105
|
-
| `totals` | Bookkeeping: `{ candidateFiles, includedFiles, fullFiles, previewFiles, skippedFiles, totalSourceBytes, totalContentBytes, estimatedTokens, partCount, warningCount, redactedLines }`. `redactedLines` counts the lines whose values were masked — one per line, not one per matching rule — and is what the summary's `Redacted:` line prints. |
|
|
106
|
-
| `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. |
|
|
105
|
+
| `totals` | Bookkeeping: `{ candidateFiles, includedFiles, fullFiles, previewFiles, skippedFiles, totalSourceBytes, totalContentBytes, sourceLines, emittedLines, estimatedTokens, partCount, warningCount, redactedLines }`. `sourceLines` is the source line count before previews and part budgets; `emittedLines` is what the parts actually carry. `redactedLines` counts the lines whose values were masked — one per line, not one per matching rule — and is what the summary's `Redacted:` line prints. |
|
|
106
|
+
| `fingerprint` | Stable hash of the snapshot content **and** the settings that shaped it. Two runs over unchanged input and unchanged settings produce the same value; changing the budget, a preset, a layer rule or the secret rules moves it, because the parts move too. It is recomputed by `validate` from `files[]` and `config.digest`, so an edited file list cannot keep the recorded value — and because the partitioner may change a file's `inclusionMode` after the fingerprint is taken, the mode is not part of the hash. |
|
|
107
107
|
| `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
|
|
108
|
-
| `artifacts` |
|
|
108
|
+
| `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. |
|
|
109
109
|
| `layers`, `kinds` | File counts per layer and per kind. |
|
|
110
110
|
| `indexes` | Cross-references: `routes`, `components`, `handlers`, `features`, `imports`, `directives`. |
|
|
111
111
|
| `parts` | One entry per part (below). |
|
package/docs/vs-gitingest.md
CHANGED
|
@@ -44,8 +44,12 @@ If you want to paste a repo into a chat right now: **use gitingest.**
|
|
|
44
44
|
|
|
45
45
|
## Where this is the better choice
|
|
46
46
|
|
|
47
|
-
- **The repository must not leave your machine.**
|
|
48
|
-
the
|
|
47
|
+
- **The repository must not leave your machine.** No source code, path or identifier is sent
|
|
48
|
+
anywhere; the tool reads the local tree. An interactive run makes one GET to the npm registry to
|
|
49
|
+
check for a newer version — CI, non-TTY and `--format json` runs skip it, and
|
|
50
|
+
`--no-update-check` or `CODEBASE_SNAPSHOT_NO_UPDATE_CHECK=1` disables it entirely (see
|
|
51
|
+
[the update notice](cli.md#update-notice)). If the code is private enough that a hosted digest is
|
|
52
|
+
not allowed, that settles it.
|
|
49
53
|
- **You need a size guarantee.** A part either fits the budget or carries an explicit truncation
|
|
50
54
|
marker naming the budget. A digest that grows with the repository eventually stops fitting, and
|
|
51
55
|
discovering that at ingestion time is too late.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-snapshot",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.17",
|
|
4
4
|
"description": "Pack a codebase for an LLM into budgeted Markdown parts, with a manifest of every file and skip, and validate to prove the snapshot is current.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codebase",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"dev": "tsup --watch",
|
|
99
99
|
"typecheck": "tsc --noEmit",
|
|
100
100
|
"lint": "node scripts/lint.mjs",
|
|
101
|
+
"check:workflows": "node scripts/check-workflows.mjs",
|
|
101
102
|
"check": "npm run lint && npm run typecheck && npm test",
|
|
102
103
|
"pretest": "npm run build",
|
|
103
104
|
"test": "node scripts/test-run.mjs",
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"audit-site": "node scripts/audit-site.mjs",
|
|
111
112
|
"readme-lint": "node scripts/readme-lint.mjs",
|
|
112
113
|
"seo-rank": "node scripts/seo-rank.mjs",
|
|
113
|
-
"verify": "npm run check && npm run sync-docs -- --check && npm run site && npm run audit-site && npm run readme-lint && npm run pack-check",
|
|
114
|
+
"verify": "npm run check && npm run check:workflows && npm run sync-docs -- --check && npm run site && node scripts/check-site-links.mjs && npm run audit-site && npm run readme-lint && npm run pack-check",
|
|
114
115
|
"snapshot": "node ./dist/bin.js generate",
|
|
115
116
|
"snapshot:validate": "node ./dist/bin.js validate"
|
|
116
117
|
},
|