codebase-snapshot 0.22.1 → 0.22.2

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/answer.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # One question, one bounded context
2
2
 
3
3
  An agent usually has one question and one budget, not a browsing session. `snapshot_context` is
4
- the one-call answer: give it a question, files or symbols, and it returns the smallest redacted,
5
- line-numbered context that fits the token ceiling. Every planned file that did not fit is named in
6
- `omitted[]`, and the response carries the same `trust` envelope as every other read-only tool.
4
+ the one-call answer: give it a question, files, symbols or explicit line ranges, and it returns the
5
+ smallest redacted, line-numbered context that fits the token ceiling. Every planned file that did
6
+ not fit is named in `omitted[]`, hidden instructions are removed, and the response carries the same
7
+ `trust` envelope as every other read-only tool plus a verifiable context receipt.
7
8
 
8
9
  ```json
9
10
  {
@@ -16,9 +17,10 @@ line-numbered context that fits the token ceiling. Every planned file that did n
16
17
  ```
17
18
 
18
19
  `planOnly: true` returns the ranked reading plan without bodies. Use it when you want to choose
19
- what to open yourself; use the default when you want the context in one call. With `files` and
20
- `symbols`, the planner is skipped and those targets are assembled directly, still under the same
21
- budget and with the same omission list.
20
+ what to open yourself; use the default when you want the context in one call. With `files`,
21
+ `symbols` and `ranges`, the planner is skipped and those targets are assembled directly, still
22
+ under the same budget and with the same omission list. A symbol target starts at its declaration
23
+ span, not line 1; a range target is numbered from the requested start line.
22
24
 
23
25
  The live index is used by default, so uncommitted edits and new files are visible without running
24
26
  generate. live: false requires the persisted snapshot.
@@ -55,12 +57,17 @@ The structured response contains:
55
57
  | :-- | :-- |
56
58
  | budgetTokens | The ceiling the caller asked for. |
57
59
  | usedTokens | The estimate actually spent on the returned bodies. |
58
- | files | The chosen files, each with its part, layer, kind, line window and why it was chosen. |
60
+ | files | The chosen files, each with its part, layer, kind, `fromLine`/`toLine`, symbol (if any) and why it was chosen. |
59
61
  | omitted | Every planned file that did not fit, with the reason. |
62
+ | security | Hidden-instruction comments and invisible characters removed from the returned bodies. |
63
+ | receipt | SHA-256 digest of the canonical response chunks, omissions, security findings and trust. Optional Ed25519 signature. |
60
64
  | trust | Index source, freshness, coverage, redaction count and named partial reasons. |
61
65
 
62
- A file in files may be a window rather than the whole body. The window is line-numbered and states
63
- whether more remains, so an agent can ask for the next page instead of assuming it has the file.
66
+ A file in files may be a window rather than the whole body. The window is line-numbered with the
67
+ real source line numbers and states whether more remains, so an agent can ask for the next page
68
+ instead of assuming it has the file. Hidden HTML comments that look like instructions, zero-width
69
+ characters and bidi controls are removed before the body is returned; the security array names what
70
+ was removed without echoing the payload.
64
71
 
65
72
  ## A worked example
66
73
 
@@ -79,10 +86,32 @@ names the files that did not fit; if the redaction tests are omitted, the trust
79
86
  coverage is complete for the plan, because the plan itself is what was bounded. Read omitted before
80
87
  concluding that the answer is complete.
81
88
 
89
+ ## Line targeting and receipts
90
+
91
+ Pass `symbols` when you know the declaration; the tool uses the parsed `declarationSpans` and
92
+ returns the span, with `fromLine`/`toLine` and `symbol`. Pass `ranges` when you already know the
93
+ lines:
94
+
95
+ ```json
96
+ {
97
+ "name": "snapshot_context",
98
+ "arguments": {
99
+ "ranges": [{ "path": "src/mcp/retrieval.ts", "startLine": 96, "endLine": 135 }],
100
+ "maxTokens": 4000
101
+ }
102
+ }
103
+ ```
104
+
105
+ The receipt is deterministic for the same index and inputs. `digest` covers the canonical chunk
106
+ metadata, omission list, security findings and trust envelope; each chunk also has its own
107
+ `sha256`. Set `signReceipt: true` with `SNAPSHOT_SIGNING_KEY` configured to add an Ed25519
108
+ signature over the same canonical payload. A receipt proves what was returned; it does not prove
109
+ the code was correct.
110
+
82
111
  ## Limits
83
112
 
84
- - **Terms, not intent.** Synonyms the planner does not know are missed. Pass files or symbols when
85
- you know the target.
113
+ - **Terms, not intent.** Synonyms the planner does not know are missed. Pass files, symbols or
114
+ ranges when you know the target.
86
115
  - **Token estimates, not tokenizer counts.** The estimate is useful for choosing a budget; it is not
87
116
  a model's exact count.
88
117
  - **No write access.** The tool never edits or runs code. It returns context.
package/docs/cli.md CHANGED
@@ -104,7 +104,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
104
104
 
105
105
  ```
106
106
  📸 Generating snapshot for: /path/to/repo
107
- Branch: main (fallback) | Part budget: 300 KB | Generator: 0.22.1 (project dependency ^0.22.1)
107
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.22.2 (project dependency ^0.22.2)
108
108
 
109
109
  ✅ Snapshot generated in 0.14s:
110
110
  - 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
@@ -302,7 +302,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
302
302
  🚀 Setup for: /path/to/repo
303
303
  ✅ Created snapshot.config.json (preset: nextjs)
304
304
  Added npm scripts: snapshot, snapshot:validate
305
- Added devDependency: codebase-snapshot ^0.22.1
305
+ Added devDependency: codebase-snapshot ^0.22.2
306
306
  Added to .gitignore: /snapshot/, /snapshot.tmp/
307
307
  ⏳ Installing dependencies…
308
308
  ✅ Installed dependencies (npm install, 2.1s)
@@ -354,7 +354,7 @@ It also has three side effects on files you own, and it says so when it does the
354
354
  ```
355
355
  ✅ Created snapshot.config.json (preset: node-lib)
356
356
  Added npm scripts: snapshot, snapshot:validate
357
- Added devDependency: codebase-snapshot ^0.22.1
357
+ Added devDependency: codebase-snapshot ^0.22.2
358
358
  Added to .gitignore: /snapshot/, /snapshot.tmp/
359
359
  ```
360
360
 
@@ -504,8 +504,8 @@ agent](agent.md).
504
504
  Ask the npm registry whether a newer release exists, and print the version it compared against:
505
505
 
506
506
  ```bash
507
- npx codebase-snapshot@0.22.1 update # is this build current? print the answer
508
- npx codebase-snapshot@0.22.1 update --format json
507
+ npx codebase-snapshot@0.22.2 update # is this build current? print the answer
508
+ npx codebase-snapshot@0.22.2 update --format json
509
509
  ```
510
510
 
511
511
  ```text
package/docs/deploy.md CHANGED
@@ -67,8 +67,8 @@ After=network.target
67
67
  Type=oneshot
68
68
  User=deploy
69
69
  WorkingDirectory=/srv/app
70
- ExecStart=/usr/bin/npx -y codebase-snapshot@0.22.1 generate --cwd /srv/app
71
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.22.1 validate --cwd /srv/app
70
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.22.2 generate --cwd /srv/app
71
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.22.2 validate --cwd /srv/app
72
72
  ```
73
73
 
74
74
  ```ini
package/docs/guard.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Change Guard
2
2
 
3
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.
4
+ not in the change set?** It returns untouched consumers, candidate tests, affected routes and
5
+ public symbols that no documentation file mentions — or nothing at all.
6
6
 
7
7
  It is the in-loop companion to [impact](impact.md) and [brief](brief.md). Impact is a report you
8
8
  ask for; Change Guard is a check that can run on every edit and stay silent until it has something
@@ -44,7 +44,7 @@ and use the hook block below.
44
44
  The hook runs a pinned CLI, so the machine needs Node.js 18+ and `npx`:
45
45
 
46
46
  ~~~bash
47
- npx -y codebase-snapshot@0.22.1 --version
47
+ npx -y codebase-snapshot@0.22.2 --version
48
48
  ~~~
49
49
 
50
50
  ## Run it
@@ -58,15 +58,19 @@ codebase-snapshot guard --diff origin/main --format json
58
58
  With no options it checks the working tree against `HEAD`. The output is small on purpose:
59
59
 
60
60
  ~~~text
61
- Change Guard: 2 gap(s) in this change
61
+ Change Guard: 3 gap(s) in this change
62
62
  consumer src/api.ts (1 hop, relative-import, via src/auth.ts)
63
63
  test tests/auth.test.ts (test: src/auth.ts)
64
+ docs src/public-api.ts (newApi)
64
65
  coverage: complete · confidence: file-import
65
66
  ~~~
66
67
 
67
- Every gap is a path outside the change. A file the change already touched is never reported again.
68
- `confidence` is `symbol-pruned` only when a diff seeded symbol-level matches; a hook payload or
69
- `--paths` run is file-level (`file-import`).
68
+ Consumer, test and route gaps name a path outside the change; a file the change already touched
69
+ is never reported again. A documentation gap names the changed public file and the exported symbols
70
+ that no Markdown/reStructuredText/AsciiDoc file mentions. Docs are checked only when the repository
71
+ has a documentation surface, and only exported symbols of at least three characters are considered,
72
+ so the signal stays small. `confidence` is `symbol-pruned` only when a diff seeded symbol-level
73
+ matches; a hook payload or `--paths` run is file-level (`file-import`).
70
74
 
71
75
  ## Hook mode
72
76
 
@@ -97,7 +101,7 @@ The plugin install above already wires this hook. Use this block only for a manu
97
101
  "hooks": [
98
102
  {
99
103
  "type": "command",
100
- "command": "npx -y codebase-snapshot@0.22.1 guard --hook claude",
104
+ "command": "npx -y codebase-snapshot@0.22.2 guard --hook claude",
101
105
  "timeout": 10
102
106
  }
103
107
  ]
@@ -116,7 +120,7 @@ The plugin install above already wires this hook. Use this block only for a manu
116
120
  "postToolUse": [
117
121
  {
118
122
  "type": "command",
119
- "command": "npx -y codebase-snapshot@0.22.1 guard --hook copilot",
123
+ "command": "npx -y codebase-snapshot@0.22.2 guard --hook copilot",
120
124
  "timeoutSec": 10
121
125
  }
122
126
  ]
@@ -135,7 +139,7 @@ The plugin install above already wires this hook. Use this block only for a manu
135
139
  "hooks": [
136
140
  {
137
141
  "type": "command",
138
- "command": "npx -y codebase-snapshot@0.22.1 guard --hook codex",
142
+ "command": "npx -y codebase-snapshot@0.22.2 guard --hook codex",
139
143
  "timeout": 10
140
144
  }
141
145
  ]
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.22.1 mcp
13
+ npx -y codebase-snapshot@0.22.2 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.22.1", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.22.2", "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.22.1 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.22.2 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.22.1 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.22.2 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
@@ -124,7 +124,7 @@ reads the index, `medium` reads a few bounded bodies, `expensive` runs a compile
124
124
  | Tool | Answers | Writes |
125
125
  | :-- | :-- | :-- |
126
126
  | `snapshot_impact` | What does this change reach? Symbol-pruned callers, routes, import cycles, candidate tests and optional snippets. Omitting `paths` and `base` compares the working tree with `HEAD`. | no |
127
- | `snapshot_context` | The minimum redacted, line-numbered context for a question, files or symbols inside a hard token budget. `planOnly` returns the reading plan. | no |
127
+ | `snapshot_context` | The minimum redacted, line-numbered context for a question, files, symbols or explicit ranges inside a hard token budget. Symbol targets use declaration spans; hidden instructions are removed; a context receipt carries chunk hashes and an optional signature. `planOnly` returns the reading plan. | no |
128
128
  | `snapshot_locate` | Paths, symbols, routes, entrypoints or bounded redacted text. Symbol mode can add compiler-resolved references. | no |
129
129
  | `snapshot_read` | A bounded, redacted line window of one file. Sensitive paths are never readable. | no |
130
130
  | `snapshot_validate` | `status` (presence, counts, fingerprint), `drift` (freshness), or `audit` (secret and integrity checks). Only drift claims `current`. | no |
@@ -133,6 +133,11 @@ addition was reviewed with the same question — what new input arrives, and wha
133
133
  now fails the audit; before, both passed. This turns a tampered snapshot into a detected one.
134
134
  - **`snapshot_context`** (0.15.5) reads only `parts/` through the same parser, so redaction and
135
135
  exclusions apply exactly as they do to `snapshot_read`; it adds no file-system surface.
136
+ - **Hidden instructions and context receipts** (0.22.2): context/read/locate remove HTML comments
137
+ that read like AI instructions, zero-width characters and bidi controls before a body is
138
+ returned, and report the removals without echoing the payload. The receipt hashes the returned
139
+ chunks and the sanitized omission/security/trust metadata; signing uses the existing Ed25519 key
140
+ path and fails closed when `signReceipt` is requested without a key.
136
141
  - **`--only`/`--ignore`** (0.14.6, tightened 0.21.0) never widen the MCP surface: the CLI may
137
142
  replace its own config's allow-list, but an MCP request that tries to replace a declared
138
143
  `include` allow-list is refused. `--ignore` only adds excludes. Sensitive files stay excluded.
package/docs/tools.md CHANGED
@@ -39,9 +39,12 @@ walk.
39
39
 
40
40
  **Cost:** medium · **Read-only:** yes
41
41
 
42
- The minimum redacted, line-numbered context for a question, file list or symbol list inside a hard
43
- token budget. `planOnly` returns the ranked reading plan without bodies. Every requested file that
44
- does not fit is named in `omitted[]`.
42
+ The minimum redacted, line-numbered context for a question, file list, symbol list or explicit
43
+ line ranges inside a hard token budget. An explicit symbol starts at its parsed declaration span;
44
+ a range is numbered from its real start line. `planOnly` returns the ranked reading plan without
45
+ bodies. Every requested file that does not fit is named in `omitted[]`. Hidden instructions and
46
+ invisible characters are removed, and the response carries a `receipt` with chunk hashes and a
47
+ canonical digest; `signReceipt` adds an Ed25519 signature when a signing key is configured.
45
48
 
46
49
  ```json
47
50
  {
@@ -54,6 +57,18 @@ does not fit is named in `omitted[]`.
54
57
  }
55
58
  ```
56
59
 
60
+ A precise request uses the same tool:
61
+
62
+ ```json
63
+ {
64
+ "name": "snapshot_context",
65
+ "arguments": {
66
+ "ranges": [{ "path": "src/impact.ts", "startLine": 180, "endLine": 240 }],
67
+ "maxTokens": 4000
68
+ }
69
+ }
70
+ ```
71
+
57
72
  - **`snapshot_locate`**
58
73
 
59
74
  **Cost:** cheap · **Read-only:** yes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.22.1",
3
+ "version": "0.22.2",
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": [