codebase-snapshot 0.22.0 → 0.22.1

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/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  var crypto = require('crypto');
4
4
  var worker_threads = require('worker_threads');
5
5
  var async_hooks = require('async_hooks');
6
- var fs28 = require('fs');
6
+ var fs29 = require('fs');
7
7
  var os2 = require('os');
8
8
  var path7 = require('path');
9
9
  var ts = require('typescript');
@@ -37,7 +37,7 @@ function _interopNamespace(e) {
37
37
  }
38
38
 
39
39
  var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
40
- var fs28__namespace = /*#__PURE__*/_interopNamespace(fs28);
40
+ var fs29__namespace = /*#__PURE__*/_interopNamespace(fs29);
41
41
  var os2__namespace = /*#__PURE__*/_interopNamespace(os2);
42
42
  var path7__namespace = /*#__PURE__*/_interopNamespace(path7);
43
43
  var ts__default = /*#__PURE__*/_interopDefault(ts);
@@ -414,9 +414,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
414
414
  var jvmProfile = {
415
415
  id: "jvm",
416
416
  extensions: [".java", ".kt", ".kts", ".scala"],
417
- summarize(path31, content) {
417
+ summarize(path32, content) {
418
418
  const summary = emptySummary();
419
- const lower = path31.toLowerCase();
419
+ const lower = path32.toLowerCase();
420
420
  const isJava = lower.endsWith(".java");
421
421
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
422
422
  eachLine(content, (line) => {
@@ -639,9 +639,9 @@ var rubyProfile = {
639
639
  eachLine(content, (line) => {
640
640
  const trimmed = line.trim();
641
641
  if (!trimmed || trimmed.startsWith("#")) return;
642
- const relative18 = REQUIRE_RELATIVE.exec(trimmed);
643
- if (relative18) {
644
- summary.imports.push(`./${relative18[1]}`);
642
+ const relative20 = REQUIRE_RELATIVE.exec(trimmed);
643
+ if (relative20) {
644
+ summary.imports.push(`./${relative20[1]}`);
645
645
  return;
646
646
  }
647
647
  const required = REQUIRE.exec(trimmed);
@@ -1190,17 +1190,17 @@ function summarizeTypeScriptSource(relativePath, content) {
1190
1190
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script(?:\s[^>]*)?>/gi;
1191
1191
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
1192
1192
  var ASTRO_FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?=\r?\n|$)/;
1193
- function componentName(path31) {
1194
- const base = path31.split("/").pop() ?? path31;
1193
+ function componentName(path32) {
1194
+ const base = path32.split("/").pop() ?? path32;
1195
1195
  return base.replace(/\.[^.]+$/, "");
1196
1196
  }
1197
1197
  var sfcProfile = {
1198
1198
  id: "sfc",
1199
1199
  extensions: [".vue", ".svelte", ".astro"],
1200
- summarize(path31, content) {
1200
+ summarize(path32, content) {
1201
1201
  let script = "";
1202
- let usesJsx = path31.toLowerCase().endsWith(".astro");
1203
- if (path31.toLowerCase().endsWith(".astro")) {
1202
+ let usesJsx = path32.toLowerCase().endsWith(".astro");
1203
+ if (path32.toLowerCase().endsWith(".astro")) {
1204
1204
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
1205
1205
  if (frontmatter) script += `${frontmatter[1]}
1206
1206
  `;
@@ -1210,7 +1210,7 @@ var sfcProfile = {
1210
1210
  script += `${match[2]}
1211
1211
  `;
1212
1212
  }
1213
- const name = componentName(path31);
1213
+ const name = componentName(path32);
1214
1214
  if (!script.trim()) {
1215
1215
  const summary2 = emptySummary();
1216
1216
  if (name) {
@@ -1401,15 +1401,15 @@ for (const profile of LANGUAGE_PROFILES) {
1401
1401
  BY_EXTENSION.set(extension.toLowerCase(), profile);
1402
1402
  }
1403
1403
  }
1404
- function profileForPath(path31) {
1405
- const lower = path31.toLowerCase();
1404
+ function profileForPath(path32) {
1405
+ const lower = path32.toLowerCase();
1406
1406
  const dot = lower.lastIndexOf(".");
1407
1407
  if (dot === -1) return null;
1408
1408
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
1409
1409
  }
1410
- function summarizeWithProfile(path31, content) {
1411
- const profile = profileForPath(path31);
1412
- return profile ? profile.summarize(path31, content) : null;
1410
+ function summarizeWithProfile(path32, content) {
1411
+ const profile = profileForPath(path32);
1412
+ return profile ? profile.summarize(path32, content) : null;
1413
1413
  }
1414
1414
  var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
1415
1415
  ".png",
@@ -1624,13 +1624,13 @@ function isBinaryFile(absolutePath) {
1624
1624
  if (isBinaryExtension(absolutePath)) return true;
1625
1625
  let fd;
1626
1626
  try {
1627
- fd = fs28__namespace.openSync(absolutePath, "r");
1627
+ fd = fs29__namespace.openSync(absolutePath, "r");
1628
1628
  const buffer = Buffer.alloc(CHUNK);
1629
1629
  let sample2;
1630
1630
  let position = 0;
1631
1631
  while (position < BINARY_SCAN_BYTES) {
1632
1632
  const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
1633
- const bytesRead = fs28__namespace.readSync(fd, buffer, 0, wanted, position);
1633
+ const bytesRead = fs29__namespace.readSync(fd, buffer, 0, wanted, position);
1634
1634
  if (bytesRead === 0) return false;
1635
1635
  const chunk = buffer.subarray(0, bytesRead);
1636
1636
  if (sample2 === void 0) {
@@ -1648,7 +1648,7 @@ function isBinaryFile(absolutePath) {
1648
1648
  } finally {
1649
1649
  if (fd !== void 0) {
1650
1650
  try {
1651
- fs28__namespace.closeSync(fd);
1651
+ fs29__namespace.closeSync(fd);
1652
1652
  } catch {
1653
1653
  }
1654
1654
  }
@@ -1670,9 +1670,9 @@ function importsOfText(relativePath, text2) {
1670
1670
  function importsOfFile(relativePath, absolutePath) {
1671
1671
  let buffer;
1672
1672
  try {
1673
- const stats = fs28__namespace.statSync(absolutePath);
1673
+ const stats = fs29__namespace.statSync(absolutePath);
1674
1674
  if (!stats.isFile() || stats.size > SUMMARY_MAX_SOURCE_BYTES) return [];
1675
- buffer = fs28__namespace.readFileSync(absolutePath);
1675
+ buffer = fs29__namespace.readFileSync(absolutePath);
1676
1676
  } catch {
1677
1677
  return [];
1678
1678
  }
@@ -2058,9 +2058,9 @@ var SKIPPED_WALK_DIRS = /* @__PURE__ */ new Set([
2058
2058
  ]);
2059
2059
  function readSmallFile(fullPath) {
2060
2060
  try {
2061
- const stats = fs28__namespace.statSync(fullPath);
2061
+ const stats = fs29__namespace.statSync(fullPath);
2062
2062
  if (!stats.isFile() || stats.size > MANIFEST_MAX_BYTES) return null;
2063
- return fs28__namespace.readFileSync(fullPath, "utf8");
2063
+ return fs29__namespace.readFileSync(fullPath, "utf8");
2064
2064
  } catch {
2065
2065
  return null;
2066
2066
  }
@@ -2126,7 +2126,7 @@ function pnpmWorkspacePatterns(raw) {
2126
2126
  function childDirectories(cwd, parent) {
2127
2127
  let entries;
2128
2128
  try {
2129
- entries = fs28__namespace.readdirSync(path7__namespace.join(cwd, parent), { withFileTypes: true });
2129
+ entries = fs29__namespace.readdirSync(path7__namespace.join(cwd, parent), { withFileTypes: true });
2130
2130
  } catch {
2131
2131
  return [];
2132
2132
  }
@@ -2161,10 +2161,10 @@ function workspacePackageDirs(cwd, patterns) {
2161
2161
  function scanWorkspacePackages(cwd, patterns) {
2162
2162
  const files = /* @__PURE__ */ new Set();
2163
2163
  const dependencies = /* @__PURE__ */ new Set();
2164
- for (const relative18 of workspacePackageDirs(cwd, patterns)) {
2165
- const full = path7__namespace.join(cwd, relative18);
2164
+ for (const relative20 of workspacePackageDirs(cwd, patterns)) {
2165
+ const full = path7__namespace.join(cwd, relative20);
2166
2166
  try {
2167
- for (const entry of fs28__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
2167
+ for (const entry of fs29__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
2168
2168
  } catch {
2169
2169
  }
2170
2170
  const raw = readSmallFile(path7__namespace.join(full, "package.json"));
@@ -2177,7 +2177,7 @@ function scanWorkspacePackages(cwd, patterns) {
2177
2177
  var SNAPSHOT_MARKER = ".codebase-snapshot";
2178
2178
  function isToolOwnedDirectory(dir) {
2179
2179
  try {
2180
- return fs28__namespace.statSync(dir).isDirectory() && fs28__namespace.existsSync(path7__namespace.join(dir, SNAPSHOT_MARKER));
2180
+ return fs29__namespace.statSync(dir).isDirectory() && fs29__namespace.existsSync(path7__namespace.join(dir, SNAPSHOT_MARKER));
2181
2181
  } catch {
2182
2182
  return false;
2183
2183
  }
@@ -2192,7 +2192,7 @@ function countMarkdownFiles(cwd) {
2192
2192
  directoriesSeen += 1;
2193
2193
  let entries;
2194
2194
  try {
2195
- entries = fs28__namespace.readdirSync(current.dir, { withFileTypes: true });
2195
+ entries = fs29__namespace.readdirSync(current.dir, { withFileTypes: true });
2196
2196
  } catch {
2197
2197
  continue;
2198
2198
  }
@@ -2214,7 +2214,7 @@ function buildPresetContext(cwd) {
2214
2214
  const files = /* @__PURE__ */ new Set();
2215
2215
  const dirs = /* @__PURE__ */ new Set();
2216
2216
  try {
2217
- for (const entry of fs28__namespace.readdirSync(cwd, { withFileTypes: true })) {
2217
+ for (const entry of fs29__namespace.readdirSync(cwd, { withFileTypes: true })) {
2218
2218
  if (entry.isDirectory()) dirs.add(entry.name);
2219
2219
  else if (entry.isFile()) files.add(entry.name);
2220
2220
  }
@@ -3345,7 +3345,7 @@ var DEFAULT_SECRET_PATTERNS = [
3345
3345
  // query parameter or `$VARIABLE` reference is not an assignment).
3346
3346
  rule: "credential-assignment-unquoted",
3347
3347
  pattern: new RegExp(
3348
- `(?:${QUOTED_CREDENTIAL_KEY}|${UNQUOTED_STRONG_NAME})\\s{0,8}${ASSIGN}\\s{0,8}${NOT_A_LITERAL_VALUE}${UNQUOTED_LITERAL}|(?<=${UNQUOTED_STRONG_NAME}\\s{0,8}=(?!=)\\s{0,8})(?![\\s#$"'\`])[^\\s]{1,}|(?<=${UNQUOTED_STRONG_NAME}\\s{0,8}:[ ]{1,8})(?![ ]*["'\`])(?![ ]*[|>])${NOT_A_LITERAL_VALUE}[^\r
3348
+ `(?:${QUOTED_CREDENTIAL_KEY}|${UNQUOTED_STRONG_NAME})\\s{0,8}${ASSIGN}\\s{0,8}${NOT_A_LITERAL_VALUE}${UNQUOTED_LITERAL}|(?<=${UNQUOTED_STRONG_NAME}["']?\\s{0,8}=(?!=)\\s{0,8})(?![\\s#$"'\`])[^\\s]{1,}|(?<=${UNQUOTED_STRONG_NAME}["']?\\s{0,8}:[ ]{1,8})(?![ ]*["'\`])(?![ ]*[|>])(?![ ]*\\$\\{[A-Za-z_][A-Za-z0-9_]*[:}#%/])${NOT_A_LITERAL_VALUE}[^\r
3349
3349
  #]{1,300}`,
3350
3350
  "i"
3351
3351
  ),
@@ -3405,7 +3405,12 @@ var DEFAULT_SECRET_PATTERNS = [
3405
3405
  pattern: new RegExp(
3406
3406
  // The operator set deliberately omits `?`: `${VAR:?message}` is an error message in shell
3407
3407
  // and Compose, not a fallback value, and masking it hid the sentence a user is meant to read.
3408
- `(?:["']${STRONG_CREDENTIAL_NAME}["']|${NOT_AFTER_QUOTE}${STRONG_CREDENTIAL_NAME})\\s{0,8}${ASSIGN}\\s{0,8}["'\`]?\\$\\{[A-Za-z_][A-Za-z0-9_]*:?[-=+]([^}"\`\\r\\n]{2,512})\\}["'\`]?`,
3408
+ // The fallback may itself be quoted — `${VAR:-"prodSecret"}` is standard POSIX shell
3409
+ // and Docker Compose — so the capture takes everything between the operator and the
3410
+ // closing brace. Quotes are part of the value here: masking the whole fallback is
3411
+ // correct, and it keeps a quoted default from slipping between the two quote-aware
3412
+ // rules.
3413
+ `(?:["']${STRONG_CREDENTIAL_NAME}["']|${NOT_AFTER_QUOTE}${STRONG_CREDENTIAL_NAME})\\s{0,8}${ASSIGN}\\s{0,8}["'\`]?\\$\\{[A-Za-z_][A-Za-z0-9_]*:?[-=+]([^}\\r\\n]{2,512})\\}["'\`]?`,
3409
3414
  "i"
3410
3415
  ),
3411
3416
  valueGroup: 1
@@ -3897,7 +3902,19 @@ function maskValueLine(line) {
3897
3902
  return `${indent}${REDACTION_MARKER}`;
3898
3903
  }
3899
3904
  var STRUCTURED_KEY = /^([ \t]*)(?:-[ \t]+)?["']?([A-Za-z0-9_$.-]{1,128})["']?[ \t]*([:=])[ \t]*(.*)$/;
3900
- var BLOCK_SCALAR = /^[|>][+-]?\d*[ \t]*(?:#.*)?$/;
3905
+ var BLOCK_SCALAR = /^[|>](?:[+-]\d*|\d[+-]?)?[ \t]*(?:#.*)?$/;
3906
+ var YAML_LIST_ITEM = /^([ \t]*-[ \t]+)(.*)$/;
3907
+ function isJsonFile(filePath) {
3908
+ return filePath !== void 0 && /\.(?:json|jsonc|json5)$/i.test(filePath);
3909
+ }
3910
+ function maskJsonStrings(line) {
3911
+ let changed = false;
3912
+ const text2 = line.replace(/"(?:[^"\\]|\\.)*"/g, () => {
3913
+ changed = true;
3914
+ return `"${REDACTION_MARKER}"`;
3915
+ });
3916
+ return { text: text2, changed };
3917
+ }
3901
3918
  function redactStructuredValues(text2, filePath, recordFinding) {
3902
3919
  if (!isStructuredFile(filePath)) return text2;
3903
3920
  const segments = text2.split(LINE_BREAK);
@@ -3910,6 +3927,7 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3910
3927
  if (!CREDENTIAL_KEY_TAIL.test(key)) continue;
3911
3928
  const baseIndent = (match[1] ?? "").length;
3912
3929
  const rest = (match[4] ?? "").trim();
3930
+ const restIsComment = rest.startsWith("#");
3913
3931
  if (BLOCK_SCALAR.test(rest)) {
3914
3932
  let cursor2 = index + 2;
3915
3933
  let masked2 = false;
@@ -3926,14 +3944,67 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3926
3944
  if (masked2) recordFinding(index / 2 + 1, ["credential-block-scalar"]);
3927
3945
  continue;
3928
3946
  }
3929
- if (rest !== "") continue;
3947
+ if (isJsonFile(filePath) && rest.startsWith("[") && !rest.startsWith(REDACTION_MARKER)) {
3948
+ let cursor2 = index;
3949
+ let masked2 = false;
3950
+ let depth = 0;
3951
+ do {
3952
+ const body = segments[cursor2] ?? "";
3953
+ const start = cursor2 === index ? body.length - (match[4] ?? "").length : 0;
3954
+ const head = body.slice(0, start);
3955
+ const tail = body.slice(start);
3956
+ const maskedTail = maskJsonStrings(tail);
3957
+ if (maskedTail.changed) {
3958
+ masked2 = true;
3959
+ segments[cursor2] = head + maskedTail.text;
3960
+ }
3961
+ depth += (tail.match(/\[/g)?.length ?? 0) - (tail.match(/\]/g)?.length ?? 0);
3962
+ cursor2 += 2;
3963
+ } while (cursor2 < segments.length && depth > 0);
3964
+ if (masked2) recordFinding(index / 2 + 1, ["credential-array-value"]);
3965
+ continue;
3966
+ }
3967
+ const quotedKey = /^["']/.test(line.slice((match[1] ?? "").length));
3968
+ const commentAt = rest.search(/[ \t]#/);
3969
+ const valueText = commentAt >= 0 ? rest.slice(0, commentAt) : rest;
3970
+ const valueSuffix = commentAt >= 0 ? rest.slice(commentAt) : "";
3971
+ const markerOnly = valueText === REDACTION_MARKER || valueText === `"${REDACTION_MARKER}"` || valueText.replace(REDACTION_MARKER, "").trim() === "";
3972
+ if (valueText !== "" && !restIsComment && !/^["'`]/.test(valueText) && (quotedKey || valueText.includes("&") || valueText.startsWith(REDACTION_MARKER))) {
3973
+ if (markerOnly) continue;
3974
+ const prefix = line.slice(0, line.length - rest.length);
3975
+ segments[index] = prefix + (isJsonFile(filePath) ? `"${REDACTION_MARKER}"` : REDACTION_MARKER) + valueSuffix;
3976
+ recordFinding(index / 2 + 1, ["credential-scalar-value"]);
3977
+ continue;
3978
+ }
3979
+ if (rest !== "" && !restIsComment) continue;
3930
3980
  let cursor = index + 2;
3931
3981
  while (cursor < segments.length && (segments[cursor] ?? "").trim() === "") cursor += 2;
3932
3982
  const firstValue = segments[cursor];
3933
3983
  if (firstValue === void 0) continue;
3934
3984
  const valueIndent = (/^[ \t]*/.exec(firstValue)?.[0] ?? "").length;
3935
3985
  if (valueIndent <= baseIndent) continue;
3936
- if (STRUCTURED_KEY.test(firstValue) || /^[ \t]*-[ \t]/.test(firstValue)) continue;
3986
+ if (STRUCTURED_KEY.test(firstValue) && !YAML_LIST_ITEM.test(firstValue)) continue;
3987
+ if (YAML_LIST_ITEM.test(firstValue)) {
3988
+ let masked2 = false;
3989
+ while (cursor < segments.length) {
3990
+ const body = segments[cursor] ?? "";
3991
+ if (body.trim() === "") {
3992
+ cursor += 2;
3993
+ continue;
3994
+ }
3995
+ const item = YAML_LIST_ITEM.exec(body);
3996
+ const indent = (/^[ \t]*/.exec(body)?.[0] ?? "").length;
3997
+ if (indent < valueIndent || item === null) break;
3998
+ const content = (item[2] ?? "").trim();
3999
+ if (content !== "" && !/^[A-Za-z0-9_$.-]+:/.test(content)) {
4000
+ if (!isMarkerLine(content)) masked2 = true;
4001
+ segments[cursor] = (item[1] ?? "") + REDACTION_MARKER;
4002
+ }
4003
+ cursor += 2;
4004
+ }
4005
+ if (masked2) recordFinding(index / 2 + 1, ["credential-list-value"]);
4006
+ continue;
4007
+ }
3937
4008
  let masked = false;
3938
4009
  while (cursor < segments.length) {
3939
4010
  const body = segments[cursor] ?? "";
@@ -3950,20 +4021,118 @@ function redactStructuredValues(text2, filePath, recordFinding) {
3950
4021
  return segments.join("");
3951
4022
  }
3952
4023
  var DOCKERFILE_ENV = /^([ \t]*)(ENV|ARG)([ \t]+)([A-Za-z_][A-Za-z0-9_]*)([ \t]*=[ \t]*|[ \t]+)(\S.*)$/i;
4024
+ var DOCKERFILE_LEADING_CONTINUATION = /^([ \t]*)(ENV|ARG)[ \t]*\\[ \t]*$/i;
3953
4025
  function endsWithDockerContinuation(line) {
3954
- const end = line.replace(/[ \t]+$/, "");
4026
+ let end = line.length;
4027
+ while (end > 0 && (line[end - 1] === " " || line[end - 1] === " ")) end -= 1;
4028
+ const trimmed = line.slice(0, end);
3955
4029
  let count = 0;
3956
- while (count < end.length && end[end.length - 1 - count] === "\\") count += 1;
4030
+ while (count < trimmed.length && trimmed[trimmed.length - 1 - count] === "\\") count += 1;
3957
4031
  return count % 2 === 1;
3958
4032
  }
4033
+ function isBenignDockerValue(value) {
4034
+ return value === "" || isMarkerLine(value) || isPlaceholderValue(value) || isShellReference(value);
4035
+ }
4036
+ function firstSensitiveAssignment(segments, start, end) {
4037
+ const assignment = /(?:^|[ \t])([A-Za-z_][A-Za-z0-9_]*)[ \t]*=[ \t]*/g;
4038
+ for (let at = start; at <= end; at += 2) {
4039
+ const line = segments[at] ?? "";
4040
+ assignment.lastIndex = 0;
4041
+ let match;
4042
+ while ((match = assignment.exec(line)) !== null) {
4043
+ const key = match[1] ?? "";
4044
+ if (!CREDENTIAL_KEY_TAIL.test(key)) continue;
4045
+ const valueStart = match.index + match[0].length;
4046
+ const parts = [];
4047
+ const first = line.slice(valueStart).replace(/\\[ \t]*$/, "").trim();
4048
+ if (first !== "") parts.push(first);
4049
+ if (first === "" && !endsWithDockerContinuation(line)) continue;
4050
+ for (let next = at + 2; next <= end; next += 2) {
4051
+ const part = (segments[next] ?? "").replace(/\\[ \t]*$/, "").trim();
4052
+ if (part !== "") parts.push(part);
4053
+ }
4054
+ if (parts.length === 0) continue;
4055
+ if (parts.every(isBenignDockerValue)) continue;
4056
+ return { at, valueStart };
4057
+ }
4058
+ }
4059
+ return null;
4060
+ }
4061
+ function maskDockerAssignment(segments, start, end, found) {
4062
+ for (let at = start; at <= end; at += 2) {
4063
+ if (at < found.at) continue;
4064
+ const body = segments[at] ?? "";
4065
+ const keep = endsWithDockerContinuation(body);
4066
+ segments[at] = at === found.at ? body.slice(0, found.valueStart) + REDACTION_MARKER + (keep ? " \\" : "") : maskLineContent(body.replace(/\\[ \t]*$/, "")) + (keep ? " \\" : "");
4067
+ }
4068
+ }
4069
+ function firstSpaceSeparatedSecret(segments, start, end) {
4070
+ for (let at = start; at <= end; at += 2) {
4071
+ const body = segments[at] ?? "";
4072
+ const match = /^([ \t]*)([A-Za-z_][A-Za-z0-9_]*)([ \t]+)(\S.*)$/.exec(body);
4073
+ if (match === null) continue;
4074
+ if (!CREDENTIAL_KEY_TAIL.test(match[2] ?? "")) continue;
4075
+ const first = (match[4] ?? "").replace(/\\[ \t]*$/, "").trim();
4076
+ const parts = [];
4077
+ if (first !== "") parts.push(first);
4078
+ if (first === "" && !endsWithDockerContinuation(body)) continue;
4079
+ for (let next = at + 2; next <= end; next += 2) {
4080
+ const part = (segments[next] ?? "").replace(/\\[ \t]*$/, "").trim();
4081
+ if (part !== "") parts.push(part);
4082
+ }
4083
+ if (parts.length === 0 || parts.every(isBenignDockerValue)) continue;
4084
+ return {
4085
+ at,
4086
+ valueStart: (match[1] ?? "").length + (match[2] ?? "").length + (match[3] ?? "").length
4087
+ };
4088
+ }
4089
+ return null;
4090
+ }
3959
4091
  function redactDockerfileEnv(text2, filePath, recordFinding) {
3960
4092
  if (!isDockerfile(filePath)) return text2;
3961
4093
  const segments = text2.split(LINE_BREAK);
3962
4094
  for (let index = 0; index < segments.length; index += 2) {
3963
4095
  const line = segments[index];
3964
4096
  if (line === void 0) continue;
4097
+ const leading = DOCKERFILE_LEADING_CONTINUATION.exec(line);
4098
+ if (leading !== null) {
4099
+ let end = index;
4100
+ let current2 = line;
4101
+ while (endsWithDockerContinuation(current2) && end + 2 < segments.length) {
4102
+ end += 2;
4103
+ current2 = segments[end] ?? "";
4104
+ }
4105
+ const found = firstSensitiveAssignment(segments, index, end);
4106
+ if (found !== null) {
4107
+ maskDockerAssignment(segments, index, end, found);
4108
+ recordFinding(found.at / 2 + 1, ["dockerfile-env-secret"]);
4109
+ } else {
4110
+ const spaced = firstSpaceSeparatedSecret(segments, index + 2, end);
4111
+ if (spaced !== null) {
4112
+ maskDockerAssignment(segments, index, end, spaced);
4113
+ recordFinding(spaced.at / 2 + 1, ["dockerfile-env-secret"]);
4114
+ }
4115
+ }
4116
+ index = end;
4117
+ continue;
4118
+ }
3965
4119
  const match = DOCKERFILE_ENV.exec(line);
3966
4120
  if (match === null) continue;
4121
+ const assignmentForm = (match[5] ?? "").includes("=");
4122
+ if (assignmentForm) {
4123
+ let end = index;
4124
+ let current2 = line;
4125
+ while (endsWithDockerContinuation(current2) && end + 2 < segments.length) {
4126
+ end += 2;
4127
+ current2 = segments[end] ?? "";
4128
+ }
4129
+ const found = firstSensitiveAssignment(segments, index, end);
4130
+ if (found === null) continue;
4131
+ maskDockerAssignment(segments, index, end, found);
4132
+ recordFinding(found.at / 2 + 1, ["dockerfile-env-secret"]);
4133
+ index = end;
4134
+ continue;
4135
+ }
3967
4136
  if (!CREDENTIAL_KEY_TAIL.test(match[4] ?? "")) continue;
3968
4137
  const value = (match[6] ?? "").trim();
3969
4138
  const continuationLines = [];
@@ -3980,9 +4149,7 @@ function redactDockerfileEnv(text2, filePath, recordFinding) {
3980
4149
  }
3981
4150
  combined = combined.trim();
3982
4151
  const keepContinuation = endsWithDockerContinuation(line);
3983
- if (markerOnly || isPlaceholderValue(combined) || /^\$[({A-Za-z_]/.test(combined)) {
3984
- continue;
3985
- }
4152
+ if (markerOnly || isBenignDockerValue(combined)) continue;
3986
4153
  const separator = match[5] ?? "";
3987
4154
  segments[index] = `${match[1]}${match[2]}${match[3]}${match[4]}${separator}${REDACTION_MARKER}`;
3988
4155
  if (keepContinuation) segments[index] += " \\";
@@ -4099,7 +4266,12 @@ function isMarkerLine(value) {
4099
4266
  return trimmed === REDACTION_MARKER || trimmed === PEM_REDACTION_MARKER;
4100
4267
  }
4101
4268
  function isPlaceholderValue(value) {
4102
- const trimmed = value.trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "");
4269
+ const base = value.trim();
4270
+ let start = 0;
4271
+ while (start < base.length && (base[start] === '"' || base[start] === "'" || base[start] === "`")) start += 1;
4272
+ let end = base.length;
4273
+ while (end > start && (base[end - 1] === '"' || base[end - 1] === "'" || base[end - 1] === "`")) end -= 1;
4274
+ const trimmed = base.slice(start, end);
4103
4275
  if (trimmed.length === 0) return false;
4104
4276
  if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) return true;
4105
4277
  if (trimmed === REDACTION_MARKER || trimmed === PEM_REDACTION_MARKER) return true;
@@ -4157,7 +4329,7 @@ function isShellFile(filePath) {
4157
4329
  return SHELL_FILE.test(normalised) || SHELL_BASENAME.test(normalised.slice(normalised.lastIndexOf("/") + 1));
4158
4330
  }
4159
4331
  function isShellReference(value) {
4160
- return /^\$(?:[A-Za-z_][A-Za-z0-9_]*|\{[^}]*\}|\([^)]*\))$/.test(value);
4332
+ return /^\$(?:[A-Za-z_][A-Za-z0-9_]*|\{[A-Za-z_][A-Za-z0-9_]*\}|\([^)]*\))$/.test(value);
4161
4333
  }
4162
4334
  function isUnquotedValue(line, start) {
4163
4335
  const before = start > 0 ? line[start - 1] : "";
@@ -4363,8 +4535,8 @@ function applySpansKeepingQuotes(line, spans) {
4363
4535
  return out;
4364
4536
  }
4365
4537
  function isInside(parent, child) {
4366
- const relative18 = path7__namespace.relative(parent, child);
4367
- return relative18 === "" || relative18 !== ".." && !relative18.startsWith(`..${path7__namespace.sep}`) && !relative18.startsWith("../") && !path7__namespace.isAbsolute(relative18);
4538
+ const relative20 = path7__namespace.relative(parent, child);
4539
+ return relative20 === "" || relative20 !== ".." && !relative20.startsWith(`..${path7__namespace.sep}`) && !relative20.startsWith("../") && !path7__namespace.isAbsolute(relative20);
4368
4540
  }
4369
4541
  function resolveConfined(baseDir, relativePath) {
4370
4542
  if (relativePath.length === 0 || relativePath.includes("\0")) {
@@ -4375,7 +4547,7 @@ function resolveConfined(baseDir, relativePath) {
4375
4547
  }
4376
4548
  let baseReal;
4377
4549
  try {
4378
- baseReal = fs28__namespace.realpathSync(path7__namespace.resolve(baseDir));
4550
+ baseReal = fs29__namespace.realpathSync(path7__namespace.resolve(baseDir));
4379
4551
  } catch {
4380
4552
  return { ok: false, reason: "missing", message: "the snapshot directory does not exist" };
4381
4553
  }
@@ -4385,7 +4557,7 @@ function resolveConfined(baseDir, relativePath) {
4385
4557
  }
4386
4558
  let stats;
4387
4559
  try {
4388
- stats = fs28__namespace.lstatSync(candidate);
4560
+ stats = fs29__namespace.lstatSync(candidate);
4389
4561
  } catch (error) {
4390
4562
  const code = error.code;
4391
4563
  return {
@@ -4402,7 +4574,7 @@ function resolveConfined(baseDir, relativePath) {
4402
4574
  }
4403
4575
  let real;
4404
4576
  try {
4405
- real = fs28__namespace.realpathSync(candidate);
4577
+ real = fs29__namespace.realpathSync(candidate);
4406
4578
  } catch {
4407
4579
  return { ok: false, reason: "unreadable", message: "the file could not be resolved" };
4408
4580
  }
@@ -4425,7 +4597,7 @@ function readConfinedBytes(baseDir, relativePath, maxBytes) {
4425
4597
  };
4426
4598
  }
4427
4599
  try {
4428
- const bytes = fs28__namespace.readFileSync(resolved.path);
4600
+ const bytes = fs29__namespace.readFileSync(resolved.path);
4429
4601
  return { ok: true, bytes, path: resolved.path, stats: resolved.stats };
4430
4602
  } catch {
4431
4603
  return { ok: false, reason: "unreadable", message: "the file could not be read" };
@@ -4442,7 +4614,7 @@ function readConfinedText(baseDir, relativePath, maxBytes) {
4442
4614
  };
4443
4615
  }
4444
4616
  try {
4445
- const text2 = fs28__namespace.readFileSync(resolved.path, "utf8");
4617
+ const text2 = fs29__namespace.readFileSync(resolved.path, "utf8");
4446
4618
  return { ok: true, text: text2, path: resolved.path, stats: resolved.stats };
4447
4619
  } catch {
4448
4620
  return { ok: false, reason: "unreadable", message: "the file could not be read" };
@@ -4452,7 +4624,7 @@ function readConfinedText(baseDir, relativePath, maxBytes) {
4452
4624
  // src/signing.ts
4453
4625
  var SIGNATURE_FILE = "signature.json";
4454
4626
  function signManifest(manifestPath, options = {}) {
4455
- const bytes = fs28__namespace.readFileSync(manifestPath);
4627
+ const bytes = fs29__namespace.readFileSync(manifestPath);
4456
4628
  const manifest = JSON.parse(bytes.toString("utf8"));
4457
4629
  if (typeof manifest.fingerprint !== "string" || !/^[0-9a-f]{64}$/.test(manifest.fingerprint)) {
4458
4630
  throw new Error("refusing to sign: the manifest has no valid fingerprint");
@@ -4525,7 +4697,7 @@ function verifySnapshotSignature(snapshotDir) {
4525
4697
 
4526
4698
  // src/version.ts
4527
4699
  var GENERATOR_NAME = "codebase-snapshot";
4528
- var GENERATOR_VERSION = "0.22.0";
4700
+ var GENERATOR_VERSION = "0.22.1";
4529
4701
  var SCHEMA_VERSION = "3.0.0";
4530
4702
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
4531
4703
  function isOurGeneratorName(name) {
@@ -4542,7 +4714,7 @@ var PRESET_IGNORES = new Set(
4542
4714
  );
4543
4715
  function readLinkTarget(linkPath, fallback) {
4544
4716
  try {
4545
- return fs28__namespace.readlinkSync(linkPath);
4717
+ return fs29__namespace.readlinkSync(linkPath);
4546
4718
  } catch {
4547
4719
  return fallback;
4548
4720
  }
@@ -4557,8 +4729,8 @@ function brokenLinkRecord(linkPath, relativePath, rootReal) {
4557
4729
  };
4558
4730
  }
4559
4731
  function isInside2(root, candidate) {
4560
- const relative18 = path7__namespace.relative(root, candidate);
4561
- return relative18 === "" || !relative18.startsWith(`..${path7__namespace.sep}`) && relative18 !== ".." && !path7__namespace.isAbsolute(relative18);
4732
+ const relative20 = path7__namespace.relative(root, candidate);
4733
+ return relative20 === "" || !relative20.startsWith(`..${path7__namespace.sep}`) && relative20 !== ".." && !path7__namespace.isAbsolute(relative20);
4562
4734
  }
4563
4735
  var GIT_OUTPUT_LIMIT = 68157440;
4564
4736
  function getGitInfo(cwd, fallbackBranch = "main") {
@@ -4880,7 +5052,7 @@ function readGitignoreRules(dir) {
4880
5052
  const gitignorePath2 = path7__namespace.join(dir, ".gitignore");
4881
5053
  let raw;
4882
5054
  try {
4883
- raw = fs28__namespace.readFileSync(gitignorePath2, "utf8");
5055
+ raw = fs29__namespace.readFileSync(gitignorePath2, "utf8");
4884
5056
  } catch {
4885
5057
  return [];
4886
5058
  }
@@ -4972,12 +5144,7 @@ function compileGitignorePattern(pattern) {
4972
5144
  }
4973
5145
  function matchesGitignoreRule(rule, scoped, isDirectory) {
4974
5146
  if (!rule.dirOnly) return matchGitignorePattern(scoped, rule.pattern);
4975
- const segments = scoped.split("/");
4976
- const limit = isDirectory ? segments.length : segments.length - 1;
4977
- for (let depth = 1; depth <= limit; depth += 1) {
4978
- if (matchGitignorePattern(segments.slice(0, depth).join("/"), rule.pattern)) return true;
4979
- }
4980
- return false;
5147
+ return isDirectory && matchGitignorePattern(scoped, rule.pattern);
4981
5148
  }
4982
5149
  function gitignoreVerdict(layers, relativePath, isDirectory) {
4983
5150
  let verdict = null;
@@ -5092,7 +5259,7 @@ function listIgnoredPaths(cwd) {
5092
5259
  }
5093
5260
  function hasSnapshotMarker(target) {
5094
5261
  try {
5095
- return fs28__namespace.statSync(target).isDirectory() && isToolOwnedDirectory2(target);
5262
+ return fs29__namespace.statSync(target).isDirectory() && isToolOwnedDirectory2(target);
5096
5263
  } catch {
5097
5264
  return false;
5098
5265
  }
@@ -5101,7 +5268,7 @@ var IGNORABLE_DIRECTORY_ENTRIES = /* @__PURE__ */ new Set([".DS_Store"]);
5101
5268
  function isToolOwnedDirectory2(dir) {
5102
5269
  let raw;
5103
5270
  try {
5104
- raw = fs28__namespace.readFileSync(path7__namespace.join(dir, ".codebase-snapshot"), "utf8");
5271
+ raw = fs29__namespace.readFileSync(path7__namespace.join(dir, ".codebase-snapshot"), "utf8");
5105
5272
  } catch {
5106
5273
  return false;
5107
5274
  }
@@ -5118,7 +5285,7 @@ function isToolOwnedDirectory2(dir) {
5118
5285
  }
5119
5286
  let manifestBytes;
5120
5287
  try {
5121
- manifestBytes = fs28__namespace.readFileSync(path7__namespace.join(dir, "manifest.json"));
5288
+ manifestBytes = fs29__namespace.readFileSync(path7__namespace.join(dir, "manifest.json"));
5122
5289
  } catch {
5123
5290
  return false;
5124
5291
  }
@@ -5136,14 +5303,14 @@ function isToolOwnedDirectory2(dir) {
5136
5303
  const full = path7__namespace.join(dir, ...entry.split("/"));
5137
5304
  let stats;
5138
5305
  try {
5139
- stats = fs28__namespace.lstatSync(full);
5306
+ stats = fs29__namespace.lstatSync(full);
5140
5307
  } catch {
5141
5308
  return false;
5142
5309
  }
5143
5310
  if (!stats.isFile() || stats.size !== record.bytes) return false;
5144
5311
  let digest;
5145
5312
  try {
5146
- digest = crypto.createHash("sha256").update(fs28__namespace.readFileSync(full)).digest("hex");
5313
+ digest = crypto.createHash("sha256").update(fs29__namespace.readFileSync(full)).digest("hex");
5147
5314
  } catch {
5148
5315
  return false;
5149
5316
  }
@@ -5155,22 +5322,22 @@ function isToolOwnedDirectory2(dir) {
5155
5322
  const current = stack.pop();
5156
5323
  let entries;
5157
5324
  try {
5158
- entries = fs28__namespace.readdirSync(path7__namespace.join(dir, current), { withFileTypes: true });
5325
+ entries = fs29__namespace.readdirSync(path7__namespace.join(dir, current), { withFileTypes: true });
5159
5326
  } catch {
5160
5327
  return false;
5161
5328
  }
5162
5329
  for (const entry of entries) {
5163
- const relative18 = current === "" ? entry.name : current + "/" + entry.name;
5164
- if (relative18 === ".codebase-snapshot" || IGNORABLE_DIRECTORY_ENTRIES.has(entry.name)) continue;
5330
+ const relative20 = current === "" ? entry.name : current + "/" + entry.name;
5331
+ if (relative20 === ".codebase-snapshot" || IGNORABLE_DIRECTORY_ENTRIES.has(entry.name)) continue;
5165
5332
  if (entry.isDirectory()) {
5166
- stack.push(relative18);
5333
+ stack.push(relative20);
5167
5334
  continue;
5168
5335
  }
5169
5336
  if (!entry.isFile()) return false;
5170
- if (relative18 === "signature.json" && !recordedFiles.has(relative18) && verifySnapshotSignature(dir).ok) {
5337
+ if (relative20 === "signature.json" && !recordedFiles.has(relative20) && verifySnapshotSignature(dir).ok) {
5171
5338
  continue;
5172
5339
  }
5173
- if (!recordedFiles.has(relative18)) return false;
5340
+ if (!recordedFiles.has(relative20)) return false;
5174
5341
  }
5175
5342
  }
5176
5343
  return true;
@@ -5202,7 +5369,7 @@ function makeLinkProbe() {
5202
5369
  let known = cache.get(absolutePath);
5203
5370
  if (known === void 0) {
5204
5371
  try {
5205
- known = fs28__namespace.lstatSync(absolutePath).isSymbolicLink();
5372
+ known = fs29__namespace.lstatSync(absolutePath).isSymbolicLink();
5206
5373
  } catch {
5207
5374
  known = false;
5208
5375
  }
@@ -5215,7 +5382,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
5215
5382
  const isLink = makeLinkProbe();
5216
5383
  let rootReal = cwd;
5217
5384
  try {
5218
- rootReal = fs28__namespace.realpathSync(cwd);
5385
+ rootReal = fs29__namespace.realpathSync(cwd);
5219
5386
  } catch {
5220
5387
  }
5221
5388
  const reported = /* @__PURE__ */ new Set();
@@ -5243,7 +5410,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
5243
5410
  const rawTarget = readLinkTarget(absolute, absolute);
5244
5411
  let targetReal = null;
5245
5412
  try {
5246
- targetReal = fs28__namespace.realpathSync(absolute);
5413
+ targetReal = fs29__namespace.realpathSync(absolute);
5247
5414
  } catch {
5248
5415
  targetReal = null;
5249
5416
  }
@@ -5261,7 +5428,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
5261
5428
  }
5262
5429
  let stats = null;
5263
5430
  try {
5264
- stats = fs28__namespace.statSync(absolute);
5431
+ stats = fs29__namespace.statSync(absolute);
5265
5432
  } catch {
5266
5433
  stats = null;
5267
5434
  }
@@ -5367,7 +5534,7 @@ function collectFiles(cwd, options = {}) {
5367
5534
  "Discovery mode is `git`, but git could not list this directory's files. Run inside a working repository, or pass --discovery walk (or auto) to scan the tree directly."
5368
5535
  );
5369
5536
  }
5370
- if (fs28__namespace.existsSync(path7__namespace.join(cwd, ".git"))) {
5537
+ if (fs29__namespace.existsSync(path7__namespace.join(cwd, ".git"))) {
5371
5538
  throw new Error(
5372
5539
  "This directory is a git repository, but git could not list its files. A plain walk honours .gitignore files, but git also applies .git/info/exclude and your global excludes file, includes files that are tracked although a .gitignore now matches them, and treats a submodule as a single entry. Fix the repository (git status should work), run outside git, or pass --discovery walk to accept those differences."
5373
5540
  );
@@ -5447,7 +5614,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
5447
5614
  const aliases = /* @__PURE__ */ new Set();
5448
5615
  for (const file of files) {
5449
5616
  try {
5450
- if (fs28__namespace.lstatSync(path7__namespace.join(cwd, file)).isSymbolicLink()) aliases.add(file);
5617
+ if (fs29__namespace.lstatSync(path7__namespace.join(cwd, file)).isSymbolicLink()) aliases.add(file);
5451
5618
  } catch {
5452
5619
  }
5453
5620
  }
@@ -5456,7 +5623,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
5456
5623
  for (const file of files) {
5457
5624
  if (aliases.has(file)) continue;
5458
5625
  try {
5459
- includedTargets.add(fs28__namespace.realpathSync(path7__namespace.join(cwd, file)));
5626
+ includedTargets.add(fs29__namespace.realpathSync(path7__namespace.join(cwd, file)));
5460
5627
  } catch {
5461
5628
  }
5462
5629
  }
@@ -5468,7 +5635,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
5468
5635
  }
5469
5636
  let target;
5470
5637
  try {
5471
- target = fs28__namespace.realpathSync(path7__namespace.join(cwd, file));
5638
+ target = fs29__namespace.realpathSync(path7__namespace.join(cwd, file));
5472
5639
  } catch {
5473
5640
  skipped.push({ path: file, reason: "read-error", detail: "symlink target could not be resolved" });
5474
5641
  continue;
@@ -5487,7 +5654,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
5487
5654
  }
5488
5655
  function rootRealFor(root) {
5489
5656
  try {
5490
- return fs28__namespace.realpathSync(root);
5657
+ return fs29__namespace.realpathSync(root);
5491
5658
  } catch {
5492
5659
  return root;
5493
5660
  }
@@ -5507,7 +5674,7 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
5507
5674
  ];
5508
5675
  let entries;
5509
5676
  try {
5510
- entries = fs28__namespace.readdirSync(current, { withFileTypes: true });
5677
+ entries = fs29__namespace.readdirSync(current, { withFileTypes: true });
5511
5678
  } catch {
5512
5679
  results.skipped.push({
5513
5680
  path: relativeToBase(current),
@@ -5571,14 +5738,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
5571
5738
  if (entry.isSymbolicLink()) {
5572
5739
  let targetReal;
5573
5740
  try {
5574
- targetReal = fs28__namespace.realpathSync(fullPath);
5741
+ targetReal = fs29__namespace.realpathSync(fullPath);
5575
5742
  } catch {
5576
5743
  results.skipped.push(brokenLinkRecord(fullPath, relPath, rootReal));
5577
5744
  continue;
5578
5745
  }
5579
5746
  let stats;
5580
5747
  try {
5581
- stats = fs28__namespace.statSync(fullPath);
5748
+ stats = fs29__namespace.statSync(fullPath);
5582
5749
  } catch {
5583
5750
  results.skipped.push({ path: relPath, reason: "read-error", detail: "unreadable symlink" });
5584
5751
  continue;
@@ -5846,6 +6013,17 @@ function assertServerSafeConfig(config, source = "The configuration") {
5846
6013
  source + " enables includeSensitiveFiles. The MCP and serve transports never emit sensitive files; remove that setting or run the CLI directly."
5847
6014
  );
5848
6015
  }
6016
+ if (config.cwd !== void 0) {
6017
+ if (typeof config.cwd !== "string" || config.cwd.trim() === "") {
6018
+ throw new Error(source + " has an invalid cwd; it must be a non-empty path string.");
6019
+ }
6020
+ const normalized = config.cwd.replace(/\\/g, "/");
6021
+ if (path7__namespace.isAbsolute(config.cwd) || normalized.split("/").includes("..")) {
6022
+ throw new Error(
6023
+ source + " sets cwd to " + config.cwd + ". The MCP and serve transports confine every run to the repository they were started for; remove cwd or make it a relative subdirectory."
6024
+ );
6025
+ }
6026
+ }
5849
6027
  if (config.secrets !== void 0 && config.secrets !== null) {
5850
6028
  if (config.secrets.disableDefaultPatterns === true) {
5851
6029
  throw new Error(
@@ -5937,20 +6115,25 @@ function normalizeResolvedConfig(config) {
5937
6115
  `maxPartBytes must be at least ${MIN_MAX_PART_BYTES} bytes (received ${String(config.maxPartBytes)}).`
5938
6116
  );
5939
6117
  }
5940
- if (!Number.isSafeInteger(config.largeFileBytes) || config.largeFileBytes < 0) {
6118
+ if (!Number.isSafeInteger(config.largeFileBytes) || config.largeFileBytes < 1) {
6119
+ throw new Error(
6120
+ `largeFileBytes must be a positive integer; received ${String(config.largeFileBytes)}.`
6121
+ );
6122
+ }
6123
+ if (config.largeFileBytes > config.maxPartBytes) {
5941
6124
  throw new Error(
5942
- `largeFileBytes must be a non-negative integer; received ${String(config.largeFileBytes)}.`
6125
+ `largeFileBytes (${config.largeFileBytes} B) is larger than maxPartBytes (${config.maxPartBytes} B). Raise maxPartBytes, or lower largeFileBytes.`
5943
6126
  );
5944
6127
  }
5945
- const maxPartTokens = config.maxPartTokens ?? Math.floor(config.maxPartBytes / 4);
5946
- if (!Number.isSafeInteger(maxPartTokens) || maxPartTokens < MIN_MAX_PART_TOKENS) {
6128
+ const maxPartTokens = config.maxPartTokens;
6129
+ if (maxPartTokens !== void 0 && (!Number.isSafeInteger(maxPartTokens) || maxPartTokens < MIN_MAX_PART_TOKENS)) {
5947
6130
  throw new Error(
5948
6131
  `maxPartTokens must be at least ${MIN_MAX_PART_TOKENS} tokens; received ${String(maxPartTokens)}.`
5949
6132
  );
5950
6133
  }
5951
6134
  return markResolvedConfig({
5952
6135
  ...config,
5953
- maxPartTokens,
6136
+ ...maxPartTokens === void 0 ? {} : { maxPartTokens },
5954
6137
  discovery,
5955
6138
  // A spread copy built before the field existed carries no value; the default applies, and it
5956
6139
  // is re-validated because the number reaches a rendered artifact.
@@ -6106,10 +6289,10 @@ function readConfigExport(exported, file) {
6106
6289
  var lastModuleConfig = null;
6107
6290
  function moduleConfigKey(fullPath) {
6108
6291
  try {
6109
- return crypto.createHash("sha256").update(fs28__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
6292
+ return crypto.createHash("sha256").update(fs29__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
6110
6293
  } catch {
6111
6294
  try {
6112
- const stats = fs28__namespace.statSync(fullPath);
6295
+ const stats = fs29__namespace.statSync(fullPath);
6113
6296
  return `stat-${stats.mtimeMs}-${stats.size}`;
6114
6297
  } catch {
6115
6298
  return "unreadable";
@@ -6151,9 +6334,9 @@ async function loadConfigFileDetailed(cwd, options = {}) {
6151
6334
  const fullPath = path7__namespace.join(cwd, filename);
6152
6335
  let candidateStats = null;
6153
6336
  try {
6154
- candidateStats = fs28__namespace.statSync(fullPath);
6337
+ candidateStats = fs29__namespace.statSync(fullPath);
6155
6338
  } catch {
6156
- if (!fs28__namespace.existsSync(fullPath)) continue;
6339
+ if (!fs29__namespace.existsSync(fullPath)) continue;
6157
6340
  }
6158
6341
  if (candidateStats !== null && !candidateStats.isFile()) {
6159
6342
  configDirectories.push(fullPath);
@@ -6161,7 +6344,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
6161
6344
  }
6162
6345
  if (filename.endsWith(".json") || filename === ".snapshotrc") {
6163
6346
  try {
6164
- const config = parseJsonish(fs28__namespace.readFileSync(fullPath, "utf8"), fullPath);
6347
+ const config = parseJsonish(fs29__namespace.readFileSync(fullPath, "utf8"), fullPath);
6165
6348
  if (config === null || typeof config !== "object" || Array.isArray(config)) {
6166
6349
  throw new Error(
6167
6350
  `${fullPath} does not hold a configuration object (received ${describeValue2(config)}).`
@@ -6207,9 +6390,9 @@ async function loadConfigFileDetailed(cwd, options = {}) {
6207
6390
  }
6208
6391
  }
6209
6392
  const pkgJsonPath = path7__namespace.join(cwd, "package.json");
6210
- if (fs28__namespace.existsSync(pkgJsonPath)) {
6393
+ if (fs29__namespace.existsSync(pkgJsonPath)) {
6211
6394
  try {
6212
- const parsed = parseJsonish(fs28__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
6395
+ const parsed = parseJsonish(fs29__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
6213
6396
  const snapshotKey = parsed.snapshot;
6214
6397
  if (snapshotKey && typeof snapshotKey === "object" && !Array.isArray(snapshotKey)) {
6215
6398
  assertKnownConfigKeys(
@@ -6388,7 +6571,7 @@ function readConfiguredBrief(cwd, value) {
6388
6571
  }
6389
6572
  const rootReal = (() => {
6390
6573
  try {
6391
- return fs28__namespace.realpathSync(cwd);
6574
+ return fs29__namespace.realpathSync(cwd);
6392
6575
  } catch {
6393
6576
  return path7__namespace.resolve(cwd);
6394
6577
  }
@@ -6396,19 +6579,19 @@ function readConfiguredBrief(cwd, value) {
6396
6579
  const requested = path7__namespace.resolve(cwd, value);
6397
6580
  let filePath;
6398
6581
  try {
6399
- filePath = fs28__namespace.realpathSync(requested);
6582
+ filePath = fs29__namespace.realpathSync(requested);
6400
6583
  } catch {
6401
6584
  throw new Error(
6402
6585
  'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
6403
6586
  );
6404
6587
  }
6405
- const relative18 = path7__namespace.relative(rootReal, filePath);
6406
- if (relative18.length === 0 || relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative18)) {
6588
+ const relative20 = path7__namespace.relative(rootReal, filePath);
6589
+ if (relative20.length === 0 || relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative20)) {
6407
6590
  throw new Error(
6408
6591
  'brief "' + value + '" resolves outside the repository. A brief must be a file inside the repository being described; an absolute or parent path is refused.'
6409
6592
  );
6410
6593
  }
6411
- const posixRelative = relative18.split(path7__namespace.sep).join("/");
6594
+ const posixRelative = relative20.split(path7__namespace.sep).join("/");
6412
6595
  if (isSensitivePath(posixRelative) || isSensitivePath(value)) {
6413
6596
  throw new Error(
6414
6597
  'brief "' + value + '" is a credential-bearing file. A snapshot must not reproduce secrets, so it cannot be used as the owner brief.'
@@ -6422,14 +6605,14 @@ function readConfiguredBrief(cwd, value) {
6422
6605
  }
6423
6606
  let text2;
6424
6607
  try {
6425
- const stats = fs28__namespace.statSync(filePath);
6608
+ const stats = fs29__namespace.statSync(filePath);
6426
6609
  if (!stats.isFile()) throw new Error("not a file");
6427
6610
  if (stats.size > MAX_BRIEF_BYTES) {
6428
6611
  throw new Error(
6429
6612
  'brief "' + value + '" is ' + stats.size + " bytes; the limit is " + MAX_BRIEF_BYTES + ". Keep it to what a reader can act on, or move the detail into a document the snapshot carries."
6430
6613
  );
6431
6614
  }
6432
- text2 = fs28__namespace.readFileSync(filePath, "utf8");
6615
+ text2 = fs29__namespace.readFileSync(filePath, "utf8");
6433
6616
  } catch (error) {
6434
6617
  if (error instanceof Error && error.message.startsWith('brief "')) throw error;
6435
6618
  throw new Error(
@@ -6556,11 +6739,11 @@ function outputExcludePatterns(cwd, outDir, tmpDir) {
6556
6739
  const patterns = [];
6557
6740
  for (const dir of [outDir, tmpDir]) {
6558
6741
  const absolute = path7__namespace.resolve(cwd, dir);
6559
- const relative18 = path7__namespace.relative(cwd, absolute);
6560
- if (!relative18 || relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative18)) {
6742
+ const relative20 = path7__namespace.relative(cwd, absolute);
6743
+ if (!relative20 || relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative20)) {
6561
6744
  continue;
6562
6745
  }
6563
- patterns.push(`${relative18.replace(/\\/g, "/")}/**`);
6746
+ patterns.push(`${relative20.replace(/\\/g, "/")}/**`);
6564
6747
  }
6565
6748
  return patterns;
6566
6749
  }
@@ -6698,10 +6881,10 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
6698
6881
  }
6699
6882
  const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
6700
6883
  const resolved = path7__namespace.resolve(candidate);
6701
- if (!fs28__namespace.existsSync(resolved)) {
6884
+ if (!fs29__namespace.existsSync(resolved)) {
6702
6885
  throw new Error(`Working directory does not exist: ${resolved}`);
6703
6886
  }
6704
- if (!fs28__namespace.statSync(resolved).isDirectory()) {
6887
+ if (!fs29__namespace.statSync(resolved).isDirectory()) {
6705
6888
  throw new Error(`Working directory is not a directory: ${resolved}`);
6706
6889
  }
6707
6890
  return resolved;
@@ -6855,10 +7038,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
6855
7038
  outDir,
6856
7039
  tmpDir,
6857
7040
  maxPartBytes: resolvedMaxPartBytes,
6858
- // Record the effective value even when the user did not set it. normalizeResolvedConfig
6859
- // derives it for the manifest; leaving validate's fresh resolution unset made a clean
6860
- // snapshot report a configuration mismatch.
6861
- maxPartTokens: maxPartTokens ?? Math.floor(resolvedMaxPartBytes / 4),
7041
+ // Record only the token ceiling the user named. The byte budget is the enforced limit; a
7042
+ // derived token number is an estimate, and writing it into the manifest made a default run
7043
+ // look like it had chosen one.
7044
+ ...maxPartTokens === void 0 ? {} : { maxPartTokens },
6862
7045
  largeFileBytes: largeFileBytesFor(resolvedMaxPartBytes, cliOptions, userConfig),
6863
7046
  previewHeadLines: strictPositiveInteger(userConfig?.previewHeadLines, 80, "`previewHeadLines`"),
6864
7047
  previewTailLines: strictPositiveInteger(userConfig?.previewTailLines, 40, "`previewTailLines`"),
@@ -6975,7 +7158,7 @@ function configDigest(config) {
6975
7158
  // The user's own unit. `maxPartBytes` above already reflects the converted ceiling, but
6976
7159
  // recording the token number means changing 32k to 64k moves the digest even in the
6977
7160
  // corner where both round to the same byte budget.
6978
- maxPartTokens: config.maxPartTokens ?? null,
7161
+ maxPartTokens: config.maxPartTokens === void 0 || config.maxPartTokens === Math.floor(config.maxPartBytes / 4) ? null : config.maxPartTokens,
6979
7162
  // A changed-files scope decides which files are in the snapshot at all, so a snapshot
6980
7163
  // taken over a different scope is a different snapshot.
6981
7164
  changedSince: config.changedSince ?? null,
@@ -7411,13 +7594,16 @@ var TOKEN_LINE_SLACK = 32;
7411
7594
  function truncateWithBudgetMarker(content, maxBytes, budget, originalLines) {
7412
7595
  const base = content.replace(BUDGET_MARKER_SUFFIX, "");
7413
7596
  const truncated = truncateToBytes(base, Math.max(0, maxBytes));
7414
- if (!truncated.isTruncated) return { content: base, isTruncated: false };
7597
+ if (!truncated.isTruncated) return { content: base, isTruncated: false, cutMidLine: false };
7415
7598
  const keptLines = countLines(truncated.content);
7416
7599
  const omitted = Math.max(1, Math.max(countLines(base), originalLines) - keptLines);
7600
+ const next = base[truncated.content.length];
7601
+ const cutMidLine = next !== void 0 && next !== "\n" && next !== "\r";
7602
+ const separator = truncated.content.endsWith("\n") || truncated.content.endsWith("\r") ? "" : "\n";
7417
7603
  return {
7418
- content: `${truncated.content}
7419
- ... [${omitted} lines omitted: part budget ${budget} B] ...`,
7420
- isTruncated: true
7604
+ content: `${truncated.content}${separator}... [${omitted} lines omitted: part budget ${budget} B] ...`,
7605
+ isTruncated: true,
7606
+ cutMidLine
7421
7607
  };
7422
7608
  }
7423
7609
  function partitionFiles(files, maxPartBytes, contentFingerprint) {
@@ -7489,7 +7675,7 @@ function partitionFilesForBuckets(buckets, contentFingerprint) {
7489
7675
  section.file.originalLines
7490
7676
  );
7491
7677
  if (shrunk.isTruncated) {
7492
- applyTruncatedContent(section.file, shrunk.content, "part-budget");
7678
+ applyTruncatedContent(section.file, shrunk.content, "part-budget", shrunk.cutMidLine);
7493
7679
  section.text = renderFileSection(section.file);
7494
7680
  section.byteSize = Buffer.byteLength(section.text, "utf8");
7495
7681
  assemblies.delete(group);
@@ -7625,7 +7811,7 @@ function prepareSection(file, sectionBudget, partBudget) {
7625
7811
  file.originalLines
7626
7812
  );
7627
7813
  if (!truncated.isTruncated) return;
7628
- applyTruncatedContent(file, truncated.content, "part-budget");
7814
+ applyTruncatedContent(file, truncated.content, "part-budget", truncated.cutMidLine);
7629
7815
  text2 = renderFileSection(file);
7630
7816
  byteSize = Buffer.byteLength(text2, "utf8");
7631
7817
  };
@@ -7692,7 +7878,7 @@ function fenceIsOpen(text2, fence) {
7692
7878
  return open;
7693
7879
  }
7694
7880
  var OMISSION_NOTICE_LINE = /^\.\.\. \[\d+ lines omitted: [^\]]*\] \.\.\.$/;
7695
- function applyTruncatedContent(file, content, reason) {
7881
+ function applyTruncatedContent(file, content, reason, cutMidLine = false) {
7696
7882
  const keptLines = content.split("\n").filter(
7697
7883
  (line) => !OMISSION_NOTICE_LINE.test(line) && line.trim() !== SECTION_TRUNCATION_NOTICE
7698
7884
  ).length;
@@ -7705,22 +7891,26 @@ function applyTruncatedContent(file, content, reason) {
7705
7891
  const noticeAt = lines.findIndex(
7706
7892
  (line) => OMISSION_NOTICE_LINE.test(line) || line.trim() === SECTION_TRUNCATION_NOTICE
7707
7893
  );
7708
- if (noticeAt >= 0 && priorGap !== void 0 && priorGap.length === 1 && priorGap[0] !== void 0) {
7894
+ if (noticeAt >= 0 && priorGap !== void 0 && priorGap.length >= 1 && priorGap[0] !== void 0) {
7709
7895
  const headKept = lines.slice(0, noticeAt).filter((line) => !OMISSION_NOTICE_LINE.test(line) && line.trim() !== SECTION_TRUNCATION_NOTICE).length;
7710
7896
  const tailKept = lines.slice(noticeAt + 1).filter((line) => !OMISSION_NOTICE_LINE.test(line) && line.trim() !== SECTION_TRUNCATION_NOTICE).length;
7711
7897
  const gapEnd = priorGap[0][1];
7712
- const headStart = Math.min(file.originalLines, headKept + 1);
7898
+ const headStart = Math.min(
7899
+ file.originalLines,
7900
+ cutMidLine ? Math.max(1, headKept) : headKept + 1
7901
+ );
7713
7902
  const ranges = [];
7714
7903
  if (tailKept === 0) {
7715
7904
  ranges.push([headStart, file.originalLines]);
7716
7905
  } else {
7717
7906
  if (headStart <= gapEnd) ranges.push([headStart, gapEnd]);
7718
- const tailStart = gapEnd + tailKept + 1;
7907
+ const tailStart = cutMidLine ? gapEnd + tailKept : gapEnd + tailKept + 1;
7719
7908
  if (tailStart <= file.originalLines) ranges.push([tailStart, file.originalLines]);
7720
7909
  }
7721
7910
  file.omittedRanges = ranges.length === 0 ? [[file.originalLines, file.originalLines]] : ranges;
7722
7911
  } else {
7723
- file.omittedRanges = keptLines >= file.originalLines ? file.originalLines > 0 ? [[file.originalLines, file.originalLines]] : [] : [[keptLines + 1, file.originalLines]];
7912
+ const firstOmitted = cutMidLine ? Math.max(1, keptLines) : keptLines + 1;
7913
+ file.omittedRanges = keptLines >= file.originalLines ? file.originalLines > 0 ? [[file.originalLines, file.originalLines]] : [] : [[Math.min(firstOmitted, file.originalLines), file.originalLines]];
7724
7914
  }
7725
7915
  file.includedBytes = Buffer.byteLength(content, "utf8");
7726
7916
  file.includedLines = countBodyLines(content);
@@ -8097,8 +8287,8 @@ var MAX_CONFIG_BYTES = 4 * 1024 * 1024;
8097
8287
  var MAX_PACKAGE_BYTES = 1 * 1024 * 1024;
8098
8288
  function repositoryRelative(cwd, target) {
8099
8289
  const absolute = path7__namespace.isAbsolute(target) ? target : path7__namespace.resolve(cwd, target);
8100
- const relative18 = path7__namespace.relative(cwd, absolute).replace(/\\/g, "/");
8101
- return relative18.length === 0 || relative18 !== ".." && !relative18.startsWith(".." + path7__namespace.sep) && !relative18.startsWith("../") && !path7__namespace.isAbsolute(relative18) ? relative18 : null;
8290
+ const relative20 = path7__namespace.relative(cwd, absolute).replace(/\\/g, "/");
8291
+ return relative20.length === 0 || relative20 !== ".." && !relative20.startsWith(".." + path7__namespace.sep) && !relative20.startsWith("../") && !path7__namespace.isAbsolute(relative20) ? relative20 : null;
8102
8292
  }
8103
8293
  function insideCwd(cwd, file) {
8104
8294
  return repositoryRelative(cwd, file);
@@ -8154,8 +8344,8 @@ function parseImports(value) {
8154
8344
  return Object.entries(record).filter(([key]) => key.startsWith("#")).map(([pattern, target]) => ({ pattern, targets: targetList(target) }));
8155
8345
  }
8156
8346
  function readPackageJson(cwd, packageDir) {
8157
- const relative18 = packageDir.length === 0 ? "package.json" : packageDir + "/package.json";
8158
- const parsed = asRecord(readJson(cwd, relative18, MAX_PACKAGE_BYTES));
8347
+ const relative20 = packageDir.length === 0 ? "package.json" : packageDir + "/package.json";
8348
+ const parsed = asRecord(readJson(cwd, relative20, MAX_PACKAGE_BYTES));
8159
8349
  if (parsed === null) return null;
8160
8350
  const exportsMap = parseExports(parsed.exports);
8161
8351
  if (exportsMap.length === 0) {
@@ -8197,18 +8387,18 @@ function parsePnpmWorkspace(cwd) {
8197
8387
  }
8198
8388
  function listChildDirectories(cwd, relativeDir) {
8199
8389
  const absolute = path7__namespace.resolve(cwd, relativeDir);
8200
- const relative18 = repositoryRelative(cwd, absolute);
8201
- if (relative18 === null) return [];
8390
+ const relative20 = repositoryRelative(cwd, absolute);
8391
+ if (relative20 === null) return [];
8202
8392
  let entries;
8203
8393
  try {
8204
- entries = fs28__namespace.readdirSync(absolute === cwd ? cwd : absolute, { withFileTypes: true });
8394
+ entries = fs29__namespace.readdirSync(absolute === cwd ? cwd : absolute, { withFileTypes: true });
8205
8395
  } catch {
8206
8396
  return [];
8207
8397
  }
8208
8398
  const out = [];
8209
8399
  for (const entry of entries) {
8210
8400
  if (!entry.isDirectory()) continue;
8211
- const child = relative18.length === 0 ? entry.name : relative18 + "/" + entry.name;
8401
+ const child = relative20.length === 0 ? entry.name : relative20 + "/" + entry.name;
8212
8402
  if (child.split("/").includes("node_modules")) continue;
8213
8403
  out.push(child);
8214
8404
  }
@@ -8221,15 +8411,15 @@ function expandWorkspacePattern(cwd, rawPattern) {
8221
8411
  if (pattern.endsWith("/*")) {
8222
8412
  const base = pattern.slice(0, -2);
8223
8413
  return listChildDirectories(cwd, base).filter(
8224
- (dir) => fs28__namespace.existsSync(path7__namespace.join(cwd, dir, "package.json"))
8414
+ (dir) => fs29__namespace.existsSync(path7__namespace.join(cwd, dir, "package.json"))
8225
8415
  );
8226
8416
  }
8227
8417
  if (pattern.includes("*")) {
8228
8418
  const base = path7__namespace.posix.dirname(pattern);
8229
8419
  const direct = listChildDirectories(cwd, base === "." ? "" : base);
8230
- return direct.filter((dir) => fs28__namespace.existsSync(path7__namespace.join(cwd, dir, "package.json")));
8420
+ return direct.filter((dir) => fs29__namespace.existsSync(path7__namespace.join(cwd, dir, "package.json")));
8231
8421
  }
8232
- return fs28__namespace.existsSync(path7__namespace.join(cwd, pattern, "package.json")) ? [pattern] : [];
8422
+ return fs29__namespace.existsSync(path7__namespace.join(cwd, pattern, "package.json")) ? [pattern] : [];
8233
8423
  }
8234
8424
  function workspaceDirectories(cwd, files) {
8235
8425
  const root = asRecord(readJson(cwd, "package.json", MAX_PACKAGE_BYTES));
@@ -8328,7 +8518,7 @@ function configCandidates(cwd, files, packageDirs) {
8328
8518
  for (const dir of packageDirs) {
8329
8519
  for (const base of ["tsconfig.json", "jsconfig.json"]) {
8330
8520
  const candidate = dir.length === 0 ? base : dir + "/" + base;
8331
- if (fs28__namespace.existsSync(path7__namespace.join(cwd, candidate))) candidates.add(candidate);
8521
+ if (fs29__namespace.existsSync(path7__namespace.join(cwd, candidate))) candidates.add(candidate);
8332
8522
  }
8333
8523
  }
8334
8524
  for (const relativePath of files) {
@@ -8337,14 +8527,14 @@ function configCandidates(cwd, files, packageDirs) {
8337
8527
  while (dir !== "." && dir.length > 0) {
8338
8528
  for (const base of ["tsconfig.json", "jsconfig.json"]) {
8339
8529
  const candidate = dir + "/" + base;
8340
- if (fs28__namespace.existsSync(path7__namespace.join(cwd, candidate))) candidates.add(candidate);
8530
+ if (fs29__namespace.existsSync(path7__namespace.join(cwd, candidate))) candidates.add(candidate);
8341
8531
  }
8342
8532
  dir = path7__namespace.posix.dirname(dir);
8343
8533
  }
8344
8534
  }
8345
8535
  return [...candidates].filter((relativePath) => {
8346
- if (!fs28__namespace.existsSync(path7__namespace.join(cwd, relativePath))) return false;
8347
- const stat = fs28__namespace.lstatSync(path7__namespace.join(cwd, relativePath));
8536
+ if (!fs29__namespace.existsSync(path7__namespace.join(cwd, relativePath))) return false;
8537
+ const stat = fs29__namespace.lstatSync(path7__namespace.join(cwd, relativePath));
8348
8538
  return stat.isFile() && !stat.isSymbolicLink();
8349
8539
  }).slice(0, MAX_CONFIG_FILES * 2);
8350
8540
  }
@@ -8767,12 +8957,12 @@ function planForQuestion(manifest, question, options = {}) {
8767
8957
  const scored = [];
8768
8958
  for (const file of manifest.files) {
8769
8959
  if (isTest(file) && !wantsTests) continue;
8770
- const path31 = file.relativePath.toLowerCase();
8771
- const words = path31.split(/[^a-z0-9_]+/).filter((word) => word.length >= 3);
8960
+ const path32 = file.relativePath.toLowerCase();
8961
+ const words = path32.split(/[^a-z0-9_]+/).filter((word) => word.length >= 3);
8772
8962
  let score = 0;
8773
8963
  const reasons = [];
8774
8964
  for (const term of terms) {
8775
- if (path31.includes(term)) {
8965
+ if (path32.includes(term)) {
8776
8966
  score += 8;
8777
8967
  reasons.push("path:" + term);
8778
8968
  continue;
@@ -9065,20 +9255,103 @@ function diffSectionPaths(body) {
9065
9255
  continue;
9066
9256
  }
9067
9257
  if (line.startsWith("+++ ")) {
9068
- const path31 = wholeLinePath(line.slice(4), "b/");
9069
- if (path31 !== null) paths.add(path31);
9258
+ const path32 = wholeLinePath(line.slice(4), "b/");
9259
+ if (path32 !== null) paths.add(path32);
9070
9260
  continue;
9071
9261
  }
9072
9262
  if (line.startsWith("--- ")) {
9073
- const path31 = wholeLinePath(line.slice(4), "a/");
9074
- if (path31 !== null) paths.add(path31);
9263
+ const path32 = wholeLinePath(line.slice(4), "a/");
9264
+ if (path32 !== null) paths.add(path32);
9075
9265
  }
9076
9266
  }
9077
9267
  if (paths.size === 0 && header2 !== null) {
9078
- for (const path31 of headerPaths(header2)) paths.add(path31);
9268
+ for (const path32 of headerPaths(header2)) paths.add(path32);
9079
9269
  }
9080
9270
  return [...paths];
9081
9271
  }
9272
+ function lineRedactions(text2, rules, relativePath) {
9273
+ if (text2 === null) return null;
9274
+ const redacted = scanAndRedactSecrets(text2, rules, relativePath).redacted;
9275
+ if (redacted === text2) return null;
9276
+ const before = text2.split("\n");
9277
+ const after = redacted.split("\n");
9278
+ if (before.length !== after.length) return null;
9279
+ const changed = /* @__PURE__ */ new Map();
9280
+ for (let index = 0; index < before.length; index += 1) {
9281
+ if (before[index] !== after[index]) changed.set(index + 1, after[index]);
9282
+ }
9283
+ return changed.size === 0 ? null : changed;
9284
+ }
9285
+ function fullFileRedactions(cwd, newPath, oldPath, rules, readOld) {
9286
+ const inside2 = (relativePath) => {
9287
+ const absolute2 = path7__namespace.resolve(cwd, relativePath);
9288
+ const relative20 = path7__namespace.relative(path7__namespace.resolve(cwd), absolute2);
9289
+ if (relative20 === "" || relative20 === ".." || relative20.startsWith(".." + path7__namespace.sep) || path7__namespace.isAbsolute(relative20)) {
9290
+ return null;
9291
+ }
9292
+ return absolute2;
9293
+ };
9294
+ let newText = null;
9295
+ const absolute = inside2(newPath);
9296
+ if (absolute !== null) {
9297
+ try {
9298
+ if (fs29__namespace.lstatSync(absolute).isFile()) newText = fs29__namespace.readFileSync(absolute, "utf8");
9299
+ } catch {
9300
+ newText = null;
9301
+ }
9302
+ }
9303
+ let oldText = null;
9304
+ if (readOld !== void 0) {
9305
+ try {
9306
+ oldText = readOld(oldPath);
9307
+ } catch {
9308
+ oldText = null;
9309
+ }
9310
+ }
9311
+ const byNewLine = lineRedactions(newText, rules, newPath);
9312
+ const byOldLine = lineRedactions(oldText, rules, oldPath);
9313
+ if (byNewLine === null && byOldLine === null) return null;
9314
+ return { byNewLine: byNewLine ?? /* @__PURE__ */ new Map(), byOldLine: byOldLine ?? /* @__PURE__ */ new Map() };
9315
+ }
9316
+ function maskHunkAgainstFullFile(section, sourcePath, oldPath, cwd, rules, readOld) {
9317
+ const redactions = fullFileRedactions(cwd, sourcePath, oldPath, rules, readOld);
9318
+ if (redactions === null) return section;
9319
+ const lines = section.split("\n");
9320
+ let oldLine = 0;
9321
+ let newLine = 0;
9322
+ let inHunk = false;
9323
+ for (let index = 0; index < lines.length; index += 1) {
9324
+ const line = lines[index];
9325
+ if (line.startsWith("@@ ")) {
9326
+ const header2 = /^@@ -(\d+)(?:,\d+)? \+(\d+)/.exec(line);
9327
+ if (header2 !== null) {
9328
+ oldLine = Number(header2[1]);
9329
+ newLine = Number(header2[2]);
9330
+ inHunk = true;
9331
+ }
9332
+ continue;
9333
+ }
9334
+ if (!inHunk) continue;
9335
+ const prefix = line[0];
9336
+ if (prefix === "+") {
9337
+ const replacement = redactions.byNewLine.get(newLine);
9338
+ if (replacement !== void 0) lines[index] = prefix + replacement;
9339
+ newLine += 1;
9340
+ } else if (prefix === "-") {
9341
+ const replacement = redactions.byOldLine.get(oldLine);
9342
+ if (replacement !== void 0) lines[index] = prefix + replacement;
9343
+ oldLine += 1;
9344
+ } else if (prefix === " ") {
9345
+ const added = redactions.byNewLine.get(newLine);
9346
+ const removed = redactions.byOldLine.get(oldLine);
9347
+ const replacement = added ?? removed;
9348
+ if (replacement !== void 0) lines[index] = prefix + replacement;
9349
+ oldLine += 1;
9350
+ newLine += 1;
9351
+ }
9352
+ }
9353
+ return lines.join("\n");
9354
+ }
9082
9355
  function generateDiffReport(cwd, options = {}) {
9083
9356
  if (!isGitRepository(cwd)) return null;
9084
9357
  const maxBytes = options.maxBytes ?? 200 * 1024;
@@ -9087,12 +9360,20 @@ function generateDiffReport(cwd, options = {}) {
9087
9360
  let omittedSensitive = 0;
9088
9361
  let omittedUnparseable = 0;
9089
9362
  const commands = [
9090
- ["Unstaged", ["diff", "--no-color", "--no-ext-diff", "--no-textconv"]],
9091
- ["Staged", ["diff", "--cached", "--no-color", "--no-ext-diff", "--no-textconv"]]
9363
+ ["Unstaged", ["diff", "--no-color", "--no-ext-diff", "--no-textconv", "--relative"], ":"],
9364
+ [
9365
+ "Staged",
9366
+ ["diff", "--cached", "--no-color", "--no-ext-diff", "--no-textconv", "--relative"],
9367
+ "HEAD"
9368
+ ]
9092
9369
  ];
9093
- for (const [title, args] of commands) {
9370
+ for (const [title, args, oldRef] of commands) {
9094
9371
  const result = runGit(cwd, args);
9095
9372
  if (!result.ok || result.out.trim() === "") continue;
9373
+ const readOld = (relativePath) => {
9374
+ const shown = runGit(cwd, ["show", oldRef + relativePath]);
9375
+ return shown.ok ? shown.out : null;
9376
+ };
9096
9377
  const rawSections = result.out.split(/(?=^diff --git )/m).filter((section) => section.length > 0);
9097
9378
  for (const rawSection of rawSections) {
9098
9379
  const paths2 = diffSectionPaths(rawSection);
@@ -9100,7 +9381,9 @@ function generateDiffReport(cwd, options = {}) {
9100
9381
  omittedUnparseable += 1;
9101
9382
  continue;
9102
9383
  }
9103
- const blocked = paths2.some((path31) => isSensitivePath(path31) || options.excluded?.(path31) === true);
9384
+ const blocked = paths2.some(
9385
+ (path32) => isSensitivePath(path32) || findSecretInPath(path32, options.secretRules) !== null || options.excluded?.(path32) === true
9386
+ );
9104
9387
  if (blocked) {
9105
9388
  omittedSensitive += 1;
9106
9389
  continue;
@@ -9111,7 +9394,7 @@ function generateDiffReport(cwd, options = {}) {
9111
9394
  truncated = true;
9112
9395
  break;
9113
9396
  }
9114
- const sourcePath = paths2[0] ?? "reports/diff.md";
9397
+ const sourcePath = paths2[paths2.length - 1] ?? "reports/diff.md";
9115
9398
  const diffLines = rawSection.split("\n");
9116
9399
  const diffPrefixes = diffLines.map((line) => /^[+\- ]/.test(line) ? line[0] : "");
9117
9400
  const logicalLines = diffLines.map(
@@ -9123,7 +9406,15 @@ function generateDiffReport(cwd, options = {}) {
9123
9406
  sourcePath
9124
9407
  ).redacted;
9125
9408
  const logicalRedactedLines = logicalRedacted.split("\n");
9126
- const redactedSection = logicalRedactedLines.length === diffLines.length ? logicalRedactedLines.map((line, index) => diffPrefixes[index] + line).join("\n") : scanAndRedactSecrets(rawSection, options.secretRules ?? [], sourcePath).redacted;
9409
+ const oldPath = paths2.length > 1 ? paths2[0] : sourcePath;
9410
+ const redactedSection = maskHunkAgainstFullFile(
9411
+ logicalRedactedLines.length === diffLines.length ? logicalRedactedLines.map((line, index) => diffPrefixes[index] + line).join("\n") : scanAndRedactSecrets(rawSection, options.secretRules ?? [], sourcePath).redacted,
9412
+ sourcePath,
9413
+ oldPath,
9414
+ cwd,
9415
+ options.secretRules ?? [],
9416
+ readOld
9417
+ );
9127
9418
  const chunk = truncateToBytes(redactedSection, remaining);
9128
9419
  if (chunk.isTruncated) truncated = true;
9129
9420
  const fence = fenceForText(chunk.content, 3);
@@ -9135,8 +9426,8 @@ function generateDiffReport(cwd, options = {}) {
9135
9426
  }
9136
9427
  if (sections.length === 0) return null;
9137
9428
  const paths = /* @__PURE__ */ new Set();
9138
- for (const section of sections) for (const path31 of diffSectionPaths(section)) paths.add(path31);
9139
- const joined = [
9429
+ for (const section of sections) for (const path32 of diffSectionPaths(section)) paths.add(path32);
9430
+ const header2 = [
9140
9431
  "# Uncommitted changes",
9141
9432
  "",
9142
9433
  "Generated from the repository at the moment the snapshot was written. Untracked files are not",
@@ -9149,12 +9440,11 @@ function generateDiffReport(cwd, options = {}) {
9149
9440
  ...omittedUnparseable > 0 ? [
9150
9441
  "> " + omittedUnparseable + " file section(s) omitted: their diff header could not be attributed to a path, so the sensitive-path filter could not run.",
9151
9442
  ""
9152
- ] : [],
9153
- ...sections,
9154
- ...truncated ? ["", "> Truncated at " + maxBytes + " bytes. Run git diff for the rest."] : [],
9155
- ""
9443
+ ] : []
9156
9444
  ].join("\n");
9157
- const text2 = scanAndRedactSecrets(joined, options.secretRules ?? [], "reports/diff.md").redacted;
9445
+ const safeHeader = scanAndRedactSecrets(header2, options.secretRules ?? [], "reports/diff.md").redacted;
9446
+ const footer = truncated ? ["", "> Truncated at " + maxBytes + " bytes. Run git diff for the rest."] : [];
9447
+ const text2 = [safeHeader, ...sections, ...footer, ""].join("\n");
9158
9448
  return { text: text2, bytes: Buffer.byteLength(text2, "utf8"), truncated, paths: [...paths].sort() };
9159
9449
  }
9160
9450
  function generateLogReport(cwd, options = {}) {
@@ -9434,7 +9724,7 @@ function systemSection(manifest, code, brief, escape, sawManifest) {
9434
9724
  " A change here reaches the most call sites; read it before judging anything that uses it."
9435
9725
  );
9436
9726
  }
9437
- const entryPoints = manifest.files.map((file) => file.relativePath).filter((path31) => ENTRY_POINT.test(path31)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
9727
+ const entryPoints = manifest.files.map((file) => file.relativePath).filter((path32) => ENTRY_POINT.test(path32)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
9438
9728
  out.push(
9439
9729
  entryPoints.length > 0 ? "- Entry points by convention: " + entryPoints.map(code).join(", ") + "." : "- No entry point was identifiable by name. The largest files below are where execution"
9440
9730
  );
@@ -9669,8 +9959,8 @@ function ownerNotesSection(brief, code, text2) {
9669
9959
  }
9670
9960
  return out;
9671
9961
  }
9672
- function ownerBlock(body, path31, code, escape) {
9673
- return ["> Written by the project owner in " + code(path31) + ", not generated.", "", escape(body)];
9962
+ function ownerBlock(body, path32, code, escape) {
9963
+ return ["> Written by the project owner in " + code(path32) + ", not generated.", "", escape(body)];
9674
9964
  }
9675
9965
  function snapshotSection(manifest, code, partsWritten) {
9676
9966
  const out = ["## This snapshot", ""];
@@ -10102,6 +10392,7 @@ function resolveDiffChangedLines(cwd, ref, files) {
10102
10392
  "--no-color",
10103
10393
  "--no-ext-diff",
10104
10394
  "--no-renames",
10395
+ "--relative",
10105
10396
  base,
10106
10397
  ...files === void 0 || files.length === 0 ? [] : ["--", ...files]
10107
10398
  ];
@@ -10129,8 +10420,8 @@ function resolveDiffChangedLines(cwd, ref, files) {
10129
10420
  continue;
10130
10421
  }
10131
10422
  const withoutPrefix = raw.startsWith("b/") ? raw.slice(2) : raw;
10132
- const path31 = withoutPrefix.split(" ")[0];
10133
- current = path31.length > 0 ? path31 : null;
10423
+ const path32 = withoutPrefix.split(" ")[0];
10424
+ current = path32.length > 0 ? path32 : null;
10134
10425
  if (current !== null && !ranges.has(current)) ranges.set(current, []);
10135
10426
  continue;
10136
10427
  }
@@ -10159,11 +10450,11 @@ function resolveChangedScope(cwd, request) {
10159
10450
  if (request.changedSince !== void 0) {
10160
10451
  assertUsableRef(request.changedSince);
10161
10452
  if (request.changedSince === "HEAD" && !hasHeadCommit(cwd)) {
10162
- for (const path31 of gitPaths(cwd, ["ls-files", "--cached", "-z", "--"])) {
10163
- paths.add(path31);
10453
+ for (const path32 of gitPaths(cwd, ["ls-files", "--cached", "-z", "--"])) {
10454
+ paths.add(path32);
10164
10455
  }
10165
- for (const path31 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
10166
- paths.add(path31);
10456
+ for (const path32 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
10457
+ paths.add(path32);
10167
10458
  }
10168
10459
  descriptions.push("changed since HEAD (unborn)");
10169
10460
  } else {
@@ -10176,7 +10467,7 @@ function resolveChangedScope(cwd, request) {
10176
10467
  );
10177
10468
  }
10178
10469
  if (base !== null) {
10179
- for (const path31 of gitPaths(cwd, [
10470
+ for (const path32 of gitPaths(cwd, [
10180
10471
  "-c",
10181
10472
  "core.quotepath=false",
10182
10473
  "-c",
@@ -10193,17 +10484,17 @@ function resolveChangedScope(cwd, request) {
10193
10484
  base,
10194
10485
  "--"
10195
10486
  ])) {
10196
- paths.add(path31);
10487
+ paths.add(path32);
10197
10488
  }
10198
10489
  }
10199
- for (const path31 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
10200
- paths.add(path31);
10490
+ for (const path32 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
10491
+ paths.add(path32);
10201
10492
  }
10202
10493
  descriptions.push(`changed since ${request.changedSince}`);
10203
10494
  }
10204
10495
  }
10205
10496
  if (request.staged === true) {
10206
- for (const path31 of gitPaths(cwd, [
10497
+ for (const path32 of gitPaths(cwd, [
10207
10498
  "-c",
10208
10499
  "core.quotepath=false",
10209
10500
  "diff",
@@ -10214,10 +10505,10 @@ function resolveChangedScope(cwd, request) {
10214
10505
  "--no-renames",
10215
10506
  "--"
10216
10507
  ])) {
10217
- paths.add(path31);
10218
- stagedPaths.add(path31);
10508
+ paths.add(path32);
10509
+ stagedPaths.add(path32);
10219
10510
  }
10220
- for (const path31 of gitPaths(cwd, [
10511
+ for (const path32 of gitPaths(cwd, [
10221
10512
  "-c",
10222
10513
  "core.quotepath=false",
10223
10514
  "diff",
@@ -10229,7 +10520,7 @@ function resolveChangedScope(cwd, request) {
10229
10520
  "--diff-filter=D",
10230
10521
  "--"
10231
10522
  ])) {
10232
- deletedPaths.add(path31);
10523
+ deletedPaths.add(path32);
10233
10524
  }
10234
10525
  descriptions.push("staged");
10235
10526
  }
@@ -10246,8 +10537,8 @@ function readProjectOverview(cwd) {
10246
10537
  releases: readReleases(cwd)
10247
10538
  };
10248
10539
  }
10249
- function readText(cwd, relative18) {
10250
- const read = readConfinedText(cwd, relative18);
10540
+ function readText(cwd, relative20) {
10541
+ const read = readConfinedText(cwd, relative20);
10251
10542
  return read.ok ? read.text : null;
10252
10543
  }
10253
10544
  function readDescription(cwd) {
@@ -10382,7 +10673,7 @@ function findStagingDirectory(config) {
10382
10673
  const tmpDir = path7__namespace.resolve(config.cwd, config.tmpDir);
10383
10674
  let entries;
10384
10675
  try {
10385
- entries = fs28__namespace.readdirSync(tmpDir);
10676
+ entries = fs29__namespace.readdirSync(tmpDir);
10386
10677
  } catch {
10387
10678
  return null;
10388
10679
  }
@@ -10395,8 +10686,8 @@ function describeMissingManifest(config, manifestPath) {
10395
10686
  const markerPath = path7__namespace.join(outDir, ".codebase-snapshot");
10396
10687
  let marker2 = null;
10397
10688
  try {
10398
- if (fs28__namespace.existsSync(markerPath)) {
10399
- const parsed = JSON.parse(fs28__namespace.readFileSync(markerPath, "utf8"));
10689
+ if (fs29__namespace.existsSync(markerPath)) {
10690
+ const parsed = JSON.parse(fs29__namespace.readFileSync(markerPath, "utf8"));
10400
10691
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
10401
10692
  marker2 = parsed;
10402
10693
  }
@@ -10433,11 +10724,11 @@ function sha256Hex(buffer) {
10433
10724
  function wouldNowBeIncluded(cwd, relativePath) {
10434
10725
  const absolutePath = path7__namespace.join(cwd, relativePath);
10435
10726
  try {
10436
- const stats = fs28__namespace.statSync(absolutePath);
10727
+ const stats = fs29__namespace.statSync(absolutePath);
10437
10728
  if (!stats.isFile()) return false;
10438
10729
  if (isBinaryExtension(absolutePath)) return false;
10439
10730
  if (stats.size > BINARY_SCAN_BYTES && isBinaryFile(absolutePath)) return false;
10440
- return !decodeText(fs28__namespace.readFileSync(absolutePath)).binary;
10731
+ return !decodeText(fs29__namespace.readFileSync(absolutePath)).binary;
10441
10732
  } catch {
10442
10733
  return false;
10443
10734
  }
@@ -10577,8 +10868,8 @@ function describeManifestShapeProblem(value) {
10577
10868
  }
10578
10869
  }
10579
10870
  const lines = fields.lines;
10580
- if (fields.includedLines > lines) {
10581
- return 'an "incomplete" entry "includedLines" exceeds its "lines"';
10871
+ if (fields.includedLines > lines + 1) {
10872
+ return 'an "incomplete" entry "includedLines" exceeds its "lines" by more than the notice line';
10582
10873
  }
10583
10874
  const ranges = fields.omittedRanges;
10584
10875
  if (!Array.isArray(ranges)) return 'an "incomplete" entry has no "omittedRanges" array';
@@ -10712,7 +11003,7 @@ function validateSnapshot(configInput) {
10712
11003
  assertUsableConfigInput(configInput);
10713
11004
  const config = isResolvedConfig(configInput) ? normalizeResolvedConfig(configInput) : resolveConfig(configInput);
10714
11005
  const manifestPath = path7__namespace.resolve(config.cwd, config.outDir, "manifest.json");
10715
- if (!fs28__namespace.existsSync(manifestPath)) {
11006
+ if (!fs29__namespace.existsSync(manifestPath)) {
10716
11007
  return {
10717
11008
  valid: false,
10718
11009
  manifestPresent: false,
@@ -10906,7 +11197,7 @@ function validateSnapshot(configInput) {
10906
11197
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
10907
11198
  (directory) => path7__namespace.relative(config.cwd, path7__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
10908
11199
  ).filter(
10909
- (relative18) => relative18.length > 0 && relative18 !== ".." && !relative18.startsWith(`..${path7__namespace.sep}`) && !relative18.startsWith("../") && !path7__namespace.isAbsolute(relative18)
11200
+ (relative20) => relative20.length > 0 && relative20 !== ".." && !relative20.startsWith(`..${path7__namespace.sep}`) && !relative20.startsWith("../") && !path7__namespace.isAbsolute(relative20)
10910
11201
  )
10911
11202
  });
10912
11203
  const discovered = new Set(collection.files);
@@ -10926,7 +11217,7 @@ function validateSnapshot(configInput) {
10926
11217
  const baseHash = deltaBaseHashes.get(diskFile);
10927
11218
  if (baseHash !== void 0) {
10928
11219
  try {
10929
- const diskHash2 = sha256Hex(fs28__namespace.readFileSync(path7__namespace.join(config.cwd, diskFile)));
11220
+ const diskHash2 = sha256Hex(fs29__namespace.readFileSync(path7__namespace.join(config.cwd, diskFile)));
10930
11221
  if (diskHash2 !== baseHash) drift.missingInSnapshot.push(diskFile);
10931
11222
  } catch {
10932
11223
  drift.unreadable.push(diskFile);
@@ -10948,7 +11239,7 @@ function validateSnapshot(configInput) {
10948
11239
  let diskHash;
10949
11240
  try {
10950
11241
  const stagedBlob = recordedStaged && stagedScope?.has(diskFile) === true ? readStagedBlob(config.cwd, diskFile) : null;
10951
- diskHash = sha256Hex(stagedBlob ?? fs28__namespace.readFileSync(path7__namespace.join(config.cwd, diskFile)));
11242
+ diskHash = sha256Hex(stagedBlob ?? fs29__namespace.readFileSync(path7__namespace.join(config.cwd, diskFile)));
10952
11243
  } catch (err) {
10953
11244
  if (err.code === "ENOENT") {
10954
11245
  drift.missingOnDisk.push(diskFile);
@@ -10970,7 +11261,7 @@ function validateSnapshot(configInput) {
10970
11261
  }
10971
11262
  let stats = null;
10972
11263
  try {
10973
- stats = fs28__namespace.lstatSync(full);
11264
+ stats = fs29__namespace.lstatSync(full);
10974
11265
  } catch {
10975
11266
  stats = null;
10976
11267
  }
@@ -11004,7 +11295,7 @@ function validateSnapshot(configInput) {
11004
11295
  let statFailure = null;
11005
11296
  let stats = null;
11006
11297
  try {
11007
- stats = fs28__namespace.lstatSync(confined);
11298
+ stats = fs29__namespace.lstatSync(confined);
11008
11299
  } catch (err) {
11009
11300
  statFailure = err;
11010
11301
  }
@@ -11458,9 +11749,9 @@ function validateSnapshot(configInput) {
11458
11749
  const target = match[1].split("#")[0];
11459
11750
  if (target.length === 0 || /^[a-z][a-z0-9+.-]*:/i.test(target)) continue;
11460
11751
  const resolved = path7__namespace.resolve(snapshotDir, "reports", target);
11461
- const relative18 = path7__namespace.relative(snapshotDir, resolved);
11462
- const linkTarget = relative18.split(path7__namespace.sep).join("/");
11463
- const escapes = relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || relative18.startsWith("../") || path7__namespace.isAbsolute(relative18);
11752
+ const relative20 = path7__namespace.relative(snapshotDir, resolved);
11753
+ const linkTarget = relative20.split(path7__namespace.sep).join("/");
11754
+ const escapes = relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || relative20.startsWith("../") || path7__namespace.isAbsolute(relative20);
11464
11755
  const partsRelative = path7__namespace.relative(path7__namespace.join(snapshotDir, "parts"), resolved);
11465
11756
  const pointsIntoParts = partsRelative === "" || partsRelative !== ".." && !partsRelative.startsWith(`..${path7__namespace.sep}`) && !partsRelative.startsWith("../") && !path7__namespace.isAbsolute(partsRelative);
11466
11757
  const expectedToBeAbsent = !config.artifacts.parts && pointsIntoParts;
@@ -11522,7 +11813,7 @@ function validateSnapshot(configInput) {
11522
11813
  );
11523
11814
  }
11524
11815
  const signaturePath = path7__namespace.join(path7__namespace.dirname(manifestPath), "signature.json");
11525
- if (fs28__namespace.existsSync(signaturePath)) {
11816
+ if (fs29__namespace.existsSync(signaturePath)) {
11526
11817
  const outcome = verifySnapshotSignature(path7__namespace.dirname(manifestPath));
11527
11818
  if (!outcome.ok) errors.push("signature: " + outcome.reason + ".");
11528
11819
  }
@@ -11584,7 +11875,6 @@ function parseIPv6(value) {
11584
11875
  const left = halves[0] === "" ? [] : halves[0].split(":");
11585
11876
  const right = halves.length === 2 && halves[1] !== "" ? halves[1].split(":") : [];
11586
11877
  const groups = [...left, ...right];
11587
- if (halves.length === 1 && groups.length !== 8) return null;
11588
11878
  if (halves.length === 2 && groups.length > 7) return null;
11589
11879
  const expand = (group) => {
11590
11880
  if (group.includes(".")) {
@@ -11637,7 +11927,7 @@ function isPrivateIPv6(groups) {
11637
11927
  if (first === 100 && second === 65435 && third === 0 && fourth === 0 && fifth === 0 && sixth === 0) {
11638
11928
  return mapped(6);
11639
11929
  }
11640
- if (first === 100 && second === 65435 && third === 1) return mapped(6);
11930
+ if (first === 100 && second === 65435 && third === 1) return true;
11641
11931
  if (first === 8194) return mapped(1);
11642
11932
  return false;
11643
11933
  }
@@ -11725,7 +12015,7 @@ async function assertPublicHost(host, allowPrivate) {
11725
12015
  }
11726
12016
  }
11727
12017
  function runGitAsync(args, options) {
11728
- return new Promise((resolve20) => {
12018
+ return new Promise((resolve21) => {
11729
12019
  let child;
11730
12020
  try {
11731
12021
  child = childProcess.spawn("git", args, {
@@ -11734,7 +12024,7 @@ function runGitAsync(args, options) {
11734
12024
  stdio: ["ignore", "pipe", "pipe"]
11735
12025
  });
11736
12026
  } catch (error) {
11737
- resolve20({
12027
+ resolve21({
11738
12028
  status: null,
11739
12029
  stdout: "",
11740
12030
  stderr: "",
@@ -11759,7 +12049,7 @@ function runGitAsync(args, options) {
11759
12049
  settled = true;
11760
12050
  if (timer !== void 0) clearTimeout(timer);
11761
12051
  if (killTimer !== void 0) clearTimeout(killTimer);
11762
- resolve20({ status, stdout, stderr, timedOut, error });
12052
+ resolve21({ status, stdout, stderr, timedOut, error });
11763
12053
  };
11764
12054
  child.stdout?.on("data", (chunk) => {
11765
12055
  stdout = append(stdout, chunk);
@@ -11807,8 +12097,8 @@ async function cloneRepository(source, options) {
11807
12097
  const log = options.log ?? (() => {
11808
12098
  });
11809
12099
  const dest = path7__namespace.resolve(options.dest);
11810
- fs28__namespace.rmSync(dest, { recursive: true, force: true });
11811
- fs28__namespace.mkdirSync(dest, { recursive: true });
12100
+ fs29__namespace.rmSync(dest, { recursive: true, force: true });
12101
+ fs29__namespace.mkdirSync(dest, { recursive: true });
11812
12102
  try {
11813
12103
  const ref = options.ref ?? source.ref;
11814
12104
  const args = [
@@ -11871,7 +12161,7 @@ async function cloneRepository(source, options) {
11871
12161
  };
11872
12162
  } catch (error) {
11873
12163
  try {
11874
- fs28__namespace.rmSync(dest, { recursive: true, force: true });
12164
+ fs29__namespace.rmSync(dest, { recursive: true, force: true });
11875
12165
  } catch {
11876
12166
  }
11877
12167
  throw error;
@@ -11884,7 +12174,7 @@ function directorySize(root) {
11884
12174
  const current = stack.pop();
11885
12175
  let entries;
11886
12176
  try {
11887
- entries = fs28__namespace.readdirSync(current, { withFileTypes: true });
12177
+ entries = fs29__namespace.readdirSync(current, { withFileTypes: true });
11888
12178
  } catch {
11889
12179
  continue;
11890
12180
  }
@@ -11893,7 +12183,7 @@ function directorySize(root) {
11893
12183
  if (entry.isDirectory()) stack.push(full);
11894
12184
  else if (entry.isFile()) {
11895
12185
  try {
11896
- total += fs28__namespace.statSync(full).size;
12186
+ total += fs29__namespace.statSync(full).size;
11897
12187
  } catch {
11898
12188
  }
11899
12189
  }
@@ -11902,7 +12192,7 @@ function directorySize(root) {
11902
12192
  return total;
11903
12193
  }
11904
12194
  function makeCloneDirectory() {
11905
- return fs28__namespace.mkdtempSync(path7__namespace.join(os2__namespace.tmpdir(), "codebase-snapshot-clone-"));
12195
+ return fs29__namespace.mkdtempSync(path7__namespace.join(os2__namespace.tmpdir(), "codebase-snapshot-clone-"));
11906
12196
  }
11907
12197
 
11908
12198
  // src/mcp/instructions.ts
@@ -12110,13 +12400,24 @@ function negotiateLegacyVersion(requested) {
12110
12400
  }
12111
12401
  return { version: DEFAULT_LEGACY_PROTOCOL_VERSION, matched: false };
12112
12402
  }
12403
+ function safeDirectory(cwd, absolute) {
12404
+ try {
12405
+ if (!fs29__namespace.statSync(absolute).isDirectory()) return false;
12406
+ const root = fs29__namespace.realpathSync(cwd);
12407
+ const real = fs29__namespace.realpathSync(absolute);
12408
+ const relative20 = path7__namespace.relative(root, real);
12409
+ return relative20 !== ".." && !relative20.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative20);
12410
+ } catch {
12411
+ return false;
12412
+ }
12413
+ }
12113
12414
  function safeRegularFile(cwd, absolute) {
12114
12415
  try {
12115
- if (!fs28__namespace.lstatSync(absolute).isFile()) return false;
12116
- const root = fs28__namespace.realpathSync(cwd);
12117
- const real = fs28__namespace.realpathSync(absolute);
12118
- const relative18 = path7__namespace.relative(root, real);
12119
- return relative18 !== ".." && !relative18.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative18);
12416
+ if (!fs29__namespace.lstatSync(absolute).isFile()) return false;
12417
+ const root = fs29__namespace.realpathSync(cwd);
12418
+ const real = fs29__namespace.realpathSync(absolute);
12419
+ const relative20 = path7__namespace.relative(root, real);
12420
+ return relative20 !== ".." && !relative20.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative20);
12120
12421
  } catch {
12121
12422
  return false;
12122
12423
  }
@@ -12132,40 +12433,42 @@ function describeMatcher(matcher) {
12132
12433
  function normalizeTarget2(cwd, target) {
12133
12434
  const resolvedCwd = path7__namespace.resolve(cwd);
12134
12435
  const absolute = path7__namespace.resolve(resolvedCwd, target);
12135
- const relative18 = path7__namespace.relative(resolvedCwd, absolute);
12136
- if (relative18 === "" || relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative18)) {
12436
+ const relative20 = path7__namespace.relative(resolvedCwd, absolute);
12437
+ if (relative20 === "" || relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative20)) {
12137
12438
  return { relative: target.replace(/\\/g, "/"), outsideRoot: true };
12138
12439
  }
12139
- return { relative: relative18.split(path7__namespace.sep).join("/"), outsideRoot: false };
12440
+ return { relative: relative20.split(path7__namespace.sep).join("/"), outsideRoot: false };
12140
12441
  }
12141
12442
  function findRuleMatch(rules, relativePath) {
12142
12443
  return rules.find(
12143
12444
  (rule) => matchRule(relativePath, rule.match)
12144
12445
  );
12145
12446
  }
12146
- function findRecordedAncestor(skipped, relative18, maskedPath2) {
12447
+ function findRecordedAncestor(skipped, relative20, maskedPath2) {
12147
12448
  let nearest;
12148
12449
  for (const record of skipped) {
12149
12450
  const ancestorPath = record.path;
12150
12451
  if (ancestorPath.length === 0) continue;
12151
- const isAncestor = relative18.startsWith(`${ancestorPath}/`) || maskedPath2.startsWith(`${ancestorPath}/`);
12452
+ const isAncestor = relative20.startsWith(`${ancestorPath}/`) || maskedPath2.startsWith(`${ancestorPath}/`);
12152
12453
  if (!isAncestor) continue;
12153
12454
  if (!nearest || ancestorPath.length > nearest.path.length) nearest = record;
12154
12455
  }
12155
12456
  return nearest;
12156
12457
  }
12157
12458
  function readManifest2(config) {
12158
- const manifestPath = path7__namespace.resolve(config.cwd, config.outDir, "manifest.json");
12459
+ const snapshotDir = path7__namespace.resolve(config.cwd, config.outDir);
12460
+ const read = readConfinedText(snapshotDir, "manifest.json", 64 * 1024 * 1024);
12461
+ if (!read.ok) return null;
12159
12462
  try {
12160
- return JSON.parse(fs28__namespace.readFileSync(manifestPath, "utf8"));
12463
+ return JSON.parse(read.text);
12161
12464
  } catch {
12162
12465
  return null;
12163
12466
  }
12164
12467
  }
12165
12468
  function explainPath(config, target) {
12166
12469
  const normalized = normalizeTarget2(config.cwd, target);
12167
- const relative18 = normalized.relative;
12168
- const maskedPath2 = findSecretInPath(relative18, config.secretRules)?.masked ?? relative18;
12470
+ const relative20 = normalized.relative;
12471
+ const maskedPath2 = findSecretInPath(relative20, config.secretRules)?.masked ?? relative20;
12169
12472
  if (normalized.outsideRoot) {
12170
12473
  return {
12171
12474
  path: maskedPath2,
@@ -12175,14 +12478,17 @@ function explainPath(config, target) {
12175
12478
  detail: "path resolves outside the configured repository root and was not inspected"
12176
12479
  };
12177
12480
  }
12178
- const absolute = path7__namespace.join(config.cwd, relative18);
12179
- const stagedBlob = config.staged === true ? readStagedBlob(config.cwd, relative18) : null;
12481
+ const absolute = path7__namespace.join(config.cwd, relative20);
12482
+ const stagedBlob = config.staged === true ? readStagedBlob(config.cwd, relative20) : null;
12483
+ const directoryExists = safeDirectory(config.cwd, absolute);
12180
12484
  const result = {
12181
12485
  path: maskedPath2,
12182
12486
  // `existsSync` follows a symlink, so an in-repo link to /etc/passwd answered "exists" for a
12183
12487
  // file the scanner refuses. `lstat` plus a canonical containment check keeps the answer about
12184
12488
  // a regular file the repository actually contains; a staged blob is the index's answer.
12185
- exists: stagedBlob !== null || safeRegularFile(config.cwd, absolute),
12489
+ // A directory is a real path too: calling `src` missing because it is not a regular file
12490
+ // was flatly false and contradicted the MCP schema's "directories are explained as a whole".
12491
+ exists: stagedBlob !== null || safeRegularFile(config.cwd, absolute) || directoryExists,
12186
12492
  included: false
12187
12493
  };
12188
12494
  const collection = collectFiles(config.cwd, {
@@ -12195,27 +12501,37 @@ function explainPath(config, target) {
12195
12501
  discovery: config.discovery,
12196
12502
  // A staged file that is absent from the working tree is still a candidate: `generate --staged`
12197
12503
  // reads its index blob, and `explain --staged` has to explain that same selection.
12198
- ...stagedBlob === null ? {} : { extraPaths: [relative18] },
12504
+ ...stagedBlob === null ? {} : { extraPaths: [relative20] },
12199
12505
  // Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
12200
12506
  // that is only missing because the walker dropped the tool's own output directory.
12201
12507
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
12202
12508
  (directory) => path7__namespace.relative(config.cwd, path7__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
12203
12509
  ).filter(
12204
- (relative19) => relative19.length > 0 && relative19 !== ".." && !relative19.startsWith(`..${path7__namespace.sep}`) && !relative19.startsWith("../") && !path7__namespace.isAbsolute(relative19)
12510
+ (relative21) => relative21.length > 0 && relative21 !== ".." && !relative21.startsWith(`..${path7__namespace.sep}`) && !relative21.startsWith("../") && !path7__namespace.isAbsolute(relative21)
12205
12511
  )
12206
12512
  });
12207
- if (!collection.files.includes(relative18)) {
12513
+ if (!collection.files.includes(relative20)) {
12208
12514
  const record = collection.skipped.find(
12209
- (entry2) => entry2.path === relative18 || entry2.path === maskedPath2
12515
+ (entry2) => entry2.path === relative20 || entry2.path === maskedPath2
12210
12516
  );
12211
12517
  if (record) {
12212
12518
  result.reason = record.reason;
12213
12519
  result.detail = record.detail;
12520
+ } else if (directoryExists) {
12521
+ const prefix = relative20 === "" ? "" : relative20.replace(/\/+$/, "") + "/";
12522
+ const descendants = collection.files.filter((path32) => path32.startsWith(prefix));
12523
+ if (descendants.length > 0) {
12524
+ result.included = true;
12525
+ result.detail = `directory containing ${descendants.length} included file(s)`;
12526
+ } else {
12527
+ result.reason = "not-discovered";
12528
+ result.detail = "directory contains no file the next snapshot would include";
12529
+ }
12214
12530
  } else if (!result.exists) {
12215
12531
  result.reason = "missing";
12216
12532
  result.detail = "no such file or directory, relative to the configured cwd";
12217
12533
  } else {
12218
- const ancestor = findRecordedAncestor(collection.skipped, relative18, maskedPath2);
12534
+ const ancestor = findRecordedAncestor(collection.skipped, relative20, maskedPath2);
12219
12535
  if (ancestor) {
12220
12536
  result.reason = ancestor.reason;
12221
12537
  result.detail = ancestor.detail ? `${ancestor.detail} \u2014 inherited from the skipped directory \`${ancestor.path}\`` : `inside the skipped directory \`${ancestor.path}\``;
@@ -12235,12 +12551,12 @@ function explainPath(config, target) {
12235
12551
  ...config.changedSince === void 0 ? {} : { changedSince: config.changedSince },
12236
12552
  ...config.staged === true ? { staged: true } : {}
12237
12553
  });
12238
- inScope = scope.paths.has(relative18);
12554
+ inScope = scope.paths.has(relative20);
12239
12555
  if (!inScope && config.withDependents === true) {
12240
12556
  const workspace = workspaceResolutionFor(config.cwd, collection.files);
12241
- const imports = stagedBlob !== null ? importsOfText(relative18, decodeText(stagedBlob).text) : importsOfFile(relative18, absolute);
12557
+ const imports = stagedBlob !== null ? importsOfText(relative20, decodeText(stagedBlob).text) : importsOfFile(relative20, absolute);
12242
12558
  inScope = importsChangedFile(
12243
- relative18,
12559
+ relative20,
12244
12560
  imports,
12245
12561
  scope.paths,
12246
12562
  buildImportResolver(collection.files.map((file) => ({ relativePath: file })), {
@@ -12273,7 +12589,7 @@ function explainPath(config, target) {
12273
12589
  let sizeOnDisk = stagedBlob?.length ?? null;
12274
12590
  if (sizeOnDisk === null) {
12275
12591
  try {
12276
- sizeOnDisk = fs28__namespace.statSync(absolute).size;
12592
+ sizeOnDisk = fs29__namespace.statSync(absolute).size;
12277
12593
  } catch {
12278
12594
  sizeOnDisk = null;
12279
12595
  }
@@ -12287,7 +12603,7 @@ function explainPath(config, target) {
12287
12603
  if (stagedBlob !== null || safeRegularFile(config.cwd, absolute)) {
12288
12604
  let buffer;
12289
12605
  try {
12290
- buffer = stagedBlob ?? fs28__namespace.readFileSync(absolute);
12606
+ buffer = stagedBlob ?? fs29__namespace.readFileSync(absolute);
12291
12607
  } catch (err) {
12292
12608
  result.included = false;
12293
12609
  result.reason = "read-error";
@@ -12305,15 +12621,16 @@ function explainPath(config, target) {
12305
12621
  result.bytes = buffer.length;
12306
12622
  result.lines = countLines(text2);
12307
12623
  if (decoded.encoding !== "utf-8") result.encoding = decoded.encoding;
12308
- const { findings } = scanAndRedactSecrets(text2, config.secretRules, relative18);
12624
+ const { findings } = scanAndRedactSecrets(text2, config.secretRules, relative20);
12309
12625
  result.secretCount = findings.length;
12310
12626
  result.secrets = findings.slice(0, 20).map((finding) => ({ rules: finding.rules, line: finding.line }));
12311
12627
  let inclusionMode = "full";
12312
- if (config.skeleton === true && isSkeletonizable(relative18)) {
12313
- const skeleton = skeletonizeTypeScript(text2, relative18);
12628
+ const oversizeForSummary = Buffer.byteLength(text2, "utf8") > SUMMARY_MAX_SOURCE_BYTES;
12629
+ if (config.skeleton === true && isSkeletonizable(relative20) && !oversizeForSummary) {
12630
+ const skeleton = skeletonizeTypeScript(text2, relative20);
12314
12631
  if (skeleton.collapsed > 0) inclusionMode = "signatures";
12315
12632
  }
12316
- if (inclusionMode === "full" && config.stripComments === true && isCommentStrippable(relative18) && stripComments2(text2, relative18).removed > 0) {
12633
+ if (inclusionMode === "full" && config.stripComments === true && isCommentStrippable(relative20) && !oversizeForSummary && stripComments2(text2, relative20).removed > 0) {
12317
12634
  inclusionMode = "comments-stripped";
12318
12635
  }
12319
12636
  if (inclusionMode !== "signatures" && buffer.length > config.largeFileBytes) {
@@ -12322,18 +12639,18 @@ function explainPath(config, target) {
12322
12639
  }
12323
12640
  result.inclusionMode = inclusionMode;
12324
12641
  }
12325
- result.layer = classifyLayer(relative18, config.layers);
12326
- result.kind = classifyKind(relative18, config.kinds);
12327
- result.language = detectLanguage(relative18);
12328
- const layerRule = findRuleMatch(config.layers, relative18);
12642
+ result.layer = classifyLayer(relative20, config.layers);
12643
+ result.kind = classifyKind(relative20, config.kinds);
12644
+ result.language = detectLanguage(relative20);
12645
+ const layerRule = findRuleMatch(config.layers, relative20);
12329
12646
  if (layerRule) result.layerMatch = describeMatcher(layerRule.match);
12330
- const kindRule = findRuleMatch(config.kinds, relative18);
12647
+ const kindRule = findRuleMatch(config.kinds, relative20);
12331
12648
  if (kindRule) result.kindMatch = describeMatcher(kindRule.match);
12332
12649
  const manifest = readManifest2(config);
12333
- const entry = Array.isArray(manifest?.files) ? manifest.files.find((file) => file.relativePath === relative18) : void 0;
12650
+ const entry = Array.isArray(manifest?.files) ? manifest.files.find((file) => file.relativePath === relative20) : void 0;
12334
12651
  result.part = entry?.part ?? null;
12335
12652
  if (entry === void 0) {
12336
- const record = manifest?.skipped?.find((skip) => skip.path === relative18);
12653
+ const record = manifest?.skipped?.find((skip) => skip.path === relative20);
12337
12654
  if (record !== void 0 && (record.reason === "not-selected" || record.reason === "unchanged")) {
12338
12655
  result.included = false;
12339
12656
  for (const key of [
@@ -12429,7 +12746,15 @@ function resolveImpactChanges(cwd, request) {
12429
12746
  throw new Error("impact needs --diff <ref> or --paths <path,...>.");
12430
12747
  }
12431
12748
  function isTestPath(filePath) {
12432
- return /\.(test|spec)\.[a-z0-9]+$/i.test(filePath);
12749
+ const base = filePath.slice(filePath.lastIndexOf("/") + 1);
12750
+ return (
12751
+ // Jest/Vitest/Mocha and their Ruby equivalents.
12752
+ /\.(?:test|spec)\.[a-z0-9]+$/i.test(base) || // Python: test_auth.py, auth_test.py, auth_tests.py.
12753
+ /^test_.*\.py$/i.test(base) || /_tests?\.py$/i.test(base) || // Go and Rust put the suffix before the extension.
12754
+ /_test\.(?:go|rs|exs?)$/i.test(base) || // Ruby spec files.
12755
+ /_spec\.rb$/i.test(base) || // JUnit/NUnit/XCTest/PHPUnit class names.
12756
+ /(?:Test|Tests)\.(?:java|kt|cs|swift|php)$/.test(base)
12757
+ );
12433
12758
  }
12434
12759
  function isTestSupportPath(filePath) {
12435
12760
  return !isTestPath(filePath) && /(^|\/)(tests?|__tests__|spec)\//.test(filePath);
@@ -12481,10 +12806,10 @@ function internalSpecifier(specifier, resolver) {
12481
12806
  }
12482
12807
  function manifestLabel(cwd, manifestPath) {
12483
12808
  if (manifestPath === void 0) return "manifest.json";
12484
- const relative18 = path7__namespace.relative(cwd, manifestPath).replace(/\\/g, "/");
12485
- if (relative18.length === 0) return "manifest.json";
12486
- if (relative18.startsWith("../") || path7__namespace.isAbsolute(relative18)) return path7__namespace.basename(manifestPath);
12487
- return relative18;
12809
+ const relative20 = path7__namespace.relative(cwd, manifestPath).replace(/\\/g, "/");
12810
+ if (relative20.length === 0) return "manifest.json";
12811
+ if (relative20.startsWith("../") || path7__namespace.isAbsolute(relative20)) return path7__namespace.basename(manifestPath);
12812
+ return relative20;
12488
12813
  }
12489
12814
  function isPureBarrel(summary, file) {
12490
12815
  if (summary.parseErrors !== void 0 && summary.parseErrors > 0) return false;
@@ -12534,18 +12859,20 @@ function matchEdge(fromSummary, fromFile, specifier, incoming) {
12534
12859
  const named = reExports2.filter(
12535
12860
  (binding) => binding.kind !== "star" && binding.kind !== "namespace"
12536
12861
  );
12537
- if (named.length > 0) {
12862
+ const onlyNamedReExports = reExports2.every((binding) => binding.kind === "named");
12863
+ if (named.length > 0 && imports2.length === 0 && onlyNamedReExports) {
12538
12864
  const next2 = /* @__PURE__ */ new Set();
12539
12865
  for (const binding of named) {
12540
12866
  for (const entry of binding.entries ?? []) next2.add(entry.exported);
12541
12867
  }
12542
12868
  if (next2.size > 0) {
12869
+ const typeOnly = named.every((binding) => binding.typeOnly);
12543
12870
  return {
12544
12871
  fired: true,
12545
- kind: "reexport",
12872
+ kind: typeOnly ? "type-only" : "reexport",
12546
12873
  next: next2,
12547
12874
  matched: [...next2].sort((left, right) => left.localeCompare(right)),
12548
- typeOnly: named.every((binding) => binding.typeOnly)
12875
+ typeOnly
12549
12876
  };
12550
12877
  }
12551
12878
  }
@@ -12736,7 +13063,7 @@ function computeImpact(input) {
12736
13063
  );
12737
13064
  const skippedByPath = new Map(manifest.skipped.map((skip) => [skip.path, skip]));
12738
13065
  const changed = input.changes.paths.map((changedPath) => {
12739
- const deleted2 = !fs28__namespace.existsSync(path7__namespace.resolve(input.cwd, changedPath));
13066
+ const deleted2 = !fs29__namespace.existsSync(path7__namespace.resolve(input.cwd, changedPath));
12740
13067
  const direct = filesByPath.get(changedPath);
12741
13068
  if (direct !== void 0) return { path: direct.relativePath, inSnapshot: true, deleted: deleted2 };
12742
13069
  const folded = filesByFoldedPath.get(changedPath.toLowerCase());
@@ -12832,7 +13159,7 @@ function computeImpact(input) {
12832
13159
  const widened = !(previous.has("*") && merged.size === previous.size) && !(previous.size === merged.size && [...merged].every((name) => previous.has(name)));
12833
13160
  if (widened) {
12834
13161
  visitedSymbols.set(edge.from, merged);
12835
- if (match.kind !== "type-only") {
13162
+ if (match.kind !== "type-only" || fromSummary !== null && isPureBarrel(fromSummary, fromFile)) {
12836
13163
  queue.push({ path: edge.from, symbols: merged, distance: current.distance + 1 });
12837
13164
  }
12838
13165
  }
@@ -12881,8 +13208,8 @@ function computeImpact(input) {
12881
13208
  }
12882
13209
  }
12883
13210
  const impacted = /* @__PURE__ */ new Set([...changedSet, ...affected.keys()]);
12884
- for (const path31 of visitedSymbols.keys()) {
12885
- if (!isTestPath(path31) && !isTestSupportPath(path31)) impacted.add(path31);
13211
+ for (const path32 of visitedSymbols.keys()) {
13212
+ if (!isTestPath(path32) && !isTestSupportPath(path32)) impacted.add(path32);
12886
13213
  }
12887
13214
  const tests = [...testHits.entries()].map(([testPath, hit]) => ({
12888
13215
  path: testPath,
@@ -12939,7 +13266,8 @@ function computeImpact(input) {
12939
13266
  ])
12940
13267
  )
12941
13268
  ) : void 0;
12942
- const coverage = input.trust?.coverage ?? (truncated || depthTruncated || notInSnapshot.length > 0 ? "partial" : "complete");
13269
+ const impactPartial = truncated || depthTruncated || notInSnapshot.length > 0;
13270
+ const coverage = input.trust?.coverage === "partial" || impactPartial ? "partial" : "complete";
12943
13271
  const trust = {
12944
13272
  indexSource: input.trust?.indexSource ?? "snapshot",
12945
13273
  freshness: input.trust?.freshness ?? "unknown",
@@ -12948,7 +13276,7 @@ function computeImpact(input) {
12948
13276
  ...input.trust?.overlayStats === void 0 ? {} : { overlayStats: input.trust.overlayStats },
12949
13277
  sensitiveExcludedCount: input.trust?.sensitiveExcludedCount ?? manifest.skipped.filter((skip) => skip.reason === "sensitive-file").length,
12950
13278
  redactedLines: input.trust?.redactedLines ?? manifest.totals.redactedLines,
12951
- omittedCount: input.trust?.omittedCount ?? notInSnapshot.length + (truncated ? 1 : 0),
13279
+ omittedCount: (input.trust?.omittedCount ?? 0) + notInSnapshot.length + (truncated || depthTruncated ? 1 : 0),
12952
13280
  unresolvedCount: unresolved.length,
12953
13281
  reasons: [...input.trust?.reasons ?? [], ...warnings]
12954
13282
  };
@@ -13098,25 +13426,25 @@ function foldPathKey(value) {
13098
13426
  }
13099
13427
  function canonicalRoot(root) {
13100
13428
  try {
13101
- return fs28__namespace.realpathSync(root);
13429
+ return fs29__namespace.realpathSync(root);
13102
13430
  } catch {
13103
13431
  return path7__namespace.resolve(root);
13104
13432
  }
13105
13433
  }
13106
13434
  function inside(parent, child) {
13107
- const relative18 = path7__namespace.relative(foldPathKey(parent), foldPathKey(child));
13108
- return relative18 === "" || relative18 !== ".." && !relative18.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative18);
13435
+ const relative20 = path7__namespace.relative(foldPathKey(parent), foldPathKey(child));
13436
+ return relative20 === "" || relative20 !== ".." && !relative20.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative20);
13109
13437
  }
13110
13438
  function canonicalCandidate(root, candidate) {
13111
13439
  const absolute = path7__namespace.isAbsolute(candidate) ? candidate : path7__namespace.resolve(root, candidate);
13112
13440
  if (!inside(root, absolute)) return null;
13113
13441
  try {
13114
- const stat = fs28__namespace.lstatSync(absolute);
13442
+ const stat = fs29__namespace.lstatSync(absolute);
13115
13443
  if (!stat.isFile() && !stat.isSymbolicLink()) return null;
13116
- const real = fs28__namespace.realpathSync(absolute);
13444
+ const real = fs29__namespace.realpathSync(absolute);
13117
13445
  if (!inside(root, real)) return null;
13118
- const relative18 = path7__namespace.relative(root, real).replace(/\\/g, "/");
13119
- if (isSensitivePath(relative18)) return null;
13446
+ const relative20 = path7__namespace.relative(root, real).replace(/\\/g, "/");
13447
+ if (isSensitivePath(relative20)) return null;
13120
13448
  return real;
13121
13449
  } catch {
13122
13450
  return null;
@@ -13140,13 +13468,13 @@ function compilerOptionsFor(root) {
13140
13468
  useCaseSensitiveFileNames: ts__default.default.sys.useCaseSensitiveFileNames,
13141
13469
  readDirectory: () => [],
13142
13470
  fileExists: (file) => {
13143
- const relative18 = path7__namespace.relative(root, file).replace(/\\/g, "/");
13144
- return relative18.length > 0 && !isSensitivePath(relative18) && readConfinedText(root, relative18).ok;
13471
+ const relative20 = path7__namespace.relative(root, file).replace(/\\/g, "/");
13472
+ return relative20.length > 0 && !isSensitivePath(relative20) && readConfinedText(root, relative20).ok;
13145
13473
  },
13146
13474
  readFile: (file) => {
13147
- const relative18 = path7__namespace.relative(root, file).replace(/\\/g, "/");
13148
- if (relative18.length === 0 || isSensitivePath(relative18)) return void 0;
13149
- const text2 = readConfinedText(root, relative18);
13475
+ const relative20 = path7__namespace.relative(root, file).replace(/\\/g, "/");
13476
+ if (relative20.length === 0 || isSensitivePath(relative20)) return void 0;
13477
+ const text2 = readConfinedText(root, relative20);
13150
13478
  return text2.ok ? text2.text : void 0;
13151
13479
  },
13152
13480
  getDirectories: () => []
@@ -13226,8 +13554,8 @@ function createScopedProgram(options) {
13226
13554
  const overlaidContent = (absolute) => {
13227
13555
  const direct = overlay.get(foldPathKey(absolute));
13228
13556
  if (direct === void 0) return void 0;
13229
- const relative18 = path7__namespace.relative(root, absolute).replace(/\\/g, "/");
13230
- return isSensitivePath(relative18) ? void 0 : direct;
13557
+ const relative20 = path7__namespace.relative(root, absolute).replace(/\\/g, "/");
13558
+ return isSensitivePath(relative20) ? void 0 : direct;
13231
13559
  };
13232
13560
  const host = {
13233
13561
  getSourceFile: (fileName, languageVersion) => {
@@ -13235,7 +13563,7 @@ function createScopedProgram(options) {
13235
13563
  const content = overlaidContent(absolute) ?? (() => {
13236
13564
  if (isTypeScriptLib(fileName)) {
13237
13565
  try {
13238
- return fs28__namespace.readFileSync(absolute, "utf8");
13566
+ return fs29__namespace.readFileSync(absolute, "utf8");
13239
13567
  } catch {
13240
13568
  return void 0;
13241
13569
  }
@@ -13243,9 +13571,9 @@ function createScopedProgram(options) {
13243
13571
  if (!allowed.has(foldPathKey(absolute))) return void 0;
13244
13572
  const confined = canonicalCandidate(root, absolute);
13245
13573
  if (confined === null) return void 0;
13246
- const relative18 = path7__namespace.relative(root, confined).replace(/\\/g, "/");
13247
- if (isSensitivePath(relative18)) return void 0;
13248
- const read = readConfinedText(root, relative18);
13574
+ const relative20 = path7__namespace.relative(root, confined).replace(/\\/g, "/");
13575
+ if (isSensitivePath(relative20)) return void 0;
13576
+ const read = readConfinedText(root, relative20);
13249
13577
  return read.ok ? read.text : void 0;
13250
13578
  })();
13251
13579
  if (content === void 0) return void 0;
@@ -13268,13 +13596,13 @@ function createScopedProgram(options) {
13268
13596
  if (overlaidContent(absolute) !== void 0) return true;
13269
13597
  if (isTypeScriptLib(fileName)) {
13270
13598
  try {
13271
- return fs28__namespace.statSync(absolute).isFile();
13599
+ return fs29__namespace.statSync(absolute).isFile();
13272
13600
  } catch {
13273
13601
  return false;
13274
13602
  }
13275
13603
  }
13276
- const relative18 = path7__namespace.relative(root, absolute).replace(/\\/g, "/");
13277
- if (isSensitivePath(relative18)) return false;
13604
+ const relative20 = path7__namespace.relative(root, absolute).replace(/\\/g, "/");
13605
+ if (isSensitivePath(relative20)) return false;
13278
13606
  if (!allowed.has(foldPathKey(absolute))) return false;
13279
13607
  return canonicalCandidate(root, absolute) !== null;
13280
13608
  },
@@ -13284,7 +13612,7 @@ function createScopedProgram(options) {
13284
13612
  if (overlaid !== void 0) return overlaid;
13285
13613
  if (isTypeScriptLib(fileName)) {
13286
13614
  try {
13287
- return fs28__namespace.readFileSync(absolute, "utf8");
13615
+ return fs29__namespace.readFileSync(absolute, "utf8");
13288
13616
  } catch {
13289
13617
  return void 0;
13290
13618
  }
@@ -13292,9 +13620,9 @@ function createScopedProgram(options) {
13292
13620
  if (!allowed.has(foldPathKey(absolute))) return void 0;
13293
13621
  const confined = canonicalCandidate(root, absolute);
13294
13622
  if (confined === null) return void 0;
13295
- const relative18 = path7__namespace.relative(root, confined).replace(/\\/g, "/");
13296
- if (isSensitivePath(relative18)) return void 0;
13297
- const read = readConfinedText(root, relative18);
13623
+ const relative20 = path7__namespace.relative(root, confined).replace(/\\/g, "/");
13624
+ if (isSensitivePath(relative20)) return void 0;
13625
+ const read = readConfinedText(root, relative20);
13298
13626
  return read.ok ? read.text : void 0;
13299
13627
  },
13300
13628
  readDirectory: (directory, extensions) => {
@@ -13315,7 +13643,7 @@ function createScopedProgram(options) {
13315
13643
  if (isTypeScriptLib(directory)) return true;
13316
13644
  if (!inside(root, absolute)) return false;
13317
13645
  try {
13318
- return fs28__namespace.statSync(absolute).isDirectory();
13646
+ return fs29__namespace.statSync(absolute).isDirectory();
13319
13647
  } catch {
13320
13648
  return false;
13321
13649
  }
@@ -13444,8 +13772,8 @@ function resolveTargetSymbolKey(checker, program, root, target) {
13444
13772
  const normalizedTarget = target.targetPath?.replace(/\\/g, "/").replace(/^\.\/+/, "");
13445
13773
  for (const sourceFile of program.getSourceFiles()) {
13446
13774
  if (sourceFile.isDeclarationFile) continue;
13447
- const relative18 = relativeInRoot(root, sourceFile.fileName);
13448
- if (normalizedTarget !== void 0 && !sameRelativePath(relative18, normalizedTarget)) continue;
13775
+ const relative20 = relativeInRoot(root, sourceFile.fileName);
13776
+ if (normalizedTarget !== void 0 && !sameRelativePath(relative20, normalizedTarget)) continue;
13449
13777
  const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
13450
13778
  if (moduleSymbol !== void 0) {
13451
13779
  for (const exported of checker.getExportsOfModule(moduleSymbol)) {
@@ -13533,15 +13861,13 @@ function findMultipleSymbolReferences(options) {
13533
13861
  reasons.push("Symbol reference search exceeded its deadline; results are partial");
13534
13862
  break;
13535
13863
  }
13536
- const relative18 = relativeInRoot(roots.root, sourceFile.fileName);
13537
- const visit = (node) => {
13538
- if (totalRefs >= maxResults) {
13539
- truncated = true;
13540
- return;
13541
- }
13542
- if (Date.now() > roots.deadline) {
13864
+ const relative20 = relativeInRoot(roots.root, sourceFile.fileName);
13865
+ const stack = [sourceFile];
13866
+ while (stack.length > 0) {
13867
+ const node = stack.pop();
13868
+ if (totalRefs >= maxResults || Date.now() > roots.deadline) {
13543
13869
  truncated = true;
13544
- return;
13870
+ break;
13545
13871
  }
13546
13872
  if (ts__default.default.isIdentifier(node)) {
13547
13873
  const symbol = checker.getSymbolAtLocation(node);
@@ -13552,7 +13878,7 @@ function findMultipleSymbolReferences(options) {
13552
13878
  const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
13553
13879
  const parent = node.parent;
13554
13880
  const ref = {
13555
- path: relative18,
13881
+ path: relative20,
13556
13882
  line: position.line + 1,
13557
13883
  column: position.character + 1,
13558
13884
  name: node.text,
@@ -13566,9 +13892,14 @@ function findMultipleSymbolReferences(options) {
13566
13892
  }
13567
13893
  }
13568
13894
  }
13569
- ts__default.default.forEachChild(node, visit);
13570
- };
13571
- visit(sourceFile);
13895
+ const children = [];
13896
+ ts__default.default.forEachChild(node, (child) => {
13897
+ children.push(child);
13898
+ });
13899
+ for (let index = children.length - 1; index >= 0; index -= 1) {
13900
+ stack.push(children[index]);
13901
+ }
13902
+ }
13572
13903
  if (truncated) break;
13573
13904
  }
13574
13905
  return {
@@ -13730,8 +14061,8 @@ function findSection(sections, relativePath) {
13730
14061
  if (exact) return exact;
13731
14062
  const foldedPath = rendered.toLowerCase();
13732
14063
  const folded = sections.filter((section) => {
13733
- const path31 = section.path.toLowerCase();
13734
- return path31 === relativePath.toLowerCase() || path31 === foldedPath;
14064
+ const path32 = section.path.toLowerCase();
14065
+ return path32 === relativePath.toLowerCase() || path32 === foldedPath;
13735
14066
  });
13736
14067
  return folded.length === 1 ? folded[0] : null;
13737
14068
  }
@@ -13827,7 +14158,7 @@ var WORKER_SOURCE = `
13827
14158
  })();
13828
14159
  `;
13829
14160
  function generateInWorker(cwd, cliOptions, options = {}) {
13830
- return new Promise((resolve20) => {
14161
+ return new Promise((resolve21) => {
13831
14162
  let settled = false;
13832
14163
  let worker = null;
13833
14164
  const finish = (result) => {
@@ -13838,7 +14169,7 @@ function generateInWorker(cwd, cliOptions, options = {}) {
13838
14169
  if (!result.ok && options.runId !== void 0 && options.lockRoots !== void 0) {
13839
14170
  releaseAbandonedRun(options.lockRoots, options.runId);
13840
14171
  }
13841
- resolve20(result);
14172
+ resolve21(result);
13842
14173
  });
13843
14174
  };
13844
14175
  const isCjs = typeof __dirname !== "undefined";
@@ -13951,21 +14282,30 @@ var WORKER_SOURCE2 = `
13951
14282
  }
13952
14283
  })();
13953
14284
  `;
13954
- function analysisInWorker(request) {
13955
- return new Promise((resolve20) => {
14285
+ function analysisInWorker(request, signal) {
14286
+ return new Promise((resolve21) => {
13956
14287
  let settled = false;
13957
14288
  let worker = null;
13958
14289
  const timer = setTimeout(() => {
13959
14290
  finish({ ok: false, message: "The analysis worker exceeded its two-minute timeout." });
13960
14291
  }, 12e4);
13961
14292
  timer.unref();
14293
+ const onAbort = () => {
14294
+ finish({ ok: false, message: "The analysis was cancelled." });
14295
+ };
13962
14296
  const finish = (result) => {
13963
14297
  if (settled) return;
13964
14298
  settled = true;
13965
14299
  clearTimeout(timer);
14300
+ signal?.removeEventListener("abort", onAbort);
13966
14301
  const terminated = worker === null ? Promise.resolve(void 0) : worker.terminate();
13967
- void terminated.catch(() => void 0).then(() => resolve20(result));
14302
+ void terminated.catch(() => void 0).then(() => resolve21(result));
13968
14303
  };
14304
+ if (signal?.aborted === true) {
14305
+ finish({ ok: false, message: "The analysis was cancelled." });
14306
+ return;
14307
+ }
14308
+ signal?.addEventListener("abort", onAbort, { once: true });
13969
14309
  const isCjs = typeof __dirname !== "undefined";
13970
14310
  const directory = isCjs ? __dirname : path7__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
13971
14311
  try {
@@ -14080,7 +14420,7 @@ function shouldCheck(argv, env) {
14080
14420
  function readCache(file) {
14081
14421
  let raw;
14082
14422
  try {
14083
- raw = fs28__namespace.readFileSync(file, "utf8");
14423
+ raw = fs29__namespace.readFileSync(file, "utf8");
14084
14424
  } catch {
14085
14425
  return null;
14086
14426
  }
@@ -14097,21 +14437,21 @@ function readCache(file) {
14097
14437
  }
14098
14438
  function writeCache(file, entry) {
14099
14439
  try {
14100
- fs28__namespace.mkdirSync(path7__namespace.dirname(file), { recursive: true });
14101
- fs28__namespace.writeFileSync(file, `${JSON.stringify(entry)}
14440
+ fs29__namespace.mkdirSync(path7__namespace.dirname(file), { recursive: true });
14441
+ fs29__namespace.writeFileSync(file, `${JSON.stringify(entry)}
14102
14442
  `, "utf8");
14103
14443
  } catch {
14104
14444
  }
14105
14445
  }
14106
14446
  function fetchLatestVersion(url = PACKAGE_LATEST_URL, timeoutMs = REQUEST_TIMEOUT_MS) {
14107
- return new Promise((resolve20) => {
14447
+ return new Promise((resolve21) => {
14108
14448
  let settled = false;
14109
14449
  let request = null;
14110
14450
  const finish = (value) => {
14111
14451
  if (settled) return;
14112
14452
  settled = true;
14113
14453
  clearTimeout(deadline);
14114
- resolve20(value);
14454
+ resolve21(value);
14115
14455
  };
14116
14456
  const deadline = setTimeout(() => {
14117
14457
  request?.destroy();
@@ -14221,6 +14561,7 @@ function baselineUsable(manifest, config) {
14221
14561
  if (manifest.generator.version !== GENERATOR_VERSION) return false;
14222
14562
  if (manifest.config.digest === void 0 || manifest.config.digest !== configDigest(config)) return false;
14223
14563
  if (manifest.slice !== void 0 || manifest.budget !== void 0 || manifest.delta !== void 0) return false;
14564
+ if (manifest.config.artifacts.parts === false) return false;
14224
14565
  return true;
14225
14566
  }
14226
14567
  function gitWorkingState(cwd) {
@@ -14279,6 +14620,26 @@ function collectStatStamps(config, manifest, gitState) {
14279
14620
  for (const dirty of gitState.dirtyPaths) candidates.add(dirty);
14280
14621
  } else {
14281
14622
  if (manifest.files.length > 500) return [];
14623
+ const directories = [];
14624
+ const pending = [""];
14625
+ while (pending.length > 0) {
14626
+ const directory = pending.shift();
14627
+ let entries;
14628
+ try {
14629
+ entries = fs29__namespace.readdirSync(path7__namespace.join(config.cwd, directory), { withFileTypes: true });
14630
+ } catch {
14631
+ continue;
14632
+ }
14633
+ for (const entry of entries) {
14634
+ if (!entry.isDirectory()) continue;
14635
+ if (entry.name === ".git" || entry.name === "node_modules") continue;
14636
+ const relative20 = directory === "" ? entry.name : directory + "/" + entry.name;
14637
+ directories.push(relative20);
14638
+ pending.push(relative20);
14639
+ if (directories.length > 500) return [];
14640
+ }
14641
+ }
14642
+ for (const directory of directories) candidates.add(directory);
14282
14643
  for (const file of manifest.files) {
14283
14644
  candidates.add(file.relativePath);
14284
14645
  let dir = path7__namespace.posix.dirname(file.relativePath);
@@ -14291,18 +14652,18 @@ function collectStatStamps(config, manifest, gitState) {
14291
14652
  }
14292
14653
  }
14293
14654
  const stamps = [];
14294
- for (const relative18 of [...candidates].sort((left, right) => left.localeCompare(right))) {
14295
- const target = relative18.length === 0 ? config.cwd : path7__namespace.join(config.cwd, relative18);
14655
+ for (const relative20 of [...candidates].sort((left, right) => left.localeCompare(right))) {
14656
+ const target = relative20.length === 0 ? config.cwd : path7__namespace.join(config.cwd, relative20);
14296
14657
  try {
14297
- const stat = fs28__namespace.lstatSync(target);
14658
+ const stat = fs29__namespace.lstatSync(target);
14298
14659
  stamps.push({
14299
- path: relative18,
14660
+ path: relative20,
14300
14661
  exists: true,
14301
14662
  mtimeMs: stat.mtimeMs,
14302
14663
  size: stat.size
14303
14664
  });
14304
14665
  } catch {
14305
- stamps.push({ path: relative18, exists: false, mtimeMs: 0, size: 0 });
14666
+ stamps.push({ path: relative20, exists: false, mtimeMs: 0, size: 0 });
14306
14667
  }
14307
14668
  }
14308
14669
  return stamps;
@@ -14312,7 +14673,7 @@ function stampsMatch(cwd, stamps) {
14312
14673
  for (const stamp of stamps) {
14313
14674
  const target = stamp.path.length === 0 ? cwd : path7__namespace.join(cwd, stamp.path);
14314
14675
  try {
14315
- const stat = fs28__namespace.lstatSync(target);
14676
+ const stat = fs29__namespace.lstatSync(target);
14316
14677
  if (!stamp.exists || stat.mtimeMs !== stamp.mtimeMs || stat.size !== stamp.size) {
14317
14678
  return false;
14318
14679
  }
@@ -14340,7 +14701,7 @@ function readCache2(config) {
14340
14701
  const file = liveIndexCachePath(config);
14341
14702
  let raw;
14342
14703
  try {
14343
- raw = fs28__namespace.readFileSync(file, "utf8");
14704
+ raw = fs29__namespace.readFileSync(file, "utf8");
14344
14705
  } catch {
14345
14706
  return null;
14346
14707
  }
@@ -14373,12 +14734,12 @@ function readCache2(config) {
14373
14734
  function writeCache2(config, payload) {
14374
14735
  try {
14375
14736
  const file = liveIndexCachePath(config);
14376
- fs28__namespace.mkdirSync(path7__namespace.dirname(file), { recursive: true, mode: 448 });
14737
+ fs29__namespace.mkdirSync(path7__namespace.dirname(file), { recursive: true, mode: 448 });
14377
14738
  const temporary = file + "." + process.pid + "." + Date.now() + ".tmp";
14378
- fs28__namespace.writeFileSync(temporary, JSON.stringify(payload), { encoding: "utf8", mode: 384 });
14379
- fs28__namespace.renameSync(temporary, file);
14739
+ fs29__namespace.writeFileSync(temporary, JSON.stringify(payload), { encoding: "utf8", mode: 384 });
14740
+ fs29__namespace.renameSync(temporary, file);
14380
14741
  try {
14381
- fs28__namespace.chmodSync(file, 384);
14742
+ fs29__namespace.chmodSync(file, 384);
14382
14743
  } catch {
14383
14744
  return;
14384
14745
  }
@@ -14463,7 +14824,25 @@ function readRedacted(config, allowedFiles, relativePath) {
14463
14824
  if (isSensitivePath(normalized)) return null;
14464
14825
  const lookup2 = CASE_INSENSITIVE_PATHS2 ? normalized.toLowerCase() : normalized;
14465
14826
  if (!allowedFiles.has(lookup2)) return null;
14466
- const read = readConfinedBytes(config.cwd, normalized, MAX_READ_BYTES);
14827
+ let read = readConfinedBytes(config.cwd, normalized, MAX_READ_BYTES);
14828
+ if (!read.ok && read.reason === "not-file") {
14829
+ try {
14830
+ const alias = path7__namespace.join(config.cwd, normalized);
14831
+ if (fs29__namespace.lstatSync(alias).isSymbolicLink()) {
14832
+ const rootReal = fs29__namespace.realpathSync(config.cwd);
14833
+ const targetReal = fs29__namespace.realpathSync(alias);
14834
+ const targetRelative = path7__namespace.relative(rootReal, targetReal).split(path7__namespace.sep).join("/");
14835
+ if (targetRelative === "" || targetRelative === ".." || targetRelative.startsWith("../") || path7__namespace.isAbsolute(targetRelative) || isSensitivePath(targetRelative)) {
14836
+ return null;
14837
+ }
14838
+ const targetLookup = CASE_INSENSITIVE_PATHS2 ? targetRelative.toLowerCase() : targetRelative;
14839
+ if (!allowedFiles.has(targetLookup)) return null;
14840
+ read = readConfinedBytes(config.cwd, targetRelative, MAX_READ_BYTES);
14841
+ }
14842
+ } catch {
14843
+ return null;
14844
+ }
14845
+ }
14467
14846
  if (!read.ok) return null;
14468
14847
  const decoded = decodeText(read.bytes);
14469
14848
  if (decoded.binary) return null;
@@ -14552,7 +14931,7 @@ function foldForComparison(value) {
14552
14931
  function canonicalPath(value) {
14553
14932
  const absolute = path7__namespace.resolve(value);
14554
14933
  try {
14555
- return fs28__namespace.realpathSync(absolute);
14934
+ return fs29__namespace.realpathSync(absolute);
14556
14935
  } catch {
14557
14936
  return absolute;
14558
14937
  }
@@ -14565,7 +14944,7 @@ function isInside3(parent, child) {
14565
14944
  function resolveThroughExistingAncestor(target) {
14566
14945
  let existing = target;
14567
14946
  const missing = [];
14568
- while (!fs28__namespace.existsSync(existing)) {
14947
+ while (!fs29__namespace.existsSync(existing)) {
14569
14948
  missing.unshift(path7__namespace.basename(existing));
14570
14949
  const parent = path7__namespace.dirname(existing);
14571
14950
  if (parent === existing) break;
@@ -14594,7 +14973,7 @@ function resolveRoot(requested, context) {
14594
14973
  if (!lexicalRoots.some((allowed) => isInside3(allowed, absolute))) return outside();
14595
14974
  let linkStats;
14596
14975
  try {
14597
- linkStats = fs28__namespace.lstatSync(absolute);
14976
+ linkStats = fs29__namespace.lstatSync(absolute);
14598
14977
  } catch {
14599
14978
  return { ok: false, message: `"${wanted}" does not exist, so it cannot be a repository root.` };
14600
14979
  }
@@ -14606,7 +14985,7 @@ function resolveRoot(requested, context) {
14606
14985
  }
14607
14986
  let stats;
14608
14987
  try {
14609
- stats = fs28__namespace.statSync(absolute);
14988
+ stats = fs29__namespace.statSync(absolute);
14610
14989
  } catch {
14611
14990
  return { ok: false, message: `"${wanted}" does not exist, so it cannot be a repository root.` };
14612
14991
  }
@@ -14685,6 +15064,21 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
14685
15064
  if (typeof overrides.sarif === "boolean") cliOptions.sarif = overrides.sarif;
14686
15065
  if (typeof overrides.staged === "boolean") cliOptions.staged = overrides.staged;
14687
15066
  if (typeof overrides.withDependents === "boolean") cliOptions.withDependents = overrides.withDependents;
15067
+ for (const key of ["includeDiffs", "tokenTree", "stripComments", "removeEmptyLines"]) {
15068
+ if (typeof overrides[key] === "boolean") cliOptions[key] = overrides[key];
15069
+ }
15070
+ if (overrides.includeLogs !== void 0) {
15071
+ if (typeof overrides.includeLogs !== "number" || !Number.isSafeInteger(overrides.includeLogs) || overrides.includeLogs < 1 || overrides.includeLogs > 500) {
15072
+ return { ok: false, message: '"includeLogs" must be an integer from 1 to 500.' };
15073
+ }
15074
+ cliOptions.includeLogs = overrides.includeLogs;
15075
+ }
15076
+ if (overrides.pack !== void 0) {
15077
+ if (overrides.pack !== "single" && overrides.pack !== "xml" && overrides.pack !== "json") {
15078
+ return { ok: false, message: '"pack" must be "single", "xml" or "json".' };
15079
+ }
15080
+ cliOptions.pack = overrides.pack;
15081
+ }
14688
15082
  for (const key of ["only", "ignore"]) {
14689
15083
  const value = overrides[key];
14690
15084
  if (value === void 0) continue;
@@ -14739,21 +15133,21 @@ function partPathFor(workspace, filename) {
14739
15133
  if (filename.length === 0 || filename.includes("\0")) return null;
14740
15134
  const partsDir = path7__namespace.resolve(workspace.root, workspace.config.outDir, "parts");
14741
15135
  const resolved = path7__namespace.resolve(partsDir, filename);
14742
- const relative18 = path7__namespace.relative(partsDir, resolved);
14743
- if (relative18.length === 0 || relative18.includes(path7__namespace.sep) || relative18.includes("/") || relative18.includes("\\") || path7__namespace.isAbsolute(relative18)) {
15136
+ const relative20 = path7__namespace.relative(partsDir, resolved);
15137
+ if (relative20.length === 0 || relative20.includes(path7__namespace.sep) || relative20.includes("/") || relative20.includes("\\") || path7__namespace.isAbsolute(relative20)) {
14744
15138
  return null;
14745
15139
  }
14746
15140
  let stats;
14747
15141
  try {
14748
- stats = fs28__namespace.lstatSync(resolved);
15142
+ stats = fs29__namespace.lstatSync(resolved);
14749
15143
  } catch {
14750
15144
  return null;
14751
15145
  }
14752
15146
  if (!stats.isFile()) return null;
14753
15147
  try {
14754
- const snapshotReal = fs28__namespace.realpathSync(path7__namespace.resolve(workspace.root, workspace.config.outDir));
14755
- const partsReal = fs28__namespace.realpathSync(partsDir);
14756
- const resolvedReal = fs28__namespace.realpathSync(resolved);
15148
+ const snapshotReal = fs29__namespace.realpathSync(path7__namespace.resolve(workspace.root, workspace.config.outDir));
15149
+ const partsReal = fs29__namespace.realpathSync(partsDir);
15150
+ const resolvedReal = fs29__namespace.realpathSync(resolved);
14757
15151
  if (!isInside3(snapshotReal, partsReal)) return null;
14758
15152
  if (!isInside3(partsReal, resolvedReal)) return null;
14759
15153
  if (path7__namespace.dirname(resolvedReal) !== partsReal) return null;
@@ -14847,8 +15241,8 @@ var WRITES = {
14847
15241
  var MAX_RESULT_BYTES = 64 * 1024;
14848
15242
  var MAX_SEARCH_BYTES = 4 * 1024 * 1024;
14849
15243
  var MAX_PART_READ_BYTES = 16 * 1024 * 1024;
14850
- function capResultText(text2) {
14851
- const clipped = truncateToBytes(text2, MAX_RESULT_BYTES);
15244
+ function capResultText(text2, maxBytes = MAX_RESULT_BYTES) {
15245
+ const clipped = truncateToBytes(text2, maxBytes);
14852
15246
  return { text: clipped.isTruncated ? clipped.content : text2, clipped: clipped.isTruncated };
14853
15247
  }
14854
15248
  function capResponseText(text2) {
@@ -14897,9 +15291,21 @@ function workspaceOverrides(args) {
14897
15291
  staged: args.staged,
14898
15292
  withDependents: args.withDependents,
14899
15293
  only: args.only,
14900
- ignore: args.ignore
15294
+ ignore: args.ignore,
15295
+ includeDiffs: args.includeDiffs,
15296
+ includeLogs: args.includeLogs,
15297
+ tokenTree: args.tokenTree,
15298
+ stripComments: args.stripComments,
15299
+ removeEmptyLines: args.removeEmptyLines,
15300
+ pack: args.pack
14901
15301
  };
14902
15302
  }
15303
+ function cancellationSignal(context) {
15304
+ if (context.onCancel === void 0) return void 0;
15305
+ const controller = new AbortController();
15306
+ context.onCancel(() => controller.abort());
15307
+ return controller.signal;
15308
+ }
14903
15309
  function failure(message) {
14904
15310
  return { text: message, isError: true };
14905
15311
  }
@@ -14933,11 +15339,11 @@ function toRelativePath(root, value) {
14933
15339
  if (cleaned.length === 0 || cleaned.includes("\0")) return null;
14934
15340
  const resolvedRoot = path7__namespace.resolve(root);
14935
15341
  const absolute = path7__namespace.resolve(resolvedRoot, cleaned);
14936
- const relative18 = path7__namespace.relative(resolvedRoot, absolute);
14937
- if (relative18 === "" || relative18 === ".." || relative18.startsWith(".." + path7__namespace.sep) || path7__namespace.isAbsolute(relative18)) {
15342
+ const relative20 = path7__namespace.relative(resolvedRoot, absolute);
15343
+ if (relative20 === "" || relative20 === ".." || relative20.startsWith(".." + path7__namespace.sep) || path7__namespace.isAbsolute(relative20)) {
14938
15344
  return null;
14939
15345
  }
14940
- return relative18.split(path7__namespace.sep).join("/");
15346
+ return relative20.split(path7__namespace.sep).join("/");
14941
15347
  }
14942
15348
  function symbolsOf(entry) {
14943
15349
  const summary = entry.summary;
@@ -15013,25 +15419,75 @@ function partTooLargeFor(workspace, entry) {
15013
15419
  const partPath = partPathFor(workspace, entry.part);
15014
15420
  if (partPath === null) return false;
15015
15421
  try {
15016
- return fs28__namespace.statSync(partPath).size > MAX_PART_READ_BYTES;
15422
+ return fs29__namespace.statSync(partPath).size > MAX_PART_READ_BYTES;
15017
15423
  } catch {
15018
15424
  return false;
15019
15425
  }
15020
15426
  }
15021
- function bodyFor(workspace, index, entry) {
15427
+ var partCaches = /* @__PURE__ */ new WeakMap();
15428
+ function sha256Of(bytes) {
15429
+ return crypto.createHash("sha256").update(bytes).digest("hex");
15430
+ }
15431
+ function noteUnverifiedPart(index, detail) {
15432
+ index.trust.coverage = "partial";
15433
+ index.trust.reasons = [.../* @__PURE__ */ new Set([...index.trust.reasons, detail])];
15434
+ }
15435
+ function liveBody(index, entry) {
15436
+ return index.live?.readRedactedFile(entry.relativePath)?.text ?? null;
15437
+ }
15438
+ function bodyFor(workspace, index, entry, cache) {
15022
15439
  if (index.live !== null && index.trust.indexSource !== "snapshot") {
15023
15440
  return index.live.readRedactedFile(entry.relativePath)?.text ?? null;
15024
15441
  }
15025
15442
  const partPath = partPathFor(workspace, entry.part);
15026
- if (partPath === null) return null;
15027
- try {
15028
- if (fs28__namespace.statSync(partPath).size > MAX_PART_READ_BYTES) return null;
15029
- const sections = parsePartSections(fs28__namespace.readFileSync(partPath, "utf8"));
15030
- const section = findSection(sections, entry.relativePath);
15031
- return section === null ? null : section.body;
15032
- } catch {
15443
+ if (partPath === null) {
15444
+ if (index.live !== null) {
15445
+ noteUnverifiedPart(index, entry.part + " is missing; live bytes used");
15446
+ return liveBody(index, entry);
15447
+ }
15033
15448
  return null;
15034
15449
  }
15450
+ const store = partCaches.get(index) ?? (() => {
15451
+ const created = /* @__PURE__ */ new Map();
15452
+ partCaches.set(index, created);
15453
+ return created;
15454
+ })();
15455
+ let sections = store.get(entry.part);
15456
+ if (sections === void 0) {
15457
+ try {
15458
+ if (fs29__namespace.statSync(partPath).size > MAX_PART_READ_BYTES) {
15459
+ store.set(entry.part, null);
15460
+ return null;
15461
+ }
15462
+ const bytes = fs29__namespace.readFileSync(partPath);
15463
+ const recorded = index.manifest.parts.find((part) => part.filename === entry.part);
15464
+ if (recorded === void 0 || bytes.length !== recorded.byteSize || sha256Of(bytes) !== recorded.sha256) {
15465
+ store.set(entry.part, null);
15466
+ noteUnverifiedPart(
15467
+ index,
15468
+ entry.part + " does not match its recorded digest; live bytes used"
15469
+ );
15470
+ return liveBody(index, entry);
15471
+ }
15472
+ sections = parsePartSections(bytes.toString("utf8"));
15473
+ store.set(entry.part, sections);
15474
+ } catch {
15475
+ store.set(entry.part, null);
15476
+ noteUnverifiedPart(index, entry.part + " could not be read; live bytes used");
15477
+ return liveBody(index, entry);
15478
+ }
15479
+ }
15480
+ if (sections === null) return liveBody(index, entry);
15481
+ const section = findSection(sections, entry.relativePath);
15482
+ if (section === null) {
15483
+ noteUnverifiedPart(index, entry.relativePath + " is absent from " + entry.part + "; live bytes used");
15484
+ return liveBody(index, entry);
15485
+ }
15486
+ return section.body;
15487
+ }
15488
+ function numberWindow(text2) {
15489
+ if (text2.length === 0) return text2;
15490
+ return text2.split("\n").map((line, index) => index + 1 + ": " + line).join("\n");
15035
15491
  }
15036
15492
  var impactTool = {
15037
15493
  name: "snapshot_impact",
@@ -15147,7 +15603,18 @@ var impactTool = {
15147
15603
  targetPath: entry.path
15148
15604
  }));
15149
15605
  });
15150
- if (tsEntries.length > DEFAULT_MAX_PROGRAM_FILES) {
15606
+ const lossyBodies = index.trust.indexSource === "snapshot" && tsEntries.some(
15607
+ (entry) => entry.inclusionMode === "preview" || entry.inclusionMode === "signatures"
15608
+ );
15609
+ if (lossyBodies) {
15610
+ const reason = "TypeScript compiler pass skipped: the snapshot holds previewed or skeletonised bodies; run snapshot_impact with live: true for compiler-resolved references";
15611
+ report2 = {
15612
+ ...report2,
15613
+ precise: { references: [], coverage: "partial", reasons: [reason] }
15614
+ };
15615
+ report2.trust.coverage = "partial";
15616
+ report2.trust.reasons = [.../* @__PURE__ */ new Set([...report2.trust.reasons, reason])];
15617
+ } else if (tsEntries.length > DEFAULT_MAX_PROGRAM_FILES) {
15151
15618
  const reason = "TypeScript compiler pass skipped: " + tsEntries.length + " TS/JS files exceed the " + DEFAULT_MAX_PROGRAM_FILES + "-file cap; fell back to import-binding results";
15152
15619
  report2 = {
15153
15620
  ...report2,
@@ -15165,14 +15632,17 @@ var impactTool = {
15165
15632
  const body = bodyFor(workspace, index, entry);
15166
15633
  return body === null ? null : { relativePath: entry.relativePath, content: body };
15167
15634
  }).filter((entry) => entry !== null);
15168
- const workerResult = await analysisInWorker({
15169
- task: "ts-batch-refs",
15170
- options: {
15171
- root: workspace.root,
15172
- files,
15173
- targets
15174
- }
15175
- });
15635
+ const workerResult = await analysisInWorker(
15636
+ {
15637
+ task: "ts-batch-refs",
15638
+ options: {
15639
+ root: workspace.root,
15640
+ files,
15641
+ targets
15642
+ }
15643
+ },
15644
+ cancellationSignal(context)
15645
+ );
15176
15646
  if (!workerResult.ok) return failure(workerResult.message);
15177
15647
  const result = workerResult.result;
15178
15648
  const references = [];
@@ -15226,6 +15696,8 @@ var contextTool = {
15226
15696
  usedTokens: { type: "integer" },
15227
15697
  files: { type: "array", items: { type: "object" } },
15228
15698
  omitted: { type: "array", items: { type: "object" } },
15699
+ skipped: { type: "array", items: { type: "object" } },
15700
+ notes: { type: "array", items: { type: "string" } },
15229
15701
  trust: { type: "object" }
15230
15702
  }
15231
15703
  },
@@ -15262,16 +15734,16 @@ var contextTool = {
15262
15734
  }
15263
15735
  }
15264
15736
  for (const wanted of wantedFiles) {
15265
- const relative18 = toRelativePath(workspace.root, wanted);
15266
- if (relative18 === null) {
15737
+ const relative20 = toRelativePath(workspace.root, wanted);
15738
+ if (relative20 === null) {
15267
15739
  preOmitted.push({ path: wanted, reason: "outside the served repository" });
15268
15740
  continue;
15269
15741
  }
15270
- if (isSensitivePath(relative18)) {
15271
- preOmitted.push({ path: relative18, reason: "sensitive-file" });
15742
+ if (isSensitivePath(relative20)) {
15743
+ preOmitted.push({ path: relative20, reason: "sensitive-file" });
15272
15744
  continue;
15273
15745
  }
15274
- targets.set(relative18, "requested file");
15746
+ targets.set(relative20, "requested file");
15275
15747
  }
15276
15748
  for (const symbol of wantedSymbols) {
15277
15749
  const needle = symbol.toLowerCase();
@@ -15361,8 +15833,9 @@ var contextTool = {
15361
15833
  });
15362
15834
  continue;
15363
15835
  }
15364
- const window = windowText(body, 1, linesPerFile);
15365
- let text2 = capResultText(window.text).text;
15836
+ let window = windowText(body, 1, linesPerFile);
15837
+ let capped2 = capResultText(numberWindow(window.text));
15838
+ let text2 = capped2.text;
15366
15839
  let tokens = Math.max(1, estimateTokens(text2));
15367
15840
  if (used + tokens > budget) {
15368
15841
  const keep = Math.max(4, Math.floor((budget - used) / tokens * linesPerFile));
@@ -15370,17 +15843,30 @@ var contextTool = {
15370
15843
  omitted.push({ path: relativePath, reason: "budget" });
15371
15844
  continue;
15372
15845
  }
15373
- const smaller = windowText(body, 1, keep);
15374
- text2 = capResultText(smaller.text).text;
15846
+ window = windowText(body, 1, keep);
15847
+ capped2 = capResultText(numberWindow(window.text));
15848
+ text2 = capped2.text;
15375
15849
  tokens = Math.max(1, estimateTokens(text2));
15376
15850
  if (used + tokens > budget || text2.length === 0) {
15377
15851
  omitted.push({ path: relativePath, reason: "budget" });
15378
15852
  continue;
15379
15853
  }
15380
15854
  }
15381
- sections.push("### " + relativePath + " (" + entry.part + ", " + linesPerFile + " line window)");
15855
+ const returnedLines = text2.length === 0 ? 0 : text2.split("\n").length;
15856
+ const truncated = window.truncated || capped2.clipped;
15857
+ sections.push(
15858
+ "### " + relativePath + " (" + entry.part + ", lines 1\u2013" + returnedLines + " of " + window.totalLines + (truncated ? "; more remains" : "") + ")"
15859
+ );
15382
15860
  sections.push(text2);
15383
- blocks.push({ path: relativePath, tokens, why });
15861
+ blocks.push({
15862
+ path: relativePath,
15863
+ tokens,
15864
+ why,
15865
+ fromLine: 1,
15866
+ returnedLines,
15867
+ totalLines: window.totalLines,
15868
+ truncated
15869
+ });
15384
15870
  used += tokens;
15385
15871
  }
15386
15872
  const notes = omitted.length === 0 ? [] : ["Not returned: " + omitted.map((entry) => entry.path + " (" + entry.reason + ")").join(", ") + "."];
@@ -15531,11 +16017,17 @@ var locateTool = {
15531
16017
  for (const entry of index.manifest.files) add(entry, "filter");
15532
16018
  }
15533
16019
  const shouldText = by === "text" || by === "auto" && matches.length === 0 && rawQuery.length >= 3;
16020
+ let textCapReason = null;
15534
16021
  if (shouldText) {
15535
16022
  let scanned = 0;
15536
16023
  for (const entry of index.manifest.files) {
15537
16024
  if (!allowed(entry)) continue;
15538
- if (scanned >= MAX_SEARCH_BYTES) break;
16025
+ if (scanned >= MAX_SEARCH_BYTES) {
16026
+ textCapReason = "text search stopped after 4 MiB of indexed bodies; later files were not scanned";
16027
+ index.trust.coverage = "partial";
16028
+ index.trust.reasons = [.../* @__PURE__ */ new Set([...index.trust.reasons, textCapReason])];
16029
+ break;
16030
+ }
15539
16031
  const body = bodyFor(workspace, index, entry);
15540
16032
  if (body === null) continue;
15541
16033
  scanned += Buffer.byteLength(body, "utf8");
@@ -15567,7 +16059,15 @@ var locateTool = {
15567
16059
  let referenceReasons = [];
15568
16060
  if (args.includeReferences === true && rawQuery.length > 0) {
15569
16061
  const tsEntries = index.manifest.files.filter((entry) => /\.(?:[cm]?[jt]sx?)$/i.test(entry.relativePath));
15570
- if (tsEntries.length > DEFAULT_MAX_PROGRAM_FILES) {
16062
+ const lossyBodies = index.trust.indexSource === "snapshot" && tsEntries.some(
16063
+ (entry) => entry.inclusionMode === "preview" || entry.inclusionMode === "signatures"
16064
+ );
16065
+ const lossyReason = "TypeScript compiler pass skipped: the snapshot holds previewed or skeletonised bodies; run snapshot_locate with live: true for compiler-resolved references";
16066
+ if (lossyBodies) {
16067
+ referenceReasons = [lossyReason];
16068
+ index.trust.coverage = "partial";
16069
+ index.trust.reasons = [.../* @__PURE__ */ new Set([...index.trust.reasons, lossyReason])];
16070
+ } else if (tsEntries.length > DEFAULT_MAX_PROGRAM_FILES) {
15571
16071
  const reason = "TypeScript compiler pass skipped: " + tsEntries.length + " TS/JS files exceed the " + DEFAULT_MAX_PROGRAM_FILES + "-file cap; fell back to syntactic matches";
15572
16072
  referenceReasons = [reason];
15573
16073
  index.trust.coverage = "partial";
@@ -15581,15 +16081,18 @@ var locateTool = {
15581
16081
  (entry) => entry.matchedBy === "symbol" && (pattern === null ? entry.detail?.toLowerCase() === needle : entry.detail === rawQuery)
15582
16082
  );
15583
16083
  const target = exact?.path;
15584
- const workerResult = await analysisInWorker({
15585
- task: "ts-refs",
15586
- options: {
15587
- root: workspace.root,
15588
- files,
15589
- symbolName: rawQuery,
15590
- ...target === void 0 ? {} : { targetPath: target }
15591
- }
15592
- });
16084
+ const workerResult = await analysisInWorker(
16085
+ {
16086
+ task: "ts-refs",
16087
+ options: {
16088
+ root: workspace.root,
16089
+ files,
16090
+ symbolName: rawQuery,
16091
+ ...target === void 0 ? {} : { targetPath: target }
16092
+ }
16093
+ },
16094
+ cancellationSignal(context)
16095
+ );
15593
16096
  if (!workerResult.ok) return failure(workerResult.message);
15594
16097
  const result = workerResult.result;
15595
16098
  references = result.references;
@@ -15606,6 +16109,7 @@ var locateTool = {
15606
16109
  (match) => match.line === void 0 ? " - " + match.path + " [" + match.matchedBy + (match.detail === void 0 ? "" : ": " + match.detail) + "]" : " - " + match.path + ":" + match.line + " " + (match.text ?? "")
15607
16110
  ),
15608
16111
  ...references.length === 0 ? [] : ["", "References:", ...references.slice(0, 25).map((reference) => " - " + reference.path + ":" + reference.line + " (" + reference.name + ")")],
16112
+ ...textCapReason === null ? [] : ["Note: " + textCapReason],
15609
16113
  ...referenceReasons.slice(0, 3).map((reason) => "Note: " + reason)
15610
16114
  ];
15611
16115
  return {
@@ -15689,29 +16193,34 @@ var readTool = {
15689
16193
  return failure(relativePath + " is recorded in " + entry.part + " but its body could not be read. Run snapshot_generate.");
15690
16194
  }
15691
16195
  const window = windowText(body, fromLine, lineCount);
15692
- const cappedText = capResultText(window.text);
15693
- const returnedLines = cappedText.text.length === 0 ? 0 : cappedText.text.split("\n").length;
16196
+ const cappedText = capResultText(window.text, MAX_RESULT_BYTES - 1024);
16197
+ const bodyLines = cappedText.text.length === 0 ? 0 : cappedText.text.split("\n").length;
15694
16198
  const header2 = [
15695
16199
  relativePath + " \u2014 " + entry.part + ", " + entry.layer + "/" + entry.kind + ", " + entry.language,
15696
- window.totalLines === 0 ? "This file is empty." : window.pastEnd ? "This file has " + window.totalLines + " line(s); fromLine=" + window.fromLine + " is past its end." : "Lines " + window.fromLine + "\u2013" + (window.fromLine + returnedLines - 1) + " of " + window.totalLines + ".",
16200
+ window.totalLines === 0 ? "This file is empty." : window.pastEnd ? "This file has " + window.totalLines + " line(s); fromLine=" + window.fromLine + " is past its end." : "Lines " + window.fromLine + "\u2013" + (window.fromLine + bodyLines - 1) + " of " + window.totalLines + ".",
15697
16201
  ...index.trust.indexSource === "snapshot" && entry.inclusionMode === "preview" ? ["Bounded preview: the snapshot holds this file's head and tail only."] : [],
15698
16202
  ...cappedText.clipped ? ["Truncated: a line is longer than one result can carry, so this page may end mid-line."] : []
15699
16203
  ];
15700
16204
  const text2 = [...header2, "", cappedText.text];
15701
- if (window.truncated || cappedText.clipped) {
15702
- text2.push("", "Truncated. Call snapshot_read with fromLine=" + (window.fromLine + returnedLines) + " for the rest.");
15703
- }
16205
+ if (!cappedText.clipped && window.truncated) {
16206
+ text2.push("", "Truncated. Call snapshot_read with fromLine=" + (window.fromLine + bodyLines) + " for the rest.");
16207
+ }
16208
+ const response = capResponseText(text2.join("\n"));
16209
+ const clipped = cappedText.clipped || response.clipped;
16210
+ const headerPrefix = header2.join("\n") + "\n\n";
16211
+ const delivered = response.text.startsWith(headerPrefix) ? response.text.slice(headerPrefix.length) : "";
16212
+ const returnedLines = response.clipped ? delivered.length === 0 ? 0 : delivered.split("\n").length : bodyLines;
15704
16213
  return {
15705
- text: capResponseText(text2.join("\n")).text,
16214
+ text: response.text,
15706
16215
  structured: {
15707
16216
  path: entry.relativePath,
15708
16217
  part: entry.part,
15709
16218
  fromLine: window.fromLine,
15710
16219
  returnedLines,
15711
16220
  totalLines: window.totalLines,
15712
- ...!cappedText.clipped && window.truncated ? { nextFromLine: window.fromLine + returnedLines } : {},
15713
- truncated: window.truncated || cappedText.clipped,
15714
- pageable: !cappedText.clipped,
16221
+ ...!clipped && window.truncated ? { nextFromLine: window.fromLine + returnedLines } : {},
16222
+ truncated: window.truncated || clipped,
16223
+ pageable: !clipped,
15715
16224
  trust: index.trust
15716
16225
  }
15717
16226
  };
@@ -15727,6 +16236,19 @@ var validateTool = {
15727
16236
  mode: { type: "string", enum: ["status", "drift", "audit"], default: "drift" },
15728
16237
  deep: { type: "boolean", description: "With audit, replay every full body." },
15729
16238
  maxScanBytes: { type: "integer", minimum: 1, description: "Cap the audit text scan." },
16239
+ // `snapshot_generate` accepts every option below, and each one enters `configDigest`.
16240
+ // A validator that did not accept them reported permanent drift for a snapshot the same
16241
+ // server had just written.
16242
+ maxPartBytes: { type: ["string", "number"], description: 'Byte budget per part, for example 307200 or "300k".' },
16243
+ maxPartTokens: { type: ["string", "number"], description: 'Token budget per part, for example 32000 or "32k".' },
16244
+ skeleton: { type: "boolean", description: "Signature-compress JS/TS bodies." },
16245
+ sarif: { type: "boolean", description: "Also write reports/audit.sarif." },
16246
+ stripComments: { type: "boolean", description: "Remove comments from JS/TS bodies." },
16247
+ removeEmptyLines: { type: "boolean", description: "Drop blank lines from bodies." },
16248
+ pack: { type: "string", enum: ["single", "xml", "json"], description: "Write one full-repository file." },
16249
+ includeDiffs: { type: "boolean", description: "Also write reports/diff.md." },
16250
+ includeLogs: { type: "integer", minimum: 1, maximum: 500, description: "Also write reports/log.md." },
16251
+ tokenTree: { type: "boolean", description: "Also write reports/tokens.md." },
15730
16252
  root: ROOT_PROPERTY,
15731
16253
  outDir: OUT_DIR_PROPERTY,
15732
16254
  ...SCOPE_PROPERTIES
@@ -15777,19 +16299,22 @@ var validateTool = {
15777
16299
  };
15778
16300
  }
15779
16301
  if (mode === "audit") {
15780
- const analysis2 = await analysisInWorker({
15781
- task: "health",
15782
- options: {
15783
- snapshotDir: path7__namespace.resolve(workspace.root, workspace.config.outDir),
15784
- repoDir: workspace.root,
15785
- // Only the project's own rules: `auditSnapshot` adds the built-in set itself for the
15786
- // section scan. Passing all 32 here re-scans every raw part under its Markdown path,
15787
- // where an unquoted TypeScript expression looks like an unmasked credential.
15788
- ...(workspace.config.customSecretRules ?? []).length === 0 ? {} : { secretRules: workspace.config.customSecretRules },
15789
- deep: args.deep === true,
15790
- ...typeof args.maxScanBytes === "number" ? { maxScanBytes: args.maxScanBytes } : {}
15791
- }
15792
- });
16302
+ const analysis2 = await analysisInWorker(
16303
+ {
16304
+ task: "health",
16305
+ options: {
16306
+ snapshotDir: path7__namespace.resolve(workspace.root, workspace.config.outDir),
16307
+ repoDir: workspace.root,
16308
+ // Only the project's own rules: `auditSnapshot` adds the built-in set itself for the
16309
+ // section scan. Passing all 32 here re-scans every raw part under its Markdown path,
16310
+ // where an unquoted TypeScript expression looks like an unmasked credential.
16311
+ ...(workspace.config.customSecretRules ?? []).length === 0 ? {} : { secretRules: workspace.config.customSecretRules },
16312
+ deep: args.deep === true,
16313
+ ...typeof args.maxScanBytes === "number" ? { maxScanBytes: args.maxScanBytes } : {}
16314
+ }
16315
+ },
16316
+ cancellationSignal(context)
16317
+ );
15793
16318
  if (!analysis2.ok) return failure(analysis2.message);
15794
16319
  const report2 = analysis2.result;
15795
16320
  const failed = report2.checks.filter((check2) => check2.status === "fail");
@@ -15809,12 +16334,15 @@ var validateTool = {
15809
16334
  }
15810
16335
  };
15811
16336
  }
15812
- const analysis = await analysisInWorker({
15813
- task: "validate-workspace",
15814
- root: workspace.root,
15815
- sourceConfig: workspace.sourceConfig,
15816
- cliOptions: workspace.cliOptions
15817
- });
16337
+ const analysis = await analysisInWorker(
16338
+ {
16339
+ task: "validate-workspace",
16340
+ root: workspace.root,
16341
+ sourceConfig: workspace.sourceConfig,
16342
+ cliOptions: workspace.cliOptions
16343
+ },
16344
+ cancellationSignal(context)
16345
+ );
15818
16346
  if (!analysis.ok) return failure(analysis.message);
15819
16347
  const result = analysis.result;
15820
16348
  const lines = [result.valid ? "The snapshot matches the repository." : "The snapshot is out of date."];
@@ -15873,13 +16401,16 @@ var explainTool = {
15873
16401
  if (typeof args.path !== "string") return failure('"path" must be a string.');
15874
16402
  const relativePath = toRelativePath(workspace.root, args.path);
15875
16403
  if (relativePath === null) return failure('"' + args.path + '" is outside ' + workspace.root + ".");
15876
- const analysis = await analysisInWorker({
15877
- task: "explain",
15878
- root: workspace.root,
15879
- sourceConfig: workspace.sourceConfig,
15880
- cliOptions: workspace.cliOptions,
15881
- path: relativePath
15882
- });
16404
+ const analysis = await analysisInWorker(
16405
+ {
16406
+ task: "explain",
16407
+ root: workspace.root,
16408
+ sourceConfig: workspace.sourceConfig,
16409
+ cliOptions: workspace.cliOptions,
16410
+ path: relativePath
16411
+ },
16412
+ cancellationSignal(context)
16413
+ );
15883
16414
  if (!analysis.ok) return failure(analysis.message);
15884
16415
  const result = analysis.result;
15885
16416
  return {
@@ -16304,7 +16835,7 @@ var COMMAND_OPTION_SCOPE = {
16304
16835
  ],
16305
16836
  // The health audit resolves the config only to find the output directory; --strict decides the
16306
16837
  // exit code, and every other setting would be a promise the command does not keep.
16307
- health: ["cwd", "out-dir", "format", "strict", "all-members", "deep", "mode", "no-update-check", "help", "version"],
16838
+ health: ["cwd", "out-dir", "format", "strict", "all-members", "deep", "no-config", "mode", "no-update-check", "help", "version"],
16308
16839
  // `impact` reads the existing manifest and the working tree. It deliberately takes no
16309
16840
  // generation settings: accepting one would imply the report regenerated or re-scoped the
16310
16841
  // snapshot, which it never does.
@@ -16750,42 +17281,42 @@ function buildAgentContract() {
16750
17281
  type: "string",
16751
17282
  default: null,
16752
17283
  appliesTo: optionAppliesTo("diff"),
16753
- summary: "impact and brief: compare the working tree against this git ref. The set includes committed, staged, unstaged and untracked changes relative to the ref."
17284
+ summary: "impact, guard and brief: compare the working tree against this git ref. The set includes committed, staged, unstaged and untracked changes relative to the ref."
16754
17285
  },
16755
17286
  {
16756
17287
  flag: "--paths",
16757
17288
  type: "string",
16758
17289
  default: null,
16759
17290
  appliesTo: optionAppliesTo("paths"),
16760
- summary: "impact and brief: comma-separated repository-relative paths to treat as the change. Mutually exclusive with --diff."
17291
+ summary: "impact, guard and brief: comma-separated repository-relative paths to treat as the change. Mutually exclusive with --diff."
16761
17292
  },
16762
17293
  {
16763
17294
  flag: "--depth",
16764
17295
  type: "number",
16765
17296
  default: 3,
16766
17297
  appliesTo: optionAppliesTo("depth"),
16767
- summary: "impact and brief: reverse-import hops to follow, 1-8 (default 3)."
17298
+ summary: "impact, guard and brief: reverse-import hops to follow, 1-8 (default 3)."
16768
17299
  },
16769
17300
  {
16770
17301
  flag: "--max-results",
16771
17302
  type: "number",
16772
17303
  default: 200,
16773
17304
  appliesTo: optionAppliesTo("max-results"),
16774
- summary: "impact and brief: maximum affected files, 1-1000 (default 200)."
17305
+ summary: "impact, guard and brief: maximum affected files, 1-1000 (default 200)."
16775
17306
  },
16776
17307
  {
16777
17308
  flag: "--no-cache",
16778
17309
  type: "boolean",
16779
17310
  default: false,
16780
17311
  appliesTo: optionAppliesTo("no-cache"),
16781
- summary: "impact/brief only: bypass the OS live-index summary cache."
17312
+ summary: "impact, guard and brief: bypass the OS live-index summary cache."
16782
17313
  },
16783
17314
  {
16784
17315
  flag: "--no-live",
16785
17316
  type: "boolean",
16786
17317
  default: false,
16787
17318
  appliesTo: optionAppliesTo("no-live"),
16788
- summary: "impact/brief only: require the generated snapshot instead of using the live index."
17319
+ summary: "impact, guard and brief: require the generated snapshot instead of using the live index."
16789
17320
  },
16790
17321
  {
16791
17322
  flag: "--tests-paths",
@@ -17028,7 +17559,7 @@ function buildAgentContract() {
17028
17559
  {
17029
17560
  flag: "--port",
17030
17561
  type: "string",
17031
- default: "4789",
17562
+ default: "4789 (mcp) / 4788 (serve)",
17032
17563
  appliesTo: optionAppliesTo("port"),
17033
17564
  summary: "mcp --http: port to bind. 0 picks an ephemeral port and prints it."
17034
17565
  },
@@ -17214,7 +17745,7 @@ function buildAgentContract() {
17214
17745
  type: "string",
17215
17746
  default: "generate",
17216
17747
  appliesTo: optionAppliesTo("mode"),
17217
- summary: "Select the command when no command word is given. Values: generate, validate, check, report, init, setup, explain, diff, describe, skill, mcp, health, impact, brief, update, serve. A command word and --mode must name the same command; a contradiction is a usage error (exit 2)."
17748
+ summary: "Select the command when no command word is given. Values: generate, validate, check, report, impact, guard, brief, init, setup, explain, diff, describe, skill, mcp, health, update, serve. A command word and --mode must name the same command; a contradiction is a usage error (exit 2)."
17218
17749
  },
17219
17750
  {
17220
17751
  flag: "--cwd",
@@ -17373,7 +17904,7 @@ function buildAgentContract() {
17373
17904
  { key: "maxParts", type: "number | null", default: null, summary: "Experimental: the most parts a snapshot may have. The per-part budget grows to fit, up to the run's own needs; the effective ceiling is recorded in manifest.budgets.maxPartBytes and may exceed maxPartBytes." },
17374
17905
  { key: "attachmentSlots", type: "number", default: 10, summary: "Files the destination accepts in one message (0 = no limit); PROMPT.md plans the delivery to fit. It does not change the payload, and it is not part of the config digest." },
17375
17906
  { key: "discovery", type: '"auto" | "git" | "walk"', default: "auto", summary: "How files are discovered; `walk` scans the tree and reads .gitignore directly when a .git directory cannot be listed." },
17376
- { key: "artifacts", type: "object", default: "all on except monolith", summary: "Per-artifact opt-out." },
17907
+ { key: "artifacts", type: "object", default: "all on except monolith, diff, log and tokenTree", summary: "Per-artifact opt-out." },
17377
17908
  { key: "budgets", type: "object", default: "{ default, byLayer }", summary: "Per-layer byte budgets." },
17378
17909
  { key: "layersMode", type: '"merge" | "replace"', default: "merge", summary: "Whether custom layers extend or replace the preset's." },
17379
17910
  { key: "layers", type: "array", default: "preset layers", summary: "Custom layer rules (glob or RegExp)." },
@@ -17709,7 +18240,7 @@ async function workspaceFor(context) {
17709
18240
  }
17710
18241
  function readFileIfPresent(file) {
17711
18242
  try {
17712
- return fs28__namespace.readFileSync(file, "utf8");
18243
+ return fs29__namespace.readFileSync(file, "utf8");
17713
18244
  } catch {
17714
18245
  return null;
17715
18246
  }
@@ -17753,7 +18284,7 @@ function buildResourceProvider() {
17753
18284
  const read = readManifest3(workspace);
17754
18285
  if (!read.ok) return resources;
17755
18286
  for (const [uri, report2] of REPORT_URIS) {
17756
- const present = reportsDir !== null && fs28__namespace.existsSync(path7__namespace.join(reportsDir, report2.file));
18287
+ const present = reportsDir !== null && fs29__namespace.existsSync(path7__namespace.join(reportsDir, report2.file));
17757
18288
  if (!present) continue;
17758
18289
  resources.push({
17759
18290
  uri,
@@ -17894,7 +18425,7 @@ function buildResourceProvider() {
17894
18425
  }
17895
18426
  let partBytes;
17896
18427
  try {
17897
- partBytes = fs28__namespace.statSync(partPath).size;
18428
+ partBytes = fs29__namespace.statSync(partPath).size;
17898
18429
  } catch {
17899
18430
  throw new ResourceNotFoundError(uri, part.filename + " is missing from this snapshot.");
17900
18431
  }
@@ -17932,41 +18463,41 @@ function validateArguments(schema, value) {
17932
18463
  }
17933
18464
  return problems;
17934
18465
  }
17935
- function checkValue(path31, schema, value) {
18466
+ function checkValue(path32, schema, value) {
17936
18467
  if (schema.enum && !schema.enum.includes(value)) {
17937
- return [`"${path31}" must be one of: ${schema.enum.join(", ")}`];
18468
+ return [`"${path32}" must be one of: ${schema.enum.join(", ")}`];
17938
18469
  }
17939
18470
  const declared = schema.type === void 0 ? [] : Array.isArray(schema.type) ? schema.type : [schema.type];
17940
18471
  if (declared.length > 0 && !declared.some((type) => matchesType(type, value))) {
17941
18472
  if (declared.length === 1 && declared[0] === "integer" && typeof value !== "number") {
17942
- return [`"${path31}" must be a number`];
18473
+ return [`"${path32}" must be a number`];
17943
18474
  }
17944
18475
  const article = (type) => type === "integer" || type === "object" || type === "array" ? `an ${type}` : `a ${type}`;
17945
- return [`"${path31}" must be ${declared.map(article).join(" or ")}`];
18476
+ return [`"${path32}" must be ${declared.map(article).join(" or ")}`];
17946
18477
  }
17947
18478
  const problems = [];
17948
18479
  if (declared.includes("string") && typeof value === "string") {
17949
18480
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
17950
- problems.push(`"${path31}" must be at least ${schema.minLength} character(s)`);
18481
+ problems.push(`"${path32}" must be at least ${schema.minLength} character(s)`);
17951
18482
  }
17952
18483
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
17953
- problems.push(`"${path31}" must be at most ${schema.maxLength} character(s)`);
18484
+ problems.push(`"${path32}" must be at most ${schema.maxLength} character(s)`);
17954
18485
  }
17955
18486
  }
17956
18487
  if ((declared.includes("number") || declared.includes("integer")) && typeof value === "number" && !Number.isNaN(value)) {
17957
18488
  if (declared.includes("integer") && !declared.includes("number") && !Number.isInteger(value)) {
17958
- problems.push(`"${path31}" must be an integer`);
18489
+ problems.push(`"${path32}" must be an integer`);
17959
18490
  }
17960
18491
  if (schema.minimum !== void 0 && value < schema.minimum) {
17961
- problems.push(`"${path31}" must be >= ${schema.minimum}`);
18492
+ problems.push(`"${path32}" must be >= ${schema.minimum}`);
17962
18493
  }
17963
18494
  if (schema.maximum !== void 0 && value > schema.maximum) {
17964
- problems.push(`"${path31}" must be <= ${schema.maximum}`);
18495
+ problems.push(`"${path32}" must be <= ${schema.maximum}`);
17965
18496
  }
17966
18497
  }
17967
18498
  if (declared.includes("array") && Array.isArray(value) && schema.items) {
17968
18499
  value.forEach((item, index) => {
17969
- problems.push(...checkValue(`${path31}[${index}]`, schema.items, item));
18500
+ problems.push(...checkValue(`${path32}[${index}]`, schema.items, item));
17970
18501
  });
17971
18502
  }
17972
18503
  return problems;
@@ -18046,10 +18577,10 @@ function createMcpServer(options) {
18046
18577
  if (method === "notifications/cancelled") {
18047
18578
  const requestId2 = params?.requestId;
18048
18579
  if (typeof requestId2 === "string" || typeof requestId2 === "number") {
18049
- const cancel = cancellations.get(requestId2);
18050
- if (cancel !== void 0) {
18580
+ const pending = cancellations.get(requestId2);
18581
+ if (pending !== void 0) {
18051
18582
  cancellations.delete(requestId2);
18052
- cancel();
18583
+ for (const cancel of pending) cancel();
18053
18584
  }
18054
18585
  }
18055
18586
  }
@@ -18130,7 +18661,13 @@ function createMcpServer(options) {
18130
18661
  ...options.context,
18131
18662
  // Always offered, so a long tool can be stopped whether or not the client asked for progress.
18132
18663
  onCancel: (cancel) => {
18133
- cancellations.set(id, cancel);
18664
+ registeredCancel = cancel;
18665
+ let pending = cancellations.get(id);
18666
+ if (pending === void 0) {
18667
+ pending = /* @__PURE__ */ new Set();
18668
+ cancellations.set(id, pending);
18669
+ }
18670
+ pending.add(cancel);
18134
18671
  },
18135
18672
  ...progressToken === void 0 || options.notify === void 0 ? {} : {
18136
18673
  notify: (event) => {
@@ -18145,6 +18682,7 @@ function createMcpServer(options) {
18145
18682
  }
18146
18683
  };
18147
18684
  let outcome;
18685
+ let registeredCancel;
18148
18686
  try {
18149
18687
  outcome = await tool.handler(args, callContext);
18150
18688
  } catch (error) {
@@ -18156,7 +18694,13 @@ function createMcpServer(options) {
18156
18694
  modern
18157
18695
  );
18158
18696
  } finally {
18159
- cancellations.delete(id);
18697
+ if (registeredCancel !== void 0) {
18698
+ const pending = cancellations.get(id);
18699
+ if (pending !== void 0) {
18700
+ pending.delete(registeredCancel);
18701
+ if (pending.size === 0) cancellations.delete(id);
18702
+ }
18703
+ }
18160
18704
  }
18161
18705
  return ok(
18162
18706
  id,
@@ -18643,14 +19187,51 @@ function createMcpHttpHandler(options) {
18643
19187
  const token = options.token;
18644
19188
  const maxBody = options.maxBodyBytes ?? DEFAULT_MAX_BODY;
18645
19189
  const extraOrigins = options.allowedOrigins ?? [];
18646
- const createMcp = () => createServer({
19190
+ const modernCancellations = /* @__PURE__ */ new Map();
19191
+ const MAX_MODERN_SCOPES = 64;
19192
+ const modernCancellationMap = (scope) => {
19193
+ let map = modernCancellations.get(scope);
19194
+ if (map !== void 0) return map;
19195
+ if (modernCancellations.size >= MAX_MODERN_SCOPES) {
19196
+ const oldest = modernCancellations.keys().next().value;
19197
+ if (oldest !== void 0) modernCancellations.delete(oldest);
19198
+ }
19199
+ map = /* @__PURE__ */ new Map();
19200
+ modernCancellations.set(scope, map);
19201
+ return map;
19202
+ };
19203
+ const createMcp = (cancellations) => createServer({
18647
19204
  cwd: options.cwd,
18648
19205
  log,
18649
- // Each server owns its cancellation map. A map shared by every HTTP and SSE session keyed
18650
- // only by the JSON-RPC id let one client's `id: 1` overwrite another's, and let either one
18651
- // cancel the other's in-flight tool call.
19206
+ // Each non-modern server owns its cancellation map. A map shared by every HTTP and SSE
19207
+ // session keyed only by the JSON-RPC id let one client's `id: 1` overwrite another's, and
19208
+ // let either one cancel the other's in-flight tool call.
19209
+ ...cancellations === void 0 ? {} : { cancellations },
18652
19210
  ...options.noConfig === true ? { noConfig: true } : {}
18653
19211
  });
19212
+ const clientScopeHint = (message) => {
19213
+ const items = Array.isArray(message) ? message : [message];
19214
+ for (const item of items) {
19215
+ if (!isJsonObject(item)) continue;
19216
+ const params = item.params;
19217
+ if (!isJsonObject(params)) continue;
19218
+ const meta = params._meta;
19219
+ if (!isJsonObject(meta)) continue;
19220
+ const info = meta[META_KEYS.clientInfo];
19221
+ if (!isJsonObject(info)) continue;
19222
+ const name = typeof info.name === "string" ? info.name : "";
19223
+ const version = typeof info.version === "string" ? info.version : "";
19224
+ if (name !== "" || version !== "") return "client:" + name + "@" + version;
19225
+ }
19226
+ return "";
19227
+ };
19228
+ const messageMethod = (message) => {
19229
+ const items = Array.isArray(message) ? message : [message];
19230
+ for (const item of items) {
19231
+ if (isJsonObject(item) && typeof item.method === "string") return item.method;
19232
+ }
19233
+ return "";
19234
+ };
18654
19235
  const toolCount = buildTools().length;
18655
19236
  const mcpSessions = /* @__PURE__ */ new Map();
18656
19237
  const socketServers = /* @__PURE__ */ new WeakMap();
@@ -18999,7 +19580,30 @@ function createMcpHttpHandler(options) {
18999
19580
  responseSession = newSessionId();
19000
19581
  rememberSession(responseSession, server, Date.now());
19001
19582
  } else if (modern) {
19002
- server = createMcp();
19583
+ const hint = clientScopeHint(message);
19584
+ const anonymous = "anonymous:" + anonymousKey(request);
19585
+ let cancellations;
19586
+ if (supplied !== "") {
19587
+ cancellations = modernCancellationMap("session:" + supplied);
19588
+ } else if (messageMethod(message) === "notifications/cancelled" && hint === "") {
19589
+ cancellations = /* @__PURE__ */ new Map();
19590
+ for (const [scope, map] of modernCancellations) {
19591
+ if (scope !== anonymous && !scope.startsWith(anonymous + "|")) continue;
19592
+ for (const [id, pending] of map) {
19593
+ let merged = cancellations.get(id);
19594
+ if (merged === void 0) {
19595
+ merged = /* @__PURE__ */ new Set();
19596
+ cancellations.set(id, merged);
19597
+ }
19598
+ for (const cancel of pending) merged.add(cancel);
19599
+ }
19600
+ }
19601
+ } else {
19602
+ cancellations = modernCancellationMap(
19603
+ hint === "" ? anonymous : anonymous + "|" + hint
19604
+ );
19605
+ }
19606
+ server = createMcp(cancellations);
19003
19607
  } else if (supplied !== "") {
19004
19608
  const now = Date.now();
19005
19609
  pruneSessions(now);
@@ -19127,10 +19731,10 @@ function walkFiles(root, prefix = "") {
19127
19731
  const stack = [prefix];
19128
19732
  while (stack.length > 0) {
19129
19733
  const current = stack.pop();
19130
- for (const entry of fs28__namespace.readdirSync(path7__namespace.join(root, current), { withFileTypes: true })) {
19131
- const relative18 = current === "" ? entry.name : current + "/" + entry.name;
19132
- if (entry.isDirectory()) stack.push(relative18);
19133
- else if (entry.isFile()) files.push(relative18);
19734
+ for (const entry of fs29__namespace.readdirSync(path7__namespace.join(root, current), { withFileTypes: true })) {
19735
+ const relative20 = current === "" ? entry.name : current + "/" + entry.name;
19736
+ if (entry.isDirectory()) stack.push(relative20);
19737
+ else if (entry.isFile()) files.push(relative20);
19134
19738
  }
19135
19739
  }
19136
19740
  return files;
@@ -19144,16 +19748,16 @@ function writeZip(options) {
19144
19748
  }
19145
19749
  if (options.directory !== void 0) {
19146
19750
  const root = options.directory;
19147
- for (const relative18 of walkFiles(root)) {
19148
- if (options.skip !== void 0 && options.skip(relative18)) continue;
19149
- const full = path7__namespace.join(root, relative18);
19150
- const stat = fs28__namespace.statSync(full);
19751
+ for (const relative20 of walkFiles(root)) {
19752
+ if (options.skip !== void 0 && options.skip(relative20)) continue;
19753
+ const full = path7__namespace.join(root, relative20);
19754
+ const stat = fs29__namespace.statSync(full);
19151
19755
  if (totalBytes + stat.size > maxTotalBytes) {
19152
19756
  throw new Error("zip: uncompressed content exceeds " + maxTotalBytes + " bytes");
19153
19757
  }
19154
- const content = fs28__namespace.readFileSync(full);
19758
+ const content = fs29__namespace.readFileSync(full);
19155
19759
  totalBytes += content.length;
19156
- entries.push({ name: relative18, content, mtime: stat.mtime });
19760
+ entries.push({ name: relative20, content, mtime: stat.mtime });
19157
19761
  }
19158
19762
  }
19159
19763
  if (entries.length > 65535) {
@@ -19438,7 +20042,7 @@ async function startWebServer(options) {
19438
20042
  const snapshotRepoRoots = /* @__PURE__ */ new Map();
19439
20043
  const canonical = (candidate) => {
19440
20044
  try {
19441
- return fs28__namespace.realpathSync(candidate);
20045
+ return fs29__namespace.realpathSync(candidate);
19442
20046
  } catch {
19443
20047
  return null;
19444
20048
  }
@@ -19447,8 +20051,8 @@ async function startWebServer(options) {
19447
20051
  const inside2 = (resolved) => allowedRoots.some((root) => {
19448
20052
  const canonicalRoot2 = canonical(root);
19449
20053
  if (canonicalRoot2 === null) return false;
19450
- const relative18 = path7__namespace.relative(fold(canonicalRoot2), fold(resolved));
19451
- return relative18 === "" || !relative18.startsWith(`..${path7__namespace.sep}`) && relative18 !== ".." && !path7__namespace.isAbsolute(relative18);
20054
+ const relative20 = path7__namespace.relative(fold(canonicalRoot2), fold(resolved));
20055
+ return relative20 === "" || !relative20.startsWith(`..${path7__namespace.sep}`) && relative20 !== ".." && !path7__namespace.isAbsolute(relative20);
19452
20056
  });
19453
20057
  const insideAllowedRoots = (candidate) => {
19454
20058
  const resolved = canonical(candidate);
@@ -19464,7 +20068,7 @@ async function startWebServer(options) {
19464
20068
  const insideAllowedRootsForWrite = (candidate) => {
19465
20069
  let existing = path7__namespace.resolve(candidate);
19466
20070
  const tail = [];
19467
- while (!fs28__namespace.existsSync(existing)) {
20071
+ while (!fs29__namespace.existsSync(existing)) {
19468
20072
  tail.unshift(path7__namespace.basename(existing));
19469
20073
  const parent = path7__namespace.dirname(existing);
19470
20074
  if (parent === existing) break;
@@ -19625,7 +20229,7 @@ async function startWebServer(options) {
19625
20229
  } catch (error) {
19626
20230
  pendingClones.delete(cloneDirectory);
19627
20231
  try {
19628
- fs28__namespace.rmSync(cloneDirectory, { recursive: true, force: true });
20232
+ fs29__namespace.rmSync(cloneDirectory, { recursive: true, force: true });
19629
20233
  } catch {
19630
20234
  }
19631
20235
  throw error;
@@ -19633,7 +20237,7 @@ async function startWebServer(options) {
19633
20237
  pendingClones.delete(cloneDirectory);
19634
20238
  if (closing) {
19635
20239
  try {
19636
- fs28__namespace.rmSync(clone.directory, { recursive: true, force: true });
20240
+ fs29__namespace.rmSync(clone.directory, { recursive: true, force: true });
19637
20241
  } catch {
19638
20242
  }
19639
20243
  send(503, { error: "the server is shutting down" });
@@ -19651,7 +20255,7 @@ async function startWebServer(options) {
19651
20255
  if (repoRoot === oldest) snapshotRepoRoots.delete(snapshot);
19652
20256
  }
19653
20257
  try {
19654
- fs28__namespace.rmSync(oldest, { recursive: true, force: true });
20258
+ fs29__namespace.rmSync(oldest, { recursive: true, force: true });
19655
20259
  } catch {
19656
20260
  }
19657
20261
  }
@@ -19667,7 +20271,7 @@ async function startWebServer(options) {
19667
20271
  send(403, { error: "outside the served directory: " + target });
19668
20272
  return;
19669
20273
  }
19670
- if (!fs28__namespace.existsSync(target)) {
20274
+ if (!fs29__namespace.existsSync(target)) {
19671
20275
  send(404, { error: "no such path: " + target });
19672
20276
  return;
19673
20277
  }
@@ -19678,7 +20282,7 @@ async function startWebServer(options) {
19678
20282
  }
19679
20283
  let stat;
19680
20284
  try {
19681
- stat = fs28__namespace.statSync(target);
20285
+ stat = fs29__namespace.statSync(target);
19682
20286
  } catch {
19683
20287
  send(404, { error: "no such path: " + target });
19684
20288
  return;
@@ -19748,9 +20352,15 @@ async function startWebServer(options) {
19748
20352
  canonical(snapshotDir) ?? path7__namespace.resolve(snapshotDir),
19749
20353
  path7__namespace.resolve(target)
19750
20354
  );
20355
+ const auditConfig = resolveConfig(runConfig, { cwd: target }, target);
20356
+ const auditRules = auditConfig.customSecretRules ?? [];
19751
20357
  const audit = await analysisInWorker({
19752
20358
  task: "health",
19753
- options: { snapshotDir, repoDir: target }
20359
+ options: {
20360
+ snapshotDir,
20361
+ repoDir: target,
20362
+ ...auditRules.length === 0 ? {} : { secretRules: auditRules }
20363
+ }
19754
20364
  });
19755
20365
  if (!audit.ok) {
19756
20366
  send(500, { error: audit.message });
@@ -19796,7 +20406,7 @@ async function startWebServer(options) {
19796
20406
  send(403, { error: "outside the served directory: " + target });
19797
20407
  return;
19798
20408
  }
19799
- if (!fs28__namespace.existsSync(target)) {
20409
+ if (!fs29__namespace.existsSync(target)) {
19800
20410
  send(404, { error: "no snapshot directory at " + target });
19801
20411
  return;
19802
20412
  }
@@ -19809,23 +20419,40 @@ async function startWebServer(options) {
19809
20419
  send(403, { error: "the repository root for this snapshot is outside the served directory" });
19810
20420
  return;
19811
20421
  }
19812
- if (!fs28__namespace.existsSync(path7__namespace.join(target, "manifest.json"))) {
20422
+ if (!fs29__namespace.existsSync(path7__namespace.join(target, "manifest.json"))) {
19813
20423
  send(404, { error: "no manifest.json under " + target });
19814
20424
  return;
19815
20425
  }
19816
- void analysisInWorker({
19817
- task: "health",
19818
- options: { snapshotDir: target, repoDir }
19819
- }).then((analysis) => {
19820
- if (!analysis.ok) {
19821
- send(500, { error: analysis.message });
19822
- return;
20426
+ void (async () => {
20427
+ let healthSecretRules = [];
20428
+ try {
20429
+ const loadedConfig = await loadConfigFileDetailed(repoDir, { allowExecutableConfig: false });
20430
+ if (loadedConfig.errors.length === 0 && loadedConfig.config !== null) {
20431
+ assertServerSafeConfig(loadedConfig.config, loadedConfig.file ?? repoDir);
20432
+ healthSecretRules = resolveConfig(loadedConfig.config, { cwd: repoDir }, repoDir).customSecretRules ?? [];
20433
+ }
20434
+ } catch {
20435
+ healthSecretRules = [];
19823
20436
  }
19824
- const report2 = analysis.result;
19825
- send(200, { score: report2.score, counts: report2.counts, checks: report2.checks });
19826
- }).catch((error) => {
19827
- send(500, { error: error instanceof Error ? error.message : String(error) });
19828
- });
20437
+ try {
20438
+ const analysis = await analysisInWorker({
20439
+ task: "health",
20440
+ options: {
20441
+ snapshotDir: target,
20442
+ repoDir,
20443
+ ...healthSecretRules.length === 0 ? {} : { secretRules: healthSecretRules }
20444
+ }
20445
+ });
20446
+ if (!analysis.ok) {
20447
+ send(500, { error: analysis.message });
20448
+ return;
20449
+ }
20450
+ const report2 = analysis.result;
20451
+ send(200, { score: report2.score, counts: report2.counts, checks: report2.checks });
20452
+ } catch (error) {
20453
+ send(500, { error: error instanceof Error ? error.message : String(error) });
20454
+ }
20455
+ })();
19829
20456
  return;
19830
20457
  }
19831
20458
  if (request.method === "GET" && (request.url?.startsWith("/api/snapshot?") === true || request.url === "/api/snapshot")) {
@@ -19834,7 +20461,7 @@ async function startWebServer(options) {
19834
20461
  send(403, { error: "outside the served directory: " + target });
19835
20462
  return;
19836
20463
  }
19837
- if (!fs28__namespace.existsSync(target)) {
20464
+ if (!fs29__namespace.existsSync(target)) {
19838
20465
  send(404, { error: "no manifest.json under " + target });
19839
20466
  return;
19840
20467
  }
@@ -19887,7 +20514,7 @@ async function startWebServer(options) {
19887
20514
  send(403, { error: "outside the served directory: " + target });
19888
20515
  return;
19889
20516
  }
19890
- if (!fs28__namespace.existsSync(target)) {
20517
+ if (!fs29__namespace.existsSync(target)) {
19891
20518
  send(404, { error: "not a snapshot directory: " + target });
19892
20519
  return;
19893
20520
  }
@@ -19926,15 +20553,15 @@ async function startWebServer(options) {
19926
20553
  }
19927
20554
  }
19928
20555
  const artifactRecord = zipManifest.artifacts ?? {};
19929
- for (const [key, relative18] of Object.entries(ARTIFACT_PATHS)) {
19930
- if (artifactRecord[key] !== void 0 && artifactRecord[key] !== null) wanted.add(relative18);
20556
+ for (const [key, relative20] of Object.entries(ARTIFACT_PATHS)) {
20557
+ if (artifactRecord[key] !== void 0 && artifactRecord[key] !== null) wanted.add(relative20);
19931
20558
  }
19932
20559
  wanted.add("signature.json");
19933
20560
  const entries = [];
19934
- for (const relative18 of wanted) {
19935
- const read = readConfinedBytes(target, relative18, 256 * 1024 * 1024);
20561
+ for (const relative20 of wanted) {
20562
+ const read = readConfinedBytes(target, relative20, 256 * 1024 * 1024);
19936
20563
  if (!read.ok) continue;
19937
- entries.push({ name: relative18, content: read.bytes, mtime: read.stats.mtime });
20564
+ entries.push({ name: relative20, content: read.bytes, mtime: read.stats.mtime });
19938
20565
  }
19939
20566
  if (entries.length === 0) {
19940
20567
  send(404, { error: "the snapshot manifest declares no readable files" });
@@ -19956,11 +20583,11 @@ async function startWebServer(options) {
19956
20583
  }
19957
20584
  send(404, { error: "not found" });
19958
20585
  });
19959
- await new Promise((resolve20, reject) => {
20586
+ await new Promise((resolve21, reject) => {
19960
20587
  server.once("error", reject);
19961
20588
  server.listen(port, host, () => {
19962
20589
  server.removeListener("error", reject);
19963
- resolve20();
20590
+ resolve21();
19964
20591
  });
19965
20592
  });
19966
20593
  const address = server.address();
@@ -19977,17 +20604,17 @@ async function startWebServer(options) {
19977
20604
  await mcp.close();
19978
20605
  const deadline = Date.now() + 5e3;
19979
20606
  while (pendingClones.size > 0 && Date.now() < deadline) {
19980
- await new Promise((resolve20) => setTimeout(resolve20, 50));
20607
+ await new Promise((resolve21) => setTimeout(resolve21, 50));
19981
20608
  }
19982
20609
  for (const directory of [...pendingClones, ...temporaryClones]) {
19983
20610
  try {
19984
- fs28__namespace.rmSync(directory, { recursive: true, force: true });
20611
+ fs29__namespace.rmSync(directory, { recursive: true, force: true });
19985
20612
  } catch {
19986
20613
  }
19987
20614
  }
19988
20615
  server.closeAllConnections();
19989
- await new Promise((resolve20) => {
19990
- server.close(() => resolve20());
20616
+ await new Promise((resolve21) => {
20617
+ server.close(() => resolve21());
19991
20618
  });
19992
20619
  }
19993
20620
  };
@@ -20011,12 +20638,12 @@ var TEXT_ARTIFACT = /\.(md|json|txt|sarif|xml)$/i;
20011
20638
  function sha256(buffer) {
20012
20639
  return crypto.createHash("sha256").update(buffer).digest("hex");
20013
20640
  }
20014
- function snapshotText(snapshotDir, relative18) {
20015
- const read = readConfinedText(snapshotDir, relative18);
20641
+ function snapshotText(snapshotDir, relative20) {
20642
+ const read = readConfinedText(snapshotDir, relative20);
20016
20643
  return read.ok ? read.text : null;
20017
20644
  }
20018
- function snapshotBytes(snapshotDir, relative18) {
20019
- const read = readConfinedBytes(snapshotDir, relative18);
20645
+ function snapshotBytes(snapshotDir, relative20) {
20646
+ const read = readConfinedBytes(snapshotDir, relative20);
20020
20647
  return read.ok ? read.bytes : null;
20021
20648
  }
20022
20649
  function readJson2(file) {
@@ -20032,15 +20659,15 @@ function readJson2(file) {
20032
20659
  function walk(dir, prefix = "") {
20033
20660
  let entries;
20034
20661
  try {
20035
- entries = fs28__namespace.readdirSync(dir, { withFileTypes: true });
20662
+ entries = fs29__namespace.readdirSync(dir, { withFileTypes: true });
20036
20663
  } catch {
20037
20664
  return [];
20038
20665
  }
20039
20666
  const files = [];
20040
20667
  for (const entry of entries) {
20041
- const relative18 = prefix === "" ? entry.name : prefix + "/" + entry.name;
20042
- if (entry.isDirectory()) files.push(...walk(path7__namespace.join(dir, entry.name), relative18));
20043
- else if (entry.isFile()) files.push(relative18);
20668
+ const relative20 = prefix === "" ? entry.name : prefix + "/" + entry.name;
20669
+ if (entry.isDirectory()) files.push(...walk(path7__namespace.join(dir, entry.name), relative20));
20670
+ else if (entry.isFile()) files.push(relative20);
20044
20671
  }
20045
20672
  return files;
20046
20673
  }
@@ -20082,12 +20709,12 @@ function readArtifactTexts(snapshotDir, maxBytes = 32 * 1024 * 1024) {
20082
20709
  const texts = [];
20083
20710
  let bytes = 0;
20084
20711
  let truncated = false;
20085
- for (const relative18 of walk(snapshotDir)) {
20086
- if (!TEXT_ARTIFACT.test(relative18)) continue;
20087
- const full = path7__namespace.join(snapshotDir, relative18);
20712
+ for (const relative20 of walk(snapshotDir)) {
20713
+ if (!TEXT_ARTIFACT.test(relative20)) continue;
20714
+ const full = path7__namespace.join(snapshotDir, relative20);
20088
20715
  let size2;
20089
20716
  try {
20090
- size2 = fs28__namespace.statSync(full).size;
20717
+ size2 = fs29__namespace.statSync(full).size;
20091
20718
  } catch {
20092
20719
  continue;
20093
20720
  }
@@ -20095,7 +20722,7 @@ function readArtifactTexts(snapshotDir, maxBytes = 32 * 1024 * 1024) {
20095
20722
  truncated = true;
20096
20723
  continue;
20097
20724
  }
20098
- const text2 = snapshotText(snapshotDir, relative18);
20725
+ const text2 = snapshotText(snapshotDir, relative20);
20099
20726
  if (text2 !== null) {
20100
20727
  texts.push(text2);
20101
20728
  bytes += Buffer.byteLength(text2, "utf8");
@@ -20116,11 +20743,11 @@ function findHostPaths(snapshotDir, repoDir, maxBytes = 32 * 1024 * 1024) {
20116
20743
  const hits = /* @__PURE__ */ new Set();
20117
20744
  let scanned = 0;
20118
20745
  let truncated = false;
20119
- for (const relative18 of walk(snapshotDir)) {
20120
- if (!TEXT_ARTIFACT.test(relative18)) continue;
20746
+ for (const relative20 of walk(snapshotDir)) {
20747
+ if (!TEXT_ARTIFACT.test(relative20)) continue;
20121
20748
  let size2;
20122
20749
  try {
20123
- size2 = fs28__namespace.statSync(path7__namespace.join(snapshotDir, relative18)).size;
20750
+ size2 = fs29__namespace.statSync(path7__namespace.join(snapshotDir, relative20)).size;
20124
20751
  } catch {
20125
20752
  continue;
20126
20753
  }
@@ -20128,14 +20755,14 @@ function findHostPaths(snapshotDir, repoDir, maxBytes = 32 * 1024 * 1024) {
20128
20755
  truncated = true;
20129
20756
  continue;
20130
20757
  }
20131
- const text2 = snapshotText(snapshotDir, relative18);
20758
+ const text2 = snapshotText(snapshotDir, relative20);
20132
20759
  if (text2 === null) continue;
20133
20760
  scanned += Buffer.byteLength(text2, "utf8");
20134
20761
  for (const pattern of patterns) {
20135
- for (const match of text2.match(pattern) ?? []) hits.add(relative18 + ": " + match);
20762
+ for (const match of text2.match(pattern) ?? []) hits.add(relative20 + ": " + match);
20136
20763
  }
20137
20764
  repoPattern.lastIndex = 0;
20138
- if (repoPattern.test(text2)) hits.add(relative18 + ": the repository absolute path");
20765
+ if (repoPattern.test(text2)) hits.add(relative20 + ": the repository absolute path");
20139
20766
  }
20140
20767
  return { hits: [...hits], truncated };
20141
20768
  }
@@ -20155,6 +20782,30 @@ function staleAgainstRepository(manifest, repoDir) {
20155
20782
  if (head === recorded) return null;
20156
20783
  return "HEAD is " + head.slice(0, 8) + " but the snapshot was generated at " + recorded.slice(0, 8) + "; regenerate before trusting it.";
20157
20784
  }
20785
+ function summaryClaimAppears(field, value, relativePath, body) {
20786
+ if (body.includes(value)) return true;
20787
+ const extension = (/\.[^./\\]+$/.exec(relativePath)?.[0] ?? "").toLowerCase();
20788
+ if (field === "imports" && /^\.+[A-Za-z_]/.test(value) && (extension === ".py" || extension === ".pyi")) {
20789
+ const leaf = value.replace(/^\.+/, "");
20790
+ return leaf.length > 0 && body.includes(leaf);
20791
+ }
20792
+ if ((field === "classes" || field === "exports") && (extension === ".tf" || extension === ".tfvars") && value.includes(".")) {
20793
+ return value.split(".").every((part) => part.length > 0 && body.includes(part));
20794
+ }
20795
+ if (field === "imports" && (extension === ".tf" || extension === ".tfvars") && value.startsWith("provider:")) {
20796
+ const provider = value.slice("provider:".length);
20797
+ return provider.length > 0 && body.includes(provider);
20798
+ }
20799
+ if ((field === "exports" || field === "reactComponents") && value === "default" && /\bexport\s*=/.test(body)) {
20800
+ return true;
20801
+ }
20802
+ if (field === "headings" && value.trimStart().startsWith("#")) {
20803
+ const collapsedBody = body.replace(/^([ \t]*#{1,6})[ \t]+/gm, "$1 ");
20804
+ const collapsedValue = value.replace(/^([ \t]*#{1,6})[ \t]+/, "$1 ");
20805
+ return collapsedBody.includes(collapsedValue);
20806
+ }
20807
+ return false;
20808
+ }
20158
20809
  function summaryClaims(summary) {
20159
20810
  if ("imports" in summary) {
20160
20811
  const fields = [
@@ -20253,6 +20904,17 @@ function xmlPackBodies(text2) {
20253
20904
  }
20254
20905
  return bodies.size === 0 ? null : bodies;
20255
20906
  }
20907
+ function diffBodyFindings(text2, rules) {
20908
+ let findings = 0;
20909
+ for (const section of text2.split(/(?=^diff --git )/m)) {
20910
+ if (!section.startsWith("diff --git ")) continue;
20911
+ const paths = [...section.matchAll(/^(?:--- a\/|\+\+\+ b\/)(.+)$/gm)].map((match) => match[1].trim()).filter((path32) => path32 !== "/dev/null");
20912
+ const sourcePath = paths[paths.length - 1] ?? "reports/diff.md";
20913
+ const logical = section.split("\n").map((line) => /^[+\- ]/.test(line) ? line.slice(1) : line).join("\n");
20914
+ findings += scanAndRedactSecrets(logical, rules, sourcePath).findings.length;
20915
+ }
20916
+ return findings;
20917
+ }
20256
20918
  function markdownPackBodies(text2) {
20257
20919
  const bodies = /* @__PURE__ */ new Map();
20258
20920
  const lines = text2.split("\n");
@@ -20382,13 +21044,13 @@ function auditSnapshot(options) {
20382
21044
  let artifactCount = 0;
20383
21045
  for (const [key, value] of Object.entries(artifacts)) {
20384
21046
  if (value === null || value === void 0) continue;
20385
- const relative18 = ARTIFACT_FILES[key];
20386
- if (relative18 === void 0) continue;
21047
+ const relative20 = ARTIFACT_FILES[key];
21048
+ if (relative20 === void 0) continue;
20387
21049
  artifactCount += 1;
20388
- const bytes = snapshotBytes(snapshotDir, relative18);
20389
- if (bytes === null) artifactProblems.push(relative18 + " is missing");
21050
+ const bytes = snapshotBytes(snapshotDir, relative20);
21051
+ if (bytes === null) artifactProblems.push(relative20 + " is missing");
20390
21052
  else if (typeof value.sha256 === "string" && sha256(bytes) !== value.sha256) {
20391
- artifactProblems.push(relative18 + " changed");
21053
+ artifactProblems.push(relative20 + " changed");
20392
21054
  }
20393
21055
  }
20394
21056
  checks.push(
@@ -20433,7 +21095,7 @@ function auditSnapshot(options) {
20433
21095
  )
20434
21096
  );
20435
21097
  const signaturePath = path7__namespace.join(snapshotDir, "signature.json");
20436
- if (fs28__namespace.existsSync(signaturePath)) {
21098
+ if (fs29__namespace.existsSync(signaturePath)) {
20437
21099
  const outcome = verifySnapshotSignature(snapshotDir);
20438
21100
  checks.push(
20439
21101
  outcome.ok ? check(
@@ -20514,14 +21176,24 @@ function auditSnapshot(options) {
20514
21176
  let summarisedFiles = 0;
20515
21177
  for (const file of manifest.files) {
20516
21178
  if (file.summary === void 0) continue;
20517
- if (file.inclusionMode === "preview" || file.emptyLinesRemoved === true) continue;
21179
+ if (file.inclusionMode === "preview" || file.inclusionMode === "signatures" || file.emptyLinesRemoved === true) {
21180
+ continue;
21181
+ }
20518
21182
  const body = bodyByPath.get(file.relativePath);
20519
21183
  if (body === void 0) continue;
20520
21184
  summarisedFiles += 1;
20521
21185
  for (const claim of summaryClaims(file.summary)) {
20522
21186
  if (claim.value.includes(REDACTION_MARKER)) continue;
21187
+ const strippedImport = claim.field === "imports" && claim.value.startsWith("./") && /\.(?:rb|rake|gemspec|c|h|cc|cpp|cxx|hpp|hxx|m|mm)$/i.test(file.relativePath) ? claim.value.slice(2) : null;
21188
+ if (strippedImport !== null && body.includes(strippedImport)) {
21189
+ claimsChecked += 1;
21190
+ continue;
21191
+ }
21192
+ if ((claim.field === "exports" || claim.field === "reactComponents") && /\.(?:vue|svelte|astro)$/i.test(file.relativePath) && claim.value === (file.relativePath.split("/").pop() ?? "").replace(/\.[^.]+$/, "")) {
21193
+ continue;
21194
+ }
20523
21195
  claimsChecked += 1;
20524
- if (!body.includes(claim.value)) {
21196
+ if (!summaryClaimAppears(claim.field, claim.value, file.relativePath, body)) {
20525
21197
  summaryProblems.push(file.relativePath + " (" + claim.field + ")");
20526
21198
  }
20527
21199
  }
@@ -20762,13 +21434,8 @@ function auditSnapshot(options) {
20762
21434
  file: "full-codebase.json",
20763
21435
  label: "JSON",
20764
21436
  paths: (text2) => {
20765
- try {
20766
- const parsed = JSON.parse(text2);
20767
- if (!Array.isArray(parsed?.files)) return null;
20768
- return new Set(parsed.files.map((entry) => String(entry?.relativePath)));
20769
- } catch {
20770
- return null;
20771
- }
21437
+ const bodies = jsonPackBodies(text2);
21438
+ return bodies === null ? null : new Set(bodies.keys());
20772
21439
  }
20773
21440
  },
20774
21441
  {
@@ -20776,9 +21443,8 @@ function auditSnapshot(options) {
20776
21443
  file: "full-codebase.xml",
20777
21444
  label: "XML",
20778
21445
  paths: (text2) => {
20779
- const found = [...text2.matchAll(/<file path="([^"]+)"/g)].map((match) => match[1]);
20780
- if (found.length === 0) return null;
20781
- return new Set(found.map((value) => value.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&")));
21446
+ const bodies = xmlPackBodies(text2);
21447
+ return bodies === null ? null : new Set(bodies.keys());
20782
21448
  }
20783
21449
  },
20784
21450
  {
@@ -20786,9 +21452,8 @@ function auditSnapshot(options) {
20786
21452
  file: "full-codebase.md",
20787
21453
  label: "markdown",
20788
21454
  paths: (text2) => {
20789
- const found = [...text2.matchAll(/^## File: (.+)$/gm)].map((match) => match[1].trim());
20790
- if (found.length === 0) return null;
20791
- return new Set(found);
21455
+ const bodies = markdownPackBodies(text2);
21456
+ return bodies === null ? null : new Set(bodies.keys());
20792
21457
  }
20793
21458
  }
20794
21459
  ];
@@ -20807,8 +21472,8 @@ function auditSnapshot(options) {
20807
21472
  for (const file of manifest.files) {
20808
21473
  if (!packed.has(file.relativePath)) problems.push(file.relativePath + " is in the manifest but not the pack");
20809
21474
  }
20810
- for (const path31 of packed) {
20811
- if (!known2.has(path31)) problems.push(path31 + " is in the pack but not the manifest");
21475
+ for (const path32 of packed) {
21476
+ if (!known2.has(path32)) problems.push(path32 + " is in the pack but not the manifest");
20812
21477
  }
20813
21478
  }
20814
21479
  }
@@ -21045,18 +21710,24 @@ function auditSnapshot(options) {
21045
21710
  replayProblems.push(file.relativePath + " line " + line + " is not the source line");
21046
21711
  }
21047
21712
  checks.push(
21048
- replayProblems.length === 0 ? check(
21713
+ replayProblems.length > 0 ? check(
21049
21714
  "fidelity.bodies",
21050
21715
  "Every full body replays from the source bytes",
21051
21716
  "critical",
21052
- "pass",
21053
- replayed + " full body/bodies replayed byte-for-byte (redaction allowed); " + unreplayable + " not replayable by design or because the file moved."
21717
+ "fail",
21718
+ replayProblems.length + " body/bodies disagree with the source: " + sample(replayProblems)
21719
+ ) : replayed === 0 ? check(
21720
+ "fidelity.bodies",
21721
+ "Every full body replays from the source bytes",
21722
+ "critical",
21723
+ "skip",
21724
+ "No full body could be replayed: every candidate was previewed, already redacted, or its source moved. The check verified nothing."
21054
21725
  ) : check(
21055
21726
  "fidelity.bodies",
21056
21727
  "Every full body replays from the source bytes",
21057
21728
  "critical",
21058
- "fail",
21059
- replayProblems.length + " body/bodies disagree with the source: " + sample(replayProblems)
21729
+ "pass",
21730
+ replayed + " full body/bodies replayed byte-for-byte (redaction allowed); " + unreplayable + " not replayable by design or because the file moved."
21060
21731
  )
21061
21732
  );
21062
21733
  }
@@ -21100,16 +21771,16 @@ function auditSnapshot(options) {
21100
21771
  if (typeof member.path === "string") {
21101
21772
  const memberPath = member.path;
21102
21773
  const candidates = [path7__namespace.dirname(indexParent), repoDir].map((anchor) => path7__namespace.resolve(anchor, memberPath)).filter((candidate) => {
21103
- const relative18 = path7__namespace.relative(repoDir, candidate);
21104
- return relative18 !== ".." && !relative18.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative18);
21774
+ const relative20 = path7__namespace.relative(repoDir, candidate);
21775
+ return relative20 !== ".." && !relative20.startsWith(".." + path7__namespace.sep) && !path7__namespace.isAbsolute(relative20);
21105
21776
  });
21106
- const resolved = candidates.find((candidate) => fs28__namespace.existsSync(candidate)) ?? candidates[0];
21777
+ const resolved = candidates.find((candidate) => fs29__namespace.existsSync(candidate)) ?? candidates[0];
21107
21778
  if (resolved === void 0) {
21108
21779
  sourceGone = "Member " + memberName + " source directory resolves outside the repository; not inspected.";
21109
21780
  } else {
21110
21781
  let canonical = null;
21111
21782
  try {
21112
- canonical = fs28__namespace.realpathSync(resolved);
21783
+ canonical = fs29__namespace.realpathSync(resolved);
21113
21784
  } catch {
21114
21785
  canonical = null;
21115
21786
  }
@@ -21117,7 +21788,7 @@ function auditSnapshot(options) {
21117
21788
  const canonicalInside = canonical !== null && (canonicalRelative === "" || canonicalRelative !== null && canonicalRelative !== ".." && !canonicalRelative.startsWith(`..${path7__namespace.sep}`) && !canonicalRelative.startsWith("../") && !path7__namespace.isAbsolute(canonicalRelative));
21118
21789
  if (canonical !== null && !canonicalInside) {
21119
21790
  sourceGone = "Member " + memberName + " source directory resolves outside the repository; not inspected.";
21120
- } else if (canonical === null || !fs28__namespace.existsSync(resolved)) {
21791
+ } else if (canonical === null || !fs29__namespace.existsSync(resolved)) {
21121
21792
  sourceGone = "Member " + memberName + " source directory is gone (" + member.path + "); the snapshot still describes it. Regenerate the workspace.";
21122
21793
  }
21123
21794
  }
@@ -21144,12 +21815,12 @@ function auditSnapshot(options) {
21144
21815
  const leakHits = [];
21145
21816
  let scannedBytes = 0;
21146
21817
  let skippedArtifacts = 0;
21147
- for (const relative18 of walk(snapshotDir)) {
21148
- if (!TEXT_ARTIFACT.test(relative18)) continue;
21149
- if (relative18 === SIGNATURE_FILE) continue;
21818
+ for (const relative20 of walk(snapshotDir)) {
21819
+ if (!TEXT_ARTIFACT.test(relative20)) continue;
21820
+ if (relative20 === SIGNATURE_FILE) continue;
21150
21821
  let size2;
21151
21822
  try {
21152
- size2 = fs28__namespace.statSync(path7__namespace.join(snapshotDir, relative18)).size;
21823
+ size2 = fs29__namespace.statSync(path7__namespace.join(snapshotDir, relative20)).size;
21153
21824
  } catch {
21154
21825
  continue;
21155
21826
  }
@@ -21157,11 +21828,11 @@ function auditSnapshot(options) {
21157
21828
  skippedArtifacts += 1;
21158
21829
  continue;
21159
21830
  }
21160
- const text2 = snapshotText(snapshotDir, relative18);
21831
+ const text2 = snapshotText(snapshotDir, relative20);
21161
21832
  if (text2 === null) continue;
21162
21833
  scannedBytes += Buffer.byteLength(text2, "utf8");
21163
21834
  let findingCount = 0;
21164
- if (/^parts[\\/].*\.md$/i.test(relative18)) {
21835
+ if (/^parts[\\/].*\.md$/i.test(relative20)) {
21165
21836
  const lines = text2.split("\n");
21166
21837
  const sections = parsePartSections(text2);
21167
21838
  for (const section of sections) {
@@ -21173,19 +21844,39 @@ function auditSnapshot(options) {
21173
21844
  }
21174
21845
  }
21175
21846
  const headerText = lines.join("\n");
21176
- findingCount += scanAndRedactSecrets(headerText, rules, relative18).findings.length;
21847
+ findingCount += scanAndRedactSecrets(headerText, rules, relative20).findings.length;
21177
21848
  if ((options.secretRules ?? []).length > 0) {
21178
- findingCount += scanAndRedactSecrets(text2, options.secretRules ?? [], relative18).findings.length;
21849
+ findingCount += scanAndRedactSecrets(text2, options.secretRules ?? [], relative20).findings.length;
21179
21850
  }
21851
+ } else if (/full-codebase\.md$/i.test(relative20)) {
21852
+ const bodies = markdownPackBodies(text2);
21853
+ findingCount = bodies === null ? scanAndRedactSecrets(text2, rules, relative20).findings.length : [...bodies].reduce(
21854
+ (total, [sourcePath, body]) => total + scanAndRedactSecrets(body, rules, sourcePath).findings.length,
21855
+ 0
21856
+ );
21857
+ } else if (/full-codebase\.xml$/i.test(relative20)) {
21858
+ const bodies = xmlPackBodies(text2);
21859
+ findingCount = bodies === null ? scanAndRedactSecrets(text2, rules, relative20).findings.length : [...bodies].reduce(
21860
+ (total, [sourcePath, body]) => total + scanAndRedactSecrets(body, rules, sourcePath).findings.length,
21861
+ 0
21862
+ );
21863
+ } else if (/full-codebase\.json$/i.test(relative20)) {
21864
+ const bodies = jsonPackBodies(text2);
21865
+ findingCount = bodies === null ? scanAndRedactSecrets(text2, rules, relative20).findings.length : [...bodies].reduce(
21866
+ (total, [sourcePath, body]) => total + scanAndRedactSecrets(body, rules, sourcePath).findings.length,
21867
+ 0
21868
+ );
21869
+ } else if (/reports[\\/]diff\.md$/i.test(relative20)) {
21870
+ findingCount = diffBodyFindings(text2, rules);
21180
21871
  } else {
21181
- findingCount = scanAndRedactSecrets(text2, rules, relative18).findings.length;
21872
+ findingCount = scanAndRedactSecrets(text2, rules, relative20).findings.length;
21182
21873
  }
21183
21874
  if (findingCount > 0) {
21184
- leakHits.push(relative18 + " (" + findingCount + " line(s))");
21875
+ leakHits.push(relative20 + " (" + findingCount + " line(s))");
21185
21876
  }
21186
21877
  }
21187
21878
  const signatureRecordPath = path7__namespace.join(snapshotDir, SIGNATURE_FILE);
21188
- if (fs28__namespace.existsSync(signatureRecordPath)) {
21879
+ if (fs29__namespace.existsSync(signatureRecordPath)) {
21189
21880
  const recordText = snapshotText(snapshotDir, SIGNATURE_FILE);
21190
21881
  if (recordText !== null) {
21191
21882
  scannedBytes += Buffer.byteLength(recordText, "utf8");
@@ -21238,7 +21929,7 @@ function auditSnapshot(options) {
21238
21929
  for (const record of skippedSensitive.slice(0, 40)) {
21239
21930
  if (record.path.includes("[REDACTED") || compared > 400) continue;
21240
21931
  try {
21241
- if (fs28__namespace.statSync(path7__namespace.join(repoDir, record.path)).size > scanBudget) continue;
21932
+ if (fs29__namespace.statSync(path7__namespace.join(repoDir, record.path)).size > scanBudget) continue;
21242
21933
  } catch {
21243
21934
  continue;
21244
21935
  }
@@ -21340,22 +22031,25 @@ function auditSnapshot(options) {
21340
22031
  manifest.parts.length + " part(s); largest about " + largestPart + " tokens, " + fits(32e3) + " fit 32k, " + fits(128e3) + " fit 128k, " + fits(2e5) + " fit 200k; largest single file about " + largestFile + " tokens."
21341
22032
  )
21342
22033
  );
21343
- const overBudget = manifest.parts.filter(
21344
- (part) => part.byteSize > manifest.budgets.maxPartBytes
21345
- );
22034
+ const budgetFor = (part) => typeof part.budgetBytes === "number" ? part.budgetBytes : manifest.budgets.maxPartBytes;
22035
+ const overBudget = manifest.parts.filter((part) => part.byteSize > budgetFor(part));
21346
22036
  checks.push(
21347
22037
  overBudget.length === 0 ? check(
21348
22038
  "tokens.budget",
21349
22039
  "Every part honours the budget the manifest publishes",
21350
22040
  "warning",
21351
22041
  "pass",
21352
- "Ceiling " + formatBytes3(manifest.budgets.maxPartBytes) + "."
22042
+ "Each part is within the budget it records."
21353
22043
  ) : check(
21354
22044
  "tokens.budget",
21355
22045
  "Every part honours the budget the manifest publishes",
21356
22046
  "warning",
21357
22047
  "warn",
21358
- overBudget.length + " part(s) exceed " + formatBytes3(manifest.budgets.maxPartBytes) + ": " + sample(overBudget.map((part) => part.filename))
22048
+ overBudget.length + " part(s) exceed their recorded budget: " + sample(
22049
+ overBudget.map(
22050
+ (part) => part.filename + " (" + formatBytes3(budgetFor(part)) + ")"
22051
+ )
22052
+ )
21359
22053
  )
21360
22054
  );
21361
22055
  const badSkips = manifest.skipped.filter((record) => !record.reason || !record.path);
@@ -21610,14 +22304,14 @@ function compareManifests(before, after, secretRules) {
21610
22304
  function loadManifest(target) {
21611
22305
  let isDirectory;
21612
22306
  try {
21613
- isDirectory = fs28__namespace.statSync(target).isDirectory();
22307
+ isDirectory = fs29__namespace.statSync(target).isDirectory();
21614
22308
  } catch {
21615
22309
  throw new Error(`No snapshot found at ${target}: the path does not exist.`);
21616
22310
  }
21617
22311
  const manifestPath = isDirectory ? path7__namespace.join(target, "manifest.json") : target;
21618
22312
  let raw;
21619
22313
  try {
21620
- raw = fs28__namespace.readFileSync(manifestPath, "utf8");
22314
+ raw = fs29__namespace.readFileSync(manifestPath, "utf8");
21621
22315
  } catch {
21622
22316
  throw new Error(`Could not read a manifest at ${manifestPath}.`);
21623
22317
  }
@@ -21723,8 +22417,8 @@ function appendGitignoreEntries(cwd, entries) {
21723
22417
  const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
21724
22418
  let decoded = { text: "", bom: Buffer.alloc(0), encoding: "utf8" };
21725
22419
  try {
21726
- if (fs28__namespace.existsSync(ignorePath)) {
21727
- const stats = fs28__namespace.lstatSync(ignorePath);
22420
+ if (fs29__namespace.existsSync(ignorePath)) {
22421
+ const stats = fs29__namespace.lstatSync(ignorePath);
21728
22422
  if (stats.isDirectory()) {
21729
22423
  return { added: [], note: `${ignorePath} is a directory, so it was not updated. ${manual}` };
21730
22424
  }
@@ -21734,16 +22428,16 @@ function appendGitignoreEntries(cwd, entries) {
21734
22428
  note: `${ignorePath} is a symbolic link, a hard link, or not a regular file, so it was not updated. ` + manual
21735
22429
  };
21736
22430
  }
21737
- const rootReal = fs28__namespace.realpathSync(cwd);
21738
- const fileReal = fs28__namespace.realpathSync(ignorePath);
21739
- const relative18 = path7__namespace.relative(rootReal, fileReal);
21740
- if (relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative18)) {
22431
+ const rootReal = fs29__namespace.realpathSync(cwd);
22432
+ const fileReal = fs29__namespace.realpathSync(ignorePath);
22433
+ const relative20 = path7__namespace.relative(rootReal, fileReal);
22434
+ if (relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || path7__namespace.isAbsolute(relative20)) {
21741
22435
  return {
21742
22436
  added: [],
21743
22437
  note: `${ignorePath} resolves outside the repository, so it was not updated. ${manual}`
21744
22438
  };
21745
22439
  }
21746
- const read = decodeGitignore(fs28__namespace.readFileSync(ignorePath));
22440
+ const read = decodeGitignore(fs29__namespace.readFileSync(ignorePath));
21747
22441
  if (read === null) {
21748
22442
  return {
21749
22443
  added: [],
@@ -21766,15 +22460,15 @@ function appendGitignoreEntries(cwd, entries) {
21766
22460
  const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : newline;
21767
22461
  const tempPath = `${ignorePath}.${process.pid}.${Date.now()}.tmp`;
21768
22462
  try {
21769
- fs28__namespace.writeFileSync(
22463
+ fs29__namespace.writeFileSync(
21770
22464
  tempPath,
21771
22465
  encodeGitignore(decoded, `${existing}${prefix}${added.join(newline)}${newline}`),
21772
22466
  { flag: "wx" }
21773
22467
  );
21774
- fs28__namespace.renameSync(tempPath, ignorePath);
22468
+ fs29__namespace.renameSync(tempPath, ignorePath);
21775
22469
  } catch (err) {
21776
22470
  try {
21777
- fs28__namespace.rmSync(tempPath, { force: true });
22471
+ fs29__namespace.rmSync(tempPath, { force: true });
21778
22472
  } catch {
21779
22473
  }
21780
22474
  return { added: [], note: `${err.message}. ${manual}` };
@@ -22231,7 +22925,7 @@ function keyReader(input) {
22231
22925
  next() {
22232
22926
  const queued = queue.shift();
22233
22927
  if (queued) return Promise.resolve(queued);
22234
- return new Promise((resolve20) => waiters.push(resolve20));
22928
+ return new Promise((resolve21) => waiters.push(resolve21));
22235
22929
  },
22236
22930
  close() {
22237
22931
  input.off("keypress", onKey);
@@ -22457,7 +23151,7 @@ function parsePackageJson(raw) {
22457
23151
  }
22458
23152
  function readPackageJson2(cwd) {
22459
23153
  try {
22460
- return parsePackageJson(fs28__namespace.readFileSync(path7__namespace.join(cwd, "package.json"), "utf8"));
23154
+ return parsePackageJson(fs29__namespace.readFileSync(path7__namespace.join(cwd, "package.json"), "utf8"));
22461
23155
  } catch {
22462
23156
  return null;
22463
23157
  }
@@ -22492,7 +23186,7 @@ function artifactAnswers(options) {
22492
23186
  }
22493
23187
  function topLevelDirs(cwd) {
22494
23188
  try {
22495
- return fs28__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
23189
+ return fs29__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
22496
23190
  } catch {
22497
23191
  return [];
22498
23192
  }
@@ -22507,7 +23201,7 @@ function writeFileOrExplain(target, content) {
22507
23201
  try {
22508
23202
  let stats = null;
22509
23203
  try {
22510
- stats = fs28__namespace.lstatSync(target);
23204
+ stats = fs29__namespace.lstatSync(target);
22511
23205
  } catch {
22512
23206
  stats = null;
22513
23207
  }
@@ -22522,12 +23216,12 @@ function writeFileOrExplain(target, content) {
22522
23216
  );
22523
23217
  }
22524
23218
  const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
22525
- fs28__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
23219
+ fs29__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
22526
23220
  try {
22527
- fs28__namespace.renameSync(temporary, target);
23221
+ fs29__namespace.renameSync(temporary, target);
22528
23222
  } catch (err) {
22529
23223
  try {
22530
- fs28__namespace.unlinkSync(temporary);
23224
+ fs29__namespace.unlinkSync(temporary);
22531
23225
  } catch {
22532
23226
  }
22533
23227
  throw err;
@@ -22580,14 +23274,14 @@ function updatePackageJson(cwd, notes) {
22580
23274
  scripts: [],
22581
23275
  dependency: { name: GENERATOR_NAME, range: null, added: false }
22582
23276
  };
22583
- if (!fs28__namespace.existsSync(packagePath)) {
23277
+ if (!fs29__namespace.existsSync(packagePath)) {
22584
23278
  notes.push("No package.json found, so npm scripts and the devDependency were not added.");
22585
23279
  return unchanged;
22586
23280
  }
22587
23281
  let raw;
22588
23282
  let parsed;
22589
23283
  try {
22590
- raw = fs28__namespace.readFileSync(packagePath, "utf8");
23284
+ raw = fs29__namespace.readFileSync(packagePath, "utf8");
22591
23285
  parsed = parsePackageJson(raw);
22592
23286
  } catch {
22593
23287
  notes.push("Could not parse package.json; npm scripts and the devDependency were not added.");
@@ -22662,11 +23356,11 @@ function gitignoreEntriesFor(cwd, outDir, tmpDir) {
22662
23356
  const entries = [];
22663
23357
  for (const directory of [outDir, tmpDir]) {
22664
23358
  if (directory === null) continue;
22665
- const relative18 = path7__namespace.relative(cwd, path7__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
22666
- if (relative18 === "" || relative18 === "." || relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || relative18.startsWith("../") || path7__namespace.isAbsolute(relative18)) {
23359
+ const relative20 = path7__namespace.relative(cwd, path7__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
23360
+ if (relative20 === "" || relative20 === "." || relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || relative20.startsWith("../") || path7__namespace.isAbsolute(relative20)) {
22667
23361
  continue;
22668
23362
  }
22669
- entries.push(`/${relative18}/`);
23363
+ entries.push(`/${relative20}/`);
22670
23364
  }
22671
23365
  return [...new Set(entries)];
22672
23366
  }
@@ -22934,7 +23628,7 @@ async function runInit(options) {
22934
23628
  }
22935
23629
  const preferredName = chooseConfigFileName(options.cwd);
22936
23630
  const presentConfigs = CONFIG_CANDIDATES.filter(
22937
- (name) => fs28__namespace.existsSync(path7__namespace.join(options.cwd, name))
23631
+ (name) => fs29__namespace.existsSync(path7__namespace.join(options.cwd, name))
22938
23632
  );
22939
23633
  const present = presentConfigs[0] ?? null;
22940
23634
  if (presentConfigs.length > 1) {
@@ -22981,13 +23675,13 @@ async function runInit(options) {
22981
23675
  'package.json already defines a "snapshot" config. Remove that key, or re-run with --force to write a config file that takes precedence over it.'
22982
23676
  );
22983
23677
  }
22984
- if (fs28__namespace.existsSync(configPath) && !options.force && !reused) {
23678
+ if (fs29__namespace.existsSync(configPath) && !options.force && !reused) {
22985
23679
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
22986
23680
  }
22987
23681
  if (!reused) writeFileOrExplain(configPath, configText);
22988
23682
  const briefPath = path7__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE);
22989
23683
  let briefWritten = false;
22990
- if (!fs28__namespace.existsSync(briefPath)) {
23684
+ if (!fs29__namespace.existsSync(briefPath)) {
22991
23685
  writeFileOrExplain(briefPath, BRIEF_SCAFFOLD);
22992
23686
  briefWritten = true;
22993
23687
  }
@@ -23015,12 +23709,12 @@ async function runInit(options) {
23015
23709
  };
23016
23710
  }
23017
23711
  function describeTarget(cwd) {
23018
- const relative18 = path7__namespace.relative(process.cwd(), cwd);
23019
- if (relative18 === "") return "this directory";
23020
- if (relative18 === ".." || relative18.startsWith(`..${path7__namespace.sep}`) || relative18.startsWith("../") || path7__namespace.isAbsolute(relative18)) {
23712
+ const relative20 = path7__namespace.relative(process.cwd(), cwd);
23713
+ if (relative20 === "") return "this directory";
23714
+ if (relative20 === ".." || relative20.startsWith(`..${path7__namespace.sep}`) || relative20.startsWith("../") || path7__namespace.isAbsolute(relative20)) {
23021
23715
  return cwd;
23022
23716
  }
23023
- return relative18;
23717
+ return relative20;
23024
23718
  }
23025
23719
  function firstRunMessage(reason, cwd) {
23026
23720
  const where = describeTarget(cwd);
@@ -23043,7 +23737,7 @@ function planFirstRun(facts) {
23043
23737
  var NOT_CONTENT = /* @__PURE__ */ new Set([".git", ".hg", ".svn", ".bzr", ".DS_Store", "Thumbs.db"]);
23044
23738
  function isEffectivelyEmpty(cwd) {
23045
23739
  try {
23046
- return fs28__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
23740
+ return fs29__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
23047
23741
  } catch {
23048
23742
  return false;
23049
23743
  }
@@ -23051,7 +23745,7 @@ function isEffectivelyEmpty(cwd) {
23051
23745
  function hasPriorSnapshot(cwd, outDir) {
23052
23746
  let parsed;
23053
23747
  try {
23054
- parsed = JSON.parse(fs28__namespace.readFileSync(path7__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
23748
+ parsed = JSON.parse(fs29__namespace.readFileSync(path7__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
23055
23749
  } catch {
23056
23750
  return false;
23057
23751
  }
@@ -23102,21 +23796,21 @@ function gitDirectory(cwd) {
23102
23796
  const dotGit = path7__namespace.join(cwd, ".git");
23103
23797
  let stats;
23104
23798
  try {
23105
- stats = fs28__namespace.statSync(dotGit);
23799
+ stats = fs29__namespace.statSync(dotGit);
23106
23800
  } catch {
23107
23801
  return null;
23108
23802
  }
23109
23803
  if (stats.isDirectory()) return dotGit;
23110
23804
  if (!stats.isFile()) return null;
23111
23805
  try {
23112
- const contents = fs28__namespace.readFileSync(dotGit, "utf8");
23806
+ const contents = fs29__namespace.readFileSync(dotGit, "utf8");
23113
23807
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
23114
23808
  if (!match) return null;
23115
23809
  const target = match[1];
23116
23810
  const resolved = path7__namespace.isAbsolute(target.trim()) ? target.trim() : path7__namespace.join(cwd, target.trim());
23117
23811
  const cwdReal = canonicalForWrite(cwd);
23118
23812
  const resolvedReal = canonicalForWrite(resolved);
23119
- if (cwdReal === null || resolvedReal === null || !fs28__namespace.statSync(resolvedReal).isDirectory()) {
23813
+ if (cwdReal === null || resolvedReal === null || !fs29__namespace.statSync(resolvedReal).isDirectory()) {
23120
23814
  return null;
23121
23815
  }
23122
23816
  if (isInside4(cwdReal, resolvedReal)) return resolvedReal;
@@ -23126,20 +23820,20 @@ function gitDirectory(cwd) {
23126
23820
  }
23127
23821
  }
23128
23822
  function isInside4(parent, child) {
23129
- const relative18 = path7__namespace.relative(parent, child);
23130
- return relative18 === "" || relative18 !== ".." && !relative18.startsWith(`..${path7__namespace.sep}`) && !relative18.startsWith("../") && !path7__namespace.isAbsolute(relative18);
23823
+ const relative20 = path7__namespace.relative(parent, child);
23824
+ return relative20 === "" || relative20 !== ".." && !relative20.startsWith(`..${path7__namespace.sep}`) && !relative20.startsWith("../") && !path7__namespace.isAbsolute(relative20);
23131
23825
  }
23132
23826
  function canonicalForWrite(target) {
23133
23827
  let existing = path7__namespace.resolve(target);
23134
23828
  const tail = [];
23135
- while (!fs28__namespace.existsSync(existing)) {
23829
+ while (!fs29__namespace.existsSync(existing)) {
23136
23830
  tail.unshift(path7__namespace.basename(existing));
23137
23831
  const parent = path7__namespace.dirname(existing);
23138
23832
  if (parent === existing) break;
23139
23833
  existing = parent;
23140
23834
  }
23141
23835
  try {
23142
- const real = fs28__namespace.realpathSync(existing);
23836
+ const real = fs29__namespace.realpathSync(existing);
23143
23837
  return tail.length === 0 ? real : path7__namespace.join(real, ...tail);
23144
23838
  } catch {
23145
23839
  return null;
@@ -23147,7 +23841,7 @@ function canonicalForWrite(target) {
23147
23841
  }
23148
23842
  function isRegisteredWorktree(gitDir, cwd) {
23149
23843
  try {
23150
- const back = fs28__namespace.readFileSync(path7__namespace.join(gitDir, "gitdir"), "utf8").trim();
23844
+ const back = fs29__namespace.readFileSync(path7__namespace.join(gitDir, "gitdir"), "utf8").trim();
23151
23845
  return path7__namespace.resolve(gitDir, back) === path7__namespace.join(path7__namespace.resolve(cwd), ".git");
23152
23846
  } catch {
23153
23847
  return false;
@@ -23211,7 +23905,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
23211
23905
  }
23212
23906
  const hookPath = path7__namespace.join(hooksDir, "pre-commit");
23213
23907
  try {
23214
- const existingStats = fs28__namespace.lstatSync(hookPath);
23908
+ const existingStats = fs29__namespace.lstatSync(hookPath);
23215
23909
  if (existingStats.isSymbolicLink()) {
23216
23910
  return {
23217
23911
  path: hookPath,
@@ -23243,7 +23937,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
23243
23937
  }
23244
23938
  }
23245
23939
  try {
23246
- fs28__namespace.mkdirSync(hooksDir, { recursive: true });
23940
+ fs29__namespace.mkdirSync(hooksDir, { recursive: true });
23247
23941
  } catch (err) {
23248
23942
  return {
23249
23943
  path: hookPath,
@@ -23253,7 +23947,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
23253
23947
  }
23254
23948
  let existing = null;
23255
23949
  try {
23256
- existing = fs28__namespace.readFileSync(hookPath, "utf8");
23950
+ existing = fs29__namespace.readFileSync(hookPath, "utf8");
23257
23951
  } catch {
23258
23952
  existing = null;
23259
23953
  }
@@ -23268,8 +23962,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
23268
23962
  };
23269
23963
  }
23270
23964
  try {
23271
- fs28__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
23272
- fs28__namespace.chmodSync(hookPath, 493);
23965
+ fs29__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
23966
+ fs29__namespace.chmodSync(hookPath, 493);
23273
23967
  } catch (err) {
23274
23968
  return {
23275
23969
  path: hookPath,
@@ -23398,7 +24092,7 @@ function buildBrief(input) {
23398
24092
  }
23399
24093
  let preambleTokens = estimateTokens(header2.join("\n"));
23400
24094
  if (input.diff !== void 0 && input.diff.trim().length > 0) {
23401
- const redacted = scanAndRedactSecrets(input.diff, input.secretRules, "diff").redacted;
24095
+ const redacted = input.diffIsRedacted === true ? input.diff : scanAndRedactSecrets(input.diff, input.secretRules, "diff").redacted;
23402
24096
  const diffBudget = Math.max(120, Math.floor((maxTokens - preambleTokens) * (targets.length > 0 ? 0.5 : 0.9)));
23403
24097
  let diffBody = redacted;
23404
24098
  if (estimateTokens(diffBody) > diffBudget) {
@@ -23456,9 +24150,25 @@ function buildBrief(input) {
23456
24150
  header2.push(...[...new Set(omitted)].map((file) => "- " + display(file) + " \u2014 did not fit the brief budget or is unavailable"));
23457
24151
  header2.push("");
23458
24152
  }
23459
- const markdown = header2.join("\n").replace(/\n{3,}/g, "\n\n").replace(/\n+$/, "") + "\n";
24153
+ const markdown = collapseBlankLines(header2.join("\n")) + "\n";
23460
24154
  return { markdown, usedTokens: estimateTokens(markdown), files, omitted: [...new Set(omitted)], impact };
23461
24155
  }
24156
+ function collapseBlankLines(value) {
24157
+ const lines = value.split("\n");
24158
+ const out = [];
24159
+ let blanks = 0;
24160
+ for (const line of lines) {
24161
+ if (line === "") {
24162
+ blanks += 1;
24163
+ if (blanks > 1) continue;
24164
+ } else {
24165
+ blanks = 0;
24166
+ }
24167
+ out.push(line);
24168
+ }
24169
+ while (out.length > 0 && out[out.length - 1] === "") out.pop();
24170
+ return out.join("\n");
24171
+ }
23462
24172
  var FULL_SUITE_TRIGGER = /(^|\/)(package\.json|tsconfig[^/]*\.json|jsconfig[^/]*\.json|vitest\.config\.[cm]?[jt]s|jest\.config\.[cm]?[jt]s|snapshot\.config\.[cm]?[jt]s|pnpm-workspace\.yaml|yarn\.lock|package-lock\.json|pnpm-lock\.yaml|\.github\/workflows\/)/;
23463
24173
  function packageJson(cwd) {
23464
24174
  const read = readConfinedText(cwd, "package.json", 4 * 1024 * 1024);
@@ -23479,14 +24189,14 @@ function insideDirectory(root, candidate) {
23479
24189
  const normalizedCandidate = foldPath(path7__namespace.resolve(candidate));
23480
24190
  return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(normalizedRoot + path7__namespace.sep);
23481
24191
  }
23482
- function confinedFile(cwd, relative18) {
24192
+ function confinedFile(cwd, relative20) {
23483
24193
  try {
23484
- const realRoot = fs28__namespace.realpathSync(cwd);
23485
- const candidate = path7__namespace.resolve(cwd, relative18);
24194
+ const realRoot = fs29__namespace.realpathSync(cwd);
24195
+ const candidate = path7__namespace.resolve(cwd, relative20);
23486
24196
  if (!insideDirectory(cwd, candidate)) return null;
23487
- const stat = fs28__namespace.lstatSync(candidate);
24197
+ const stat = fs29__namespace.lstatSync(candidate);
23488
24198
  if (!stat.isFile()) return null;
23489
- const realTarget = fs28__namespace.realpathSync(candidate);
24199
+ const realTarget = fs29__namespace.realpathSync(candidate);
23490
24200
  if (!insideDirectory(realRoot, realTarget)) return null;
23491
24201
  return realTarget;
23492
24202
  } catch {
@@ -23521,7 +24231,7 @@ function planTestRun(cwd, input) {
23521
24231
  const testScript = typeof scripts === "object" && scripts !== null && !Array.isArray(scripts) ? scripts.test : void 0;
23522
24232
  const script = typeof testScript === "string" ? testScript : "";
23523
24233
  if (hasPackage(cwd, "vitest") || /\bvitest\b/.test(script)) {
23524
- const entry = ["node_modules/vitest/vitest.mjs", "node_modules/vitest/dist/cli.js"].map((relative18) => confinedFile(cwd, relative18)).find((resolved) => resolved !== null);
24234
+ const entry = ["node_modules/vitest/vitest.mjs", "node_modules/vitest/dist/cli.js"].map((relative20) => confinedFile(cwd, relative20)).find((resolved) => resolved !== null);
23525
24235
  if (entry !== void 0) {
23526
24236
  if (changed.length === 0) {
23527
24237
  return {
@@ -23613,16 +24323,16 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
23613
24323
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
23614
24324
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
23615
24325
  var fileDerivationBytes = 0;
23616
- function takeDerivation(path31, relativePath, hash, settings) {
23617
- const key = path31 + "\0" + relativePath;
24326
+ function takeDerivation(path32, relativePath, hash, settings) {
24327
+ const key = path32 + "\0" + relativePath;
23618
24328
  const cached = FILE_DERIVATIONS.get(key);
23619
24329
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
23620
24330
  FILE_DERIVATIONS.delete(key);
23621
24331
  FILE_DERIVATIONS.set(key, cached);
23622
24332
  return cached;
23623
24333
  }
23624
- function rememberDerivation(path31, relativePath, hash, settings, derivation) {
23625
- const key = path31 + "\0" + relativePath;
24334
+ function rememberDerivation(path32, relativePath, hash, settings, derivation) {
24335
+ const key = path32 + "\0" + relativePath;
23626
24336
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
23627
24337
  const bytes = bodyBytes * 2 + 512;
23628
24338
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
@@ -23647,7 +24357,7 @@ function derivationSettings(config) {
23647
24357
  ).join("");
23648
24358
  return `${GENERATOR_VERSION}${configDigest(config)}${sha256Hex3(rules)}`;
23649
24359
  }
23650
- function collapseBlankLines(text2) {
24360
+ function collapseBlankLines2(text2) {
23651
24361
  const lines = text2.split("\n");
23652
24362
  const kept = lines.filter((line) => line.trim() !== "");
23653
24363
  const removed = lines.length - kept.length;
@@ -23698,7 +24408,7 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
23698
24408
  }
23699
24409
  let emptyLinesRemoved = false;
23700
24410
  if (config.removeEmptyLines === true && !isPreviewTruncated) {
23701
- const collapsed = collapseBlankLines(finalContent);
24411
+ const collapsed = collapseBlankLines2(finalContent);
23702
24412
  if (collapsed.removed > 0) {
23703
24413
  finalContent = collapsed.text;
23704
24414
  includedLines = countLines(finalContent);
@@ -23889,6 +24599,11 @@ function verifyInMemory(files, parts, unaccounted) {
23889
24599
  );
23890
24600
  }
23891
24601
  }
24602
+ if (typeof file.includedLines === "number" && file.includedLines > file.lines + 1) {
24603
+ errors.push(
24604
+ `${file.relativePath} records ${file.includedLines} included line(s) for a ${file.lines}-line file.`
24605
+ );
24606
+ }
23892
24607
  }
23893
24608
  const partNames = new Set(parts.map((part) => part.filename));
23894
24609
  for (const file of files) {
@@ -24024,14 +24739,14 @@ function listEntries(dir) {
24024
24739
  const walk2 = (absolute, prefix) => {
24025
24740
  let children;
24026
24741
  try {
24027
- children = fs28__namespace.readdirSync(absolute, { withFileTypes: true });
24742
+ children = fs29__namespace.readdirSync(absolute, { withFileTypes: true });
24028
24743
  } catch {
24029
24744
  return;
24030
24745
  }
24031
24746
  for (const child of children) {
24032
- const relative18 = prefix === "" ? child.name : `${prefix}/${child.name}`;
24033
- entries.push(relative18);
24034
- if (child.isDirectory()) walk2(path7__namespace.join(absolute, child.name), relative18);
24747
+ const relative20 = prefix === "" ? child.name : `${prefix}/${child.name}`;
24748
+ entries.push(relative20);
24749
+ if (child.isDirectory()) walk2(path7__namespace.join(absolute, child.name), relative20);
24035
24750
  }
24036
24751
  };
24037
24752
  walk2(dir, "");
@@ -24046,7 +24761,7 @@ function markerInventory(dir, written) {
24046
24761
  const full = path7__namespace.join(dir, ...entry.split("/"));
24047
24762
  let stats;
24048
24763
  try {
24049
- stats = fs28__namespace.lstatSync(full);
24764
+ stats = fs29__namespace.lstatSync(full);
24050
24765
  } catch {
24051
24766
  continue;
24052
24767
  }
@@ -24058,7 +24773,7 @@ function markerInventory(dir, written) {
24058
24773
  }
24059
24774
  let digest;
24060
24775
  try {
24061
- digest = sha256Hex3(fs28__namespace.readFileSync(full));
24776
+ digest = sha256Hex3(fs29__namespace.readFileSync(full));
24062
24777
  } catch {
24063
24778
  continue;
24064
24779
  }
@@ -24081,13 +24796,13 @@ function markerPayload(dir, state, id, createdAt, written, runId) {
24081
24796
  files
24082
24797
  };
24083
24798
  const manifestPath = path7__namespace.join(dir, "manifest.json");
24084
- if (fs28__namespace.existsSync(manifestPath)) {
24085
- marker2.manifestSha256 = sha256Hex3(fs28__namespace.readFileSync(manifestPath));
24799
+ if (fs29__namespace.existsSync(manifestPath)) {
24800
+ marker2.manifestSha256 = sha256Hex3(fs29__namespace.readFileSync(manifestPath));
24086
24801
  }
24087
24802
  return marker2;
24088
24803
  }
24089
24804
  function writeOwnershipMarker(dir, marker2) {
24090
- fs28__namespace.writeFileSync(
24805
+ fs29__namespace.writeFileSync(
24091
24806
  path7__namespace.join(dir, OWNERSHIP_MARKER),
24092
24807
  `${JSON.stringify(marker2, null, 2)}
24093
24808
  `,
@@ -24101,12 +24816,12 @@ function markerBelongsTo(dir, id) {
24101
24816
  }
24102
24817
  function readOwnershipMarker(dir) {
24103
24818
  const markerPath = path7__namespace.join(dir, OWNERSHIP_MARKER);
24104
- if (!fs28__namespace.existsSync(markerPath)) {
24819
+ if (!fs29__namespace.existsSync(markerPath)) {
24105
24820
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
24106
24821
  }
24107
24822
  let raw;
24108
24823
  try {
24109
- raw = fs28__namespace.readFileSync(markerPath, "utf8");
24824
+ raw = fs29__namespace.readFileSync(markerPath, "utf8");
24110
24825
  } catch {
24111
24826
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
24112
24827
  }
@@ -24210,7 +24925,7 @@ function verifyMarkerInventory(dir, entries, files) {
24210
24925
  const full = path7__namespace.join(dir, ...entry.split("/"));
24211
24926
  let stats;
24212
24927
  try {
24213
- stats = fs28__namespace.lstatSync(full);
24928
+ stats = fs29__namespace.lstatSync(full);
24214
24929
  } catch {
24215
24930
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
24216
24931
  }
@@ -24235,7 +24950,7 @@ function verifyMarkerInventory(dir, entries, files) {
24235
24950
  }
24236
24951
  let digest;
24237
24952
  try {
24238
- digest = sha256Hex3(fs28__namespace.readFileSync(full));
24953
+ digest = sha256Hex3(fs29__namespace.readFileSync(full));
24239
24954
  } catch {
24240
24955
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
24241
24956
  }
@@ -24257,11 +24972,11 @@ function assessSnapshotDirectory(dir) {
24257
24972
  };
24258
24973
  }
24259
24974
  const manifestPath = path7__namespace.join(dir, "manifest.json");
24260
- const hasManifest = fs28__namespace.existsSync(manifestPath);
24975
+ const hasManifest = fs29__namespace.existsSync(manifestPath);
24261
24976
  if (hasManifest) {
24262
24977
  let raw;
24263
24978
  try {
24264
- raw = fs28__namespace.readFileSync(manifestPath, "utf8");
24979
+ raw = fs29__namespace.readFileSync(manifestPath, "utf8");
24265
24980
  } catch {
24266
24981
  return {
24267
24982
  owned: false,
@@ -24362,7 +25077,7 @@ function containsNoFiles(dir) {
24362
25077
  const current = pending.pop();
24363
25078
  let entries;
24364
25079
  try {
24365
- entries = fs28__namespace.readdirSync(current, { withFileTypes: true });
25080
+ entries = fs29__namespace.readdirSync(current, { withFileTypes: true });
24366
25081
  } catch {
24367
25082
  return false;
24368
25083
  }
@@ -24377,13 +25092,13 @@ function containsNoFiles(dir) {
24377
25092
  return true;
24378
25093
  }
24379
25094
  function assertReplaceable(target, label, secretRules) {
24380
- if (!fs28__namespace.existsSync(target)) return;
24381
- if (!fs28__namespace.statSync(target).isDirectory()) {
25095
+ if (!fs29__namespace.existsSync(target)) return;
25096
+ if (!fs29__namespace.statSync(target).isDirectory()) {
24382
25097
  throw new Error(
24383
25098
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
24384
25099
  );
24385
25100
  }
24386
- const entries = fs28__namespace.readdirSync(target);
25101
+ const entries = fs29__namespace.readdirSync(target);
24387
25102
  if (entries.length === 0) return;
24388
25103
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
24389
25104
  if (containsNoFiles(target)) return;
@@ -24403,18 +25118,18 @@ function assertReplaceable(target, label, secretRules) {
24403
25118
  );
24404
25119
  }
24405
25120
  function assertStagingRootUsable(tmpDir, secretRules) {
24406
- if (!fs28__namespace.existsSync(tmpDir)) return;
24407
- if (!fs28__namespace.statSync(tmpDir).isDirectory()) {
25121
+ if (!fs29__namespace.existsSync(tmpDir)) return;
25122
+ if (!fs29__namespace.statSync(tmpDir).isDirectory()) {
24408
25123
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
24409
25124
  }
24410
- const entries = fs28__namespace.readdirSync(tmpDir);
25125
+ const entries = fs29__namespace.readdirSync(tmpDir);
24411
25126
  if (entries.length === 0) return;
24412
25127
  const foreign = entries.filter((name) => {
24413
25128
  const full = path7__namespace.join(tmpDir, name);
24414
25129
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
24415
25130
  let stats;
24416
25131
  try {
24417
- stats = fs28__namespace.statSync(full);
25132
+ stats = fs29__namespace.statSync(full);
24418
25133
  } catch {
24419
25134
  return true;
24420
25135
  }
@@ -24422,7 +25137,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
24422
25137
  const { marker: marker2 } = readOwnershipMarker(full);
24423
25138
  if (marker2) return false;
24424
25139
  try {
24425
- return fs28__namespace.readdirSync(full).length > 0;
25140
+ return fs29__namespace.readdirSync(full).length > 0;
24426
25141
  } catch {
24427
25142
  return true;
24428
25143
  }
@@ -24437,7 +25152,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
24437
25152
  function cleanStaleRunDirs(tmpDir) {
24438
25153
  let entries;
24439
25154
  try {
24440
- entries = fs28__namespace.readdirSync(tmpDir);
25155
+ entries = fs29__namespace.readdirSync(tmpDir);
24441
25156
  } catch {
24442
25157
  return;
24443
25158
  }
@@ -24451,33 +25166,33 @@ function cleanStaleRunDirs(tmpDir) {
24451
25166
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
24452
25167
  if (aged || abandoned) {
24453
25168
  try {
24454
- fs28__namespace.rmSync(full, { recursive: true, force: true });
25169
+ fs29__namespace.rmSync(full, { recursive: true, force: true });
24455
25170
  } catch {
24456
25171
  }
24457
25172
  }
24458
25173
  continue;
24459
25174
  }
24460
25175
  try {
24461
- if (fs28__namespace.readdirSync(full).length === 0) fs28__namespace.rmSync(full, { recursive: true, force: true });
25176
+ if (fs29__namespace.readdirSync(full).length === 0) fs29__namespace.rmSync(full, { recursive: true, force: true });
24462
25177
  } catch {
24463
25178
  }
24464
25179
  }
24465
25180
  }
24466
25181
  function removeIfEmpty(dir) {
24467
25182
  try {
24468
- if (fs28__namespace.readdirSync(dir).length === 0) fs28__namespace.rmSync(dir, { recursive: true, force: true });
25183
+ if (fs29__namespace.readdirSync(dir).length === 0) fs29__namespace.rmSync(dir, { recursive: true, force: true });
24469
25184
  } catch {
24470
25185
  }
24471
25186
  }
24472
25187
  function ensureParentDirectory(target, label) {
24473
25188
  const parent = path7__namespace.dirname(target);
24474
- if (fs28__namespace.existsSync(parent) && !fs28__namespace.statSync(parent).isDirectory()) {
25189
+ if (fs29__namespace.existsSync(parent) && !fs29__namespace.statSync(parent).isDirectory()) {
24475
25190
  throw new Error(
24476
25191
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
24477
25192
  );
24478
25193
  }
24479
25194
  try {
24480
- fs28__namespace.mkdirSync(parent, { recursive: true });
25195
+ fs29__namespace.mkdirSync(parent, { recursive: true });
24481
25196
  } catch (err) {
24482
25197
  throw new Error(
24483
25198
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -24541,17 +25256,17 @@ function acquireRunLock(stagingRoot, runId) {
24541
25256
  `;
24542
25257
  for (let attempt = 0; attempt < 2; attempt += 1) {
24543
25258
  try {
24544
- const handle = fs28__namespace.openSync(lockPath, "wx");
25259
+ const handle = fs29__namespace.openSync(lockPath, "wx");
24545
25260
  try {
24546
- fs28__namespace.writeSync(handle, payload);
25261
+ fs29__namespace.writeSync(handle, payload);
24547
25262
  } finally {
24548
- fs28__namespace.closeSync(handle);
25263
+ fs29__namespace.closeSync(handle);
24549
25264
  }
24550
25265
  const stopHeartbeat = startLockHeartbeat(lockPath);
24551
25266
  return () => {
24552
25267
  stopHeartbeat();
24553
25268
  try {
24554
- fs28__namespace.rmSync(lockPath, { force: true });
25269
+ fs29__namespace.rmSync(lockPath, { force: true });
24555
25270
  } catch {
24556
25271
  }
24557
25272
  };
@@ -24576,7 +25291,7 @@ function canonicalLockTarget(targetPath) {
24576
25291
  const tail = [];
24577
25292
  for (; ; ) {
24578
25293
  try {
24579
- return path7__namespace.join(fs28__namespace.realpathSync(existing), ...tail);
25294
+ return path7__namespace.join(fs29__namespace.realpathSync(existing), ...tail);
24580
25295
  } catch {
24581
25296
  const parent = path7__namespace.dirname(existing);
24582
25297
  if (parent === existing) return resolved;
@@ -24593,13 +25308,13 @@ function releaseAbandonedRun(stagingRoots, runId) {
24593
25308
  for (const root of new Set(stagingRoots)) {
24594
25309
  const lockPath = lockPathFor(root);
24595
25310
  try {
24596
- const payload = JSON.parse(fs28__namespace.readFileSync(lockPath, "utf8"));
24597
- if (payload.runId === runId) fs28__namespace.rmSync(lockPath, { force: true });
25311
+ const payload = JSON.parse(fs29__namespace.readFileSync(lockPath, "utf8"));
25312
+ if (payload.runId === runId) fs29__namespace.rmSync(lockPath, { force: true });
24598
25313
  } catch {
24599
25314
  }
24600
25315
  let entries;
24601
25316
  try {
24602
- entries = fs28__namespace.readdirSync(root);
25317
+ entries = fs29__namespace.readdirSync(root);
24603
25318
  } catch {
24604
25319
  continue;
24605
25320
  }
@@ -24609,7 +25324,7 @@ function releaseAbandonedRun(stagingRoots, runId) {
24609
25324
  const { marker: marker2 } = readOwnershipMarker(directory);
24610
25325
  if (marker2?.runId !== runId) continue;
24611
25326
  try {
24612
- fs28__namespace.rmSync(directory, { recursive: true, force: true });
25327
+ fs29__namespace.rmSync(directory, { recursive: true, force: true });
24613
25328
  } catch {
24614
25329
  }
24615
25330
  }
@@ -24617,7 +25332,7 @@ function releaseAbandonedRun(stagingRoots, runId) {
24617
25332
  }
24618
25333
  function lockHeartbeatAgeMs(lockPath) {
24619
25334
  try {
24620
- return Date.now() - fs28__namespace.statSync(lockPath).mtimeMs;
25335
+ return Date.now() - fs29__namespace.statSync(lockPath).mtimeMs;
24621
25336
  } catch {
24622
25337
  return Number.POSITIVE_INFINITY;
24623
25338
  }
@@ -24625,7 +25340,7 @@ function lockHeartbeatAgeMs(lockPath) {
24625
25340
  function lockOwnerIsGone(lockPath) {
24626
25341
  let raw;
24627
25342
  try {
24628
- raw = fs28__namespace.readFileSync(lockPath, "utf8");
25343
+ raw = fs29__namespace.readFileSync(lockPath, "utf8");
24629
25344
  } catch {
24630
25345
  return false;
24631
25346
  }
@@ -24649,16 +25364,16 @@ function lockOwnerIsGone(lockPath) {
24649
25364
  function reclaimStaleLock(lockPath) {
24650
25365
  let before;
24651
25366
  try {
24652
- before = fs28__namespace.statSync(lockPath);
25367
+ before = fs29__namespace.statSync(lockPath);
24653
25368
  } catch {
24654
25369
  return true;
24655
25370
  }
24656
25371
  if (!lockOwnerIsGone(lockPath)) return false;
24657
25372
  try {
24658
- const current = fs28__namespace.statSync(lockPath);
25373
+ const current = fs29__namespace.statSync(lockPath);
24659
25374
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
24660
25375
  if (!sameFile) return false;
24661
- fs28__namespace.rmSync(lockPath, { force: true });
25376
+ fs29__namespace.rmSync(lockPath, { force: true });
24662
25377
  return true;
24663
25378
  } catch {
24664
25379
  return false;
@@ -24669,12 +25384,12 @@ function lockFileIsAncient(lockPath, thresholdMs = LOCK_STALE_HEARTBEAT_MS) {
24669
25384
  }
24670
25385
  function writeManifestAtomically(manifestPath, manifest) {
24671
25386
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
24672
- fs28__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
25387
+ fs29__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
24673
25388
  try {
24674
- fs28__namespace.renameSync(tempPath, manifestPath);
25389
+ fs29__namespace.renameSync(tempPath, manifestPath);
24675
25390
  } catch (err) {
24676
25391
  try {
24677
- fs28__namespace.rmSync(tempPath, { force: true });
25392
+ fs29__namespace.rmSync(tempPath, { force: true });
24678
25393
  } catch {
24679
25394
  }
24680
25395
  throw err;
@@ -24699,12 +25414,12 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap, onStagingPreserved) {
24699
25414
  }
24700
25415
  }
24701
25416
  function recoverInterruptedPublish(outDir) {
24702
- if (fs28__namespace.existsSync(outDir)) return;
25417
+ if (fs29__namespace.existsSync(outDir)) return;
24703
25418
  const parent = path7__namespace.dirname(outDir);
24704
25419
  const base = path7__namespace.basename(outDir);
24705
25420
  let backups;
24706
25421
  try {
24707
- backups = fs28__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
25422
+ backups = fs29__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
24708
25423
  } catch {
24709
25424
  return;
24710
25425
  }
@@ -24713,7 +25428,7 @@ function recoverInterruptedPublish(outDir) {
24713
25428
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
24714
25429
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
24715
25430
  try {
24716
- fs28__namespace.renameSync(backupDir, outDir);
25431
+ fs29__namespace.renameSync(backupDir, outDir);
24717
25432
  process.stderr.write(
24718
25433
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
24719
25434
  `
@@ -24723,17 +25438,17 @@ function recoverInterruptedPublish(outDir) {
24723
25438
  }
24724
25439
  function swapOnce(stagingDir, outDir, beforeSwap, onStagingPreserved) {
24725
25440
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
24726
- const hadPrevious = fs28__namespace.existsSync(outDir);
25441
+ const hadPrevious = fs29__namespace.existsSync(outDir);
24727
25442
  if (hadPrevious) beforeSwap?.();
24728
25443
  let movedAside = false;
24729
25444
  if (hadPrevious) {
24730
25445
  try {
24731
- fs28__namespace.renameSync(outDir, backupDir);
25446
+ fs29__namespace.renameSync(outDir, backupDir);
24732
25447
  movedAside = true;
24733
25448
  } catch (err) {
24734
25449
  if (!isLockError(err)) throw err;
24735
25450
  onStagingPreserved?.();
24736
- fs28__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
25451
+ fs29__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
24737
25452
  process.stderr.write(
24738
25453
  `\u26A0 ${outDir} could not be moved aside (${err.message}), so it was replaced in place. Close anything holding the old snapshot open to avoid this next time.
24739
25454
  `
@@ -24742,26 +25457,26 @@ function swapOnce(stagingDir, outDir, beforeSwap, onStagingPreserved) {
24742
25457
  }
24743
25458
  try {
24744
25459
  try {
24745
- fs28__namespace.renameSync(stagingDir, outDir);
25460
+ fs29__namespace.renameSync(stagingDir, outDir);
24746
25461
  } catch (err) {
24747
25462
  if (err.code !== "EXDEV") throw err;
24748
25463
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
24749
25464
  try {
24750
- fs28__namespace.cpSync(stagingDir, partialDir, { recursive: true });
24751
- fs28__namespace.renameSync(partialDir, outDir);
24752
- fs28__namespace.rmSync(stagingDir, { recursive: true, force: true });
25465
+ fs29__namespace.cpSync(stagingDir, partialDir, { recursive: true });
25466
+ fs29__namespace.renameSync(partialDir, outDir);
25467
+ fs29__namespace.rmSync(stagingDir, { recursive: true, force: true });
24753
25468
  } catch (copyErr) {
24754
25469
  try {
24755
- fs28__namespace.rmSync(partialDir, { recursive: true, force: true });
25470
+ fs29__namespace.rmSync(partialDir, { recursive: true, force: true });
24756
25471
  } catch {
24757
25472
  }
24758
25473
  throw copyErr;
24759
25474
  }
24760
25475
  }
24761
25476
  } catch (err) {
24762
- if (hadPrevious && movedAside && fs28__namespace.existsSync(backupDir)) {
24763
- if (fs28__namespace.existsSync(outDir)) fs28__namespace.rmSync(outDir, { recursive: true, force: true });
24764
- fs28__namespace.renameSync(backupDir, outDir);
25477
+ if (hadPrevious && movedAside && fs29__namespace.existsSync(backupDir)) {
25478
+ if (fs29__namespace.existsSync(outDir)) fs29__namespace.rmSync(outDir, { recursive: true, force: true });
25479
+ fs29__namespace.renameSync(backupDir, outDir);
24765
25480
  } else if (hadPrevious && !movedAside) {
24766
25481
  onStagingPreserved?.();
24767
25482
  process.stderr.write(
@@ -24773,7 +25488,7 @@ function swapOnce(stagingDir, outDir, beforeSwap, onStagingPreserved) {
24773
25488
  }
24774
25489
  if (hadPrevious) {
24775
25490
  try {
24776
- fs28__namespace.rmSync(backupDir, { recursive: true, force: true });
25491
+ fs29__namespace.rmSync(backupDir, { recursive: true, force: true });
24777
25492
  } catch (err) {
24778
25493
  process.stderr.write(
24779
25494
  `\u26A0 The previous snapshot could not be removed from ${backupDir} (${err.message}). The new snapshot is in place; delete that directory by hand when convenient.
@@ -24955,7 +25670,7 @@ function generateSnapshot(configInput, options) {
24955
25670
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
24956
25671
  (directory) => path7__namespace.relative(config.cwd, path7__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
24957
25672
  ).filter(
24958
- (relative18) => relative18.length > 0 && relative18 !== ".." && !relative18.startsWith(`..${path7__namespace.sep}`) && !relative18.startsWith("../") && !path7__namespace.isAbsolute(relative18)
25673
+ (relative20) => relative20.length > 0 && relative20 !== ".." && !relative20.startsWith(`..${path7__namespace.sep}`) && !relative20.startsWith("../") && !path7__namespace.isAbsolute(relative20)
24959
25674
  ),
24960
25675
  // A staged path can be absent from the working tree while its index blob exists. Discovery
24961
25676
  // lists the working tree, so those paths would never reach the scan at all.
@@ -25015,9 +25730,9 @@ function generateSnapshot(configInput, options) {
25015
25730
  } else {
25016
25731
  let stats;
25017
25732
  try {
25018
- stats = fs28__namespace.statSync(absolutePath);
25733
+ stats = fs29__namespace.statSync(absolutePath);
25019
25734
  if (!stats.isFile()) {
25020
- const nestedRepository = stats.isDirectory() && fs28__namespace.existsSync(path7__namespace.join(absolutePath, ".git"));
25735
+ const nestedRepository = stats.isDirectory() && fs29__namespace.existsSync(path7__namespace.join(absolutePath, ".git"));
25021
25736
  skipped.push(
25022
25737
  nestedRepository ? {
25023
25738
  path: relativePath,
@@ -25053,7 +25768,7 @@ function generateSnapshot(configInput, options) {
25053
25768
  continue;
25054
25769
  }
25055
25770
  try {
25056
- buffer = fs28__namespace.readFileSync(absolutePath);
25771
+ buffer = fs29__namespace.readFileSync(absolutePath);
25057
25772
  } catch (err) {
25058
25773
  const code = err.code;
25059
25774
  skipped.push({
@@ -25170,14 +25885,14 @@ function generateSnapshot(configInput, options) {
25170
25885
  }
25171
25886
  retain(secretFindings, (finding) => finding.path === void 0 || keep.has(finding.path));
25172
25887
  retain(encodingNotes, (note) => keep.has(note.path));
25173
- retain(oversizeSummaryPaths, (path31) => keep.has(path31));
25174
- retain(previewSummaryPaths, (path31) => keep.has(path31));
25888
+ retain(oversizeSummaryPaths, (path32) => keep.has(path32));
25889
+ retain(previewSummaryPaths, (path32) => keep.has(path32));
25175
25890
  retain(fileWarnings, (warning) => keep.has(warning.path));
25176
- for (const path31 of [...monolithBodies.keys()]) {
25177
- if (!keep.has(path31)) monolithBodies.delete(path31);
25891
+ for (const path32 of [...monolithBodies.keys()]) {
25892
+ if (!keep.has(path32)) monolithBodies.delete(path32);
25178
25893
  }
25179
- for (const path31 of [...skippedSummaryImports.keys()]) {
25180
- if (!keep.has(path31)) skippedSummaryImports.delete(path31);
25894
+ for (const path32 of [...skippedSummaryImports.keys()]) {
25895
+ if (!keep.has(path32)) skippedSummaryImports.delete(path32);
25181
25896
  }
25182
25897
  };
25183
25898
  if (changedScope !== null && changedPaths !== null && config.withDependents === true) {
@@ -25439,7 +26154,8 @@ function generateSnapshot(configInput, options) {
25439
26154
  );
25440
26155
  }
25441
26156
  }
25442
- const partitioned = partitionByBudget(files, config, fingerprint);
26157
+ const partitionConfig = indexOnly ? { ...config, maxParts: null } : config;
26158
+ const partitioned = partitionByBudget(files, partitionConfig, fingerprint);
25443
26159
  const parts = partitioned.parts;
25444
26160
  const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
25445
26161
  const incomplete = files.flatMap((file) => {
@@ -25797,12 +26513,12 @@ function generateSnapshot(configInput, options) {
25797
26513
  let releaseDeferred = false;
25798
26514
  try {
25799
26515
  ensureParentDirectory(outDir, "outDir");
25800
- fs28__namespace.mkdirSync(tmpDir, { recursive: true });
26516
+ fs29__namespace.mkdirSync(tmpDir, { recursive: true });
25801
26517
  cleanStaleRunDirs(tmpDir);
25802
26518
  const snapshotId = crypto__namespace.randomUUID();
25803
26519
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
25804
26520
  stagingDir = path7__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
25805
- fs28__namespace.mkdirSync(stagingDir);
26521
+ fs29__namespace.mkdirSync(stagingDir);
25806
26522
  writeOwnershipMarker(stagingDir, {
25807
26523
  generator: GENERATOR_NAME,
25808
26524
  version: GENERATOR_VERSION,
@@ -25815,17 +26531,17 @@ function generateSnapshot(configInput, options) {
25815
26531
  });
25816
26532
  const partsDir = path7__namespace.join(stagingDir, "parts");
25817
26533
  const reportsDir = path7__namespace.join(stagingDir, "reports");
25818
- if (artifacts.parts) fs28__namespace.mkdirSync(partsDir, { recursive: true });
25819
- if (artifacts.navigation || artifacts.projectTree || artifacts.audit || artifacts.diff || artifacts.log || artifacts.tokenTree || config.sarif === true) {
25820
- fs28__namespace.mkdirSync(reportsDir, { recursive: true });
26534
+ if (artifacts.parts) fs29__namespace.mkdirSync(partsDir, { recursive: true });
26535
+ if (artifacts.navigation || artifacts.projectTree || artifacts.audit || artifacts.diff || artifacts.log || artifacts.tokenTree || config.sarif === true || selectionText !== null) {
26536
+ fs29__namespace.mkdirSync(reportsDir, { recursive: true });
25821
26537
  }
25822
26538
  const writtenArtifacts = /* @__PURE__ */ new Map();
25823
26539
  const ledgerRoot = (targetDir) => stagingDir !== null && (targetDir === stagingDir || targetDir.startsWith(stagingDir + path7__namespace.sep)) ? stagingDir : outDir;
25824
26540
  const ledgerEntry = (targetDir, relativeEntry) => path7__namespace.relative(ledgerRoot(targetDir), path7__namespace.join(targetDir, ...relativeEntry.split("/"))).split(path7__namespace.sep).join("/");
25825
26541
  const writeArtifact = (targetDir, relativeEntry, data) => {
25826
26542
  const full = path7__namespace.join(targetDir, ...relativeEntry.split("/"));
25827
- fs28__namespace.writeFileSync(full, data, "utf8");
25828
- const stats = fs28__namespace.statSync(full);
26543
+ fs29__namespace.writeFileSync(full, data, "utf8");
26544
+ const stats = fs29__namespace.statSync(full);
25829
26545
  const entry = ledgerEntry(targetDir, relativeEntry);
25830
26546
  writtenArtifacts.set(entry, {
25831
26547
  digest: { path: entry, bytes: stats.size, sha256: sha256Hex3(data) },
@@ -25834,13 +26550,13 @@ function generateSnapshot(configInput, options) {
25834
26550
  };
25835
26551
  const recordArtifact = (targetDir, relativeEntry) => {
25836
26552
  const full = path7__namespace.join(targetDir, ...relativeEntry.split("/"));
25837
- const stats = fs28__namespace.statSync(full);
26553
+ const stats = fs29__namespace.statSync(full);
25838
26554
  const entry = ledgerEntry(targetDir, relativeEntry);
25839
26555
  writtenArtifacts.set(entry, {
25840
26556
  digest: {
25841
26557
  path: entry,
25842
26558
  bytes: stats.size,
25843
- sha256: sha256Hex3(fs28__namespace.readFileSync(full))
26559
+ sha256: sha256Hex3(fs29__namespace.readFileSync(full))
25844
26560
  },
25845
26561
  mtimeMs: stats.mtimeMs
25846
26562
  });
@@ -25970,7 +26686,7 @@ function generateSnapshot(configInput, options) {
25970
26686
  } catch (err) {
25971
26687
  if (stagingDir !== null && !stagingPreserved) {
25972
26688
  try {
25973
- fs28__namespace.rmSync(stagingDir, { recursive: true, force: true });
26689
+ fs29__namespace.rmSync(stagingDir, { recursive: true, force: true });
25974
26690
  } catch {
25975
26691
  }
25976
26692
  }