codebase-snapshot 0.20.13 → 0.21.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +33 -6
  2. package/README.md +41 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/bin.js +12482 -10348
  5. package/dist/{chunk-GNVRD7XS.js → chunk-TDPYLX7X.js} +6062 -4438
  6. package/dist/cli.cjs +11759 -9645
  7. package/dist/cli.d.cts +76 -2
  8. package/dist/cli.d.ts +76 -2
  9. package/dist/cli.js +549 -14
  10. package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-D56JeXwx.d.cts} +2 -2
  11. package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-DakxZs-l.d.ts} +2 -2
  12. package/dist/index.cjs +6037 -4435
  13. package/dist/index.d.cts +281 -63
  14. package/dist/index.d.ts +281 -63
  15. package/dist/index.js +1 -1
  16. package/dist/mcp.cjs +10231 -4354
  17. package/dist/mcp.d.cts +13 -7
  18. package/dist/mcp.d.ts +13 -7
  19. package/dist/mcp.js +1 -1
  20. package/dist/{types-C5ytHMYz.d.ts → types-D5XYzksd.d.cts} +50 -2
  21. package/dist/{types-C5ytHMYz.d.cts → types-D5XYzksd.d.ts} +50 -2
  22. package/docs/about.md +86 -0
  23. package/docs/agent.md +28 -6
  24. package/docs/answer.md +99 -48
  25. package/docs/benchmarks.md +34 -34
  26. package/docs/brief.md +80 -81
  27. package/docs/cli.md +100 -25
  28. package/docs/codebase-token-budget.md +14 -13
  29. package/docs/contents.md +66 -0
  30. package/docs/deploy.md +2 -2
  31. package/docs/faq.md +112 -0
  32. package/docs/glossary.md +152 -0
  33. package/docs/health.md +1 -1
  34. package/docs/how-to-feed-a-repo-to-claude.md +6 -0
  35. package/docs/impact.md +102 -0
  36. package/docs/install.md +4 -3
  37. package/docs/llm-codebase-context.md +166 -0
  38. package/docs/mcp-server-for-codebase.md +155 -0
  39. package/docs/mcp.md +43 -66
  40. package/docs/migration.md +83 -90
  41. package/docs/output.md +1 -3
  42. package/docs/security-review.md +8 -8
  43. package/docs/slice.md +1 -1
  44. package/docs/tools.md +159 -185
  45. package/docs/troubleshooting.md +11 -11
  46. package/docs/vs-code2prompt.md +7 -0
  47. package/docs/vs-gitingest.md +7 -0
  48. package/docs/vs-repomix.md +10 -1
  49. package/docs/workspace.md +1 -1
  50. package/package.json +8 -2
package/CHANGELOG.md CHANGED
@@ -10,14 +10,13 @@ This package started its public life as `@ankurhalder/codebase-snapshot`, which
10
10
  moved to the unscoped name and **restarted at 0.9.0**, so the numbers below are not a continuation of
11
11
  the old line — `0.9.0` is newer than `4.4.1`, not older.
12
12
 
13
- The current line is **`0.20.x`, with literal sub-bumps**: every change ships as its own version,
14
- `0.20.12`, `0.20.13`, and so on. The number is not the promise; the entry below is. `1.0.0` is never
13
+ The current line is **`0.21.x`, with literal sub-bumps**: every change ships as its own version,
14
+ `0.21.0`, `0.21.1`, and so on. The number is not the promise; the entry below is. `1.0.0` is never
15
15
  released.
16
16
 
17
- GitHub carries a tag for every version and `main` carries every commit. For earlier lines, **npm
18
- publication happens only at `x.y.0`** (`0.13.0`, `0.14.0`, …). **The 0.20 line is the deliberate
19
- exception:** patches may be published and pinned, so the registry stays current without leaving
20
- 0.20.
17
+ GitHub carries a tag for every version and `main` carries every commit. **npm publication normally
18
+ happens only at `x.y.0`** (`0.13.0`, `0.14.0`, …). The 0.20 line was the deliberate patch-line
19
+ exception; 0.21.0 closes it.
21
20
 
22
21
  Two versions exist on the registry that are not releases, and both are deprecated:
23
22
 
@@ -31,6 +30,34 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
31
30
 
32
31
  ---
33
32
 
33
+ ## 0.21.0
34
+
35
+ **Daily code intelligence without a native binary: seven focused MCP tools, a live in-memory index, compiler-backed symbol references, barrel-pruned impact, and a one-command review brief.**
36
+
37
+ - The MCP server drops from 27 overlapping tools to seven — `snapshot_impact`, `snapshot_context`, `snapshot_locate`, `snapshot_read`, `snapshot_validate`, `snapshot_explain` and `snapshot_generate` — so agents can keep it enabled without spending their whole tool budget. Every surviving tool carries a `trust` envelope that names its index source, freshness, coverage, redaction count and any explicit reason the answer is partial.
38
+ - Read-only commands and tools no longer fail when `snapshot/manifest.json` is missing. A new `LiveIndex` reuses a current manifest, overlays only changed files in memory, or scans the confined working tree when no snapshot exists. It never writes into the repository; optional summary metadata lives in the OS cache and is disabled with `--no-cache` or `SNAPSHOT_NO_CACHE=1`.
39
+ - The split import resolver is gone. Slice planning, MCP context and impact all use the same tsconfig-aware resolver, now covering `jsconfig.json`, nested configs, TS 5 `extends` arrays, `baseUrl`-less `paths`, `package.json#imports` and workspace packages declared through `workspaces` or `pnpm-workspace.yaml`.
40
+ - TypeScript summaries record import bindings, re-export bindings and declaration spans. Impact seeds changed symbols from `git diff` hunks, parses barrels instead of treating every re-export as a wildcard, reports `direct-symbol` / `reexport` / `namespace-or-cjs` / `type-only` / `file-import` provenance, and counts every pruned barrel neighbour.
41
+ - A bounded, repo-confined `TypeScript` program powers opt-in `impact --precise` and `snapshot_locate({ by: "symbol", includeReferences: true })`. It follows aliases with `getAliasedSymbol`, never emits unredacted source, and falls back to syntactic bindings with an explicit `partial` reason above 2,500 files or four seconds.
42
+ - `impact` works with no arguments in a git repository by comparing the working tree with `HEAD`. It adds `--tests-paths`, safe `--run` execution through the repository's own Jest/Vitest/node-test CLI entry, `--precise`, `--include-imports`, `--include-cycles`, `--no-live`, `--no-cache` and Markdown PR output. Changed root build configuration raises a named full-suite warning.
43
+ - `brief` packs one redacted, bounded Markdown review or question brief, with `--copy` and `--out`. `skill --install` now writes the portable `.agents/skills` target alongside Claude and Cursor, and `--with-mcp` merges one entry into `.mcp.json` without clobbering other servers.
44
+ - The registry surfaces are prepared: `server.json` follows the `2025-12-11` schema, `package.json` carries the matching `mcpName`, and a composite `action.yml` exposes impact, validation and SARIF modes without adding a runtime dependency.
45
+ - A five-pass release audit hardened the new surfaces: brief `--out` refuses symlinks and hard links, diff hunks are sensitive-file filtered and source-extension redacted, marker-prefixed and quoted-dollar credentials are masked, named default exports and aliased barrels no longer prune callers, MCP forwards `maxPartBytes` and no longer claims `current` from status/audit, a dirty snapshot is not reused after reverting, precise targets keep their file, and all Markdown paths are escaped.
46
+ - Documentation and discovery: new LLM codebase context and MCP server guides, a glossary, FAQ, About page and complete documentation index; per-page git dates, author/publisher and FAQ/TechArticle/SoftwareApplication structured data, a custom 404, IndexNow notification, and a site audit that enforces titles, dates, canonical links, the sitemap and the documentation graph.
47
+
48
+ ---
49
+
50
+ ## 0.20.14
51
+
52
+ **A verified change-impact report, built from the existing manifest: changed files, transitive importers with the exact specifier for every hop, and candidate tests.**
53
+
54
+ - `codebase-snapshot impact --diff <ref>` (or `--paths <a,b>`) reads the generated manifest, resolves the change through the generator's own import resolver — including `tsconfig` path aliases and deleted-file tombstones — and reports the reverse-import closure. It never re-scans the repository or rewrites the snapshot.
55
+ - Each affected entry carries its distance, the file it was reached from and the raw import specifier, so a reviewer can check the edge rather than trust a list. Candidate tests are labelled candidates, never coverage; unresolved imports and paths outside the snapshot are named instead of omitted.
56
+ - `--depth` (default 3, max 8) and `--max-results` (default 200, max 1000) bound the walk; a truncated result says so and adds a warning. `--format json` is the stable contract; text mode follows the existing stderr convention.
57
+ - The MCP server gains `snapshot_impact` (27 tools total) with the same engine, `paths` or `base`, and bounded structured output. It is read-only; `snapshot_generate` remains the only writable tool.
58
+ - The report reuses the manifest's inclusion, redaction and skip policy, so a sensitive or excluded path cannot re-enter through the impact surface.
59
+ - New tests cover alias resolution, transitive traversal, depth, deletions, missing paths, ambiguous arguments, the missing-manifest case and the MCP wrapper. Documentation and the generated contract are updated with the command, options, tool and examples.
60
+
34
61
  ## 0.20.13
35
62
 
36
63
  **MCP 2026-07-28 conformance: the modern HTTP headers, cache metadata and resource error code now match the revision, and an independent client drives both modern transports.**
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  <h1>codebase-snapshot</h1>
5
5
 
6
- <p><b>A snapshot you can prove is current.</b><br>
7
- Plain-text parts under a hard byte budget, an index of every file and every skipped<br>
8
- file with the reason, and a <code>validate</code> command that fails when the code moves.</p>
6
+ <p><b>Turn a codebase into LLM-ready context you can verify.</b><br>
7
+ Bounded, redacted snapshots with a manifest, plus live impact and review briefs —<br>
8
+ local, deterministic, and no native binary. A snapshot is still there when you need it.</p>
9
9
 
10
10
  <p>
11
11
  <a href="https://www.npmjs.com/package/codebase-snapshot"><img alt="npm version" src="https://img.shields.io/npm/v/codebase-snapshot.svg"></a>
@@ -14,17 +14,27 @@
14
14
  <a href="https://nodejs.org"><img alt="node: 18 or newer" src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg"></a>
15
15
  <a href="https://ankurhalder.github.io/codebase-snapshot/"><img alt="documentation" src="https://img.shields.io/badge/docs-read-1a7f37"></a>
16
16
  <a href="https://m8ven.ai/mcp/ankurhalder-codebase-snapshot-9hzkhs?s=readme"><img alt="M8ven Live: continuously verified" src="https://m8ven.ai/badge/mcp/ankurhalder-codebase-snapshot-9hzkhs?variant=verified"></a>
17
+ <a href="https://glama.ai/mcp/servers/ankurhalder/codebase-snapshot"><img alt="Glama MCP server score" src="https://glama.ai/mcp/servers/ankurhalder/codebase-snapshot/badges/score.svg"></a>
17
18
  </p>
18
19
  </div>
19
20
 
20
21
  ```bash
21
- npx codebase-snapshot generate # no install: straight to the snapshot
22
- snapshot # once installed: detects the project, sets it up, generates
22
+ npx codebase-snapshot impact --diff HEAD # what does this change reach?
23
+ npx codebase-snapshot brief "how does auth work?" --copy
24
+ npx codebase-snapshot generate # persist a shareable snapshot when you need one
23
25
  ```
24
26
 
25
- That writes `./snapshot/` — a directory you can drop into a chat, a prompt, a RAG pipeline or a
26
- repository review. TypeScript and JavaScript first, but also Python, Go, Rust, Java/Kotlin,
27
- C#/.NET, PHP, Ruby, C/C++, Vue, Svelte and Astro, without configuration.
27
+ The first two work in a fresh clone: no snapshot, no config, no install. They index the working
28
+ tree in memory, overlay uncommitted edits, and never write into the repository. The third writes
29
+ `./snapshot/` — a directory you can drop into a chat, a prompt, a RAG pipeline or a repository
30
+ review. TypeScript and JavaScript first, but also Python, Go, Rust, Java/Kotlin, C#/.NET, PHP,
31
+ Ruby, C/C++, Vue, Svelte and Astro, without configuration.
32
+
33
+ A **codebase snapshot** is not a copy of the repository: it is a bounded, indexed artefact — parts
34
+ under a byte ceiling, a manifest that names every include and every skip, and a validator that can
35
+ prove the bytes still match the tree. The [glossary](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/glossary.md)
36
+ defines the terms; the [LLM codebase context guide](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/llm-codebase-context.md)
37
+ explains when a pack, a live MCP server or a scoped slice is the right tool.
28
38
 
29
39
  ![Two ways to give a repository to a model: a dump that was silently truncated, and a snapshot
30
40
  with a manifest and a validator](https://raw.githubusercontent.com/ankurhalder/codebase-snapshot/main/docs/assets/how-it-works.svg)
@@ -189,6 +199,10 @@ to trust it.
189
199
  | `setup` | Config, npm scripts, devDependency, install and generate, in one command. |
190
200
  | `validate` / `check` | Compare the snapshot with the repository; exit `1` on drift. |
191
201
  | `report` | Snapshot health, layer metrics, secret audit. |
202
+ | `health` | Audit a snapshot's integrity and secrets; `--deep` replays every body. |
203
+ | `serve` | Browser UI and the MCP endpoint on loopback. |
204
+ | `impact --diff <ref>` | Changed files, symbol-pruned callers, routes and candidate tests from the live index. |
205
+ | `brief` | One redacted review pack for a question, a diff or changed paths. |
192
206
  | `init` | Interactive (or `--yes`) setup that writes a self-documenting config. |
193
207
  | `explain <path>` | Why one path is included, which part it lands in, or why it was skipped. |
194
208
  | `diff <a> <b>` | Compare two snapshots. |
@@ -211,18 +225,18 @@ Everything an agent needs is available as data, and the tool can install its own
211
225
 
212
226
  ```bash
213
227
  npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
214
- npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
215
- npx -y codebase-snapshot@0.20.12 mcp # or serve it over MCP
228
+ npx codebase-snapshot skill --install # into .agents, .claude and .cursor
229
+ npx -y codebase-snapshot@0.21.0 mcp # or serve it over MCP
216
230
  ```
217
231
 
218
232
  An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
219
233
  workflow, and produce a validated snapshot unaided — that path is covered by a test.
220
234
 
221
- The MCP server exposes 26 tools — status, health, budget, history, tests, workspace, entrypoints, neighbors, routes, cycles, search, stats, review, diff_context, symbol, context, query, plan_for, answer, plan, generate, validate, locate, dependents, read and explain — plus
222
- `snapshot://` resources and seven prompts. Its reads come from the snapshot rather than the working
223
- tree, so an excluded file stays excluded and a redacted value stays redacted, and
224
- `snapshot_validate` answers the question an agent otherwise cannot ask: is the context I was given
225
- still true?
235
+ The MCP server exposes 7 tools — impact, context, locate, read, validate, explain and generate — plus
236
+ `snapshot://` resources and seven prompts. Reads are live by default: uncommitted edits and new files
237
+ are overlaid in memory, no snapshot directory is required, an excluded file stays excluded and a
238
+ redacted value stays redacted. `snapshot_validate` still answers the question an agent otherwise
239
+ cannot ask: is the context I was given still true?
226
240
 
227
241
  It speaks both protocol eras, including the `2026-07-28` revision: stateless `server/discover`,
228
242
  required `MCP-Protocol-Version`/`Mcp-Method`/`Mcp-Name` HTTP headers, cache hints on every
@@ -272,7 +286,11 @@ others.
272
286
  | :--- | :--- |
273
287
  | [Installation](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/install.md) | Every client, version pinning, agent skill install |
274
288
  | [CLI reference](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/cli.md) | Commands, options, exit codes, examples |
289
+ | [Impact reports](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/impact.md) | `impact`: symbol-pruned callers, candidate tests, routes, cycles and the limits of the answer |
290
+ | [Briefs](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/brief.md) | `brief`: one redacted review pack with a trust stamp and every omission named |
275
291
  | [Configuration](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/configuration.md) | Every setting, all 25 presets, budgets, hooks, secrets |
292
+ | [LLM codebase context](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/llm-codebase-context.md) | What it is, why a raw dump fails, and the four practical approaches |
293
+ | [MCP server for a codebase](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp-server-for-codebase.md) | Setup for Claude, Cursor and generic clients; the seven tools, security and limits |
276
294
  | [Snapshot output](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/output.md) | Directory layout and the full manifest schema |
277
295
  | [Health audit](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/health.md) | Leak, integrity and token audit of a generated snapshot |
278
296
  | [In the browser](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/serve.md) | `serve`: a local page to generate, preview and download a snapshot |
@@ -283,12 +301,16 @@ others.
283
301
  | [Benchmarks](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/benchmarks.md) | Reproducible token and time numbers for the three modes |
284
302
  | [Security review](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/security-review.md) | Threat model, controls, tests and residual risks |
285
303
  | [Deploy](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/deploy.md) | Container, compose and systemd, with the token requirement |
286
- | [Migrating](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/migration.md) | What changed from 0.12.14 to 0.20.13, and the behaviour changes that matter |
304
+ | [Migrating](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/migration.md) | What changed in 0.21.0: seven MCP tools, live reads, and the new flags |
287
305
  | [Workspaces](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/workspace.md) | `--workspace`: one snapshot per member, plus the index |
288
306
  | [Token budget](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/budget.md) | `--budget-tokens`: whole files chosen to fit a limit, not torn to fit a part |
289
- | [The brief](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/brief.md) | The half of PROMPT.md only you can write, and what is refused |
290
307
  | [AI agents](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/agent.md) | The contract, the skill, what an agent should avoid |
291
- | [MCP server](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp.md) | 26 tools, resources, both protocol eras, modern HTTP conformance |
308
+ | [MCP server](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp.md) | 7 tools, resources, both protocol eras, modern HTTP conformance |
309
+ | [MCP tools](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/tools.md) | Every tool schema and an example call |
310
+ | [snapshot_context](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/answer.md) | One question, cited line windows, a hard token budget |
311
+ | [Glossary](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/glossary.md) | Codebase snapshot, token budget, manifest, drift, MCP and agent experience |
312
+ | [FAQ](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/faq.md) | Direct answers about MCP, tokens, secrets, CI and comparisons |
313
+ | [All documentation](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/contents.md) | Every page, grouped by the job you are doing |
292
314
  | [Troubleshooting](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/troubleshooting.md) | Every message and what to do about it |
293
315
  | [Changelog](https://github.com/ankurhalder/codebase-snapshot/blob/main/CHANGELOG.md) | Release history and breaking changes |
294
316
 
@@ -316,7 +338,7 @@ Security reports: [SECURITY.md](https://github.com/ankurhalder/codebase-snapshot
316
338
  [MIT](https://github.com/ankurhalder/codebase-snapshot/blob/main/LICENSE) © Ankur Halder
317
339
 
318
340
  <p align="center">
319
- <sub>Built by <a href="https://ankurhalder.com" rel="author">Ankur Halder</a> ·
341
+ <sub>Built by <a href="https://github.com/ankurhalder" rel="author">Ankur Halder</a> ·
320
342
  <a href="https://ankurhalder.github.io/codebase-snapshot/">documentation</a> ·
321
343
  <a href="https://www.npmjs.com/package/codebase-snapshot">npm</a></sub>
322
344
  </p>
package/SECURITY.md CHANGED
@@ -6,11 +6,11 @@ Only the latest published release receives security fixes.
6
6
 
7
7
  | Version | Supported |
8
8
  | :--- | :--- |
9
- | <!--@majorMinor-->0.20<!--/@majorMinor-->.x | ✅ |
9
+ | <!--@majorMinor-->0.21<!--/@majorMinor-->.x | ✅ |
10
10
  | anything older | ❌ |
11
11
 
12
12
  The number line restarted at 0.9.0 when the package moved to the unscoped `codebase-snapshot` name,
13
- so <!--@majorMinor-->0.20<!--/@majorMinor-->.x is newer than 4.4.1, not older. That is explained in full in the
13
+ so <!--@majorMinor-->0.21<!--/@majorMinor-->.x is newer than 4.4.1, not older. That is explained in full in the
14
14
  [changelog](CHANGELOG.md#a-note-on-version-numbers).
15
15
 
16
16
  ## Reporting a vulnerability