codebase-snapshot 0.21.0 → 0.22.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/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.21.0 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.21.0 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.22.0 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.22.0 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
package/docs/guard.md ADDED
@@ -0,0 +1,154 @@
1
+ # Change Guard
2
+
3
+ `guard` answers one question after an agent edits code: **what does this change reach that is
4
+ not in the change set?** It returns untouched consumers, candidate tests and affected routes — or
5
+ nothing at all.
6
+
7
+ It is the in-loop companion to [impact](impact.md) and [brief](brief.md). Impact is a report you
8
+ ask for; Change Guard is a check that can run on every edit and stay silent until it has something
9
+ useful to say.
10
+
11
+ ## Run it
12
+
13
+ ~~~bash
14
+ codebase-snapshot guard --changed
15
+ codebase-snapshot guard --paths src/auth.ts --format json
16
+ codebase-snapshot guard --diff origin/main --format json
17
+ ~~~
18
+
19
+ With no options it checks the working tree against `HEAD`. The output is small on purpose:
20
+
21
+ ~~~text
22
+ Change Guard: 2 gap(s) in this change
23
+ consumer src/api.ts (1 hop, relative-import, via src/auth.ts)
24
+ test tests/auth.test.ts (test: src/auth.ts)
25
+ coverage: complete · confidence: symbol-pruned
26
+ ~~~
27
+
28
+ Every gap is a path outside the change. A file the change already touched is never reported again.
29
+
30
+ ## Hook mode
31
+
32
+ `--hook <client>` reads one JSON payload from stdin and writes the host-shaped response to stdout.
33
+ It never fails the agent's turn: a malformed payload or a missing manifest produces an empty object
34
+ and a note on stderr.
35
+
36
+ | Client | Flag | Response |
37
+ | :-- | :-- | :-- |
38
+ | Claude Code | `--hook claude` | `hookSpecificOutput.additionalContext` with `hookEventName` |
39
+ | Copilot | `--hook copilot` | top-level `additionalContext` |
40
+ | Codex | `--hook codex` | top-level `additionalContext` |
41
+ | Other | `--hook raw` | top-level `additionalContext` |
42
+
43
+ When there is nothing to report, the response is `{}`. That is the point: a guard that speaks when
44
+ there is nothing wrong is a guard users disable.
45
+
46
+ ### Claude Code
47
+
48
+ ~~~json
49
+ {
50
+ "hooks": {
51
+ "PostToolUse": [
52
+ {
53
+ "matcher": "Edit|Write",
54
+ "hooks": [
55
+ {
56
+ "type": "command",
57
+ "command": "npx -y codebase-snapshot@0.22.0 guard --hook claude",
58
+ "timeout": 10
59
+ }
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ }
65
+ ~~~
66
+
67
+ ### Copilot in VS Code
68
+
69
+ ~~~json
70
+ {
71
+ "version": 1,
72
+ "hooks": {
73
+ "postToolUse": [
74
+ {
75
+ "type": "command",
76
+ "command": "npx -y codebase-snapshot@0.22.0 guard --hook copilot",
77
+ "timeoutSec": 10
78
+ }
79
+ ]
80
+ }
81
+ }
82
+ ~~~
83
+
84
+ ### Codex CLI
85
+
86
+ ~~~json
87
+ {
88
+ "hooks": {
89
+ "PostToolUse": [
90
+ {
91
+ "matcher": "Edit|Write",
92
+ "hooks": [
93
+ {
94
+ "type": "command",
95
+ "command": "npx -y codebase-snapshot@0.22.0 guard --hook codex",
96
+ "timeout": 10
97
+ }
98
+ ]
99
+ }
100
+ ]
101
+ }
102
+ }
103
+ ~~~
104
+
105
+ The exact file location is the host's: `.claude/settings.json`, `.github/hooks/*.json`,
106
+ `.codex/hooks.json`, or the plugin's own `hooks/hooks.json`. The command is the same.
107
+
108
+ ## What it reads
109
+
110
+ The guard reuses the live index: the working tree is scanned in memory and uncommitted edits are
111
+ overlaid, so no `generate` run is required. `--no-live` requires a persisted manifest instead.
112
+
113
+ It reads the same manifest and import resolver as [impact](impact.md). It never writes into the
114
+ repository and never reads a sensitive file: `.env`, `*.pem` and the rest stay out.
115
+
116
+ ## What it does not claim
117
+
118
+ - **Candidate tests, not coverage.** A test that imports a changed file is a candidate; it may not
119
+ exercise the changed behavior.
120
+ - **Static reach, not runtime reach.** A dynamic import the parser cannot evaluate is absent rather
121
+ than guessed; the trust envelope says when coverage is partial.
122
+ - **No proof.** A clean report means no gap was found within the bounds, not that the change is
123
+ correct.
124
+ - **No model call.** The guard is deterministic. It does not ask another model to review the diff.
125
+
126
+ ## Bounds
127
+
128
+ | Limit | Default | Why |
129
+ | :-- | --: | :-- |
130
+ | Consumers in one report | 10 | Keep the model-facing note under a token budget |
131
+ | Candidate tests | 5 | The agent can run the highest-value ones first |
132
+ | Routes | 5 | Same |
133
+ | Hook text | 1200 chars | `--max-chars` changes it (200-10000) |
134
+
135
+ When the list is cut, `truncated` is true and the omitted counts are recorded. Nothing disappears
136
+ without a number.
137
+
138
+ ## Exit codes
139
+
140
+ | Code | Meaning |
141
+ | :-- | :-- |
142
+ | 0 | The check ran. This includes a clean report and a hook that returned `{}`. |
143
+ | 1 | The live index could not be built, or `--no-live` was given without a manifest. |
144
+ | 2 | A usage error: an unknown client, `--max-chars` out of range, or `--hook` combined with `--paths`. |
145
+
146
+ In hook mode a failure is fail-open: stdout is `{}` and the reason is on stderr, so a broken guard
147
+ cannot break the agent's turn.
148
+
149
+ ## Related
150
+
151
+ - [Impact reports](impact.md) — the analysis the guard summarizes.
152
+ - [Briefs](brief.md) — the reviewer-facing pack.
153
+ - [MCP tools](tools.md) — the same analysis over MCP.
154
+ - [Stale context is your bug](stale-context-is-your-bug.md) — why freshness is a separate check.
@@ -5,8 +5,16 @@ impact facts a question needs, instead of attaching the whole repository.** code
5
5
  one: seven tools (six read-only) over stdio or Streamable HTTP, a live index that sees uncommitted
6
6
  edits, and a persistent snapshot when you need a shared artefact.
7
7
 
8
- This guide covers what the server exposes, how to wire it into Claude, Cursor, Claude Code or any
9
- generic MCP client, what it can read, and where its limits are.
8
+ The server is listed in the official MCP Registry as
9
+ [`io.github.ankurhalder/codebase-snapshot`](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.ankurhalder%2Fcodebase-snapshot).
10
+ This guide covers what it exposes, how to wire it into Claude, Cursor, Claude Code or any generic
11
+ MCP client, what it can read, and where its limits are.
12
+
13
+ <p align="center">
14
+ <a href="https://mcprush.com/to/codebase-snapshot-mcp?ref=badge">
15
+ <img width="380" height="200" src="https://mcprush.com/badge/codebase-snapshot-mcp/card.svg" alt="Codebase Snapshot MCP server on mcprush">
16
+ </a>
17
+ </p>
10
18
 
11
19
  ## Why a local MCP server instead of a packed file
12
20
 
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.21.0 mcp
13
+ npx -y codebase-snapshot@0.22.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.21.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.22.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.21.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.22.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,7 +43,7 @@ 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.21.0 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.22.0 mcp --http --port 4789
47
47
  ```
48
48
 
49
49
  This is the Streamable HTTP shape: POST one JSON-RPC message to `/mcp` and read the JSON-RPC
@@ -51,7 +51,11 @@ answer from the response body. Modern (`2026-07-28`) requests must also carry
51
51
  `MCP-Protocol-Version`, `Mcp-Method` and — for `tools/call`, `resources/read` and
52
52
  `prompts/get` — `Mcp-Name`. A missing header, or one that disagrees with the body, is refused
53
53
  with HTTP `400` and JSON-RPC `-32020` before dispatch; the CORS preflight allows all three
54
- names. Legacy requests keep the session behaviour below. `GET /healthz` answers
54
+ names. Modern cacheable results (`server/discover`, `tools/list`, `prompts/list`,
55
+ `resources/list`, `resources/read`, `resources/templates/list`) also carry `ttlMs` and
56
+ `cacheScope`; this server sets `ttlMs` to `0` and `cacheScope` to `private`, so a regenerated
57
+ snapshot is never served from a stale shared cache. Legacy requests keep the session behaviour
58
+ below. `GET /healthz` answers
55
59
  `{ ok, name, version, tools, uptimeSeconds }` without a token, and `GET /metrics` answers Prometheus
56
60
  text: `snapshot_requests_total`, `snapshot_requests_by_method_total{method="…"}` (fixed labels,
57
61
  never a path or a credential), `snapshot_requests_refused_total` (every 4xx except 429: an
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "mcpName": "io.github.ankurhalder/codebase-snapshot",
5
5
  "description": "LLM codebase context you can verify: turn a repository into budgeted Markdown with a manifest of every included and skipped file, secret redaction, drift validation, and 7 MCP tools for Claude, ChatGPT, Cursor and CI.",
6
6
  "keywords": [