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
@@ -16,17 +16,17 @@ This repository, measured rather than estimated:
16
16
 
17
17
  | | |
18
18
  | :--- | ---: |
19
- | TypeScript files under `src/` | 88 |
20
- | Lines | 28,992 |
21
- | Bytes | 1,191,949 |
22
- | **Estimated tokens** | **≈ 340,000** |
23
-
24
- That single number decides the whole conversation. 340k tokens does not fit in an 8k window, it
25
- does not fit a 200k window at all — it is the whole window and two thirds of another — and it fits
26
- in a 1M window with room for the question. Measured on 2026-11-17 with `git ls-files src` plus the
27
- tool's own `countLines`, over the files present that day. The count moves with every commit — the
28
- order of magnitude does not, which is what the number is for; run `codebase-snapshot report` on a
29
- snapshot of this repository to re-measure a checkout.
19
+ | Included files | 221 |
20
+ | Lines | ≈59,000 |
21
+ | Source bytes | ≈2.5 MB |
22
+ | **Estimated tokens** | **≈764,000** |
23
+
24
+ That single number decides the whole conversation. 764k tokens does not fit in an 8k window, it
25
+ does not fit a 200k window at all, and it is three quarters of a 1M window before the question is
26
+ asked. Measured on 2026-11-30 at 0.21.0, from `snapshot/manifest.json`; the source-only part (116
27
+ TypeScript files under `src/`) is smaller, and the documentation is the rest. The count moves with
28
+ every commit — the order of magnitude does not, which is what the number is for; run
29
+ `codebase-snapshot report` on a snapshot of this repository to re-measure a checkout.
30
30
 
31
31
  ## What the default part budget means
32
32
 
@@ -64,8 +64,8 @@ budget of any single part.
64
64
 
65
65
  ## When the repository does not fit
66
66
 
67
- It usually does not. 340k tokens is a small library; a real application is five to twenty times
68
- that. In order of preference:
67
+ It usually does not. 763k tokens is a documentation-heavy repository; a real application is
68
+ several times that, and a large monorepo more still. In order of preference:
69
69
 
70
70
  1. **Scope the run, not the budget.** `include`/`exclude` patterns, or the wizard's "only
71
71
  specific folders" option, cut more than any budget change. Packing the thing you are asking
@@ -100,3 +100,4 @@ intended to fill, the budget was not the problem — the selection was.
100
100
  - [Budgeting LLM context](how-to-context-budget.md) — choosing ceilings per layer
101
101
  - [Feeding a repo to an LLM](how-to-feed-a-repo-to-claude.md) — the end-to-end recipe
102
102
  - [Configuration](configuration.md) — `maxPartBytes`, `largeFileBytes`, `maxMonolithBytes`
103
+ - [Glossary](glossary.md) — token, context window, byte budget and the other terms
@@ -0,0 +1,66 @@
1
+ # All codebase-snapshot documentation
2
+
3
+ Every page on this site, grouped by the job you are doing. If you are new, start with the
4
+ [overview](../README.md), then [installation](install.md), then the [CLI reference](cli.md).
5
+
6
+ ## Start here
7
+
8
+ - [Overview and quick start](../README.md) — what the tool does, install, first run and the shape
9
+ of the output.
10
+ - [Installation](install.md) — npm, yarn, pnpm, bun, npx, version pinning and a shadowed npx.
11
+ - [CLI reference](cli.md) — every command, option, default and exit code.
12
+ - [Configuration](configuration.md) — every setting, the 25 project presets, budgets and hooks.
13
+ - [Snapshot output](output.md) — parts, manifest, reports and the schema.
14
+ - [AI agents](agent.md) — the machine-readable contract and the installable skill.
15
+
16
+ ## Core workflows
17
+
18
+ - [Impact reports](impact.md) — what a change reaches and which tests to run.
19
+ - [Briefs](brief.md) — one redacted, bounded review pack.
20
+ - [MCP server](mcp.md) — transports, sessions, resources and protocol details.
21
+ - [MCP server for a codebase](mcp-server-for-codebase.md) — setup for Claude, Cursor and generic
22
+ clients, the seven tools, security and limits.
23
+ - [MCP tools](tools.md) — every tool schema and an example call.
24
+ - [snapshot_context](answer.md) — cited, line-numbered context in one call.
25
+ - [Health](health.md) — hashes, secrets, host paths, accounting and freshness.
26
+ - [Serve](serve.md) — the browser page and the MCP endpoint on one local port.
27
+ - [Remote sources](remote.md) — shallow, SSRF-safe cloning.
28
+ - [Delta snapshots](delta.md) — send only what changed since a base.
29
+ - [Slices](slice.md) — a snapshot for one question.
30
+ - [Token budgets](budget.md) — fit a repository into a window by selecting whole files.
31
+ - [Benchmarks](benchmarks.md) — measured tokens and time on ten public repositories.
32
+ - [Workspaces](workspace.md) — one snapshot per member, plus an index.
33
+ - [Signing](signing.md) — Ed25519 signatures and verification.
34
+
35
+ ## Guides and concepts
36
+
37
+ - [LLM codebase context](llm-codebase-context.md) — what it is, why raw dumps fail, and the four
38
+ practical approaches.
39
+ - [How to feed a repository to Claude or ChatGPT](how-to-feed-a-repo-to-claude.md) — the end-to-end
40
+ recipe.
41
+ - [Budgeting LLM context](how-to-context-budget.md) — choose maxPartBytes from the destination.
42
+ - [How many tokens is a codebase?](codebase-token-budget.md) — the arithmetic and a budget table.
43
+ - [Stale context is your bug](stale-context-is-your-bug.md) — detect drift and gate it in CI.
44
+ - [Glossary](glossary.md) — codebase snapshot, token budget, manifest, drift, MCP, AX and more.
45
+ - [FAQ](faq.md) — direct answers about MCP, tokens, secrets, CI and comparisons.
46
+
47
+ ## Comparisons
48
+
49
+ - [vs repomix](vs-repomix.md) — two ways to pack a repository, and when repomix is the better fit.
50
+ - [vs gitingest](vs-gitingest.md) — a CLI artefact versus a URL-to-text trick.
51
+ - [vs code2prompt](vs-code2prompt.md) — a prompt versus an indexed artefact.
52
+
53
+ ## Operations and trust
54
+
55
+ - [Migration to 0.21](migration.md) — the seven-tool MCP surface, live impact and every breaking
56
+ change.
57
+ - [Deploy](deploy.md) — a container, compose file and systemd timer.
58
+ - [Security review](security-review.md) — the threat model, controls and residual risks.
59
+ - [Troubleshooting](troubleshooting.md) — every message and its one-line fix.
60
+ - [About this project](about.md) — who maintains it, how claims are tested and the editorial policy.
61
+
62
+ ## Machine-readable
63
+
64
+ - [llms.txt](https://ankurhalder.github.io/codebase-snapshot/llms.txt) — a compact index for agents.
65
+ - [llms-full.txt](https://ankurhalder.github.io/codebase-snapshot/llms-full.txt) — every page in one file.
66
+ - [Sitemap](https://ankurhalder.github.io/codebase-snapshot/sitemap.xml) — every canonical URL.
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.20.12 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.12 validate --cwd /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
66
66
  ```
67
67
 
68
68
  ```ini
package/docs/faq.md ADDED
@@ -0,0 +1,112 @@
1
+ # Codebase snapshot FAQ
2
+
3
+ Short answers to the questions people ask before using codebase-snapshot. Each answer links to
4
+ the page with the full detail.
5
+
6
+ ## What is a codebase snapshot?
7
+
8
+ A codebase snapshot is a bounded, indexed copy of a repository prepared for a language model:
9
+ source files are packed into Markdown parts under a byte budget, and a manifest records every
10
+ included file, every skipped path with the reason, and every file that had to be shortened. The
11
+ point is not to copy the repository; it is to produce context a reader can inspect and a pipeline
12
+ can validate.
13
+
14
+ ## How is this different from repomix or gitingest?
15
+
16
+ repomix and gitingest pack a repository into one AI-readable document. codebase-snapshot also
17
+ partitions the output, records why each path was included or skipped, redacts secret-shaped values,
18
+ and can prove the snapshot still matches the tree. That last property is the main difference: a
19
+ packed file cannot tell you it is stale. See the honest comparisons with
20
+ [repomix](vs-repomix.md), [gitingest](vs-gitingest.md) and [code2prompt](vs-code2prompt.md).
21
+
22
+ ## Does codebase-snapshot send my code anywhere?
23
+
24
+ No. The CLI and the MCP server run locally. They read a directory you name and write a directory
25
+ you name. There is no account, no upload and no telemetry. A remote source is fetched only when you
26
+ explicitly pass a URL with --remote, and that path is documented in
27
+ [remote sources](remote.md).
28
+
29
+ ## Which languages are supported?
30
+
31
+ TypeScript and JavaScript get the deepest parser and symbol support. Python, Go, Rust, Java/Kotlin,
32
+ C#/.NET, PHP, Ruby, C/C++, Vue, Svelte and Astro have language profiles for classification, imports
33
+ and previews. Every file type can still be included as text when the profile has nothing to add.
34
+ See [configuration](configuration.md) for the preset and layer rules.
35
+
36
+ ## How do I feed a whole repository to Claude or ChatGPT?
37
+
38
+ Generate a snapshot, attach the parts the prompt tells you to attach, and paste the instructions
39
+ from PROMPT.md. If the repository does not fit the destination's file limit, increase the part
40
+ budget or scope the run to the folders you are asking about. The end-to-end recipe is
41
+ [Feeding a codebase to an LLM](how-to-feed-a-repo-to-claude.md).
42
+
43
+ ## How many tokens is my codebase?
44
+
45
+ A rough estimate is bytes divided by 3.5, or lines multiplied by 11. Source code is denser than
46
+ English prose, so a 1 MB repository is usually around 285,000 tokens, not 250,000. The tool reports
47
+ the estimate it actually used in manifest.totals.estimatedTokens. The arithmetic and a table of
48
+ budgets are in [How many tokens is a codebase?](codebase-token-budget.md).
49
+
50
+ ## What is the MCP server for?
51
+
52
+ The MCP server exposes the repository to an MCP client as seven tools (six read-only): impact, context,
53
+ locate, read, validate, explain and generate. Instead of attaching a 12-part snapshot, an agent can
54
+ ask for the one part, symbol or changed-file report it needs. Setup, tool schemas and the security
55
+ boundary are in [MCP server for a codebase](mcp-server-for-codebase.md).
56
+
57
+ ## How do I keep a snapshot from going stale?
58
+
59
+ Run validate after the code changes. It re-hashes the files and exits non-zero when the snapshot no
60
+ longer matches the tree, so a CI job or a pre-commit hook can refuse stale context. The MCP read
61
+ tools use the live tree by default, so an agent sees uncommitted edits without regenerating. See
62
+ [Stale context is your bug](stale-context-is-your-bug.md).
63
+
64
+ ## Does it include .env files or secrets?
65
+
66
+ Credential files such as .env, .pem, .npmrc, .ssh and .tfstate are excluded by default and recorded
67
+ as skipped. Secret-shaped values inside ordinary files are replaced with a marker; the audit
68
+ artifact names the file and line but never the value. If you explicitly pass
69
+ --include-sensitive-files, the MCP and serve transports refuse to serve that snapshot. Read the
70
+ [security review](security-review.md) for the exact guarantees and residual risks.
71
+
72
+ ## Can I use it in CI?
73
+
74
+ Yes. generate writes the snapshot, validate exits non-zero on drift, and health --strict fails on a
75
+ critical integrity or secret finding. The CLI keeps progress on stderr and JSON on stdout, so a
76
+ pipeline can parse it. A typical job is: generate once on the base branch, validate on every pull
77
+ request, and upload the parts as an artifact only when they are current.
78
+
79
+ ## Does it work with monorepos and Windows?
80
+
81
+ Yes. A workspace run writes one snapshot per member plus a WORKSPACE.json index; Windows paths,
82
+ junctions and OneDrive rename failures are handled explicitly. The output directory is only
83
+ replaced when the tool can prove it wrote it. See [workspaces](workspace.md) and the
84
+ [troubleshooting guide](troubleshooting.md).
85
+
86
+ ## Is it free, and how is it maintained?
87
+
88
+ MIT licensed, with no paid tier and no hosted service. The project is maintained in public; the
89
+ test suite, security review, changelog and source are all in the repository. If you need a
90
+ guarantee for a regulated environment, commission your own review rather than treating a README
91
+ as one.
92
+
93
+ ## What is a token budget?
94
+
95
+ A token budget is the number of model tokens a run is allowed to spend on context. In this tool it
96
+ is expressed as a byte ceiling per part (maxPartBytes), because the partitioner enforces bytes and
97
+ estimates tokens. The budget is a hard ceiling: a file that does not fit is shortened with an
98
+ explicit omission record, never silently overflowed. See
99
+ [Budgeting LLM context](how-to-context-budget.md).
100
+
101
+ ## What is agent experience?
102
+
103
+ Agent experience (AX) is whether an agent can fetch, read and act on a site or tool without a human
104
+ translating for it. For documentation that means static HTML, clear headings, stable URLs, a
105
+ machine-readable contract and bounded responses. The evidence behind that claim is summarised in
106
+ [AX is the New AEO](https://arxiv.org/abs/2609.34951) and [What Drives AI Citations?](https://arxiv.org/abs/2610.15033).
107
+
108
+ ## Related
109
+
110
+ - [About this project](about.md)
111
+ - [All documentation](contents.md)
112
+ - [Glossary](glossary.md)
@@ -0,0 +1,152 @@
1
+ # Codebase snapshot and LLM context glossary
2
+
3
+ The words this project uses, defined plainly. Where a term has a narrower meaning in the code, the
4
+ narrower meaning is the one that applies.
5
+
6
+ ### Codebase snapshot
7
+
8
+ A bounded, indexed copy of a repository prepared for a language model: Markdown parts containing
9
+ the source, plus a manifest that records every included file, every skipped path, and every file
10
+ whose body was shortened. A snapshot is not a git commit and not a backup; it is context with an
11
+ audit trail.
12
+
13
+ ### Context window
14
+
15
+ The maximum number of tokens a model can read and generate in one request. A 128k context window
16
+ does not mean 128,000 tokens of source code: the system prompt, the question, the snapshot and the
17
+ reply all share the same budget.
18
+
19
+ ### Token
20
+
21
+ A unit of text a model processes. Tokens are not words or characters. English prose is often around
22
+ four characters per token; source code is denser because identifiers, punctuation and indentation
23
+ tokenise less efficiently. A token count is therefore model-specific, which is why this tool
24
+ reports an estimate and enforces a byte ceiling rather than pretending to know a tokenizer's exact
25
+ answer.
26
+
27
+ ### Token budget
28
+
29
+ The amount of context a run is allowed to produce. codebase-snapshot expresses it as maxPartBytes
30
+ because the partitioner writes bytes, and reports the estimated tokens beside it. The budget is a
31
+ ceiling, not a target.
32
+
33
+ ### Part
34
+
35
+ One Markdown file written by the partitioner. A part contains a fixed header, a file listing and
36
+ one or more file sections, and never exceeds its byte budget. Parts are the unit a chat destination
37
+ attaches, which is why the prompt does delivery arithmetic instead of asking a model to read a
38
+ single enormous file.
39
+
40
+ ### Manifest
41
+
42
+ The JSON index at the root of a snapshot. It records the configuration digest, file entries with
43
+ layer, kind, language, part and hash, skipped paths with reasons, part hashes, artifact hashes, git
44
+ state and counts. The manifest is the contract every reader trusts; validate compares it with the
45
+ tree.
46
+
47
+ ### Drift
48
+
49
+ The difference between what a snapshot records and what the repository contains now. Drift includes
50
+ changed bytes, added and deleted files, changed ignore or configuration rules, damaged parts and
51
+ stale reports. validate reports drift and exits non-zero.
52
+
53
+ ### Fingerprint
54
+
55
+ A hash of the snapshot's content and configuration, recorded in the manifest and printed by the
56
+ CLI. Two runs over unchanged input produce the same fingerprint. It is a summary, not a signature;
57
+ signing is a separate operation.
58
+
59
+ ### MCP
60
+
61
+ Model Context Protocol: a standard way for an AI client to discover and call tools and read
62
+ resources exposed by a local or remote server. codebase-snapshot serves seven tools; six are
63
+ read-only and one writes a snapshot. See [MCP server for a codebase](mcp-server-for-codebase.md).
64
+
65
+ ### Tool
66
+
67
+ A callable operation with a JSON Schema input and structured output. Tools are listed by the MCP
68
+ server, have a cost class, and are the unit an agent decides to call. Resources are the other half
69
+ of the protocol: URI-addressed content such as snapshot://manifest.
70
+
71
+ ### Resource
72
+
73
+ A URI-addressed, read-only document exposed over MCP. This server publishes the manifest, the
74
+ prompt, the parts, reports, the contract and the skill. Resources are listed before they are read,
75
+ so a missing artifact is not advertised as if it existed.
76
+
77
+ ### LLM context
78
+
79
+ The information a model is given before it answers. Good context is relevant, bounded, attributable
80
+ and current. More context is not automatically better: a 1M-token dump can bury the one file that
81
+ matters and leave no room for the answer.
82
+
83
+ ### Repository packing
84
+
85
+ Collecting a repository into one document or a small set of documents for a model. Packing is a
86
+ transport decision; it says nothing about whether the content is current, complete or safe to
87
+ share. Those properties have to be added deliberately.
88
+
89
+ ### Retrieval-augmented generation (RAG)
90
+
91
+ A pattern where a system retrieves relevant passages from an index and puts them in the model's
92
+ context at question time. Repository packing is the opposite trade-off: it prepares a stable,
93
+ inspectable artefact ahead of time. The two can be combined; codebase-snapshot's MCP tools are
94
+ closer to bounded retrieval over a local index.
95
+
96
+ ### Agent experience (AX)
97
+
98
+ Whether an agent can fetch, read and act on a site or tool without a human translating for it.
99
+ Static HTML, stable URLs, a machine-readable contract, bounded responses and explicit errors are
100
+ AX. The [AX is the New AEO](https://arxiv.org/abs/2609.34951) study finds that agent-ready sites are
101
+ recommended more often and answered from their own pages more often.
102
+
103
+ ### Generative engine optimization (GEO) and answer engine optimization (AEO)
104
+
105
+ The practice of making content discoverable, citable and useful in AI-generated answers. The
106
+ credible parts are the old parts: unique first-hand content, clear structure, verifiable facts and
107
+ a readable site. The unreliable parts are paid placements, synthetic listicles and claims that a
108
+ special file guarantees inclusion.
109
+
110
+ ### llms.txt
111
+
112
+ A proposed Markdown index for language models, with a short summary and links to the pages an agent
113
+ should read. It is useful as an agent-facing table of contents. Google has said that special AI
114
+ text files are not required for its AI features, so this project treats llms.txt as documentation
115
+ infrastructure, not as a ranking switch.
116
+
117
+ ### Secret redaction
118
+
119
+ Replacing a matched credential-shaped value with a marker before it reaches an artifact. Redaction
120
+ is span-based: the surrounding line and the file's structure stay readable, while the value does
121
+ not. It is defence in depth, not a guarantee that every possible secret shape is known.
122
+
123
+ ### Byte budget
124
+
125
+ A hard ceiling on the bytes a part or artifact may contain. Bytes are what the writer controls, so
126
+ the budget is enforceable without a tokenizer. The tool estimates tokens from bytes for planning,
127
+ but the ceiling that can fail a run is the byte ceiling.
128
+
129
+ ### Preview and omission
130
+
131
+ A preview is a bounded head and tail of a file that did not fit. An omission range records the
132
+ lines that were not emitted. The rule is that nothing disappears without a reason: a shortened file
133
+ is listed in incomplete[], with its reason and ranges, and verifyInMemory fails the run if the
134
+ accounting does not add up.
135
+
136
+ ### Symbol-pruned impact
137
+
138
+ A reverse-import analysis that follows the exported symbol a change actually touches, rather than
139
+ every file that imports the module. It is conservative where the symbol cannot be determined and
140
+ reports the limits of its answer. See [impact reports](impact.md).
141
+
142
+ ### Workspace
143
+
144
+ A repository whose packages are snapshotted separately but recorded in one WORKSPACE.json index.
145
+ A workspace run preserves each member's real path and local budget, and reports a missing member
146
+ rather than silently skipping it.
147
+
148
+ ## Related
149
+
150
+ - [All documentation](contents.md)
151
+ - [FAQ](faq.md)
152
+ - [How many tokens is a codebase?](codebase-token-budget.md)
package/docs/health.md CHANGED
@@ -152,7 +152,7 @@ codebase-snapshot health --all-members --cwd /repo
152
152
 
153
153
  ## In the MCP server
154
154
 
155
- `snapshot_health` returns the same report as structured output, so an agent can call it before
155
+ `snapshot_validate` with `mode: "audit"` returns the same report as structured output, so an agent can call it before
156
156
  trusting a snapshot it was handed. Pass `deep: true` for the source replay:
157
157
 
158
158
  ```json
@@ -214,3 +214,9 @@ context for the code that is being asked about.
214
214
  - [Configuration](configuration.md) — every setting and its default
215
215
  - [Snapshot output](output.md) — what each artifact contains
216
216
  - [Comparing with other tools](vs-repomix.md)
217
+
218
+ ## Related
219
+
220
+ - [LLM codebase context](llm-codebase-context.md) — what context is and why a raw dump fails.
221
+ - [MCP server for a codebase](mcp-server-for-codebase.md) — the live alternative when the client supports MCP.
222
+ - [All documentation](contents.md) — every guide and reference.
package/docs/impact.md ADDED
@@ -0,0 +1,102 @@
1
+ # Impact reports
2
+
3
+ `codebase-snapshot impact` answers one question before a change is opened for review: **what does
4
+ this change reach, and which tests are candidates?** It is not a code graph for browsing. It is a
5
+ bounded, evidence-carrying report built from the same import resolver the generator uses, with a
6
+ `trust` envelope that says how fresh and complete the answer is.
7
+
8
+ ## Run it
9
+
10
+ ```bash
11
+ codebase-snapshot impact --diff HEAD
12
+ codebase-snapshot impact --paths src/impact.ts,src/cli.ts --format markdown
13
+ codebase-snapshot impact --diff origin/main --tests-paths
14
+ codebase-snapshot impact --diff HEAD --run
15
+ ```
16
+
17
+ With neither `--diff` nor `--paths`, the base is `HEAD`. The change set includes committed,
18
+ staged, unstaged and untracked changes relative to the ref. A ref beginning with `-` is refused;
19
+ `shell: false` is used for every git invocation.
20
+
21
+ The report works without a generated snapshot. A current `manifest.json` is reused, changed and
22
+ new files are overlaid in memory, and a repository with no snapshot is scanned in memory. Nothing
23
+ is written into the repository. `--no-live` requires the persisted snapshot instead.
24
+
25
+ ## What is in the report
26
+
27
+ | Field | Meaning |
28
+ | :-- | :-- |
29
+ | `changed[]` | Path, whether it is in the snapshot, whether it is deleted, and why it is absent when it is. |
30
+ | `affected[]` | One entry per impacted file: `distance`, `via`, the exact `specifier`, `confidence` (how the edge resolved), `impactKind` and `matchedSymbols`. |
31
+ | `tests[]` | Candidate tests, with the files they cover. These are import relationships, never runtime coverage. |
32
+ | `unresolved[]` | Repository-internal imports that did not resolve. Bare packages and Node built-ins are outside the repository and are not listed. |
33
+ | `routesAffected[]` | Route files in the changed or affected set, with the methods their summaries recorded. |
34
+ | `prunedByBarrel` | Barrel edges rejected because they do not consume the changed symbol. |
35
+ | `cycles` | Import cycles in the impacted subgraph, with `--include-cycles`. |
36
+ | `imports` | Outgoing dependencies of changed files, with `--include-imports`. |
37
+ | `trust` | Index source, freshness, coverage, redaction and omission counts, and named partial reasons. |
38
+ | `truncated` / `limits` | Whether `--max-results` cut the list, and the bounds that applied. |
39
+
40
+ Test files are excluded from `affected[]` and listed in `tests[]`. A file that changed from full to
41
+ preview is still a file: the node is present, the body may not be.
42
+
43
+ ## How an edge is decided
44
+
45
+ 1. The changed file is resolved against the manifest. A deleted path, an unknown path, a non-TypeScript
46
+ file and a paths-only run seed a wildcard. A `--diff` run maps the new-side hunks to the exported
47
+ declarations whose line spans they overlap; an edit outside every declaration widens to a wildcard.
48
+ 2. Reverse importers are walked. The walk reads the importing file's `importBindings` and
49
+ `reExportBindings`, not just the specifier:
50
+ - `import { foo as f }` matches the original `foo`;
51
+ - `export * from "./a"` propagates the symbol set;
52
+ - `export { foo as publicFoo }` maps `foo` to `publicFoo`;
53
+ - `export * as ns` propagates `ns`;
54
+ - CommonJS destructured `require()` and dynamic `import()` are file-level edges;
55
+ - a pure barrel is traversed but not reported as an affected consumer.
56
+ 3. If a barrel edge matches nothing in the incoming symbol set, it is pruned and counted. A consumer
57
+ of a *different* export is not reported.
58
+ 4. Direct or transitive importers are reported with the exact hop that reached them. Tests are collected
59
+ when their import consumes the impacted symbol set.
60
+
61
+ The compiler pass behind `--precise` is bounded to 2,500 files and four seconds. It follows
62
+ `getAliasedSymbol` through aliases and returns only path/line/name references, never source text. Above
63
+ the cap or past the deadline the report stays partial and says why; it never silently falls back.
64
+
65
+ ## Tests
66
+
67
+ `tests[]` is a **candidate list**. A candidate test imports a changed or affected file. It may not
68
+ exercise the changed behaviour, and no coverage claim is made. `--tests-paths` prints one path per
69
+ line for a CI step. `--run` invokes the repository's own runner:
70
+
71
+ - Vitest: `node node_modules/vitest/vitest.mjs related <changed...> --run`
72
+ - Jest: `node node_modules/jest/bin/jest.js --findRelatedTests <changed...> --runInBand`
73
+ - node:test: `node --test <candidate tests>`
74
+
75
+ No package manager, shell or network is used. A change to a build, test or workspace configuration
76
+ adds a warning that the selective run may be incomplete; run the full suite too.
77
+
78
+ ## Output
79
+
80
+ `--format json` is the stable contract and writes one JSON document to stdout. Text goes to stderr,
81
+ as every human-facing command does. `--format markdown` writes a PR-ready report to stdout;
82
+ `--format pr-comment` is accepted by `brief`, which is the page-oriented command.
83
+
84
+ Exit `0` when the report was produced, `1` when the live index cannot be built or an explicit
85
+ `--no-live` manifest is missing, and `2` for a usage error.
86
+
87
+ ## What it does not claim
88
+
89
+ - It is not runtime coverage, a call graph, or a security review.
90
+ - It does not resolve bare package specifiers to `node_modules`, or Node built-ins.
91
+ - It does not see a dependency created through a dynamic string the parser cannot evaluate; such a
92
+ path is absent rather than guessed.
93
+ - A manifest generated from a dirty tree may describe bytes that have already moved. The `trust`
94
+ envelope names that condition; `validate` is the separate proof.
95
+
96
+ → [CLI reference](cli.md) · [Impact in MCP](tools.md) · [Brief](brief.md)
97
+
98
+ ## Related
99
+
100
+ - [Briefs](brief.md) — turn an impact report into a review pack.
101
+ - [LLM codebase context](llm-codebase-context.md) — why symbol-pruned context beats a repository dump.
102
+ - [All documentation](contents.md) — every guide and reference.
package/docs/install.md CHANGED
@@ -115,9 +115,10 @@ it exists — run:
115
115
  npx codebase-snapshot skill --install
116
116
  ```
117
117
 
118
- That writes `.claude/skills/codebase-snapshot/SKILL.md` and
119
- `.cursor/rules/codebase-snapshot.mdc`, and adds both to `.gitignore` so the install leaves
120
- nothing untracked. It does not touch `AGENTS.md`: that file is your project's own agent
118
+ That writes `.agents/skills/codebase-snapshot/SKILL.md`,
119
+ `.claude/skills/codebase-snapshot/SKILL.md` and `.cursor/rules/codebase-snapshot.mdc`, and adds
120
+ all three to `.gitignore` so the install leaves nothing untracked. Add `--with-mcp` to merge a
121
+ server entry into `.mcp.json`. It does not touch `AGENTS.md`: that file is your project's own agent
121
122
  contract. To put the skill there, print it and paste it —
122
123
  `npx codebase-snapshot skill >> AGENTS.md`. See
123
124
  [Using this with an AI agent](agent.md).