codebase-snapshot 0.13.0 → 0.15.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.js CHANGED
@@ -1,2 +1,2 @@
1
- export { generateToken, startHttpTransport } from './chunk-NESEHOPU.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-BOJYZQFB.js';
1
+ export { generateToken, startHttpTransport } from './chunk-4OHQULCV.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-KHHUC6UT.js';
@@ -923,6 +923,10 @@ interface CliOptions {
923
923
  stripComments?: boolean;
924
924
  /** `--remove-empty-lines`: drop blank lines from emitted bodies. */
925
925
  removeEmptyLines?: boolean;
926
+ /** `--only <globs>`: override the config include allow-list for this run. */
927
+ only?: string[];
928
+ /** `--ignore <globs>`: add to the config exclude list for this run. */
929
+ ignore?: string[];
926
930
  maxPartBytes?: number;
927
931
  maxPartTokens?: ByteSize | null;
928
932
  largeFileBytes?: number;
@@ -923,6 +923,10 @@ interface CliOptions {
923
923
  stripComments?: boolean;
924
924
  /** `--remove-empty-lines`: drop blank lines from emitted bodies. */
925
925
  removeEmptyLines?: boolean;
926
+ /** `--only <globs>`: override the config include allow-list for this run. */
927
+ only?: string[];
928
+ /** `--ignore <globs>`: add to the config exclude list for this run. */
929
+ ignore?: string[];
926
930
  maxPartBytes?: number;
927
931
  maxPartTokens?: ByteSize | null;
928
932
  largeFileBytes?: number;
@@ -37,6 +37,47 @@ tokens in full.
37
37
  4. **Generation is not the bottleneck.** All three modes take about the same time; the saving is in
38
38
  what gets written, not in what gets read.
39
39
 
40
+ ## Ten public repositories
41
+
42
+ ```bash
43
+ node scripts/benchmark-suite.mjs # the ten default repositories
44
+ node scripts/benchmark-suite.mjs --json # the same run, as data
45
+ node scripts/benchmark-suite.mjs <url> ... # your own list
46
+ ```
47
+
48
+ Each repository is cloned shallow into a scratch directory, packed by all three tools, and the
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:
51
+
52
+ | Repository | Ours files | Ours tokens | repomix tokens | repomix / ours | gitingest bytes |
53
+ | :-- | --: | --: | --: | --: | --: |
54
+ | jonschlinkert/is-odd | 11 | 5,450 | 4,291 | 0.79 | 29,392 |
55
+ | chalk/chalk | 32 | 77,684 | 79,006 | 1.02 | 238,864 |
56
+ | 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 |
58
+ | moment/luxon | 151 | 303,032 | 250,093 | 0.83 | 806,740 |
59
+ | psf/requests | 117 | 382,695 | 687,333 | 1.80 | 524,712 |
60
+ | pallets/click | 177 | 470,265 | 335,153 | 0.71 | 1,413,342 |
61
+ | expressjs/express | 215 | 261,829 | 198,639 | 0.76 | 792,177 |
62
+ | colinhacks/zod | 686 | 1,762,835 | 1,748,187 | 0.99 | 4,468,877 |
63
+ | anuraghazra/github-readme-stats | 131 | 205,009 | 169,079 | 0.82 | 553,367 |
64
+
65
+ Read it carefully:
66
+
67
+ - **The ratio is not a contest.** Our estimate is one token per four bytes of emitted body; repomix
68
+ uses a tokenizer. Across nine repositories the two land within about plus or minus 30%, which is
69
+ what two reasonable estimates of the same text do.
70
+ - **minimatch is the exception, and it is a policy difference, not an estimate.** That repository
71
+ carries five benchmark fixtures of 20 to 25 MB of JSON. repomix emits them (64.8M tokens); our
72
+ large-file rule emits a bounded preview and records the omission, so the pack stays 319,879 tokens.
73
+ A pack that will not fit in a context window has not helped the reader, however complete it is.
74
+ - **gitingest publishes no token count**, so its column is the size of its one-document digest.
75
+ - **File counts agree within one or two** everywhere except minimatch, where our preview keeps the
76
+ files and repomix keeps their bytes.
77
+
78
+ The point of ten repositories is not a leaderboard; it is that the shape holds outside the
79
+ repository the tool was written in.
80
+
40
81
  ## Honest limits
41
82
 
42
83
  - Self-benchmark. This repository is TypeScript with a clean import graph; a vendored monorepo with
@@ -52,15 +93,17 @@ tokens in full.
52
93
  node scripts/compare.mjs --repomix # add --json for machine-readable output
53
94
  ```
54
95
 
55
- repomix is fetched through `npx` at run time; it is never a dependency of this package. Measured on
56
- this repository at 0.12.65, repomix 1.19.0, same machine:
96
+ repomix is fetched through `npx` at run time and gitingest through `python -m gitingest`;
97
+ neither is a dependency of this package. Measured on this repository at 0.14.2, repomix 1.19.0,
98
+ gitingest from PyPI, same machine:
57
99
 
58
100
  | Tool / mode | Files | Content bytes | Tokens | vs full | Time |
59
101
  | :-- | --: | --: | --: | --: | --: |
60
- | codebase-snapshot (full) | 330 | 3,197,091 | 1,027,911 | 100% | 2.14 s |
61
- | codebase-snapshot (slice) | 4 | 239,395 | 66,653 | 6.5% | 2.13 s |
62
- | codebase-snapshot (budget 30,000) | 24 | 119,701 | 36,261 | 3.5% | 2.07 s |
63
- | repomix 1.19.0 | 329 | 3,386,284 | 854,178 | 83.1% | n/a |
102
+ | codebase-snapshot (full) | 336 | 3,301,883 | 1,060,727 | 100% | 2.22 s |
103
+ | codebase-snapshot (slice) | 4 | 239,837 | 66,903 | 6.3% | 2.14 s |
104
+ | codebase-snapshot (budget 30,000) | 22 | 119,915 | 36,107 | 3.4% | 2.09 s |
105
+ | repomix 1.19.0 | 335 | 3,519,653 | 888,168 | 83.7% | n/a |
106
+ | gitingest | ? | 3,123,817 | n/a | n/a | n/a |
64
107
 
65
108
  Read that honestly:
66
109
 
@@ -72,9 +115,11 @@ Read that honestly:
72
115
  which includes its own wrappers), and the file sets differ slightly: 330 against 329.
73
116
  - **The modes are what the other tool does not have.** repomix packs the repository; a slice and a
74
117
  budget are the same snapshot narrowed after scanning, at 6.5% and 3.5% of the tokens.
75
- - **gitingest is not installed here** (`python -m gitingest` is missing). The harness supports it —
76
- `--gitingest` — and reports its digest size, not a token count, because it does not publish one.
118
+ - **gitingest's digest is smaller in bytes** (3.12 MB against our 3.30 MB of file content), and it
119
+ publishes no token count at all; the harness reports its digest size and says so. Its output is
120
+ one flat document with a tree and a separator per file, which is why a byte comparison is the
121
+ only honest one.
77
122
 
78
123
  The same caveats apply to any comparison: different ignore rules, different wrappers, different
79
124
  tokenizers. What is comparable is the shape — full packs are too large for a context window, and a
80
- selection is one to two orders of magnitude smaller.
125
+ selection is one to two orders of magnitude smaller.
package/docs/cli.md CHANGED
@@ -97,7 +97,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
97
97
 
98
98
  ```
99
99
  📸 Generating snapshot for: /path/to/repo
100
- Branch: main | Part budget: 300 KB | Generator: 0.13.0 (project dependency ^0.13.0)
100
+ Branch: main | Part budget: 300 KB | Generator: 0.15.0 (project dependency ^0.15.0)
101
101
 
102
102
  ✅ Snapshot generated in 0.14s:
103
103
  - Tracked files: 121 included of 128 paths found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
@@ -218,7 +218,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
218
218
  🚀 Setup for: /path/to/repo
219
219
  ✅ Created snapshot.config.ts (preset: nextjs)
220
220
  Added npm scripts: snapshot, snapshot:validate
221
- Added devDependency: codebase-snapshot ^0.13.0
221
+ Added devDependency: codebase-snapshot ^0.15.0
222
222
  Added to .gitignore: /snapshot/, /snapshot.tmp/
223
223
  ⏳ Installing dependencies…
224
224
  ✅ Installed dependencies (npm install, 2.1s)
@@ -270,7 +270,7 @@ It also has three side effects on files you own, and it says so when it does the
270
270
  ```
271
271
  ✅ Created snapshot.config.ts (preset: node-lib)
272
272
  Added npm scripts: snapshot, snapshot:validate
273
- Added devDependency: codebase-snapshot ^0.13.0
273
+ Added devDependency: codebase-snapshot ^0.15.0
274
274
  Added to .gitignore: /snapshot/, /snapshot.tmp/
275
275
  ```
276
276
 
@@ -494,6 +494,8 @@ for the two install flags, and the init-and-setup flags list both commands.
494
494
  | `--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. |
495
495
  | `--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). |
496
496
  | `--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). |
497
+ | `--only <globs>` | list | unset | generate, validate, explain | Comma-separated globs to include: **replaces** the config `include` list for this run. |
498
+ | `--ignore <globs>` | list | unset | generate, validate, explain | Comma-separated globs to exclude: **adds to** the config exclude list for this run. Both are part of the config digest, so `validate` needs the same flags. |
497
499
  | `--remove-empty-lines` | flag | off | generate, validate | Drop blank and whitespace-only lines from emitted bodies. Line numbers no longer match the source; every affected file records `emptyLinesRemoved: true` and the brief says so. |
498
500
  | `--strip-comments` | flag | off | generate, validate | Remove comment text from JavaScript/TypeScript bodies. Newlines are kept, so line numbers do not move; files record `inclusionMode: "comments-stripped"`. |
499
501
  | `--workspace <a,b>` | list | unset | generate | One snapshot per member under `<outDir>/<name>`, plus `WORKSPACE.json`. Exits 1 if any member failed. See [workspaces](workspace.md). |
@@ -671,4 +673,4 @@ npx codebase-snapshot generate --watch
671
673
 
672
674
  # Give an agent everything it needs
673
675
  npx codebase-snapshot skill --install
674
- ```
676
+ ```
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.13.0 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.13.0 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.15.0 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.15.0 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
package/docs/health.md CHANGED
@@ -43,6 +43,37 @@ secret, but you may not want it in the payload either.
43
43
  The score starts at 100; each failure costs 25 and each warning 5, with a floor of zero. It is a
44
44
  summary, not a substitute for the checks — the report always lists every one.
45
45
 
46
+ ### The JSON pack against the manifest
47
+
48
+ When the run wrote `full-codebase.json`, the audit parses it and compares its file set with
49
+ `manifest.files` in both directions. The artifact digest proves the pack is the file the manifest
50
+ recorded; it does not prove the manifest recorded a pack holding every file. An entry removed and
51
+ the digest updated would otherwise be invisible.
52
+
53
+ ### The counts against the data
54
+
55
+ A manifest edited to claim more files, parts, skips or content bytes than it holds used to pass
56
+ every check: each part hashed correctly, the artifacts were present, and the numbers a summary
57
+ quotes were never compared with the arrays they summarise. The audit now recomputes
58
+ `counts.totalFiles`, `counts.partsCount`, `counts.skippedCount`, `totals.totalContentBytes` and the
59
+ per-layer counts from the manifest's own arrays; any disagreement is a critical failure naming the
60
+ field and both numbers.
61
+
62
+ ### Every body against the accounting
63
+
64
+ The manifest says how many bytes and lines each file contributed. The audit now checks that
65
+ claim against the part: each section is parsed out (by anchor, not by heading) and its body must
66
+ match `includedBytes` and `includedLines` exactly. A truncated body, a missing section or a
67
+ hand-edited part that still hashes correctly fails the audit, because the manifest would be
68
+ describing a file the reader does not receive.
69
+
70
+ ### A member of a workspace
71
+
72
+ When a snapshot sits beside a `WORKSPACE.json`, the audit compares that member's record with the
73
+ snapshot: fingerprint and file count must agree. A workspace index that describes a different
74
+ snapshot than the one beside it is a warning, not a failure — the member itself is intact — and
75
+ `--strict` makes it exit 1.
76
+
46
77
  ## A workspace, all at once
47
78
 
48
79
  `health --all-members` reads `WORKSPACE.json` and audits every snapshot a `--workspace` run wrote,
package/docs/mcp.md CHANGED
@@ -10,7 +10,7 @@ walk — that the client sees.
10
10
  ## Start it
11
11
 
12
12
  ```bash
13
- npx -y codebase-snapshot@0.13.0 mcp
13
+ npx -y codebase-snapshot@0.15.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.13.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.15.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.13.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.15.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,11 +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.13.0 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.15.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
- the JSON-RPC answer from the response body. `GET /healthz` answers `{ ok, name, version, tools, uptimeSeconds }`, without a token.
50
+ the JSON-RPC answer from the response body. `GET /healthz` answers
51
+ `{ ok, name, version, tools, uptimeSeconds }` without a token, and `GET /metrics` answers Prometheus
52
+ text: `snapshot_requests_total`, `snapshot_requests_by_method_total{method="…"}` (fixed labels,
53
+ never a path or a credential), `snapshot_requests_refused_total`,
54
+ `snapshot_requests_rate_limited_total`, `snapshot_tools`, `snapshot_uptime_seconds`.
51
55
 
52
56
  The first run prints the URL and a generated bearer token:
53
57
 
package/docs/tools.md CHANGED
@@ -52,7 +52,9 @@ Every tool is read-only unless it says **writes**. Cost is the class `tools/list
52
52
  ```json
53
53
  { "name": "snapshot_locate", "arguments": { "query": "src/mcp/tools.ts", "by": "path" } }
54
54
  ```
55
- - **`snapshot_symbol`** — medium, read-only. A symbol by name: defining file, kind, signature and
55
+ - **`snapshot_symbol`** — medium, read-only. A symbol by name: defining file, kind, signature,
56
+ and — unless `references: false` — the call sites where the name appears, with line numbers.
57
+
56
58
  the exports that reference it.
57
59
  ```json
58
60
  { "name": "snapshot_symbol", "arguments": { "name": "generateSnapshot" } }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
5
5
  "keywords": [
6
6
  "codebase-snapshot",