codebase-snapshot 0.21.0 → 0.22.1
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 +28 -2
- package/README.md +35 -21
- package/SECURITY.md +2 -2
- package/dist/bin.js +2239 -1063
- package/dist/{chunk-TDPYLX7X.js → chunk-7AAXOTKS.js} +1499 -724
- package/dist/cli.cjs +2359 -1189
- package/dist/cli.d.cts +20 -2
- package/dist/cli.d.ts +20 -2
- package/dist/cli.js +556 -161
- package/dist/{generate-worker-D56JeXwx.d.cts → generate-worker-BUNhTXkj.d.cts} +1 -1
- package/dist/{generate-worker-DakxZs-l.d.ts → generate-worker-TUMvHlgz.d.ts} +1 -1
- package/dist/index.cjs +1474 -710
- package/dist/index.d.cts +182 -180
- package/dist/index.d.ts +182 -180
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +875 -346
- package/dist/mcp.d.cts +7 -4
- package/dist/mcp.d.ts +7 -4
- package/dist/mcp.js +1 -1
- package/dist/{types-D5XYzksd.d.ts → types-DQXKiaXk.d.cts} +1 -1
- package/dist/{types-D5XYzksd.d.cts → types-DQXKiaXk.d.ts} +1 -1
- package/docs/about.md +3 -2
- package/docs/agent.md +2 -1
- package/docs/cli.md +53 -26
- package/docs/contents.md +2 -0
- package/docs/deploy.md +10 -4
- package/docs/guard.md +197 -0
- package/docs/impact.md +3 -2
- package/docs/mcp-server-for-codebase.md +12 -4
- package/docs/mcp.md +9 -5
- package/docs/security-review.md +3 -2
- package/docs/troubleshooting.md +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,8 +10,8 @@ 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.
|
|
14
|
-
`0.
|
|
13
|
+
The current line is **`0.22.x`, with literal sub-bumps**: every change ships as its own version,
|
|
14
|
+
`0.22.0`, `0.22.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
17
|
GitHub carries a tag for every version and `main` carries every commit. **npm publication normally
|
|
@@ -30,6 +30,32 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
30
30
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
+
## 0.22.1
|
|
34
|
+
|
|
35
|
+
**Security and trust hardening after three adversarial audit passes.**
|
|
36
|
+
|
|
37
|
+
- Change Guard hooks now refuse executable repository configs, apply the server-safe config rules, and stay fail-open when a config is malformed or being edited. `health` accepts `--no-config`.
|
|
38
|
+
- Dockerfile redaction masks values that merely start with `$` and every physical line of `ENV \` continuations. YAML comments, `|2-`/`>2+` headers, quoted-key scalars, YAML lists and JSON arrays are masked. Unified diffs are redacted against both the old and new full files, prefer the new path on a rename, and use `--relative`.
|
|
39
|
+
- MCP part reads verify the recorded digest and byte size, fall back to live bytes when a part is missing or tampered, and parse each part once per call. `snapshot_context` emits numbered, truncation-aware windows. Analysis workers stop on cancellation, and stateless HTTP cancellation still matches when `clientInfo` is omitted from the notification.
|
|
40
|
+
- `explain` reports directories honestly and applies the same 2 MB parser cap as `generate`. `health` skips deep fidelity when nothing could be replayed, scans packs and diff reports under their source paths, keeps root workspace rules for members without a config, and accepts `export =` summaries.
|
|
41
|
+
- `impact` traverses type-only pure barrels, recognises Python, Go, Rust and Ruby test names, and keeps deletions in the guard's change set. Non-git live caches notice files created in previously empty directories; IPv4-embedded and local-use NAT64 IPv6 addresses are private.
|
|
42
|
+
- The Docker entrypoint honours `SNAPSHOT_CWD`, and the CLI output, option-scope, `--root`, `pr-comment` and guard USAGE documentation match the code.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 0.22.0
|
|
47
|
+
|
|
48
|
+
**Change Guard: a silent-by-default check for the consumers, tests and routes an agent's edit did not touch.**
|
|
49
|
+
|
|
50
|
+
- New `guard` command. It reuses the live index (or `--no-live`), takes `--paths`, `--diff` or the working tree against `HEAD`, and reports only what is outside the change: untouched consumers, candidate tests and affected routes. The report is capped at 10 consumers, 5 tests and 5 routes; `truncated` and `omitted` record what was cut, and the trust envelope says when coverage is partial.
|
|
51
|
+
- New hook mode. `guard --hook claude|copilot|codex|raw` reads one host payload from stdin and writes the host-shaped `additionalContext`, or `{}` when there is nothing to report. It is fail-open: an error returns `{}` and a stderr note, so a broken guard cannot fail an agent turn.
|
|
52
|
+
- New portable Agent Plugins 1.0 package under `agent-plugin/`: a `change-guard` skill, Claude and Copilot hook configs, and a pinned command. It calls the CLI instead of adding MCP tools, so it adds no tool-schema context until it has a gap to report.
|
|
53
|
+
- New `docs/guard.md` and CLI reference entries. The command is in `describe`; the parser rejects `--hook` with `--paths`; `--max-chars` is bounded to 200-10000.
|
|
54
|
+
- The hook text is capped at 1,200 characters by default. A clean check is one line in text mode and an empty object in hook mode. Tests cover consumers and tests, the Claude and Copilot response shapes, silence, and the character cap.
|
|
55
|
+
- The plugin is listed in native marketplaces. `.claude-plugin`, `.qoder-plugin`, `.github/plugin` and `.agents/plugins` catalogs install it with native commands in Claude Code, Codex, Copilot, Qoder and Devin, with no file copying or JSON merging.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
33
59
|
## 0.21.0
|
|
34
60
|
|
|
35
61
|
**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.**
|
package/README.md
CHANGED
|
@@ -15,21 +15,38 @@
|
|
|
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
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>
|
|
18
|
+
<a href="https://mcprush.com/to/codebase-snapshot-mcp?ref=badge"><img alt="Codebase Snapshot MCP on mcprush" src="https://mcprush.com/badge/codebase-snapshot-mcp/compact.svg"></a>
|
|
19
|
+
<a href="https://mcpservers.org/servers/ankurhalder/codebase-snapshot"><img alt="Listed on mcpservers.org" src="https://mcpservers.org/badge.svg"></a>
|
|
18
20
|
</p>
|
|
19
21
|
</div>
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
npx codebase-snapshot impact --diff HEAD # what does this change reach?
|
|
25
|
+
npx codebase-snapshot guard --changed # what did this edit leave untouched?
|
|
23
26
|
npx codebase-snapshot brief "how does auth work?" --copy
|
|
24
27
|
npx codebase-snapshot generate # persist a shareable snapshot when you need one
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
The first
|
|
28
|
-
tree in memory, overlay uncommitted edits, and never write into the repository. The
|
|
30
|
+
The first three work in a fresh clone: no snapshot, no config, no install. They index the working
|
|
31
|
+
tree in memory, overlay uncommitted edits, and never write into the repository. The last writes
|
|
29
32
|
`./snapshot/` — a directory you can drop into a chat, a prompt, a RAG pipeline or a repository
|
|
30
33
|
review. TypeScript and JavaScript first, but also Python, Go, Rust, Java/Kotlin, C#/.NET, PHP,
|
|
31
34
|
Ruby, C/C++, Vue, Svelte and Astro, without configuration.
|
|
32
35
|
|
|
36
|
+
**Using an agent?** Install the plugin instead of wiring hooks by hand:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
/plugin marketplace add ankurhalder/codebase-snapshot
|
|
40
|
+
/plugin install codebase-snapshot-change-guard@codebase-snapshot
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Codex: `codex plugin marketplace add ankurhalder/codebase-snapshot`, then
|
|
44
|
+
`codex plugin add codebase-snapshot-change-guard@codebase-snapshot`. Copilot CLI and Devin use
|
|
45
|
+
`copilot plugin install ankurhalder/codebase-snapshot:agent-plugin` and
|
|
46
|
+
`devin plugins install ankurhalder/codebase-snapshot#agent-plugin`. The plugin installs the
|
|
47
|
+
[Change Guard](https://ankurhalder.github.io/codebase-snapshot/guard.html) skill; in Claude Code it
|
|
48
|
+
also wires the post-edit hook, and Codex calls the guard when the change warrants it.
|
|
49
|
+
|
|
33
50
|
A **codebase snapshot** is not a copy of the repository: it is a bounded, indexed artefact — parts
|
|
34
51
|
under a byte ceiling, a manifest that names every include and every skip, and a validator that can
|
|
35
52
|
prove the bytes still match the tree. The [glossary](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/glossary.md)
|
|
@@ -56,11 +73,10 @@ Feeding a real repository to a model is awkward: files are too big, context wind
|
|
|
56
73
|
and choosing what matters by hand neither scales nor repeats. This does it deterministically.
|
|
57
74
|
|
|
58
75
|
- **A hard ceiling, not a target.** `maxPartBytes` is a limit, and nothing overflows it silently:
|
|
59
|
-
a file too big for a part becomes a head/tail excerpt
|
|
60
|
-
|
|
76
|
+
a file too big for a part becomes a head/tail excerpt, and `incomplete[]` records the line ranges
|
|
77
|
+
it lost.
|
|
61
78
|
- **An index, not just text.** `manifest.json` lists every included file with its layer, kind,
|
|
62
|
-
language, part, hash and
|
|
63
|
-
`incomplete[]` list of every file it could only emit in part, with the line ranges it lost.
|
|
79
|
+
language, part, hash and structural summary, and every *excluded* path with its reason.
|
|
64
80
|
- **Provably current.** `validate` re-hashes the repository against the snapshot and exits non-zero
|
|
65
81
|
on any drift, so a pipeline can gate on the context being fresh.
|
|
66
82
|
- **Repeatable.** Two runs over unchanged input give byte-identical parts and the same
|
|
@@ -75,8 +91,7 @@ npm install -D codebase-snapshot # or add it to a project
|
|
|
75
91
|
```
|
|
76
92
|
|
|
77
93
|
`codebase-snapshot` is the canonical name to script against; `snapshot` is the short command a
|
|
78
|
-
global install provides
|
|
79
|
-
`npm run snapshot` script `init` writes.
|
|
94
|
+
global install provides.
|
|
80
95
|
|
|
81
96
|
Requires **Node.js 18+**. Any npm client works — npm, yarn (classic and Berry with strict PnP), pnpm
|
|
82
97
|
and bun. Published from GitHub Actions with [build
|
|
@@ -157,14 +172,11 @@ contain.
|
|
|
157
172
|
- **The output directory is the tool's.** Each run is written to a scratch directory and swapped in
|
|
158
173
|
atomically, and it refuses to replace a directory it did not create — `--out-dir src` cannot
|
|
159
174
|
destroy source code.
|
|
160
|
-
- **The brief travels with the payload.** `PROMPT.md`
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
can come from your own file (`brief`) and the job from `promptTask`. A prompt that names
|
|
166
|
-
the wrong snapshot is a lie that reads as current, so it is an artifact with a recorded digest and
|
|
167
|
-
`validate` fails when it is edited.
|
|
175
|
+
- **The brief travels with the payload.** `PROMPT.md` carries the job, the system map the
|
|
176
|
+
manifest can prove, recent commits as claims to verify, the evidence bar, the coverage owed and
|
|
177
|
+
calibration examples, then this run's parts, partial files, fingerprint and attachment arithmetic.
|
|
178
|
+
The judgement half can come from your own `brief`, the job from `promptTask`; its digest is
|
|
179
|
+
validated, so an edited prompt is drift.
|
|
168
180
|
- **Credential files are excluded by default** — `.env`, `*.pem`, `.npmrc`, `id_rsa`, `*.tfstate`
|
|
169
181
|
and more — and secret-shaped strings inside ordinary files are redacted by masking only the
|
|
170
182
|
matched span, never the whole line.
|
|
@@ -184,9 +196,8 @@ patterns and a recommended part budget.
|
|
|
184
196
|
| Laravel (PHP) | Rails (Ruby) | Terraform / Docker infra | Docs-only |
|
|
185
197
|
| generic fallback | | | |
|
|
186
198
|
|
|
187
|
-
Non-TypeScript languages get import/export/class/function summaries rather than
|
|
188
|
-
|
|
189
|
-
to trust it.
|
|
199
|
+
Non-TypeScript languages get import/export/class/function summaries rather than opaque text, each
|
|
200
|
+
labelled `ast`, `structural` or `heuristic`.
|
|
190
201
|
|
|
191
202
|
→ [Preset table and detection rules](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/configuration.md#project-presets)
|
|
192
203
|
|
|
@@ -202,6 +213,7 @@ to trust it.
|
|
|
202
213
|
| `health` | Audit a snapshot's integrity and secrets; `--deep` replays every body. |
|
|
203
214
|
| `serve` | Browser UI and the MCP endpoint on loopback. |
|
|
204
215
|
| `impact --diff <ref>` | Changed files, symbol-pruned callers, routes and candidate tests from the live index. |
|
|
216
|
+
| `guard` | What the change reaches that the diff does not; `--hook` stays fail-open. |
|
|
205
217
|
| `brief` | One redacted review pack for a question, a diff or changed paths. |
|
|
206
218
|
| `init` | Interactive (or `--yes`) setup that writes a self-documenting config. |
|
|
207
219
|
| `explain <path>` | Why one path is included, which part it lands in, or why it was skipped. |
|
|
@@ -226,7 +238,7 @@ Everything an agent needs is available as data, and the tool can install its own
|
|
|
226
238
|
```bash
|
|
227
239
|
npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
|
|
228
240
|
npx codebase-snapshot skill --install # into .agents, .claude and .cursor
|
|
229
|
-
npx -y codebase-snapshot@0.
|
|
241
|
+
npx -y codebase-snapshot@0.22.1 mcp # or serve it over MCP
|
|
230
242
|
```
|
|
231
243
|
|
|
232
244
|
An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
|
|
@@ -236,7 +248,9 @@ The MCP server exposes 7 tools — impact, context, locate, read, validate, expl
|
|
|
236
248
|
`snapshot://` resources and seven prompts. Reads are live by default: uncommitted edits and new files
|
|
237
249
|
are overlaid in memory, no snapshot directory is required, an excluded file stays excluded and a
|
|
238
250
|
redacted value stays redacted. `snapshot_validate` still answers the question an agent otherwise
|
|
239
|
-
cannot ask: is the context I was given still true?
|
|
251
|
+
cannot ask: is the context I was given still true? The server is listed in the
|
|
252
|
+
[official MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.ankurhalder%2Fcodebase-snapshot)
|
|
253
|
+
as `io.github.ankurhalder/codebase-snapshot`.
|
|
240
254
|
|
|
241
255
|
It speaks both protocol eras, including the `2026-07-28` revision: stateless `server/discover`,
|
|
242
256
|
required `MCP-Protocol-Version`/`Mcp-Method`/`Mcp-Name` HTTP headers, cache hints on every
|
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.
|
|
9
|
+
| <!--@majorMinor-->0.22<!--/@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.
|
|
13
|
+
so <!--@majorMinor-->0.22<!--/@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
|