codebase-snapshot 0.9.14 → 0.9.16
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 +172 -0
- package/README.md +2 -2
- package/SECURITY.md +52 -5
- package/dist/bin.js +675 -281
- package/dist/{chunk-DUZK5VL2.js → chunk-6TRFLA7N.js} +310 -49
- package/dist/{chunk-J4W74N4Y.js → chunk-WIL536QD.js} +650 -554
- package/dist/cli.cjs +671 -277
- package/dist/cli.js +102 -65
- package/dist/index.cjs +310 -49
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +3678 -3354
- package/dist/mcp.d.cts +10 -0
- package/dist/mcp.d.ts +10 -0
- package/dist/mcp.js +2 -2
- package/docs/cli.md +74 -48
- package/docs/configuration.md +37 -12
- package/docs/install.md +4 -3
- package/docs/mcp.md +30 -6
- package/docs/output.md +38 -9
- package/docs/stale-context-is-your-bug.md +4 -3
- package/docs/troubleshooting.md +32 -8
- package/docs/vs-code2prompt.md +1 -1
- package/docs/vs-gitingest.md +1 -1
- package/docs/vs-repomix.md +1 -1
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -23,6 +23,178 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
+
## 0.9.16
|
|
27
|
+
|
|
28
|
+
A run refused by the lock it did not get could leave a lock of its own behind — one naming a
|
|
29
|
+
**live** pid, so the refusal outlived the run that caused it. The suite that should have noticed
|
|
30
|
+
was itself leaving scratch directories in the host temp directory: five days of runs had left 616
|
|
31
|
+
of them and about 600 MB. Both are fixed, and the second is why the first stayed hidden.
|
|
32
|
+
|
|
33
|
+
### A refused run kept the lock it took
|
|
34
|
+
|
|
35
|
+
`generate` locks the staging root and the output directory, in sorted order, before staging is
|
|
36
|
+
touched. The acquisitions came from one `map()`, so when the second lock was refused the first was
|
|
37
|
+
still held — and there was no list of releases to run in the `finally`, because the throw happened
|
|
38
|
+
before the assignment. The file left behind named the current process, so `reclaimStaleLock` read
|
|
39
|
+
it as an active run. An MCP server, watch mode, or a `setup` that retries would be refused for the
|
|
40
|
+
rest of that process's life, with no other run in existence.
|
|
41
|
+
|
|
42
|
+
Each acquisition is now recorded, and a failure releases the locks already taken. The regression
|
|
43
|
+
test starts a run that a fresh staging lock must refuse and asserts the output-directory lock is
|
|
44
|
+
gone afterwards.
|
|
45
|
+
|
|
46
|
+
### The test suite stops leaving its scratch directories behind
|
|
47
|
+
|
|
48
|
+
`npm test` created every fixture in the host temp directory and relied on each test to remove it.
|
|
49
|
+
Two tests never did: `agent-simulation.test.js` made two fixtures per run with no cleanup, and one
|
|
50
|
+
`repo()` argument in `generation-truth.test.js` was never assigned, so its directory had no handle
|
|
51
|
+
to remove. A wrapper now runs the suite with `TEMP`, `TMP` and `TMPDIR` pointed at one scratch root
|
|
52
|
+
that is deleted when the run ends, pass or fail, and reports by name anything a test leaves inside
|
|
53
|
+
it. Tests create scratch trees with `makeTempDir(t, prefix)`, which registers the removal with the
|
|
54
|
+
test, and a hygiene suite fails the build if a test creates a directory it never removes, if the
|
|
55
|
+
npm scripts stop using the wrapper, or if the fixture-heavy generation suite leaves anything behind.
|
|
56
|
+
|
|
57
|
+
### Verified
|
|
58
|
+
|
|
59
|
+
`npm run verify` — lint, typecheck, 1032 tests (0 failures, 7 skipped), the docs sync check, the
|
|
60
|
+
site build, the site audit, the readme lint and the tarball check — on the release commit. The same
|
|
61
|
+
gate runs on every pull request and every push to `main`, and the release runs it on Node 18, 20
|
|
62
|
+
and 22; Node 18 caught a portability defect in this release's own new test before it shipped.
|
|
63
|
+
|
|
64
|
+
## 0.9.15
|
|
65
|
+
|
|
66
|
+
A sixth audit, of the promises rather than the code paths the gate already covers. The gate was
|
|
67
|
+
green before this release and is green after it; every defect below lived somewhere the test suite
|
|
68
|
+
did not look. Two put credentials in the artifact, one broke the repeatability guarantee, and one
|
|
69
|
+
made `validate` fail on a snapshot it had just written.
|
|
70
|
+
|
|
71
|
+
### Two credential shapes were left in clear text
|
|
72
|
+
|
|
73
|
+
**A quoted camelCase key in JSON or YAML was never redacted.** `{"dbPassword": "hunter2"}`,
|
|
74
|
+
`"discordToken"`, `"awsSecret"`, `"botToken"`, `"jwtSecret"` and `"sessionKey"` were emitted
|
|
75
|
+
verbatim, while the same names unquoted — and the short names `"password"` and `"apiKey"` — were
|
|
76
|
+
masked. The quoted rule wanted the whole key between quotes; the bare-tail rule was suppressed
|
|
77
|
+
after a quote. Every JSON configuration file has that shape.
|
|
78
|
+
|
|
79
|
+
**A mask could print `[REDACTED]` and keep most of the value.** Unquoted values stopped at `$`,
|
|
80
|
+
`!` and `@`, so `db_password: [REDACTED]$$w0rdSecr3t` shipped twelve characters of a seventeen
|
|
81
|
+
character password while looking redacted. A value that begins with punctuation was not matched at
|
|
82
|
+
all, so `!en$value` went out whole, and one containing `&` was masked as a prefix. A mask now
|
|
83
|
+
covers the whole value or nothing is emitted: a match that cannot be bounded is dropped in source
|
|
84
|
+
code and masked whole in a data file, never half-written.
|
|
85
|
+
|
|
86
|
+
The same pass closed narrower leaks: URL userinfo with an empty user part (`redis://:pass@host`),
|
|
87
|
+
`curl -u user:pass`, short unpadded Basic credentials, and fixed shapes for Discord, Telegram,
|
|
88
|
+
Azure DevOps, Shopify and Azure SAS tokens. The rule count stays 31 — the coverage folded into
|
|
89
|
+
existing rules rather than adding new ones.
|
|
90
|
+
|
|
91
|
+
### The second run could change the preset, and drop a file
|
|
92
|
+
|
|
93
|
+
Preset detection counts markdown to decide whether a repository is `docs`. It excluded the output
|
|
94
|
+
directory only when that directory was literally named `snapshot`. With `--out-dir snap` on a
|
|
95
|
+
repository with no root `package.json`, run one detected `generic` and included `site/page.md`;
|
|
96
|
+
run two counted its own output, detected `docs`, applied that preset's `site/` exclusion, and
|
|
97
|
+
**silently dropped a source file** — with a different fingerprint, and in one variant with the same
|
|
98
|
+
fingerprint and different parts. The walk now skips any directory carrying an ownership marker,
|
|
99
|
+
whatever it is called, which is the same evidence the scanner already uses.
|
|
100
|
+
|
|
101
|
+
### validate failed on a snapshot it had just generated
|
|
102
|
+
|
|
103
|
+
A text file with a binary extension — a Git-LFS pointer is the common case, three lines of plain
|
|
104
|
+
text ending in `.png` — was skipped by `generate` as binary and then reported by `validate` as
|
|
105
|
+
`new file`, exit 1, forever. Regenerating could not clear it, because the two commands asked
|
|
106
|
+
different questions. `validate` now applies `generate`'s decision order exactly, so they agree by
|
|
107
|
+
construction, and `explain` agrees with both: it no longer says `included: true` for a file the
|
|
108
|
+
snapshot skipped, and a skipped path no longer carries layer, kind or language.
|
|
109
|
+
|
|
110
|
+
### A JSON consumer received nothing when the config was broken
|
|
111
|
+
|
|
112
|
+
`--format json` with an unparseable config, an unknown key, an invalid value or a bad preset exited
|
|
113
|
+
1 with **zero bytes on stdout**, contradicting the documented error document and the contract in
|
|
114
|
+
`describe`. Every config failure now goes through the same writer as every other failure.
|
|
115
|
+
|
|
116
|
+
### snapshot://manifest was not JSON on an ordinary repository
|
|
117
|
+
|
|
118
|
+
Above roughly 350 files the resource was cut at 512 kB with a truncation marker injected mid-document,
|
|
119
|
+
advertised as `application/json`. Resource reads are now all-or-nothing: a document that does not
|
|
120
|
+
fit one read fails with `-32000`, its size, the limit and the tool to use instead. The same rule
|
|
121
|
+
covers parts and reports.
|
|
122
|
+
|
|
123
|
+
### Ownership evidence was a shape, not evidence
|
|
124
|
+
|
|
125
|
+
A hand-written `.codebase-snapshot` listing the directory's own files was accepted as proof that
|
|
126
|
+
this tool wrote the directory, and the next `generate` deleted those files. Markers now record the
|
|
127
|
+
sha256 and byte length of every file written, and replacement verifies them. A marker that cannot
|
|
128
|
+
prove a completed run is refused and nothing is deleted. Snapshots written by earlier releases are
|
|
129
|
+
still accepted on their manifest digest, so an upgrade does not strand the output directory a user
|
|
130
|
+
already has.
|
|
131
|
+
|
|
132
|
+
### The rest
|
|
133
|
+
|
|
134
|
+
- **`setup`** honoured neither `--only-artifacts` over a reused config that disabled the artifact,
|
|
135
|
+
nor the config it actually kept: it reported a filename that did not exist and a preset it had not
|
|
136
|
+
applied. `--install-hook` baked `snapshot` as the output directory whatever the config said, and
|
|
137
|
+
`--dry-run --install-hook` wrote the hook anyway.
|
|
138
|
+
- **`--mode explain <path>`** and **`--mode diff <a> <b>`** could not work: the positional arguments
|
|
139
|
+
were parsed as the command word. Both forms now run.
|
|
140
|
+
- **`report`** accepted seven generation flags as silent no-ops while rejecting `--discovery`. It
|
|
141
|
+
rejects all of them now, and `describe` agrees.
|
|
142
|
+
- **A closed pipe** (`generate --format json | head`) was an uncaught `EPIPE` stack trace and exit 1;
|
|
143
|
+
it is now a quiet early exit.
|
|
144
|
+
- **The omission marker** named an internal section allowance (1887 B for a 4096 B part) instead of
|
|
145
|
+
the part budget the manifest and the CLI report.
|
|
146
|
+
- **The docs site** had heading elements with no `id` while carrying 49 anchor links: every table of
|
|
147
|
+
contents on all fifteen published pages was dead. The site generator emits GitHub-compatible ids
|
|
148
|
+
and the link checker now validates fragments, so the gate can see it.
|
|
149
|
+
- **`docs/install.md`** claimed the release check enforces the verified-client list "on every pull
|
|
150
|
+
request". There was no pull-request workflow and no client install test; the claim is gone.
|
|
151
|
+
- **The CLI reference** carried stale rows: `setup` missing from ten options, `report` advertised
|
|
152
|
+
with flags it rejects, `--mode` listing nine command names where there are eleven, "text-mode
|
|
153
|
+
stdout is empty" false for `skill`, and `validate` documented with five drift classes where there
|
|
154
|
+
are six. All corrected against the source.
|
|
155
|
+
- **`docs/configuration.md`**'s "complete example" omitted six settings that `init` writes.
|
|
156
|
+
- **The redaction section of `SECURITY.md`** described the old, narrower behaviour; it now states
|
|
157
|
+
what the rules do, including the shapes that are still not covered.
|
|
158
|
+
- **A pull-request workflow** now runs the same verify gate as a release, on Node 18, 20 and 22.
|
|
159
|
+
Until now that matrix ran only at release time, which is why 0.9.14 needed four publish attempts.
|
|
160
|
+
- **Publishing** asserts that the release tag agrees with `package.json`, ships the LICENSE the
|
|
161
|
+
`create` package declares, and no longer builds `dist` twice for one publish.
|
|
162
|
+
|
|
163
|
+
### Verified
|
|
164
|
+
|
|
165
|
+
`npm run verify` — lint, typecheck, 1027 tests (0 failures), the docs sync check, the site build,
|
|
166
|
+
the site audit, the readme lint and the tarball check — on the release commit. Beyond the suite:
|
|
167
|
+
the published-install path, and real repositories in five languages where every part stays inside
|
|
168
|
+
its budget, repeat runs are byte-identical, `validate` is clean, and a snapshot written by 0.9.14
|
|
169
|
+
is upgraded in place without being refused.
|
|
170
|
+
|
|
171
|
+
An independent red-team pass then ran against the built artifact, trying to reproduce each of the
|
|
172
|
+
seven blockers from the outside. Six were closed outright; the seventh exposed a `.env` value whose
|
|
173
|
+
mask left a punctuation tail, and a quoted `id-token` that was over-redacted. Both were fixed and
|
|
174
|
+
re-tested before this release — which is the argument for a verifier who did not write the fix.
|
|
175
|
+
|
|
176
|
+
### Three limitations became fixes instead
|
|
177
|
+
|
|
178
|
+
The first cut of these notes listed three known limitations. All three are fixed here, because a
|
|
179
|
+
release note that documents a leak is still a leak.
|
|
180
|
+
|
|
181
|
+
- `parsePartSections` reported the wrong count for a one-line file (`null`) and for a section that
|
|
182
|
+
collapsed to one line — `1 line of 3 lines` was read as 3, the source count. The counts are now
|
|
183
|
+
read from the metadata field that holds them, singular or plural, and free-form layer and language
|
|
184
|
+
names can no longer be mistaken for a count.
|
|
185
|
+
- `manifest.fingerprint` covered the input but not the settings, so two runs with different part
|
|
186
|
+
budgets over the same source shared a fingerprint while their parts differed. The settings digest
|
|
187
|
+
is folded in, so the fingerprint identifies the artifact set the documentation promises, and
|
|
188
|
+
`diff` says `packed or configured differently` when only the settings moved.
|
|
189
|
+
- A lowercase `key=value` credential in an INI or properties file was masked only while its value
|
|
190
|
+
fitted the rules' alphabet. In a data or shell file the whole value is masked now, whatever it
|
|
191
|
+
contains; the same line in source code is still left alone.
|
|
192
|
+
|
|
193
|
+
Two deliberate behaviours remain. A YAML value that is really a reference
|
|
194
|
+
(`password: !Ref SomeParam`) is masked, because in a data file the fail-closed choice is the right
|
|
195
|
+
one. And no rule set can promise that every credential shape is recognised — a clean audit is
|
|
196
|
+
evidence that the known patterns did not fire, not a guarantee, which `SECURITY.md` says plainly.
|
|
197
|
+
|
|
26
198
|
## 0.9.14
|
|
27
199
|
|
|
28
200
|
A fifth audit, of what the tool does to text it did not write. Three of the defects below were
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ with a manifest and a validator](https://raw.githubusercontent.com/ankurhalder/c
|
|
|
31
31
|
<p align="center">
|
|
32
32
|
<a href="#install">Install</a> ·
|
|
33
33
|
<a href="#quick-start">Quick start</a> ·
|
|
34
|
-
<a href="#built-to-be-trusted">Trust</a> ·
|
|
34
|
+
<a href="#built-to-be-trusted-with-a-whole-repository">Trust</a> ·
|
|
35
35
|
<a href="#for-ai-agents">AI agents</a> ·
|
|
36
36
|
<a href="#documentation">Docs</a> ·
|
|
37
37
|
<a href="https://ankurhalder.github.io/codebase-snapshot/">Site</a>
|
|
@@ -200,7 +200,7 @@ Everything an agent needs is available as data, and the tool can install its own
|
|
|
200
200
|
```bash
|
|
201
201
|
npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
|
|
202
202
|
npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
|
|
203
|
-
npx -y codebase-snapshot@0.9.
|
|
203
|
+
npx -y codebase-snapshot@0.9.16 mcp # or serve it over MCP
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
|
package/SECURITY.md
CHANGED
|
@@ -40,11 +40,29 @@ secret deliberately split across two string literals, joined with a backslash li
|
|
|
40
40
|
continuation, or assembled by template-literal concatenation can be missed, because the
|
|
41
41
|
pattern never sees the whole value on one line.
|
|
42
42
|
|
|
43
|
-
In YAML and similar `key: value` files, an **unquoted** value
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
In YAML and similar `key: value` files, the file type decides how an **unquoted** value is read.
|
|
44
|
+
A strong credential name in colon form — `password:`, `token:`, `api_key:` — makes the rest of
|
|
45
|
+
the line a value, and in a data or shell file that value is masked whole whatever symbols it
|
|
46
|
+
holds: `password: pa&ss` and `password: getPassword() & 0xff` are masked in a `.yaml`, while the
|
|
47
|
+
same lines in a `.ts` are left as written, because there they are expressions and the tool does
|
|
48
|
+
not edit expressions. In a source file a value that reads like a reference —
|
|
49
|
+
`password: opts.db.password` — is emitted as written; an unquoted value in a declaration is an
|
|
50
|
+
initializer, not a credential.
|
|
51
|
+
|
|
52
|
+
A punctuation-led value is masked when the token also carries a digit or a second punctuation
|
|
53
|
+
character — `token: !hunter2hunter2` is masked, while YAML tags such as `!Ref` and prose words such
|
|
54
|
+
as `!important` stay readable. Quote the value — `password: "…"` — when you need certainty: a
|
|
55
|
+
quoted value under a credential-shaped name is masked whatever it contains.
|
|
56
|
+
|
|
57
|
+
In a data or shell file a **colon-form** assignment is masked whole even when a symbol would make
|
|
58
|
+
the value impossible to bound — it runs to the end of the line (a trailing `#` comment is kept, and
|
|
59
|
+
the match is capped at 300 characters). In source code such a match is dropped instead, so no
|
|
60
|
+
marker is written in front of an expression. The `.env`/shell `NAME=value` rule also masks its
|
|
61
|
+
whole value, comment aside. The `=` form follows the same rule by file type: in a data or shell
|
|
62
|
+
file, a key whose name ends in a credential word — upper or lower case, `password`, `client_secret`,
|
|
63
|
+
`access_key`, `apiKey` — masks the whole value whatever symbols it contains; in source code the
|
|
64
|
+
same line is left alone unless it matches an existing source rule, and a key that merely contains a
|
|
65
|
+
credential word (`tokenCount`, `secretary`) is not a credential.
|
|
48
66
|
|
|
49
67
|
A clean audit is therefore evidence that the known patterns did not fire — not a guarantee
|
|
50
68
|
that the repository holds no credentials.
|
|
@@ -53,6 +71,35 @@ Reports we want to hear about: a pattern that is *not* detected, a redaction tha
|
|
|
53
71
|
secret readable elsewhere (a report file, the manifest, a navigation index), or a way to make
|
|
54
72
|
the tool emit a sensitive file without `--include-sensitive-files`.
|
|
55
73
|
|
|
74
|
+
### Secret scanning of this repository
|
|
75
|
+
|
|
76
|
+
This repository is a *secret-redaction engine*, so it necessarily contains credential-shaped
|
|
77
|
+
strings: the test suites, the rule definitions in `src/security/patterns.ts` and
|
|
78
|
+
`src/security/redact.ts`, and the documentation all carry synthetic samples. They are the vectors
|
|
79
|
+
the engine is meant to detect, they cannot authenticate against any service, and they exist so
|
|
80
|
+
that detection can be proved. They are **not** credentials.
|
|
81
|
+
|
|
82
|
+
Secret scanners are therefore configured to skip those surfaces, instead of asking a human to
|
|
83
|
+
dismiss the same alert on every push:
|
|
84
|
+
|
|
85
|
+
| Surface | Why it is excluded |
|
|
86
|
+
| :--- | :--- |
|
|
87
|
+
| `tests/**` | the fixtures assert that detection fires |
|
|
88
|
+
| `src/security/patterns.ts`, `src/security/redact.ts` | the rule definitions and their worked examples |
|
|
89
|
+
| `**/*.md`, `**/docs/**`, `llms.txt` | documentation explains the shapes by showing them |
|
|
90
|
+
| `package-lock.json` | integrity digests are not credentials |
|
|
91
|
+
|
|
92
|
+
Both scanner configurations carry that list: `.github/secret_scanning.yml` for GitHub's scanner
|
|
93
|
+
and `.gitguardian.yaml` for ggshield, the GitGuardian CLI and CI scanner. The GitGuardian
|
|
94
|
+
*dashboard* does not read either file — its exclusions live in workspace settings
|
|
95
|
+
(**Secrets detection → Filepath exclusions**) and are applied retroactively, so adding them
|
|
96
|
+
there also clears incidents that already exist.
|
|
97
|
+
|
|
98
|
+
Anywhere outside those paths, a real credential is handled normally: it is reported and it must
|
|
99
|
+
be revoked. If you add a fixture outside them, use a placeholder no detector matches, or extend
|
|
100
|
+
the exclusion list deliberately in the same commit — do not weaken detection.
|
|
101
|
+
|
|
102
|
+
|
|
56
103
|
**Filesystem safety.** The output directory is written to a scratch directory and swapped in
|
|
57
104
|
atomically, and it is only replaced when a previous run wrote it. Ownership is proved by the
|
|
58
105
|
`.codebase-snapshot` marker — a JSON object naming this generator, with a schema version, a
|