codebase-snapshot 0.18.0 → 0.20.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/CHANGELOG.md CHANGED
@@ -30,6 +30,63 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
30
30
 
31
31
  ---
32
32
 
33
+ ## 0.20.0
34
+
35
+ **`snapshot update` did not bypass the cache, which is the one thing it promises.**
36
+
37
+ - The command forces a check, but `resolveLatest` let the cache-age branch overwrite the `force`
38
+ decision. While the registry's edge still served the previous document, a cached `0.18.0` made
39
+ `snapshot update` print "the registry publishes 0.18.0" for up to an hour after 0.19.0 was live.
40
+ - `force` now wins: the cache is read only as a **fallback** for a failed request, never as the
41
+ answer, and the age intervals are skipped entirely. A test with an injected cache and fetch pins
42
+ both halves — the forced answer, and the cached fallback when the request fails.
43
+ ## 0.19.0
44
+
45
+ **The audit now agrees with the generator about what a secret is.**
46
+
47
+ - Two false positives made `health` fail a snapshot it had just written: it did not recognise its own
48
+ `[REDACTED: …]` marker as a placeholder, and it scanned each part as one markdown document instead
49
+ of section by section under the source path, so a comment the generator had deliberately left
50
+ (`DB_PASSWORD=envpass!@#$%^&*()` in prose) was read as a credential. A real snapshot of this
51
+ repository scored **70/100** for leaks that did not exist.
52
+ - Fixed: a candidate containing the marker is a placeholder; a finding whose original line carried the
53
+ marker is not reported (masking still runs); marker-only YAML blocks are not counted as masked
54
+ values; and parts are scanned per section under their source paths, while the heading, meta,
55
+ summaries and file list are still scanned as the part — removing bodies from a copy keeps that
56
+ coverage instead of trading a false positive for a blind spot.
57
+
58
+ The same snapshot regenerated: **95/100, 14 passed, 0 failed, 1 warning** — the warning is
59
+ `pii.paths` finding `/Users/name` and `C:\Users\name` in documentation examples, which are genuinely
60
+ in the text. Tests cover the marker shapes, a real secret in the same shapes, and a health run over a
61
+ snapshot that quotes the marker.
62
+ ## 0.18.2
63
+
64
+ **The audit failed a snapshot for containing the redaction marker.**
65
+
66
+ - Reviewing a real 0.18.0 snapshot of this repository: 343 files, 13 parts, 1.1M tokens, no
67
+ incomplete files — structurally clean, but `health` scored **70/100** with one critical failure:
68
+ "7 artifact(s) contain a secret-shaped value".
69
+ - Every one of those hits was the marker itself: `token: [REDACTED: potential secret-like value
70
+ omitted from snapshot]`. The scanner did not recognise its own output, so a second pass over an
71
+ emitted artifact re-found lines the generator had already redacted. The audit also scanned each
72
+ part as a whole under `parts/part-007.md`, losing the source path — the generator had deliberately
73
+ left `DB_PASSWORD=envpass!@#$%^&*()` in a comment, because an unquoted value in a source file is an
74
+ expression, but the same text inside a part was read as markdown and flagged.
75
+ - Three fixes: a candidate that already contains the marker is a placeholder; a finding whose original
76
+ line carried the marker is not reported (the mask still runs, so a credential added after the marker
77
+ is still removed); and the artifact scan is per section, under the section's own path, so the
78
+ path-aware rules see what the generator saw. Marker-only YAML blocks no longer count as masked
79
+ values either.
80
+
81
+ The same snapshot regenerated: **95/100, 14 passed, 0 failed, 1 warning** — the warning is the
82
+ host-path check finding `/Users/name` and `C:\Users\name` in the documentation examples, which are
83
+ genuinely in the text. Tests: the marker shapes produce no finding, a real secret in the same shapes
84
+ still does, and a health run over a snapshot that quotes the marker exits 0.
85
+ ## 0.18.1
86
+
87
+ - `PUBLISHED` moves to 0.18.0, so every `npx codebase-snapshot@…` example in the docs now pins the
88
+ milestone that is actually on the registry (`publish-train` run 44312176554: `+
89
+ codebase-snapshot@0.18.0`, provenance published).
33
90
  ## 0.18.0
34
91
 
35
92
  **"A newer version is available" now has a command, and stops hiding after one failure.**
package/README.md CHANGED
@@ -211,7 +211,7 @@ Everything an agent needs is available as data, and the tool can install its own
211
211
  ```bash
212
212
  npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
213
213
  npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
214
- npx -y codebase-snapshot@0.17.0 mcp # or serve it over MCP
214
+ npx -y codebase-snapshot@0.20.0 mcp # or serve it over MCP
215
215
  ```
216
216
 
217
217
  An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
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.18<!--/@majorMinor-->.x | ✅ |
9
+ | <!--@majorMinor-->0.20<!--/@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.18<!--/@majorMinor-->.x is newer than 4.4.1, not older. That is explained in full in the
13
+ so <!--@majorMinor-->0.20<!--/@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
package/dist/bin.js CHANGED
@@ -1873,7 +1873,11 @@ function scanAndRedactSecrets(content, rules, filePath) {
1873
1873
  let finalText = segments.join("");
1874
1874
  finalText = redactStructuredValues(finalText, filePath, recordFinding);
1875
1875
  finalText = redactDockerfileEnv(finalText, filePath, recordFinding);
1876
- const findings = [...findingsByLine.entries()].sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
1876
+ const originalLines = content.split(/\r\n|\r|\n/);
1877
+ const findings = [...findingsByLine.entries()].filter(([line]) => {
1878
+ const original = originalLines[line - 1] ?? "";
1879
+ return !original.includes(REDACTION_MARKER) && !original.includes(PEM_REDACTION_MARKER);
1880
+ }).sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
1877
1881
  rules: [...rulesForLine],
1878
1882
  line,
1879
1883
  path: filePath
@@ -1941,8 +1945,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
1941
1945
  if (body.trim() !== "") {
1942
1946
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
1943
1947
  if (indent <= baseIndent) break;
1948
+ if (!isMarkerLine(body)) masked2 = true;
1944
1949
  segments[cursor2] = maskLineContent(body);
1945
- masked2 = true;
1946
1950
  }
1947
1951
  cursor2 += 2;
1948
1952
  }
@@ -1962,8 +1966,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
1962
1966
  if (body.trim() !== "") {
1963
1967
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
1964
1968
  if (indent < valueIndent) break;
1969
+ if (!isMarkerLine(body)) masked = true;
1965
1970
  segments[cursor] = maskValueLine(body);
1966
- masked = true;
1967
1971
  }
1968
1972
  cursor += 2;
1969
1973
  }
@@ -2073,10 +2077,14 @@ var PLACEHOLDER_PATTERNS = [
2073
2077
  /^your[-_ ].*$/i,
2074
2078
  /^(?:example|sample)(?:[-_ ].*)?$/i
2075
2079
  ];
2080
+ function isMarkerLine(value) {
2081
+ return value.includes(REDACTION_MARKER) || value.includes(PEM_REDACTION_MARKER);
2082
+ }
2076
2083
  function isPlaceholderValue(value) {
2077
2084
  const trimmed = value.trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "");
2078
2085
  if (trimmed.length === 0) return false;
2079
2086
  if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) return true;
2087
+ if (trimmed.includes(REDACTION_MARKER) || trimmed.includes(PEM_REDACTION_MARKER)) return true;
2080
2088
  return trimmed.includes("...") || /^<[^>]*$/.test(trimmed);
2081
2089
  }
2082
2090
  function quotesAreBalanced(text2) {
@@ -2191,7 +2199,7 @@ function applySpansKeepingQuotes(line, spans) {
2191
2199
 
2192
2200
  // src/version.ts
2193
2201
  var GENERATOR_NAME = "codebase-snapshot";
2194
- var GENERATOR_VERSION = "0.18.0";
2202
+ var GENERATOR_VERSION = "0.20.0";
2195
2203
  var SCHEMA_VERSION = "3.0.0";
2196
2204
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2197
2205
  function isOurGeneratorName(name) {
@@ -12559,9 +12567,19 @@ function auditSnapshot(options) {
12559
12567
  const text2 = readText2(path16.join(snapshotDir, relative15));
12560
12568
  if (text2 === null) continue;
12561
12569
  scannedBytes += Buffer.byteLength(text2, "utf8");
12562
- const found = scanAndRedactSecrets(text2, rules, relative15);
12563
- if (found.findings.length > 0) {
12564
- leakHits.push(relative15 + " (" + found.findings.length + " line(s))");
12570
+ let findingCount = 0;
12571
+ if (/^parts[\\/].*\.md$/i.test(relative15)) {
12572
+ let headerText = text2;
12573
+ for (const section of parsePartSections(text2)) {
12574
+ findingCount += scanAndRedactSecrets(section.body, rules, section.path).findings.length;
12575
+ headerText = headerText.replace(section.body, "");
12576
+ }
12577
+ findingCount += scanAndRedactSecrets(headerText, rules, relative15).findings.length;
12578
+ } else {
12579
+ findingCount = scanAndRedactSecrets(text2, rules, relative15).findings.length;
12580
+ }
12581
+ if (findingCount > 0) {
12582
+ leakHits.push(relative15 + " (" + findingCount + " line(s))");
12565
12583
  }
12566
12584
  }
12567
12585
  const signatureRecordPath = path16.join(snapshotDir, SIGNATURE_FILE);
@@ -18512,7 +18530,8 @@ async function resolveLatest(options) {
18512
18530
  try {
18513
18531
  const cached = readCache(options.cacheFile);
18514
18532
  let needsFetch = cached === null || options.force === true;
18515
- if (cached) {
18533
+ if (cached) latest = cached.latest;
18534
+ if (cached && options.force !== true) {
18516
18535
  const age = now() - cached.checkedAt;
18517
18536
  if (cached.latest === null) {
18518
18537
  needsFetch = age >= FAILURE_INTERVAL_MS;
@@ -1,4 +1,4 @@
1
- import { createServer, buildTools, GENERATOR_VERSION } from './chunk-VMRKUSXL.js';
1
+ import { createServer, buildTools, GENERATOR_VERSION } from './chunk-S27VYVC4.js';
2
2
  import * as http from 'http';
3
3
  import * as crypto from 'crypto';
4
4
 
@@ -3676,7 +3676,11 @@ function scanAndRedactSecrets(content, rules, filePath) {
3676
3676
  let finalText = segments.join("");
3677
3677
  finalText = redactStructuredValues(finalText, filePath, recordFinding);
3678
3678
  finalText = redactDockerfileEnv(finalText, filePath, recordFinding);
3679
- const findings = [...findingsByLine.entries()].sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
3679
+ const originalLines = content.split(/\r\n|\r|\n/);
3680
+ const findings = [...findingsByLine.entries()].filter(([line]) => {
3681
+ const original = originalLines[line - 1] ?? "";
3682
+ return !original.includes(REDACTION_MARKER) && !original.includes(PEM_REDACTION_MARKER);
3683
+ }).sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
3680
3684
  rules: [...rulesForLine],
3681
3685
  line,
3682
3686
  path: filePath
@@ -3744,8 +3748,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3744
3748
  if (body.trim() !== "") {
3745
3749
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
3746
3750
  if (indent <= baseIndent) break;
3751
+ if (!isMarkerLine(body)) masked2 = true;
3747
3752
  segments[cursor2] = maskLineContent(body);
3748
- masked2 = true;
3749
3753
  }
3750
3754
  cursor2 += 2;
3751
3755
  }
@@ -3765,8 +3769,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3765
3769
  if (body.trim() !== "") {
3766
3770
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
3767
3771
  if (indent < valueIndent) break;
3772
+ if (!isMarkerLine(body)) masked = true;
3768
3773
  segments[cursor] = maskValueLine(body);
3769
- masked = true;
3770
3774
  }
3771
3775
  cursor += 2;
3772
3776
  }
@@ -3876,10 +3880,14 @@ var PLACEHOLDER_PATTERNS = [
3876
3880
  /^your[-_ ].*$/i,
3877
3881
  /^(?:example|sample)(?:[-_ ].*)?$/i
3878
3882
  ];
3883
+ function isMarkerLine(value) {
3884
+ return value.includes(REDACTION_MARKER) || value.includes(PEM_REDACTION_MARKER);
3885
+ }
3879
3886
  function isPlaceholderValue(value) {
3880
3887
  const trimmed = value.trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "");
3881
3888
  if (trimmed.length === 0) return false;
3882
3889
  if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) return true;
3890
+ if (trimmed.includes(REDACTION_MARKER) || trimmed.includes(PEM_REDACTION_MARKER)) return true;
3883
3891
  return trimmed.includes("...") || /^<[^>]*$/.test(trimmed);
3884
3892
  }
3885
3893
  function quotesAreBalanced(text2) {
@@ -3994,7 +4002,7 @@ function applySpansKeepingQuotes(line, spans) {
3994
4002
 
3995
4003
  // src/version.ts
3996
4004
  var GENERATOR_NAME = "codebase-snapshot";
3997
- var GENERATOR_VERSION = "0.18.0";
4005
+ var GENERATOR_VERSION = "0.20.0";
3998
4006
  var SCHEMA_VERSION = "3.0.0";
3999
4007
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
4000
4008
  function isOurGeneratorName(name) {
@@ -10722,9 +10730,19 @@ function auditSnapshot(options) {
10722
10730
  const text2 = readText2(path25.join(snapshotDir, relative13));
10723
10731
  if (text2 === null) continue;
10724
10732
  scannedBytes += Buffer.byteLength(text2, "utf8");
10725
- const found = scanAndRedactSecrets(text2, rules, relative13);
10726
- if (found.findings.length > 0) {
10727
- leakHits.push(relative13 + " (" + found.findings.length + " line(s))");
10733
+ let findingCount = 0;
10734
+ if (/^parts[\\/].*\.md$/i.test(relative13)) {
10735
+ let headerText = text2;
10736
+ for (const section of parsePartSections(text2)) {
10737
+ findingCount += scanAndRedactSecrets(section.body, rules, section.path).findings.length;
10738
+ headerText = headerText.replace(section.body, "");
10739
+ }
10740
+ findingCount += scanAndRedactSecrets(headerText, rules, relative13).findings.length;
10741
+ } else {
10742
+ findingCount = scanAndRedactSecrets(text2, rules, relative13).findings.length;
10743
+ }
10744
+ if (findingCount > 0) {
10745
+ leakHits.push(relative13 + " (" + findingCount + " line(s))");
10728
10746
  }
10729
10747
  }
10730
10748
  const signatureRecordPath = path25.join(snapshotDir, SIGNATURE_FILE);
@@ -16888,7 +16906,8 @@ async function resolveLatest(options) {
16888
16906
  try {
16889
16907
  const cached = readCache(options.cacheFile);
16890
16908
  let needsFetch = cached === null || options.force === true;
16891
- if (cached) {
16909
+ if (cached) latest = cached.latest;
16910
+ if (cached && options.force !== true) {
16892
16911
  const age = now() - cached.checkedAt;
16893
16912
  if (cached.latest === null) {
16894
16913
  needsFetch = age >= FAILURE_INTERVAL_MS;
package/dist/cli.cjs CHANGED
@@ -1903,7 +1903,11 @@ function scanAndRedactSecrets(content, rules, filePath) {
1903
1903
  let finalText = segments.join("");
1904
1904
  finalText = redactStructuredValues(finalText, filePath, recordFinding);
1905
1905
  finalText = redactDockerfileEnv(finalText, filePath, recordFinding);
1906
- const findings = [...findingsByLine.entries()].sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
1906
+ const originalLines = content.split(/\r\n|\r|\n/);
1907
+ const findings = [...findingsByLine.entries()].filter(([line]) => {
1908
+ const original = originalLines[line - 1] ?? "";
1909
+ return !original.includes(REDACTION_MARKER) && !original.includes(PEM_REDACTION_MARKER);
1910
+ }).sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
1907
1911
  rules: [...rulesForLine],
1908
1912
  line,
1909
1913
  path: filePath
@@ -1971,8 +1975,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
1971
1975
  if (body.trim() !== "") {
1972
1976
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
1973
1977
  if (indent <= baseIndent) break;
1978
+ if (!isMarkerLine(body)) masked2 = true;
1974
1979
  segments[cursor2] = maskLineContent(body);
1975
- masked2 = true;
1976
1980
  }
1977
1981
  cursor2 += 2;
1978
1982
  }
@@ -1992,8 +1996,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
1992
1996
  if (body.trim() !== "") {
1993
1997
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
1994
1998
  if (indent < valueIndent) break;
1999
+ if (!isMarkerLine(body)) masked = true;
1995
2000
  segments[cursor] = maskValueLine(body);
1996
- masked = true;
1997
2001
  }
1998
2002
  cursor += 2;
1999
2003
  }
@@ -2103,10 +2107,14 @@ var PLACEHOLDER_PATTERNS = [
2103
2107
  /^your[-_ ].*$/i,
2104
2108
  /^(?:example|sample)(?:[-_ ].*)?$/i
2105
2109
  ];
2110
+ function isMarkerLine(value) {
2111
+ return value.includes(REDACTION_MARKER) || value.includes(PEM_REDACTION_MARKER);
2112
+ }
2106
2113
  function isPlaceholderValue(value) {
2107
2114
  const trimmed = value.trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "");
2108
2115
  if (trimmed.length === 0) return false;
2109
2116
  if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) return true;
2117
+ if (trimmed.includes(REDACTION_MARKER) || trimmed.includes(PEM_REDACTION_MARKER)) return true;
2110
2118
  return trimmed.includes("...") || /^<[^>]*$/.test(trimmed);
2111
2119
  }
2112
2120
  function quotesAreBalanced(text2) {
@@ -2221,7 +2229,7 @@ function applySpansKeepingQuotes(line, spans) {
2221
2229
 
2222
2230
  // src/version.ts
2223
2231
  var GENERATOR_NAME = "codebase-snapshot";
2224
- var GENERATOR_VERSION = "0.18.0";
2232
+ var GENERATOR_VERSION = "0.20.0";
2225
2233
  var SCHEMA_VERSION = "3.0.0";
2226
2234
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2227
2235
  function isOurGeneratorName(name) {
@@ -12458,9 +12466,19 @@ function auditSnapshot(options) {
12458
12466
  const text2 = readText2(path27__namespace.join(snapshotDir, relative15));
12459
12467
  if (text2 === null) continue;
12460
12468
  scannedBytes += Buffer.byteLength(text2, "utf8");
12461
- const found = scanAndRedactSecrets(text2, rules, relative15);
12462
- if (found.findings.length > 0) {
12463
- leakHits.push(relative15 + " (" + found.findings.length + " line(s))");
12469
+ let findingCount = 0;
12470
+ if (/^parts[\\/].*\.md$/i.test(relative15)) {
12471
+ let headerText = text2;
12472
+ for (const section of parsePartSections(text2)) {
12473
+ findingCount += scanAndRedactSecrets(section.body, rules, section.path).findings.length;
12474
+ headerText = headerText.replace(section.body, "");
12475
+ }
12476
+ findingCount += scanAndRedactSecrets(headerText, rules, relative15).findings.length;
12477
+ } else {
12478
+ findingCount = scanAndRedactSecrets(text2, rules, relative15).findings.length;
12479
+ }
12480
+ if (findingCount > 0) {
12481
+ leakHits.push(relative15 + " (" + findingCount + " line(s))");
12464
12482
  }
12465
12483
  }
12466
12484
  const signatureRecordPath = path27__namespace.join(snapshotDir, SIGNATURE_FILE);
@@ -18386,7 +18404,8 @@ async function resolveLatest(options) {
18386
18404
  try {
18387
18405
  const cached = readCache(options.cacheFile);
18388
18406
  let needsFetch = cached === null || options.force === true;
18389
- if (cached) {
18407
+ if (cached) latest = cached.latest;
18408
+ if (cached && options.force !== true) {
18390
18409
  const age = now() - cached.checkedAt;
18391
18410
  if (cached.latest === null) {
18392
18411
  needsFetch = age >= FAILURE_INTERVAL_MS;
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import { startHttpTransport } from './chunk-IZPCJYZU.js';
2
- import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, buildAgentContract, startWebServer, runStdioServer, parseRemoteSource, assertPublicHost, cloneRepository, makeCloneDirectory, loadConfigFileDetailed, resolveConfig, validateSnapshot, auditSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, getGitInfo, signManifest, loadSigningKey, writeSignature, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, COMMAND_OPTION_SCOPE, commandsForOption, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, SKILL_NAME, renderSkill, resolveLatest, isNewer, updateCommand, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, escapeControls, runWithStdoutCapture, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderContractText, renderExplainText } from './chunk-VMRKUSXL.js';
3
- export { buildAgentContract } from './chunk-VMRKUSXL.js';
1
+ import { startHttpTransport } from './chunk-JCGCY6R3.js';
2
+ import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, buildAgentContract, startWebServer, runStdioServer, parseRemoteSource, assertPublicHost, cloneRepository, makeCloneDirectory, loadConfigFileDetailed, resolveConfig, validateSnapshot, auditSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, getGitInfo, signManifest, loadSigningKey, writeSignature, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, COMMAND_OPTION_SCOPE, commandsForOption, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, SKILL_NAME, renderSkill, resolveLatest, isNewer, updateCommand, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, escapeControls, runWithStdoutCapture, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderContractText, renderExplainText } from './chunk-S27VYVC4.js';
3
+ export { buildAgentContract } from './chunk-S27VYVC4.js';
4
4
  import { spawnSync } from 'child_process';
5
5
  import * as fs2 from 'fs';
6
6
  import * as path2 from 'path';
package/dist/index.cjs CHANGED
@@ -3694,7 +3694,11 @@ function scanAndRedactSecrets(content, rules, filePath) {
3694
3694
  let finalText = segments.join("");
3695
3695
  finalText = redactStructuredValues(finalText, filePath, recordFinding);
3696
3696
  finalText = redactDockerfileEnv(finalText, filePath, recordFinding);
3697
- const findings = [...findingsByLine.entries()].sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
3697
+ const originalLines = content.split(/\r\n|\r|\n/);
3698
+ const findings = [...findingsByLine.entries()].filter(([line]) => {
3699
+ const original = originalLines[line - 1] ?? "";
3700
+ return !original.includes(REDACTION_MARKER) && !original.includes(PEM_REDACTION_MARKER);
3701
+ }).sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
3698
3702
  rules: [...rulesForLine],
3699
3703
  line,
3700
3704
  path: filePath
@@ -3762,8 +3766,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3762
3766
  if (body.trim() !== "") {
3763
3767
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
3764
3768
  if (indent <= baseIndent) break;
3769
+ if (!isMarkerLine(body)) masked2 = true;
3765
3770
  segments[cursor2] = maskLineContent(body);
3766
- masked2 = true;
3767
3771
  }
3768
3772
  cursor2 += 2;
3769
3773
  }
@@ -3783,8 +3787,8 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3783
3787
  if (body.trim() !== "") {
3784
3788
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
3785
3789
  if (indent < valueIndent) break;
3790
+ if (!isMarkerLine(body)) masked = true;
3786
3791
  segments[cursor] = maskValueLine(body);
3787
- masked = true;
3788
3792
  }
3789
3793
  cursor += 2;
3790
3794
  }
@@ -3894,10 +3898,14 @@ var PLACEHOLDER_PATTERNS = [
3894
3898
  /^your[-_ ].*$/i,
3895
3899
  /^(?:example|sample)(?:[-_ ].*)?$/i
3896
3900
  ];
3901
+ function isMarkerLine(value) {
3902
+ return value.includes(REDACTION_MARKER) || value.includes(PEM_REDACTION_MARKER);
3903
+ }
3897
3904
  function isPlaceholderValue(value) {
3898
3905
  const trimmed = value.trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "");
3899
3906
  if (trimmed.length === 0) return false;
3900
3907
  if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) return true;
3908
+ if (trimmed.includes(REDACTION_MARKER) || trimmed.includes(PEM_REDACTION_MARKER)) return true;
3901
3909
  return trimmed.includes("...") || /^<[^>]*$/.test(trimmed);
3902
3910
  }
3903
3911
  function quotesAreBalanced(text2) {
@@ -4012,7 +4020,7 @@ function applySpansKeepingQuotes(line, spans) {
4012
4020
 
4013
4021
  // src/version.ts
4014
4022
  var GENERATOR_NAME = "codebase-snapshot";
4015
- var GENERATOR_VERSION = "0.18.0";
4023
+ var GENERATOR_VERSION = "0.20.0";
4016
4024
  var SCHEMA_VERSION = "3.0.0";
4017
4025
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
4018
4026
  function isOurGeneratorName(name) {
@@ -10678,9 +10686,19 @@ function auditSnapshot(options) {
10678
10686
  const text2 = readText2(path25__namespace.join(snapshotDir, relative13));
10679
10687
  if (text2 === null) continue;
10680
10688
  scannedBytes += Buffer.byteLength(text2, "utf8");
10681
- const found = scanAndRedactSecrets(text2, rules, relative13);
10682
- if (found.findings.length > 0) {
10683
- leakHits.push(relative13 + " (" + found.findings.length + " line(s))");
10689
+ let findingCount = 0;
10690
+ if (/^parts[\\/].*\.md$/i.test(relative13)) {
10691
+ let headerText = text2;
10692
+ for (const section of parsePartSections(text2)) {
10693
+ findingCount += scanAndRedactSecrets(section.body, rules, section.path).findings.length;
10694
+ headerText = headerText.replace(section.body, "");
10695
+ }
10696
+ findingCount += scanAndRedactSecrets(headerText, rules, relative13).findings.length;
10697
+ } else {
10698
+ findingCount = scanAndRedactSecrets(text2, rules, relative13).findings.length;
10699
+ }
10700
+ if (findingCount > 0) {
10701
+ leakHits.push(relative13 + " (" + findingCount + " line(s))");
10684
10702
  }
10685
10703
  }
10686
10704
  const signatureRecordPath = path25__namespace.join(snapshotDir, SIGNATURE_FILE);
@@ -16586,7 +16604,8 @@ async function resolveLatest(options) {
16586
16604
  try {
16587
16605
  const cached = readCache(options.cacheFile);
16588
16606
  let needsFetch = cached === null || options.force === true;
16589
- if (cached) {
16607
+ if (cached) latest = cached.latest;
16608
+ if (cached && options.force !== true) {
16590
16609
  const age = now() - cached.checkedAt;
16591
16610
  if (cached.latest === null) {
16592
16611
  needsFetch = age >= FAILURE_INTERVAL_MS;
@@ -20687,6 +20706,7 @@ exports.renderExplainText = renderExplainText;
20687
20706
  exports.renumberParts = renumberParts;
20688
20707
  exports.resolveChangedScope = resolveChangedScope;
20689
20708
  exports.resolveConfig = resolveConfig;
20709
+ exports.resolveLatest = resolveLatest;
20690
20710
  exports.resolveSafeOutputDirs = resolveSafeOutputDirs;
20691
20711
  exports.resolveSpecifier = resolveSpecifier;
20692
20712
  exports.runInit = runInit;
package/dist/index.d.cts CHANGED
@@ -554,7 +554,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
554
554
  * `package.json` carries the same version; `npm run verify` compares the two.
555
555
  */
556
556
  declare const GENERATOR_NAME = "codebase-snapshot";
557
- declare const GENERATOR_VERSION = "0.18.0";
557
+ declare const GENERATOR_VERSION = "0.20.0";
558
558
  /**
559
559
  * The manifest and ownership-marker schema this build writes and understands.
560
560
  *
@@ -790,6 +790,14 @@ declare function fetchLatestVersion(url?: string, timeoutMs?: number): Promise<s
790
790
  * Never throws: the caller runs this alongside a real command and must not be affected by it.
791
791
  */
792
792
  declare function checkForUpdate(options: UpdateCheckOptions): Promise<UpdateNotice | null>;
793
+ /**
794
+ * The published version, from the cache when it is fresh or the registry when it is not.
795
+ *
796
+ * `checkForUpdate` only answers "is there a newer one"; `snapshot update` has to print the
797
+ * version it compared against even when the answer is no, so the cache and fetch rules live here
798
+ * once and both callers share them.
799
+ */
800
+ declare function resolveLatest(options: UpdateCheckOptions): Promise<string | null>;
793
801
  /** The two lines a user sees, or an empty string when there is nothing to say. */
794
802
  declare function formatUpdateNotice(notice: UpdateNotice, kind: InstallKind): string;
795
803
 
@@ -1520,4 +1528,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
1520
1528
  /** Promise-returning wrapper for consumers that prefer an async call site. */
1521
1529
  declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
1522
1530
 
1523
- export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, type CloneOptions, type CloneResult, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, type ParsedSource, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, type RemoteSource, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, type ServeHandle, type ServeOptions, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, type ZipEntry, type ZipOptions, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, wrapLines, writeZip };
1531
+ export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, type CloneOptions, type CloneResult, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, type ParsedSource, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, type RemoteSource, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, type ServeHandle, type ServeOptions, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, type ZipEntry, type ZipOptions, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveLatest, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, wrapLines, writeZip };
package/dist/index.d.ts CHANGED
@@ -554,7 +554,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
554
554
  * `package.json` carries the same version; `npm run verify` compares the two.
555
555
  */
556
556
  declare const GENERATOR_NAME = "codebase-snapshot";
557
- declare const GENERATOR_VERSION = "0.18.0";
557
+ declare const GENERATOR_VERSION = "0.20.0";
558
558
  /**
559
559
  * The manifest and ownership-marker schema this build writes and understands.
560
560
  *
@@ -790,6 +790,14 @@ declare function fetchLatestVersion(url?: string, timeoutMs?: number): Promise<s
790
790
  * Never throws: the caller runs this alongside a real command and must not be affected by it.
791
791
  */
792
792
  declare function checkForUpdate(options: UpdateCheckOptions): Promise<UpdateNotice | null>;
793
+ /**
794
+ * The published version, from the cache when it is fresh or the registry when it is not.
795
+ *
796
+ * `checkForUpdate` only answers "is there a newer one"; `snapshot update` has to print the
797
+ * version it compared against even when the answer is no, so the cache and fetch rules live here
798
+ * once and both callers share them.
799
+ */
800
+ declare function resolveLatest(options: UpdateCheckOptions): Promise<string | null>;
793
801
  /** The two lines a user sees, or an empty string when there is nothing to say. */
794
802
  declare function formatUpdateNotice(notice: UpdateNotice, kind: InstallKind): string;
795
803
 
@@ -1520,4 +1528,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
1520
1528
  /** Promise-returning wrapper for consumers that prefer an async call site. */
1521
1529
  declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
1522
1530
 
1523
- export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, type CloneOptions, type CloneResult, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, type ParsedSource, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, type RemoteSource, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, type ServeHandle, type ServeOptions, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, type ZipEntry, type ZipOptions, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, wrapLines, writeZip };
1531
+ export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, type CloneOptions, type CloneResult, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, type ParsedSource, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, type RemoteSource, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, type ServeHandle, type ServeOptions, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, type ZipEntry, type ZipOptions, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveLatest, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, wrapLines, writeZip };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, workerEntry, wrapLines, writeZip } from './chunk-VMRKUSXL.js';
1
+ export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveLatest, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, workerEntry, wrapLines, writeZip } from './chunk-S27VYVC4.js';
package/dist/mcp.cjs CHANGED
@@ -2230,7 +2230,11 @@ function scanAndRedactSecrets(content, rules, filePath) {
2230
2230
  let finalText = segments.join("");
2231
2231
  finalText = redactStructuredValues(finalText, filePath, recordFinding);
2232
2232
  finalText = redactDockerfileEnv(finalText, filePath, recordFinding);
2233
- const findings = [...findingsByLine.entries()].sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
2233
+ const originalLines = content.split(/\r\n|\r|\n/);
2234
+ const findings = [...findingsByLine.entries()].filter(([line]) => {
2235
+ const original = originalLines[line - 1] ?? "";
2236
+ return !original.includes(REDACTION_MARKER) && !original.includes(PEM_REDACTION_MARKER);
2237
+ }).sort(([left], [right]) => left - right).map(([line, rulesForLine]) => ({
2234
2238
  rules: [...rulesForLine],
2235
2239
  line,
2236
2240
  path: filePath
@@ -2298,8 +2302,8 @@ function redactStructuredValues(text, filePath, recordFinding) {
2298
2302
  if (body.trim() !== "") {
2299
2303
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
2300
2304
  if (indent <= baseIndent) break;
2305
+ if (!isMarkerLine(body)) masked2 = true;
2301
2306
  segments[cursor2] = maskLineContent(body);
2302
- masked2 = true;
2303
2307
  }
2304
2308
  cursor2 += 2;
2305
2309
  }
@@ -2319,8 +2323,8 @@ function redactStructuredValues(text, filePath, recordFinding) {
2319
2323
  if (body.trim() !== "") {
2320
2324
  const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
2321
2325
  if (indent < valueIndent) break;
2326
+ if (!isMarkerLine(body)) masked = true;
2322
2327
  segments[cursor] = maskValueLine(body);
2323
- masked = true;
2324
2328
  }
2325
2329
  cursor += 2;
2326
2330
  }
@@ -2430,10 +2434,14 @@ var PLACEHOLDER_PATTERNS = [
2430
2434
  /^your[-_ ].*$/i,
2431
2435
  /^(?:example|sample)(?:[-_ ].*)?$/i
2432
2436
  ];
2437
+ function isMarkerLine(value) {
2438
+ return value.includes(REDACTION_MARKER) || value.includes(PEM_REDACTION_MARKER);
2439
+ }
2433
2440
  function isPlaceholderValue(value) {
2434
2441
  const trimmed = value.trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "");
2435
2442
  if (trimmed.length === 0) return false;
2436
2443
  if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) return true;
2444
+ if (trimmed.includes(REDACTION_MARKER) || trimmed.includes(PEM_REDACTION_MARKER)) return true;
2437
2445
  return trimmed.includes("...") || /^<[^>]*$/.test(trimmed);
2438
2446
  }
2439
2447
  function quotesAreBalanced(text) {
@@ -2548,7 +2556,7 @@ function applySpansKeepingQuotes(line, spans) {
2548
2556
 
2549
2557
  // src/version.ts
2550
2558
  var GENERATOR_NAME = "codebase-snapshot";
2551
- var GENERATOR_VERSION = "0.18.0";
2559
+ var GENERATOR_VERSION = "0.20.0";
2552
2560
  var SCHEMA_VERSION = "3.0.0";
2553
2561
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2554
2562
  function isOurGeneratorName(name) {
@@ -8709,9 +8717,19 @@ function auditSnapshot(options) {
8709
8717
  const text = readText(path5__namespace.join(snapshotDir, relative9));
8710
8718
  if (text === null) continue;
8711
8719
  scannedBytes += Buffer.byteLength(text, "utf8");
8712
- const found = scanAndRedactSecrets(text, rules, relative9);
8713
- if (found.findings.length > 0) {
8714
- leakHits.push(relative9 + " (" + found.findings.length + " line(s))");
8720
+ let findingCount = 0;
8721
+ if (/^parts[\\/].*\.md$/i.test(relative9)) {
8722
+ let headerText = text;
8723
+ for (const section of parsePartSections(text)) {
8724
+ findingCount += scanAndRedactSecrets(section.body, rules, section.path).findings.length;
8725
+ headerText = headerText.replace(section.body, "");
8726
+ }
8727
+ findingCount += scanAndRedactSecrets(headerText, rules, relative9).findings.length;
8728
+ } else {
8729
+ findingCount = scanAndRedactSecrets(text, rules, relative9).findings.length;
8730
+ }
8731
+ if (findingCount > 0) {
8732
+ leakHits.push(relative9 + " (" + findingCount + " line(s))");
8715
8733
  }
8716
8734
  }
8717
8735
  const signatureRecordPath = path5__namespace.join(snapshotDir, SIGNATURE_FILE);
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
- export { generateToken, startHttpTransport } from './chunk-IZPCJYZU.js';
2
- export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-VMRKUSXL.js';
1
+ export { generateToken, startHttpTransport } from './chunk-JCGCY6R3.js';
2
+ export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, stripComments, validateArguments, windowText } from './chunk-S27VYVC4.js';
package/docs/cli.md CHANGED
@@ -98,7 +98,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
98
98
 
99
99
  ```
100
100
  📸 Generating snapshot for: /path/to/repo
101
- Branch: main (fallback) | Part budget: 300 KB | Generator: 0.18.0 (project dependency ^0.18.0)
101
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.0 (project dependency ^0.20.0)
102
102
 
103
103
  ✅ Snapshot generated in 0.14s:
104
104
  - 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
@@ -219,7 +219,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
219
219
  🚀 Setup for: /path/to/repo
220
220
  ✅ Created snapshot.config.ts (preset: nextjs)
221
221
  Added npm scripts: snapshot, snapshot:validate
222
- Added devDependency: codebase-snapshot ^0.18.0
222
+ Added devDependency: codebase-snapshot ^0.20.0
223
223
  Added to .gitignore: /snapshot/, /snapshot.tmp/
224
224
  ⏳ Installing dependencies…
225
225
  ✅ Installed dependencies (npm install, 2.1s)
@@ -271,7 +271,7 @@ It also has three side effects on files you own, and it says so when it does the
271
271
  ```
272
272
  ✅ Created snapshot.config.ts (preset: node-lib)
273
273
  Added npm scripts: snapshot, snapshot:validate
274
- Added devDependency: codebase-snapshot ^0.18.0
274
+ Added devDependency: codebase-snapshot ^0.20.0
275
275
  Added to .gitignore: /snapshot/, /snapshot.tmp/
276
276
  ```
277
277
 
@@ -421,8 +421,8 @@ agent](agent.md).
421
421
  Ask the npm registry whether a newer release exists, and print the version it compared against:
422
422
 
423
423
  ```bash
424
- npx codebase-snapshot@0.17.0 update # is 0.17.0 still current? print the answer
425
- npx codebase-snapshot@0.17.0 update --format json
424
+ npx codebase-snapshot@0.20.0 update # is 0.17.0 still current? print the answer
425
+ npx codebase-snapshot@0.20.0 update --format json
426
426
  ```
427
427
 
428
428
  ```text
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.17.0 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.17.0 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.0 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.0 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
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.17.0 mcp
13
+ npx -y codebase-snapshot@0.20.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.17.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.20.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.17.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.20.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.17.0 mcp --http --port 4789
46
+ npx -y codebase-snapshot@0.20.0 mcp --http --port 4789
47
47
  ```
48
48
 
49
49
  This is the Streamable HTTP shape: POST one JSON-RPC message (or an array) to `/mcp` and read
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
5
5
  "keywords": [
6
6
  "codebase-snapshot",