codebase-snapshot 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-B79yGkQO.cjs';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-C6Z1I0XS.cjs';
2
2
  import { Readable, Writable } from 'node:stream';
3
3
 
4
4
  /**
@@ -421,6 +421,26 @@ declare function windowText(body: string, fromLine: number, lineCount: number):
421
421
 
422
422
  declare function buildPrompts(): McpPrompt[];
423
423
 
424
+ /**
425
+ * The `snapshot://` URI set, in one place.
426
+ *
427
+ * Both the resource provider and the `describe` contract publish these, and `describe` must not
428
+ * import the provider — the provider reads the manifest, and the contract has to be printable in a
429
+ * repository that has never been generated. A leaf module keeps both honest without a cycle.
430
+ */
431
+ /** Resources that exist regardless of what is on disk, in the order `resources/list` reports them. */
432
+ declare const STATIC_RESOURCE_URIS: readonly string[];
433
+ /**
434
+ * Report resources, listed only when the run wrote the file.
435
+ *
436
+ * They are not in {@link STATIC_RESOURCE_URIS} because a resource in `resources/list` has to be
437
+ * readable, and `--include-diffs`, `--include-logs` and `--token-tree` are opt-in. The contract
438
+ * publishes them separately so a client can know they exist without being promised one.
439
+ */
440
+ declare const REPORT_RESOURCE_URIS: readonly string[];
441
+ /** Parameterised resource families, advertised through `resources/templates/list`. */
442
+ declare const RESOURCE_TEMPLATE_URIS: readonly string[];
443
+
424
444
  declare function buildResourceProvider(): ResourceProvider;
425
445
 
426
446
  interface ServerOptions {
@@ -575,4 +595,4 @@ declare function validateArguments(schema: InputSchema, value: unknown): string[
575
595
  */
576
596
  declare function coerceNumericStrings(schema: InputSchema, value: JsonObject): JsonObject;
577
597
 
578
- export { ERROR_CODES, type HttpTransport, type HttpTransportOptions, type JsonRpcResponse, type JsonSchema, LEGACY_PROTOCOL_VERSIONS, type LineReaderOptions, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, type McpPrompt, type McpResourceContents, type McpResourceDescriptor, type McpResourceTemplate, type McpServer, type McpServerInfo, type McpServerOptions, type McpTool, type MessageWriter, type PartSection, type ProtocolEra, type ResourceProvider, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, type ServerOptions, type SessionState, type ToolAnnotations, type ToolContext, type ToolOutcome, type Window, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText };
598
+ export { ERROR_CODES, type HttpTransport, type HttpTransportOptions, type JsonRpcResponse, type JsonSchema, LEGACY_PROTOCOL_VERSIONS, type LineReaderOptions, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, type McpPrompt, type McpResourceContents, type McpResourceDescriptor, type McpResourceTemplate, type McpServer, type McpServerInfo, type McpServerOptions, type McpTool, type MessageWriter, type PartSection, type ProtocolEra, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, type ResourceProvider, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, type ServerOptions, type SessionState, type ToolAnnotations, type ToolContext, type ToolOutcome, type Window, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText };
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-B79yGkQO.js';
1
+ export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-C6Z1I0XS.js';
2
2
  import { Readable, Writable } from 'node:stream';
3
3
 
4
4
  /**
@@ -421,6 +421,26 @@ declare function windowText(body: string, fromLine: number, lineCount: number):
421
421
 
422
422
  declare function buildPrompts(): McpPrompt[];
423
423
 
424
+ /**
425
+ * The `snapshot://` URI set, in one place.
426
+ *
427
+ * Both the resource provider and the `describe` contract publish these, and `describe` must not
428
+ * import the provider — the provider reads the manifest, and the contract has to be printable in a
429
+ * repository that has never been generated. A leaf module keeps both honest without a cycle.
430
+ */
431
+ /** Resources that exist regardless of what is on disk, in the order `resources/list` reports them. */
432
+ declare const STATIC_RESOURCE_URIS: readonly string[];
433
+ /**
434
+ * Report resources, listed only when the run wrote the file.
435
+ *
436
+ * They are not in {@link STATIC_RESOURCE_URIS} because a resource in `resources/list` has to be
437
+ * readable, and `--include-diffs`, `--include-logs` and `--token-tree` are opt-in. The contract
438
+ * publishes them separately so a client can know they exist without being promised one.
439
+ */
440
+ declare const REPORT_RESOURCE_URIS: readonly string[];
441
+ /** Parameterised resource families, advertised through `resources/templates/list`. */
442
+ declare const RESOURCE_TEMPLATE_URIS: readonly string[];
443
+
424
444
  declare function buildResourceProvider(): ResourceProvider;
425
445
 
426
446
  interface ServerOptions {
@@ -575,4 +595,4 @@ declare function validateArguments(schema: InputSchema, value: unknown): string[
575
595
  */
576
596
  declare function coerceNumericStrings(schema: InputSchema, value: JsonObject): JsonObject;
577
597
 
578
- export { ERROR_CODES, type HttpTransport, type HttpTransportOptions, type JsonRpcResponse, type JsonSchema, LEGACY_PROTOCOL_VERSIONS, type LineReaderOptions, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, type McpPrompt, type McpResourceContents, type McpResourceDescriptor, type McpResourceTemplate, type McpServer, type McpServerInfo, type McpServerOptions, type McpTool, type MessageWriter, type PartSection, type ProtocolEra, type ResourceProvider, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, type ServerOptions, type SessionState, type ToolAnnotations, type ToolContext, type ToolOutcome, type Window, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText };
598
+ export { ERROR_CODES, type HttpTransport, type HttpTransportOptions, type JsonRpcResponse, type JsonSchema, LEGACY_PROTOCOL_VERSIONS, type LineReaderOptions, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, type McpPrompt, type McpResourceContents, type McpResourceDescriptor, type McpResourceTemplate, type McpServer, type McpServerInfo, type McpServerOptions, type McpTool, type MessageWriter, type PartSection, type ProtocolEra, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, type ResourceProvider, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, type ServerOptions, type SessionState, type ToolAnnotations, type ToolContext, type ToolOutcome, type Window, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText };
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
- export { generateToken, startHttpTransport } from './chunk-VI3JLKPX.js';
2
- 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, generateInWorker, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-PDLN24ZZ.js';
1
+ export { generateToken, startHttpTransport } from './chunk-TQXTKDFD.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, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-RTWSGQ3U.js';
@@ -393,6 +393,12 @@ interface ManifestConfigSnapshot {
393
393
  includeSensitiveFiles: boolean;
394
394
  /** Whether comment text was stripped from JS/TS bodies in this run. */
395
395
  stripComments?: boolean;
396
+ /** Whether blank lines were dropped from emitted bodies in this run. */
397
+ removeEmptyLines?: boolean;
398
+ /** The single-file pack this run wrote, when one was requested. */
399
+ pack?: "single" | "xml" | "json";
400
+ /** How many commits `reports/log.md` carries, when the report was written. */
401
+ logCount?: number;
396
402
  /**
397
403
  * The file-slot ceiling `PROMPT.md` was planned for; `0` for no limit.
398
404
  *
@@ -472,6 +478,8 @@ interface Manifest {
472
478
  branch: string;
473
479
  commit: string;
474
480
  isDirty: boolean;
481
+ /** Absent in manifests written before 0.17.47; false means `branch` is the configured fallback. */
482
+ branchFromGit?: boolean;
475
483
  };
476
484
  /**
477
485
  * Where the described tree came from, when it was fetched rather than found on disk.
@@ -393,6 +393,12 @@ interface ManifestConfigSnapshot {
393
393
  includeSensitiveFiles: boolean;
394
394
  /** Whether comment text was stripped from JS/TS bodies in this run. */
395
395
  stripComments?: boolean;
396
+ /** Whether blank lines were dropped from emitted bodies in this run. */
397
+ removeEmptyLines?: boolean;
398
+ /** The single-file pack this run wrote, when one was requested. */
399
+ pack?: "single" | "xml" | "json";
400
+ /** How many commits `reports/log.md` carries, when the report was written. */
401
+ logCount?: number;
396
402
  /**
397
403
  * The file-slot ceiling `PROMPT.md` was planned for; `0` for no limit.
398
404
  *
@@ -472,6 +478,8 @@ interface Manifest {
472
478
  branch: string;
473
479
  commit: string;
474
480
  isDirty: boolean;
481
+ /** Absent in manifests written before 0.17.47; false means `branch` is the configured fallback. */
482
+ branchFromGit?: boolean;
475
483
  };
476
484
  /**
477
485
  * Where the described tree came from, when it was fetched rather than found on disk.
package/docs/agent.md CHANGED
@@ -115,8 +115,8 @@ devDependency and the `.gitignore` entries for the snapshot directory, and nothi
115
115
 
116
116
  ## When the client speaks MCP
117
117
 
118
- `codebase-snapshot mcp` serves the repository to a Model Context Protocol client over stdio: eleven
119
- tools, `snapshot://` resources and two prompts. Prefer it over shelling out when the agent already
118
+ `codebase-snapshot mcp` serves the repository to a Model Context Protocol client over stdio: 26
119
+ tools, `snapshot://` resources and seven prompts. Prefer it over shelling out when the agent already
120
120
  has an MCP connection, for two reasons that are properties of the design rather than of the wiring:
121
121
 
122
122
  - **Reads come from the snapshot, not the working tree.** `snapshot_read` extracts a file's section
package/docs/answer.md CHANGED
@@ -39,6 +39,9 @@ the server, not in every client.
39
39
  - **It will not exceed the budget silently.** If the first planned file alone is larger than the
40
40
  budget it is still returned, and the block says `first lines of N`; an empty answer would be
41
41
  worse than an oversized one that admits it.
42
+ - **It will not flood the transport.** One block is capped at 64 KiB, the same cap `snapshot_read`
43
+ applies to one response; a block that hits it says `first 64 KiB of the window`. Without the cap
44
+ a single 200 KB line came back whole, and `usedTokens` described text the client never got.
42
45
 
43
46
  ## The CLI version of the same question
44
47
 
@@ -47,14 +47,16 @@ node scripts/benchmark-suite.mjs <url> ... # your own list
47
47
 
48
48
  Each repository is cloned shallow into a scratch directory, packed by all three tools, and the
49
49
  clone is deleted. A repository that cannot be cloned is reported as skipped with the reason, never
50
- dropped from the table. Measured at 0.14.5, repomix 1.19.0, gitingest from PyPI:
50
+ dropped from the table. Measured at 0.14.5, repomix 1.19.0, gitingest from PyPI, and
51
+ re-run on 2026-11-18 at 0.17.55: all ten repositories packed by all three tools, every number
52
+ identical, which is what a deterministic scanner should do.
51
53
 
52
54
  | Repository | Ours files | Ours tokens | repomix tokens | repomix / ours | gitingest bytes |
53
55
  | :-- | --: | --: | --: | --: | --: |
54
56
  | jonschlinkert/is-odd | 11 | 5,450 | 4,291 | 0.79 | 29,392 |
55
57
  | chalk/chalk | 32 | 77,684 | 79,006 | 1.02 | 238,864 |
56
58
  | tj/co | 19 | 12,996 | 9,189 | 0.71 | 74,613 |
57
- | isaacs/minimatch | 85 | 319,879 | 64,846,987 | 202.7 | 1,800,672 |
59
+ | isaacs/minimatch | 85 | 319,879 | 64,846,987 | 202.72 | 1,800,672 |
58
60
  | moment/luxon | 151 | 303,032 | 250,093 | 0.83 | 806,740 |
59
61
  | psf/requests | 117 | 382,695 | 687,333 | 1.80 | 524,712 |
60
62
  | pallets/click | 177 | 470,265 | 335,153 | 0.71 | 1,413,342 |
package/docs/cli.md CHANGED
@@ -63,6 +63,7 @@ as it makes it.
63
63
  - [`explain <path>`](#explain-path)
64
64
  - [`diff <before> <after>`](#diff-before-after)
65
65
  - [`describe`](#describe)
66
+ - [`update`](#update)
66
67
  - [`skill`](#skill)
67
68
  - [Options](#options)
68
69
  - [Exit codes](#exit-codes)
@@ -97,7 +98,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
97
98
 
98
99
  ```
99
100
  📸 Generating snapshot for: /path/to/repo
100
- Branch: main | Part budget: 300 KB | Generator: 0.17.0 (project dependency ^0.17.0)
101
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.19.0 (project dependency ^0.19.0)
101
102
 
102
103
  ✅ Snapshot generated in 0.14s:
103
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
@@ -218,7 +219,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
218
219
  🚀 Setup for: /path/to/repo
219
220
  ✅ Created snapshot.config.ts (preset: nextjs)
220
221
  Added npm scripts: snapshot, snapshot:validate
221
- Added devDependency: codebase-snapshot ^0.17.0
222
+ Added devDependency: codebase-snapshot ^0.19.0
222
223
  Added to .gitignore: /snapshot/, /snapshot.tmp/
223
224
  ⏳ Installing dependencies…
224
225
  ✅ Installed dependencies (npm install, 2.1s)
@@ -270,7 +271,7 @@ It also has three side effects on files you own, and it says so when it does the
270
271
  ```
271
272
  ✅ Created snapshot.config.ts (preset: node-lib)
272
273
  Added npm scripts: snapshot, snapshot:validate
273
- Added devDependency: codebase-snapshot ^0.17.0
274
+ Added devDependency: codebase-snapshot ^0.19.0
274
275
  Added to .gitignore: /snapshot/, /snapshot.tmp/
275
276
  ```
276
277
 
@@ -415,6 +416,29 @@ list, config filenames, output layout, safety rules and a troubleshooting table.
415
416
  form is what an agent should read instead of `--help`. See [Using this with an AI
416
417
  agent](agent.md).
417
418
 
419
+ ### `update`
420
+
421
+ Ask the npm registry whether a newer release exists, and print the version it compared against:
422
+
423
+ ```bash
424
+ npx codebase-snapshot@0.19.0 update # is 0.17.0 still current? print the answer
425
+ npx codebase-snapshot@0.19.0 update --format json
426
+ ```
427
+
428
+ ```text
429
+ ↑ codebase-snapshot 0.18.0 is available — you have 0.17.0.
430
+ npm install -g codebase-snapshot
431
+ ```
432
+
433
+ Exit `0` when the installed version is current, `1` when a newer release exists, `2` when the
434
+ registry could not be reached. It always asks — the cache is bypassed — and it works without a
435
+ terminal, so a script can branch on the exit code. Set `CODEBASE_SNAPSHOT_REGISTRY_URL` to a
436
+ mirror's `latest` document to check against something other than npmjs.org.
437
+
438
+ You do not have to run it: an interactive command prints the same notice after its own work, unless
439
+ `--format json`, `--no-update-check`, a pipe or CI is in play. That notice is cached for a day when it
440
+ finds a release, an hour when it finds none, and five minutes after a failed request.
441
+
418
442
  ### `skill`
419
443
 
420
444
  ```bash
@@ -451,7 +475,7 @@ codebase-snapshot mcp --cwd <path> # serve another repository
451
475
  ```
452
476
 
453
477
  Serves the repository to a Model Context Protocol client over stdio: 26 tools, `snapshot://`
454
- resources and two prompts. Stdout carries JSON-RPC messages and nothing else; every note goes to
478
+ resources and seven prompts. Stdout carries JSON-RPC messages and nothing else; every note goes to
455
479
  stderr. It speaks both protocol eras — the legacy `initialize` handshake and the stateless
456
480
  `2026-07-28` revision — and answers whichever the client starts with.
457
481
 
@@ -503,8 +527,8 @@ for the two install flags, and the init-and-setup flags list both commands.
503
527
  | `--slice <question>` | string | unset | generate | Narrow the snapshot to what the retrieval planner picks for this question. Records a `slice` block and `skipped[]` reasons `not-selected`. See [slices](slice.md). |
504
528
  | `--slice-tokens <n>` | count | `30000` | generate | The token budget for `--slice`. |
505
529
  | `--delta <path>` | path | unset | generate | Narrow the snapshot to what changed since a base snapshot, plus the one-hop importers. Unchanged files are recorded in `delta.unchanged` and `skipped[]`. See [delta](delta.md). |
506
- | `--include-diffs` | flag | off | generate | Also write `reports/diff.md`: the unstaged and staged diff, with the commands, bounded to 200 KiB. Absent when the tree is clean. |
507
- | `--include-logs <n>` | count | unset | generate | Also write `reports/log.md`: the last n commits (1–500), one line each. |
530
+ | `--include-diffs` | flag | off | generate | Also write `reports/diff.md`: the unstaged and staged diff, with the commands, bounded to 200 KiB. Absent when the tree is clean; outside a git repository the run warns and writes nothing. |
531
+ | `--include-logs <n>` | count | unset | generate | Also write `reports/log.md`: the last n commits (1–500), one line each; outside a git repository the run warns and writes nothing. |
508
532
  | `--token-tree` | flag | off | generate | Also write `reports/tokens.md`: per-file token estimates sorted by cost, with directory rollups. |
509
533
  | `--max-parts <n>` | count | unset | generate, validate | **Experimental.** Grow the per-part budget until the snapshot has at most `n` parts, so the file count stays fixed as the code grows. The budget it settles on is recorded in `manifest.budgets.maxPartBytes` and may exceed `--max-part-bytes`; a warning says so. `0` is a usage error. |
510
534
  | `--attachment-slots <n>` | count | `10` | generate | Files the destination accepts in one message; `0` means no limit. `PROMPT.md` plans the delivery against it — which parts to attach, what to leave behind, and the `--max-part-bytes` value that would merge them. It changes no part and no file, so it is recorded in the manifest but is not part of the config digest. |
@@ -637,9 +661,14 @@ a global install would leave a second copy shadowing the pinned one.
637
661
  The request goes to `registry.npmjs.org/codebase-snapshot/latest` and carries no identifier of any
638
662
  kind. Its answer is remembered for 24 hours when it names a newer release — the upgrade command is
639
663
  already known — and for one hour when it says you are current, because that is the only answer a
640
- new release can change. A machine therefore makes at most one request an hour while it is current,
641
- and at most one a day while an upgrade is waiting. It is skipped when stdout is not a terminal, in
642
- CI, in any `--format json` run, and in `mcp`, whose server makes no outbound connections at all.
664
+ new release can change. A **failed** request is remembered for five minutes: long enough that a
665
+ hostile network is not retried on every run, short enough that one transient failure does not look
666
+ like "you are current" for an hour. It is skipped when stdout is not a terminal, in CI, in any
667
+ `--format json` run, in `mcp` (whose server makes no outbound connections at all), and in
668
+ `--version`.
669
+
670
+ If the notice never appears and you want the answer now, `snapshot update` asks directly, bypasses
671
+ the cache and prints the comparison even when it is "current" (see [`update`](#update)).
643
672
 
644
673
  `--no-update-check` or `CODEBASE_SNAPSHOT_NO_UPDATE_CHECK=1` turns it off entirely.
645
674
 
@@ -673,4 +702,4 @@ npx codebase-snapshot generate --watch
673
702
 
674
703
  # Give an agent everything it needs
675
704
  npx codebase-snapshot skill --install
676
- ```
705
+ ```
@@ -574,7 +574,7 @@ values with no config at all.
574
574
  const config = {
575
575
  // ── Project ──────────────────────────────────────────────
576
576
  preset: "detected", // "detected" auto-detects; or name one of the 25
577
- branch: "main", // recorded when git cannot report one
577
+ branch: "main", // recorded when git cannot report one, and marked branchFromGit: false
578
578
 
579
579
  // ── Output ───────────────────────────────────────────────
580
580
  outDir: "snapshot",
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.17.0 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.17.0 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.19.0 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.19.0 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
package/docs/health.md CHANGED
@@ -12,28 +12,32 @@ npx codebase-snapshot health --format json # the report, for a dashboard
12
12
 
13
13
  ## What it checks
14
14
 
15
- | Check | Severity | What it proves |
16
- | :--- | :--- | :--- |
17
- | Manifest present and well-formed | critical | The file parses and has the snapshot shape. |
18
- | Every part on disk | critical | Every part the manifest names exists. |
19
- | Every part matches its size and hash | critical | The bytes on disk are the bytes recorded. |
20
- | Every file in exactly one part | critical | No file was silently dropped from the layout. |
21
- | Every recorded artifact present and unchanged | critical | `README.md`, `PROMPT.md`, reports and monolith still match their digests. |
22
- | Nothing unexpected in the directory | warning | No stale file from an earlier run is sitting in the payload. |
23
- | No unmasked secret in any artifact | critical | Every written text file is re-scanned with the secret rules. |
24
- | No value from an excluded sensitive file appears | critical | Values from `.env`, keys and similar files are compared byte-for-byte against the artifacts. |
25
- | No host path or machine identity | warning | `/home/…`, `/Users/…`, `C:\Users\…` and the repository's absolute path are searched for. |
26
- | Token estimate is plausible | warning | The recorded estimate is compared with one recomputed from the parts. |
27
- | Every part honours the published budget | warning | A part larger than the ceiling the manifest advertises is reported. |
28
- | Every excluded path has a reason | critical | `skipped[]` is complete and the totals agree. |
29
- | The snapshot still describes the repository | warning | HEAD is compared with the recorded commit. |
30
- | The manifest signature verifies | critical | When `signature.json` exists: the manifest bytes match `manifestSha256` and the Ed25519 signature checks out. Absent signature is a skip, not a failure. |
15
+ | Check | Id | Severity | What it proves |
16
+ | :--- | :--- | :--- | :--- |
17
+ | Manifest present and well-formed | `manifest` | critical | The file parses and has the snapshot shape. |
18
+ | Every part on disk | `parts.present` | critical | Every part the manifest names exists. |
19
+ | Every part matches its size and hash | `parts.hashes` | critical | The bytes on disk are the bytes recorded. |
20
+ | Every file in exactly one part | `parts.accounting` | critical | No file was silently dropped from the layout. |
21
+ | Every recorded artifact present and unchanged | `artifacts` | critical | `README.md`, `PROMPT.md`, reports and monoliths still match their digests. |
22
+ | Nothing unexpected in the directory | `artifacts.extra` | warning | No stale file from an earlier run is sitting in the payload. |
23
+ | 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. |
24
+ | 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. |
25
+ | No host path or machine identity | `pii.paths` | warning | `/home/…`, `/Users/…`, `C:\Users\…` and the repository's absolute path are searched for. |
26
+ | The manifest signature verifies | `signature` | critical | When `signature.json` exists: the manifest bytes match `manifestSha256` and the Ed25519 signature checks out. |
27
+ | The counts equal the data | `bookkeeping` | critical | `totalFiles`, `partsCount`, `skippedCount`, `totalContentBytes` and the per-layer counts are recomputed from the arrays. |
28
+ | Every file body matches the accounting | `pipeline.bodies` | critical | Each part section's bytes and lines equal the file's `includedBytes` and `includedLines`. |
29
+ | Every pack holds exactly the manifest's files | `pipeline.monolith` | critical | When `full-codebase.json`, `.xml` or `.md` is recorded, its file set is compared both ways. |
30
+ | 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. |
31
+ | Token estimate is plausible | `tokens.count` | warning | The recorded estimate is compared with one recomputed from the parts. |
32
+ | Every part honours the published budget | `tokens.budget` | warning | A part larger than the ceiling the manifest advertises is reported. |
33
+ | Every excluded path has a reason | `skips` | critical | `skipped[]` is complete and the totals agree. |
34
+ | The snapshot still describes the repository | `freshness` | warning | HEAD is compared with the recorded commit. |
31
35
 
32
36
  ## Reading the result
33
37
 
34
38
  ```text
35
39
  🩺 Snapshot health: 100/100
36
- 13 passed, 0 warning(s), 0 failed, 0 skipped
40
+ 15 passed, 0 warning(s), 0 failed, 1 skipped
37
41
  ```
38
42
 
39
43
  A **failed** check (critical) means the snapshot is not safe to hand to a model as it stands; the
@@ -43,6 +47,13 @@ secret, but you may not want it in the payload either.
43
47
  The score starts at 100; each failure costs 25 and each warning 5, with a floor of zero. It is a
44
48
  summary, not a substitute for the checks — the report always lists every one.
45
49
 
50
+ ### A member whose source is gone
51
+
52
+ `health --all-members` audits the written member snapshots. If a member's source directory has
53
+ been deleted since the workspace was generated, the snapshot is still intact but no longer
54
+ describes that workspace: the audit warns, names the missing path and says to regenerate.
55
+ Before this it scored 100/100 for a member nobody could refresh.
56
+
46
57
  ### The JSON pack against the manifest
47
58
 
48
59
  When the run wrote `full-codebase.json`, the audit parses it and compares its file set with
@@ -99,7 +110,7 @@ codebase-snapshot health --all-members --cwd /repo
99
110
  trusting a snapshot it was handed:
100
111
 
101
112
  ```json
102
- { "score": 95, "counts": { "pass": 12, "warn": 1, "fail": 0, "skip": 0 }, "checks": [ … ] }
113
+ { "score": 100, "counts": { "pass": 15, "warn": 0, "fail": 0, "skip": 1 }, "checks": [ … ] }
103
114
  ```
104
115
 
105
116
  The cheap subset — manifest, parts, artifacts, skips — also runs inside `validate`, so a normal
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.17.0 mcp
13
+ npx -y codebase-snapshot@0.19.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.17.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.19.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.17.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.19.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
@@ -43,14 +43,15 @@ 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.17.0 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.19.0 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
50
50
  the JSON-RPC answer from the response body. `GET /healthz` answers
51
51
  `{ ok, name, version, tools, uptimeSeconds }` without a token, and `GET /metrics` answers Prometheus
52
52
  text: `snapshot_requests_total`, `snapshot_requests_by_method_total{method="…"}` (fixed labels,
53
- never a path or a credential), `snapshot_requests_refused_total`,
53
+ never a path or a credential), `snapshot_requests_refused_total` (every 4xx except 429: an
54
+ unauthorized token, a refused origin, a wrong method, an oversize body),
54
55
  `snapshot_requests_rate_limited_total`, `snapshot_tools`, `snapshot_uptime_seconds`.
55
56
 
56
57
  The first run prints the URL and a generated bearer token:
@@ -86,7 +87,8 @@ data: /messages?sessionId=<id>
86
87
  ```
87
88
 
88
89
  The client POSTs JSON-RPC to that path, receives `202`, and reads the answer as a `message`
89
- event on the open stream. This exists for browsers and older clients where `EventSource` cannot
90
+ event on the open stream. A client that cannot set an `Authorization` header appends
91
+ `&token=<token>` to the announced path; the POST accepts the same query token the stream did. This exists for browsers and older clients where `EventSource` cannot
90
92
  set `Authorization`; the token may travel as `?token=` **on this path only**, which is a leak
91
93
  into logs and is documented as such. A heartbeat every 15 s keeps the connection alive, and
92
94
  shutdown ends the streams rather than waiting on them. Request bodies are capped at 2 MB, the rate is
@@ -177,13 +179,17 @@ stays responsive.
177
179
 
178
180
  Resources are the browse surface; tools are the act surface.
179
181
 
180
- The first four rows are always listed. The report resources are listed only when the run wrote
181
- the file — a resource in `resources/list` has to be readable — and `describe --format json`
182
+ `snapshot://manifest`, `snapshot://contract`, `snapshot://skill` and `snapshot://prompt` are always
183
+ listed, as is one `snapshot://parts/{index}` per part. The report resources are listed only when the
184
+ run wrote the file — a resource in `resources/list` has to be readable — and `describe --format json`
182
185
  publishes them separately as `reportResources`.
183
186
 
184
187
  | URI | Contents |
185
188
  | :-- | :-- |
186
- | `snapshot://manifest` | Every included file with layer, kind, part and hash, every skip reason, and `incomplete[]` — the files whose body is not the whole file, with their missing line ranges |
189
+ | `snapshot://manifest` | Every included file with layer, kind, part and hash, every skip reason, and `incomplete[]` — the files whose body was reduced |
190
+ | `snapshot://contract` | The machine-readable CLI contract |
191
+ | `snapshot://skill` | The agent skill, as one read |
192
+ | `snapshot://prompt` | `PROMPT.md` — the brief: the job, what the snapshot contains and omits, the history it was built from, and the owner |
187
193
  | `snapshot://parts/{index}` | One budgeted part, by 1-based index |
188
194
  | `snapshot://reports/audit` | Secret findings, large files, parse diagnostics |
189
195
  | `snapshot://reports/tree` | The directory tree of included files |
@@ -191,17 +197,13 @@ publishes them separately as `reportResources`.
191
197
  | `snapshot://reports/diff` | `reports/diff.md`, when the snapshot was generated with `--include-diffs` |
192
198
  | `snapshot://reports/log` | `reports/log.md`, when generated with `--include-logs` |
193
199
  | `snapshot://reports/tokens` | `reports/tokens.md`, when generated with `--token-tree` |
194
- | `snapshot://prompt` | `PROMPT.md` — the brief: the job, what the snapshot contains and omits, the history it was built from, and the owner half when a `brief` is configured |
195
- | `snapshot://contract` | The machine-readable CLI contract |
196
- | `snapshot://skill` | The agent skill, as one read |
197
-
198
200
  A resource read is **all-or-nothing**. Above the 512 kB single-read limit the read fails with
199
201
  JSON-RPC error `-32000` (the implementation-defined server-error range) and
200
202
  `data: { uri, bytes, limit }`; the message says what to use instead — `snapshot_locate`,
201
203
  `snapshot_read` or `snapshot_status` for a manifest or part, the file on disk for a report, and
202
204
  the CLI for the contract or the skill. It never returns a truncated document: half a JSON manifest
203
205
  does not parse, and half a part is a fragment that looks complete. The rule applies to every
204
- resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the three reports,
206
+ resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the report resources,
205
207
  `snapshot://prompt`, `snapshot://contract` and `snapshot://skill`.
206
208
 
207
209
  A URI this build serves but this snapshot does not contain — `snapshot://prompt` when the prompt
package/docs/output.md CHANGED
@@ -22,7 +22,9 @@ snapshot/
22
22
  ├── audit.md secrets, large files, parse diagnostics, git state
23
23
  ├── diff.md uncommitted changes (--include-diffs)
24
24
  ├── log.md recent commits (--include-logs <n>)
25
- └── tokens.md per-file token estimates (--token-tree)
25
+ ├── tokens.md per-file token estimates (--token-tree)
26
+ ├── selection.md question, budget and every chosen file (--slice, --budget-tokens)
27
+ └── audit.sarif the audit as SARIF for code scanning (--sarif)
26
28
  ```
27
29
 
28
30
  With `--include-monolith` you also get `full-codebase.json` and `full-codebase.md` — the
@@ -171,14 +173,14 @@ diff the manifest only when you need to know that a run happened.
171
173
  | `schemaVersion` | Manifest format version (`3.0.0`). |
172
174
  | `generatedAt` | ISO timestamp of the run. |
173
175
  | `generator` | `{ name, version }` of the tool that wrote it. |
174
- | `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. |
176
+ | `git` | `{ branch, commit, isDirty, branchFromGit }`. `branch` falls back to the configured branch on a detached HEAD and outside a repository, and `branchFromGit: false` marks that fallback — the reports print "fallback; git reported no branch here" so a reader cannot mistake it for a real branch. `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. |
175
177
  | `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. |
176
178
  | `config` | The resolved configuration actually used (preset, artifacts, sizing, scoping). |
177
179
  | `counts` | `{ totalFiles, totalSizeBytes, totalLines, partsCount, skippedCount, largeFileCount, truncatedPreviewCount, incompleteCount }`. |
178
180
  | `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. |
179
181
  | `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. |
180
182
  | `validation` | `{ status: "passed" \| "failed", errors: [] }` for the run's own integrity check. |
181
- | `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. |
183
+ | `artifacts` | A digest of every artifact the run wrote: `readme`, `prompt`, `navigation`, `projectTree`, `audit`, `selection` (slice or budget runs), `fullJson`, `fullMarkdown`, `fullXml` and `sarif`, each `{ byteSize, sha256 }` when present. `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. |
182
184
  | `layers`, `kinds` | File counts per layer and per kind. |
183
185
  | `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". |
184
186
  | `parts` | One entry per part (below). |
@@ -35,8 +35,8 @@ untrusted input can arrive.
35
35
 
36
36
  A `snapshot.config.ts` is code. The CLI runs it because the user invoked the repository's own
37
37
  command; the **MCP server and the web page refuse it** and say so. A repository fetched with
38
- `--remote` is generated on the defaults for the same reason: a fetched repository is not a trusted
39
- one.
38
+ `--remote` is treated the same way: its JSON configuration is applied (it is data), and an
39
+ executable config in it is refused, because a fetched repository is not a trusted one.
40
40
 
41
41
  ### MCP over HTTP
42
42
 
package/docs/serve.md CHANGED
@@ -21,10 +21,10 @@ Serving http://127.0.0.1:4788/
21
21
  files to fit the number you give. The result line reports how many paths were not selected.
22
22
  2. **Generate.** Paste an absolute path or a public repository URL and press Generate. A URL is
23
23
  cloned shallowly into a temporary directory (removed when the server exits) with the same
24
- provenance record the CLI writes. The page calls the same
25
- `generateSnapshot` the CLI calls, with the default settings — the defaults are what a browser
26
- session can honestly promise, because a config file can run code and this process will not run
27
- repository code on a page's request. For a project config, use the CLI.
24
+ provenance record the CLI writes. The page calls the same `generateSnapshot` the CLI calls,
25
+ with the repository's `snapshot.config.json` (or the `snapshot` key of `package.json`) applied, so
26
+ the browser and the terminal produce the same snapshot. An executable config is refused rather
27
+ than run: this process does not execute repository code on a page's request.
28
28
  3. **Preview.** The brief (`PROMPT.md`) and the file list come back from the written snapshot, not
29
29
  from the working tree. If the snapshot is wrong, the page shows the wrongness.
30
30
  4. **See the health score.** The page audits what it just wrote and shows the score, with the
@@ -39,6 +39,14 @@ a path outside the directory it was started for, or outside a clone it created i
39
39
  decides who may ask; this decides what may be asked about — otherwise a leaked token would be an
40
40
  arbitrary-file-read primitive over the whole disk.
41
41
 
42
+ ## The repository's configuration
43
+
44
+ The page loads the repository's `snapshot.config.json` (or the `snapshot` key of `package.json`),
45
+ so a project configured to exclude a directory generates the same snapshot in the browser as it
46
+ does on the command line. An **executable** config (`snapshot.config.ts`, `.mjs`, `.cjs`) is
47
+ refused with the reason, exactly as the MCP server refuses it: this surface does not run
48
+ repository code.
49
+
42
50
  ## The token
43
51
 
44
52
  The page is HTML and is served without a token; everything that reads or writes a repository needs
@@ -51,6 +59,14 @@ off and is refused on a non-loopback bind.
51
59
  `POST /mcp` on the same port is the MCP endpoint from [MCP](mcp.md), with the same token. A browser
52
60
  agent and a human look at the same snapshot.
53
61
 
62
+ ## Using it without a mouse, or without sight
63
+
64
+ The page is a form with four controls, and each has an accessible name (`aria-label`) rather than
65
+ only a placeholder that disappears when you type. The status line is a `role="status"` live region,
66
+ so a screen reader announces "Generating…" and the result without the focus jumping. The mode
67
+ `select`, the token field and the budget field behave the same way, and the token is never
68
+ rendered into the page.
69
+
54
70
  ## Limits, stated
55
71
 
56
72
  | Limit | Value | Why |
package/docs/signing.md CHANGED
@@ -39,7 +39,9 @@ public half.
39
39
 
40
40
  ## Verifying
41
41
 
42
- `snapshot health` verifies the signature when `signature.json` exists:
42
+ Both `snapshot validate` and `snapshot health` verify the signature when `signature.json`
43
+ exists. `validate` reports it as an error (`signature: manifest.json changed after it was signed.`)
44
+ and exits 1; `health` reports it as a critical check with the same reason:
43
45
 
44
46
  - **critical failure** when the manifest changed after signing, the record is malformed, or the
45
47
  signature does not match;