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 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.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
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 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
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 with an omission marker, and `manifest.json`
60
- records it in `incomplete[]` with the line ranges it lost.
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 a structural summary, every *excluded* file with the reason, and an
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, and from a project dependency the same binary is `npx snapshot` or the
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` is a brief, not a packing slip: the job,
161
- the system map the manifest can prove (layers, load-bearing modules, entry points, indexed
162
- surfaces), the recent commit history as claims to verify rather than rediscover, the evidence bar,
163
- the coverage owed, and calibration examples. Then the apparatus — this run's parts, partial files
164
- with their missing line ranges, fingerprint, and the attachment arithmetic. The judgement half
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 being treated as
188
- opaque text, and every summary is labelled `ast`, `structural` or `heuristic` so you know how much
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.21.0 mcp # or serve it over MCP
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.21<!--/@majorMinor-->.x | ✅ |
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.21<!--/@majorMinor-->.x is newer than 4.4.1, not older. That is explained in full in the
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