codebase-snapshot 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var childProcess = require('child_process');
4
4
  var fs27 = require('fs');
5
- var path32 = require('path');
5
+ var path33 = require('path');
6
6
  var url = require('url');
7
7
  var util = require('util');
8
8
  var crypto = require('crypto');
@@ -39,7 +39,7 @@ function _interopNamespace(e) {
39
39
 
40
40
  var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
41
41
  var fs27__namespace = /*#__PURE__*/_interopNamespace(fs27);
42
- var path32__namespace = /*#__PURE__*/_interopNamespace(path32);
42
+ var path33__namespace = /*#__PURE__*/_interopNamespace(path33);
43
43
  var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
44
44
  var ts2__default = /*#__PURE__*/_interopDefault(ts2);
45
45
  var os2__namespace = /*#__PURE__*/_interopNamespace(os2);
@@ -277,7 +277,7 @@ function readSmallFile(fullPath) {
277
277
  }
278
278
  }
279
279
  function readManifest(cwd, name) {
280
- return readSmallFile(path32__namespace.join(cwd, name));
280
+ return readSmallFile(path33__namespace.join(cwd, name));
281
281
  }
282
282
  function dependenciesFromPackageJson(raw) {
283
283
  const names = /* @__PURE__ */ new Set();
@@ -337,7 +337,7 @@ function pnpmWorkspacePatterns(raw) {
337
337
  function childDirectories(cwd, parent) {
338
338
  let entries;
339
339
  try {
340
- entries = fs27__namespace.readdirSync(path32__namespace.join(cwd, parent), { withFileTypes: true });
340
+ entries = fs27__namespace.readdirSync(path33__namespace.join(cwd, parent), { withFileTypes: true });
341
341
  } catch {
342
342
  return [];
343
343
  }
@@ -372,13 +372,13 @@ function workspacePackageDirs(cwd, patterns) {
372
372
  function scanWorkspacePackages(cwd, patterns) {
373
373
  const files = /* @__PURE__ */ new Set();
374
374
  const dependencies = /* @__PURE__ */ new Set();
375
- for (const relative20 of workspacePackageDirs(cwd, patterns)) {
376
- const full = path32__namespace.join(cwd, relative20);
375
+ for (const relative21 of workspacePackageDirs(cwd, patterns)) {
376
+ const full = path33__namespace.join(cwd, relative21);
377
377
  try {
378
378
  for (const entry of fs27__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
379
379
  } catch {
380
380
  }
381
- const raw = readSmallFile(path32__namespace.join(full, "package.json"));
381
+ const raw = readSmallFile(path33__namespace.join(full, "package.json"));
382
382
  if (raw !== null) {
383
383
  for (const name of dependenciesFromPackageJson(raw)) dependencies.add(name);
384
384
  }
@@ -388,7 +388,7 @@ function scanWorkspacePackages(cwd, patterns) {
388
388
  var SNAPSHOT_MARKER = ".codebase-snapshot";
389
389
  function isToolOwnedDirectory(dir) {
390
390
  try {
391
- return fs27__namespace.statSync(dir).isDirectory() && fs27__namespace.existsSync(path32__namespace.join(dir, SNAPSHOT_MARKER));
391
+ return fs27__namespace.statSync(dir).isDirectory() && fs27__namespace.existsSync(path33__namespace.join(dir, SNAPSHOT_MARKER));
392
392
  } catch {
393
393
  return false;
394
394
  }
@@ -414,7 +414,7 @@ function countMarkdownFiles(cwd) {
414
414
  }
415
415
  if (!entry.isDirectory() || current.depth >= 2) continue;
416
416
  if (entry.name.startsWith(".") || SKIPPED_WALK_DIRS.has(entry.name)) continue;
417
- const child = path32__namespace.join(current.dir, entry.name);
417
+ const child = path33__namespace.join(current.dir, entry.name);
418
418
  if (isToolOwnedDirectory(child)) continue;
419
419
  queue.push({ dir: child, depth: current.depth + 1 });
420
420
  }
@@ -442,7 +442,7 @@ function buildPresetContext(cwd) {
442
442
  const isWorkspace = files.has("pnpm-workspace.yaml") || files.has("nx.json") || files.has("turbo.json") || files.has("lerna.json") || packageJson2 !== void 0 && packageJson2.includes('"workspaces"') || declaredWorkspaces.length > 0;
443
443
  let workspace = { files: /* @__PURE__ */ new Set(), dependencies: /* @__PURE__ */ new Set() };
444
444
  if (isWorkspace) {
445
- const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path32__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
445
+ const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path33__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
446
446
  const declared = pnpmRaw === null ? [] : pnpmWorkspacePatterns(pnpmRaw);
447
447
  const patterns = declared.length > 0 ? declared : declaredWorkspaces.length > 0 ? declaredWorkspaces : DEFAULT_WORKSPACE_PATTERNS;
448
448
  workspace = scanWorkspacePackages(cwd, patterns);
@@ -2574,23 +2574,23 @@ function applySpansKeepingQuotes(line, spans) {
2574
2574
  return out;
2575
2575
  }
2576
2576
  function isInside(parent, child) {
2577
- const relative20 = path32__namespace.relative(parent, child);
2578
- return relative20 === "" || relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20);
2577
+ const relative21 = path33__namespace.relative(parent, child);
2578
+ return relative21 === "" || relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21);
2579
2579
  }
2580
2580
  function resolveConfined(baseDir, relativePath) {
2581
2581
  if (relativePath.length === 0 || relativePath.includes("\0")) {
2582
2582
  return { ok: false, reason: "not-file", message: "the file name is empty or contains a NUL byte" };
2583
2583
  }
2584
- if (path32__namespace.isAbsolute(relativePath)) {
2584
+ if (path33__namespace.isAbsolute(relativePath)) {
2585
2585
  return { ok: false, reason: "outside", message: "an absolute path is not a snapshot-relative file" };
2586
2586
  }
2587
2587
  let baseReal;
2588
2588
  try {
2589
- baseReal = fs27__namespace.realpathSync(path32__namespace.resolve(baseDir));
2589
+ baseReal = fs27__namespace.realpathSync(path33__namespace.resolve(baseDir));
2590
2590
  } catch {
2591
2591
  return { ok: false, reason: "missing", message: "the snapshot directory does not exist" };
2592
2592
  }
2593
- const candidate = path32__namespace.resolve(baseReal, relativePath);
2593
+ const candidate = path33__namespace.resolve(baseReal, relativePath);
2594
2594
  if (!isInside(baseReal, candidate)) {
2595
2595
  return { ok: false, reason: "outside", message: "the path resolves outside the snapshot directory" };
2596
2596
  }
@@ -2741,7 +2741,7 @@ function verifySnapshotSignature(snapshotDir) {
2741
2741
 
2742
2742
  // src/version.ts
2743
2743
  var GENERATOR_NAME = "codebase-snapshot";
2744
- var GENERATOR_VERSION = "0.21.0";
2744
+ var GENERATOR_VERSION = "0.22.0";
2745
2745
  var SCHEMA_VERSION = "3.0.0";
2746
2746
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2747
2747
  function isOurGeneratorName(name) {
@@ -2765,7 +2765,7 @@ function readLinkTarget(linkPath, fallback) {
2765
2765
  }
2766
2766
  function brokenLinkRecord(linkPath, relativePath, rootReal) {
2767
2767
  const rawTarget = readLinkTarget(linkPath, linkPath);
2768
- const resolvedFallback = path32__namespace.resolve(path32__namespace.dirname(linkPath), rawTarget);
2768
+ const resolvedFallback = path33__namespace.resolve(path33__namespace.dirname(linkPath), rawTarget);
2769
2769
  return isInside2(rootReal, resolvedFallback) ? { path: relativePath, reason: "read-error", detail: "broken symlink" } : {
2770
2770
  path: relativePath,
2771
2771
  reason: "outside-root",
@@ -2773,8 +2773,8 @@ function brokenLinkRecord(linkPath, relativePath, rootReal) {
2773
2773
  };
2774
2774
  }
2775
2775
  function isInside2(root, candidate) {
2776
- const relative20 = path32__namespace.relative(root, candidate);
2777
- return relative20 === "" || !relative20.startsWith(`..${path32__namespace.sep}`) && relative20 !== ".." && !path32__namespace.isAbsolute(relative20);
2776
+ const relative21 = path33__namespace.relative(root, candidate);
2777
+ return relative21 === "" || !relative21.startsWith(`..${path33__namespace.sep}`) && relative21 !== ".." && !path33__namespace.isAbsolute(relative21);
2778
2778
  }
2779
2779
  var GIT_OUTPUT_LIMIT = 68157440;
2780
2780
  function getGitInfo(cwd, fallbackBranch = "main") {
@@ -3093,7 +3093,7 @@ function trimUnescapedTrailingSpaces(line) {
3093
3093
  return line.slice(0, end);
3094
3094
  }
3095
3095
  function readGitignoreRules(dir) {
3096
- const gitignorePath2 = path32__namespace.join(dir, ".gitignore");
3096
+ const gitignorePath2 = path33__namespace.join(dir, ".gitignore");
3097
3097
  let raw;
3098
3098
  try {
3099
3099
  raw = fs27__namespace.readFileSync(gitignorePath2, "utf8");
@@ -3317,7 +3317,7 @@ var IGNORABLE_DIRECTORY_ENTRIES = /* @__PURE__ */ new Set([".DS_Store"]);
3317
3317
  function isToolOwnedDirectory2(dir) {
3318
3318
  let raw;
3319
3319
  try {
3320
- raw = fs27__namespace.readFileSync(path32__namespace.join(dir, ".codebase-snapshot"), "utf8");
3320
+ raw = fs27__namespace.readFileSync(path33__namespace.join(dir, ".codebase-snapshot"), "utf8");
3321
3321
  } catch {
3322
3322
  return false;
3323
3323
  }
@@ -3334,7 +3334,7 @@ function isToolOwnedDirectory2(dir) {
3334
3334
  }
3335
3335
  let manifestBytes;
3336
3336
  try {
3337
- manifestBytes = fs27__namespace.readFileSync(path32__namespace.join(dir, "manifest.json"));
3337
+ manifestBytes = fs27__namespace.readFileSync(path33__namespace.join(dir, "manifest.json"));
3338
3338
  } catch {
3339
3339
  return false;
3340
3340
  }
@@ -3346,10 +3346,10 @@ function isToolOwnedDirectory2(dir) {
3346
3346
  if (!item || typeof item !== "object" || Array.isArray(item)) return false;
3347
3347
  const record = item;
3348
3348
  const entry = record.path;
3349
- if (typeof entry !== "string" || entry.length === 0 || entry.includes(String.fromCharCode(92)) || entry.includes("\0") || path32__namespace.isAbsolute(entry) || entry.split("/").includes("..") || typeof record.bytes !== "number" || !Number.isSafeInteger(record.bytes) || record.bytes < 0 || typeof record.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(record.sha256)) {
3349
+ if (typeof entry !== "string" || entry.length === 0 || entry.includes(String.fromCharCode(92)) || entry.includes("\0") || path33__namespace.isAbsolute(entry) || entry.split("/").includes("..") || typeof record.bytes !== "number" || !Number.isSafeInteger(record.bytes) || record.bytes < 0 || typeof record.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(record.sha256)) {
3350
3350
  return false;
3351
3351
  }
3352
- const full = path32__namespace.join(dir, ...entry.split("/"));
3352
+ const full = path33__namespace.join(dir, ...entry.split("/"));
3353
3353
  let stats;
3354
3354
  try {
3355
3355
  stats = fs27__namespace.lstatSync(full);
@@ -3371,22 +3371,22 @@ function isToolOwnedDirectory2(dir) {
3371
3371
  const current = stack.pop();
3372
3372
  let entries;
3373
3373
  try {
3374
- entries = fs27__namespace.readdirSync(path32__namespace.join(dir, current), { withFileTypes: true });
3374
+ entries = fs27__namespace.readdirSync(path33__namespace.join(dir, current), { withFileTypes: true });
3375
3375
  } catch {
3376
3376
  return false;
3377
3377
  }
3378
3378
  for (const entry of entries) {
3379
- const relative20 = current === "" ? entry.name : current + "/" + entry.name;
3380
- if (relative20 === ".codebase-snapshot" || IGNORABLE_DIRECTORY_ENTRIES.has(entry.name)) continue;
3379
+ const relative21 = current === "" ? entry.name : current + "/" + entry.name;
3380
+ if (relative21 === ".codebase-snapshot" || IGNORABLE_DIRECTORY_ENTRIES.has(entry.name)) continue;
3381
3381
  if (entry.isDirectory()) {
3382
- stack.push(relative20);
3382
+ stack.push(relative21);
3383
3383
  continue;
3384
3384
  }
3385
3385
  if (!entry.isFile()) return false;
3386
- if (relative20 === "signature.json" && !recordedFiles.has(relative20) && verifySnapshotSignature(dir).ok) {
3386
+ if (relative21 === "signature.json" && !recordedFiles.has(relative21) && verifySnapshotSignature(dir).ok) {
3387
3387
  continue;
3388
3388
  }
3389
- if (!recordedFiles.has(relative20)) return false;
3389
+ if (!recordedFiles.has(relative21)) return false;
3390
3390
  }
3391
3391
  }
3392
3392
  return true;
@@ -3404,7 +3404,7 @@ function makeToolOwnedDecider(cwd, toolOwnedPaths) {
3404
3404
  if (reservedPaths.has(prefix)) return "reserved";
3405
3405
  let marker2 = markers.get(prefix);
3406
3406
  if (marker2 === void 0) {
3407
- marker2 = hasToolMarker(path32__namespace.join(cwd, prefix));
3407
+ marker2 = hasToolMarker(path33__namespace.join(cwd, prefix));
3408
3408
  markers.set(prefix, marker2);
3409
3409
  }
3410
3410
  if (marker2) return "marker";
@@ -3446,7 +3446,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
3446
3446
  let linkedPath = null;
3447
3447
  for (let depth = 1; depth <= parts.length; depth += 1) {
3448
3448
  const prefix = parts.slice(0, depth).join("/");
3449
- if (isLink(path32__namespace.join(cwd, prefix))) {
3449
+ if (isLink(path33__namespace.join(cwd, prefix))) {
3450
3450
  linkedPath = prefix;
3451
3451
  break;
3452
3452
  }
@@ -3455,7 +3455,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
3455
3455
  kept.push(candidate);
3456
3456
  continue;
3457
3457
  }
3458
- const absolute = path32__namespace.join(cwd, linkedPath);
3458
+ const absolute = path33__namespace.join(cwd, linkedPath);
3459
3459
  const rawTarget = readLinkTarget(absolute, absolute);
3460
3460
  let targetReal = null;
3461
3461
  try {
@@ -3501,7 +3501,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
3501
3501
  });
3502
3502
  continue;
3503
3503
  }
3504
- const targetRelative = path32__namespace.relative(rootReal, targetReal).split(path32__namespace.sep).join("/");
3504
+ const targetRelative = path33__namespace.relative(rootReal, targetReal).split(path33__namespace.sep).join("/");
3505
3505
  if (isSensitivePath(targetRelative)) {
3506
3506
  report2(linkedPath, {
3507
3507
  path: linkedPath,
@@ -3583,7 +3583,7 @@ function collectFiles(cwd, options = {}) {
3583
3583
  "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."
3584
3584
  );
3585
3585
  }
3586
- if (fs27__namespace.existsSync(path32__namespace.join(cwd, ".git"))) {
3586
+ if (fs27__namespace.existsSync(path33__namespace.join(cwd, ".git"))) {
3587
3587
  throw new Error(
3588
3588
  "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."
3589
3589
  );
@@ -3663,7 +3663,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
3663
3663
  const aliases = /* @__PURE__ */ new Set();
3664
3664
  for (const file of files) {
3665
3665
  try {
3666
- if (fs27__namespace.lstatSync(path32__namespace.join(cwd, file)).isSymbolicLink()) aliases.add(file);
3666
+ if (fs27__namespace.lstatSync(path33__namespace.join(cwd, file)).isSymbolicLink()) aliases.add(file);
3667
3667
  } catch {
3668
3668
  }
3669
3669
  }
@@ -3672,7 +3672,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
3672
3672
  for (const file of files) {
3673
3673
  if (aliases.has(file)) continue;
3674
3674
  try {
3675
- includedTargets.add(fs27__namespace.realpathSync(path32__namespace.join(cwd, file)));
3675
+ includedTargets.add(fs27__namespace.realpathSync(path33__namespace.join(cwd, file)));
3676
3676
  } catch {
3677
3677
  }
3678
3678
  }
@@ -3684,7 +3684,7 @@ function dropSymlinksToUnincludedTargets(cwd, files, skipped) {
3684
3684
  }
3685
3685
  let target;
3686
3686
  try {
3687
- target = fs27__namespace.realpathSync(path32__namespace.join(cwd, file));
3687
+ target = fs27__namespace.realpathSync(path33__namespace.join(cwd, file));
3688
3688
  } catch {
3689
3689
  skipped.push({ path: file, reason: "read-error", detail: "symlink target could not be resolved" });
3690
3690
  continue;
@@ -3712,14 +3712,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3712
3712
  const results = { files: [], skipped: [] };
3713
3713
  const stack = [];
3714
3714
  const toolDirNames = toolDirNamesFor(reservedPaths);
3715
- const relativeToBase = (target) => path32__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
3715
+ const relativeToBase = (target) => path33__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
3716
3716
  const enter = (current, layers) => {
3717
3717
  if (visited.has(current)) return false;
3718
3718
  visited.add(current);
3719
3719
  const localRules = readGitignoreRules(current);
3720
3720
  const gitignoreLayers = localRules.length === 0 ? layers : [
3721
3721
  ...layers,
3722
- { prefix: path32__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
3722
+ { prefix: path33__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
3723
3723
  ];
3724
3724
  let entries;
3725
3725
  try {
@@ -3745,8 +3745,8 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3745
3745
  }
3746
3746
  const entry = frame.entries[frame.index];
3747
3747
  frame.index += 1;
3748
- const fullPath = path32__namespace.join(frame.dir, entry.name);
3749
- const relPath = path32__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
3748
+ const fullPath = path33__namespace.join(frame.dir, entry.name);
3749
+ const relPath = path33__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
3750
3750
  if (reservedPaths.has(relPath)) continue;
3751
3751
  if (entry.isDirectory() && hasToolMarker(fullPath)) {
3752
3752
  results.skipped.push({
@@ -3824,7 +3824,7 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3824
3824
  });
3825
3825
  continue;
3826
3826
  }
3827
- const targetRelative = path32__namespace.relative(rootReal, targetReal).split(path32__namespace.sep).join("/");
3827
+ const targetRelative = path33__namespace.relative(rootReal, targetReal).split(path33__namespace.sep).join("/");
3828
3828
  if (isSensitivePath(targetRelative)) {
3829
3829
  results.skipped.push({
3830
3830
  path: relPath,
@@ -4185,7 +4185,7 @@ function assertServerSafeConfig(config, source = "The configuration") {
4185
4185
  }
4186
4186
  function findConfigFile(cwd) {
4187
4187
  for (const filename of CONFIG_FILENAMES) {
4188
- const fullPath = path32__namespace.join(cwd, filename);
4188
+ const fullPath = path33__namespace.join(cwd, filename);
4189
4189
  let stats = null;
4190
4190
  try {
4191
4191
  stats = fs27__namespace.statSync(fullPath);
@@ -4195,7 +4195,7 @@ function findConfigFile(cwd) {
4195
4195
  }
4196
4196
  if (stats.isFile()) return fullPath;
4197
4197
  }
4198
- const pkgJsonPath = path32__namespace.join(cwd, "package.json");
4198
+ const pkgJsonPath = path33__namespace.join(cwd, "package.json");
4199
4199
  if (!fs27__namespace.existsSync(pkgJsonPath)) return null;
4200
4200
  try {
4201
4201
  const parsed = JSON.parse(stripJsonComments(fs27__namespace.readFileSync(pkgJsonPath, "utf8")));
@@ -4460,7 +4460,7 @@ async function importConfigModule(fullPath) {
4460
4460
  function attachConfigDir(config, filePath) {
4461
4461
  if (typeof config === "object" && config !== null) {
4462
4462
  Object.defineProperty(config, CONFIG_DIR_SYMBOL, {
4463
- value: path32__namespace.dirname(filePath),
4463
+ value: path33__namespace.dirname(filePath),
4464
4464
  enumerable: false,
4465
4465
  configurable: true
4466
4466
  });
@@ -4473,7 +4473,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
4473
4473
  const configDirectories = [];
4474
4474
  const executableRefusals = /* @__PURE__ */ new Set();
4475
4475
  for (const filename of CONFIG_FILENAMES) {
4476
- const fullPath = path32__namespace.join(cwd, filename);
4476
+ const fullPath = path33__namespace.join(cwd, filename);
4477
4477
  let candidateStats = null;
4478
4478
  try {
4479
4479
  candidateStats = fs27__namespace.statSync(fullPath);
@@ -4531,7 +4531,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
4531
4531
  continue;
4532
4532
  }
4533
4533
  }
4534
- const pkgJsonPath = path32__namespace.join(cwd, "package.json");
4534
+ const pkgJsonPath = path33__namespace.join(cwd, "package.json");
4535
4535
  if (fs27__namespace.existsSync(pkgJsonPath)) {
4536
4536
  try {
4537
4537
  const parsed = parseJsonish(fs27__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
@@ -4708,10 +4708,10 @@ function readConfiguredBrief(cwd, value) {
4708
4708
  try {
4709
4709
  return fs27__namespace.realpathSync(cwd);
4710
4710
  } catch {
4711
- return path32__namespace.resolve(cwd);
4711
+ return path33__namespace.resolve(cwd);
4712
4712
  }
4713
4713
  })();
4714
- const requested = path32__namespace.resolve(cwd, value);
4714
+ const requested = path33__namespace.resolve(cwd, value);
4715
4715
  let filePath;
4716
4716
  try {
4717
4717
  filePath = fs27__namespace.realpathSync(requested);
@@ -4720,13 +4720,13 @@ function readConfiguredBrief(cwd, value) {
4720
4720
  'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
4721
4721
  );
4722
4722
  }
4723
- const relative20 = path32__namespace.relative(rootReal, filePath);
4724
- if (relative20.length === 0 || relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || path32__namespace.isAbsolute(relative20)) {
4723
+ const relative21 = path33__namespace.relative(rootReal, filePath);
4724
+ if (relative21.length === 0 || relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || path33__namespace.isAbsolute(relative21)) {
4725
4725
  throw new Error(
4726
4726
  'brief "' + value + '" resolves outside the repository. A brief must be a file inside the repository being described; an absolute or parent path is refused.'
4727
4727
  );
4728
4728
  }
4729
- const posixRelative = relative20.split(path32__namespace.sep).join("/");
4729
+ const posixRelative = relative21.split(path33__namespace.sep).join("/");
4730
4730
  if (isSensitivePath(posixRelative) || isSensitivePath(value)) {
4731
4731
  throw new Error(
4732
4732
  'brief "' + value + '" is a credential-bearing file. A snapshot must not reproduce secrets, so it cannot be used as the owner brief.'
@@ -4768,24 +4768,24 @@ function readConfiguredBrief(cwd, value) {
4768
4768
  }
4769
4769
  return parsed.brief;
4770
4770
  }
4771
- function strictPositiveInteger(value, fallback, label) {
4771
+ function strictPositiveInteger(value, fallback, label2) {
4772
4772
  if (value === void 0) return fallback;
4773
4773
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
4774
- throw new Error(`${label} must be a positive integer (received ${describeValue2(value)}).`);
4774
+ throw new Error(`${label2} must be a positive integer (received ${describeValue2(value)}).`);
4775
4775
  }
4776
4776
  return value;
4777
4777
  }
4778
- function strictBoolean(value, fallback, label) {
4778
+ function strictBoolean(value, fallback, label2) {
4779
4779
  if (value === void 0) return fallback;
4780
4780
  if (typeof value !== "boolean") {
4781
- throw new Error(`${label} must be true or false (received ${describeValue2(value)}).`);
4781
+ throw new Error(`${label2} must be true or false (received ${describeValue2(value)}).`);
4782
4782
  }
4783
4783
  return value;
4784
4784
  }
4785
- function strictString(value, fallback, label) {
4785
+ function strictString(value, fallback, label2) {
4786
4786
  if (value === void 0) return fallback;
4787
4787
  if (typeof value !== "string" || value.trim() === "") {
4788
- throw new Error(`${label} must be a non-empty string (received ${describeValue2(value)}).`);
4788
+ throw new Error(`${label2} must be a non-empty string (received ${describeValue2(value)}).`);
4789
4789
  }
4790
4790
  return value;
4791
4791
  }
@@ -4873,12 +4873,12 @@ function resolveKindRules(value) {
4873
4873
  function outputExcludePatterns(cwd, outDir, tmpDir) {
4874
4874
  const patterns = [];
4875
4875
  for (const dir of [outDir, tmpDir]) {
4876
- const absolute = path32__namespace.resolve(cwd, dir);
4877
- const relative20 = path32__namespace.relative(cwd, absolute);
4878
- if (!relative20 || relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || path32__namespace.isAbsolute(relative20)) {
4876
+ const absolute = path33__namespace.resolve(cwd, dir);
4877
+ const relative21 = path33__namespace.relative(cwd, absolute);
4878
+ if (!relative21 || relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || path33__namespace.isAbsolute(relative21)) {
4879
4879
  continue;
4880
4880
  }
4881
- patterns.push(`${relative20.replace(/\\/g, "/")}/**`);
4881
+ patterns.push(`${relative21.replace(/\\/g, "/")}/**`);
4882
4882
  }
4883
4883
  return patterns;
4884
4884
  }
@@ -4909,42 +4909,42 @@ function parseByteSize(value) {
4909
4909
  function describeBytes(value) {
4910
4910
  return typeof value === "number" ? String(value) : `"${value}"`;
4911
4911
  }
4912
- function boundedBytes(value, fallback, minimum, label) {
4912
+ function boundedBytes(value, fallback, minimum, label2) {
4913
4913
  if (value === void 0) return fallback;
4914
4914
  const parsed = parseByteSize(value);
4915
4915
  if (parsed === void 0) {
4916
4916
  throw new Error(
4917
- `${label} must be a byte count such as 120000, "120k" or "1.5mb" (received ${describeBytes(value)}).`
4917
+ `${label2} must be a byte count such as 120000, "120k" or "1.5mb" (received ${describeBytes(value)}).`
4918
4918
  );
4919
4919
  }
4920
4920
  if (parsed <= 0) {
4921
- throw new Error(`${label} must be a positive byte count (received ${describeBytes(value)}).`);
4921
+ throw new Error(`${label2} must be a positive byte count (received ${describeBytes(value)}).`);
4922
4922
  }
4923
4923
  if (parsed < minimum) {
4924
- throw new Error(`${label} must be at least ${minimum} bytes (received ${describeBytes(value)}).`);
4924
+ throw new Error(`${label2} must be at least ${minimum} bytes (received ${describeBytes(value)}).`);
4925
4925
  }
4926
4926
  return parsed;
4927
4927
  }
4928
- function boundedTokens(value, label) {
4928
+ function boundedTokens(value, label2) {
4929
4929
  const parsed = parseByteSize(value);
4930
4930
  if (parsed === void 0 || !Number.isInteger(parsed)) {
4931
4931
  throw new Error(
4932
- `${label} must be a whole token count such as 30000 or "30k" (received ${describeBytes(value)}).`
4932
+ `${label2} must be a whole token count such as 30000 or "30k" (received ${describeBytes(value)}).`
4933
4933
  );
4934
4934
  }
4935
4935
  if (parsed < MIN_MAX_PART_TOKENS) {
4936
4936
  throw new Error(
4937
- `${label} must be at least ${MIN_MAX_PART_TOKENS} tokens (${MIN_MAX_PART_BYTES} bytes is the smallest part budget); received ${describeBytes(value)}.`
4937
+ `${label2} must be at least ${MIN_MAX_PART_TOKENS} tokens (${MIN_MAX_PART_BYTES} bytes is the smallest part budget); received ${describeBytes(value)}.`
4938
4938
  );
4939
4939
  }
4940
4940
  return parsed;
4941
4941
  }
4942
- function optionalBytes(value, label) {
4942
+ function optionalBytes(value, label2) {
4943
4943
  if (value === void 0 || value === null) return null;
4944
4944
  const parsed = parseByteSize(value);
4945
4945
  if (parsed === void 0 || parsed <= 0) {
4946
4946
  throw new Error(
4947
- `${label} must be a positive byte count such as 1000000 or "1mb" (received ${describeBytes(value)}).`
4947
+ `${label2} must be a positive byte count such as 1000000 or "1mb" (received ${describeBytes(value)}).`
4948
4948
  );
4949
4949
  }
4950
4950
  return parsed;
@@ -5015,7 +5015,7 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
5015
5015
  );
5016
5016
  }
5017
5017
  const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
5018
- const resolved = path32__namespace.resolve(candidate);
5018
+ const resolved = path33__namespace.resolve(candidate);
5019
5019
  if (!fs27__namespace.existsSync(resolved)) {
5020
5020
  throw new Error(`Working directory does not exist: ${resolved}`);
5021
5021
  }
@@ -5492,8 +5492,8 @@ function resolveDiffChangedLines(cwd, ref, files) {
5492
5492
  continue;
5493
5493
  }
5494
5494
  const withoutPrefix = raw.startsWith("b/") ? raw.slice(2) : raw;
5495
- const path33 = withoutPrefix.split(" ")[0];
5496
- current = path33.length > 0 ? path33 : null;
5495
+ const path34 = withoutPrefix.split(" ")[0];
5496
+ current = path34.length > 0 ? path34 : null;
5497
5497
  if (current !== null && !ranges.has(current)) ranges.set(current, []);
5498
5498
  continue;
5499
5499
  }
@@ -5522,11 +5522,11 @@ function resolveChangedScope(cwd, request) {
5522
5522
  if (request.changedSince !== void 0) {
5523
5523
  assertUsableRef(request.changedSince);
5524
5524
  if (request.changedSince === "HEAD" && !hasHeadCommit(cwd)) {
5525
- for (const path33 of gitPaths(cwd, ["ls-files", "--cached", "-z", "--"])) {
5526
- paths.add(path33);
5525
+ for (const path34 of gitPaths(cwd, ["ls-files", "--cached", "-z", "--"])) {
5526
+ paths.add(path34);
5527
5527
  }
5528
- for (const path33 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
5529
- paths.add(path33);
5528
+ for (const path34 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
5529
+ paths.add(path34);
5530
5530
  }
5531
5531
  descriptions.push("changed since HEAD (unborn)");
5532
5532
  } else {
@@ -5539,7 +5539,7 @@ function resolveChangedScope(cwd, request) {
5539
5539
  );
5540
5540
  }
5541
5541
  if (base !== null) {
5542
- for (const path33 of gitPaths(cwd, [
5542
+ for (const path34 of gitPaths(cwd, [
5543
5543
  "-c",
5544
5544
  "core.quotepath=false",
5545
5545
  "-c",
@@ -5556,17 +5556,17 @@ function resolveChangedScope(cwd, request) {
5556
5556
  base,
5557
5557
  "--"
5558
5558
  ])) {
5559
- paths.add(path33);
5559
+ paths.add(path34);
5560
5560
  }
5561
5561
  }
5562
- for (const path33 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
5563
- paths.add(path33);
5562
+ for (const path34 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
5563
+ paths.add(path34);
5564
5564
  }
5565
5565
  descriptions.push(`changed since ${request.changedSince}`);
5566
5566
  }
5567
5567
  }
5568
5568
  if (request.staged === true) {
5569
- for (const path33 of gitPaths(cwd, [
5569
+ for (const path34 of gitPaths(cwd, [
5570
5570
  "-c",
5571
5571
  "core.quotepath=false",
5572
5572
  "diff",
@@ -5577,10 +5577,10 @@ function resolveChangedScope(cwd, request) {
5577
5577
  "--no-renames",
5578
5578
  "--"
5579
5579
  ])) {
5580
- paths.add(path33);
5581
- stagedPaths.add(path33);
5580
+ paths.add(path34);
5581
+ stagedPaths.add(path34);
5582
5582
  }
5583
- for (const path33 of gitPaths(cwd, [
5583
+ for (const path34 of gitPaths(cwd, [
5584
5584
  "-c",
5585
5585
  "core.quotepath=false",
5586
5586
  "diff",
@@ -5592,7 +5592,7 @@ function resolveChangedScope(cwd, request) {
5592
5592
  "--diff-filter=D",
5593
5593
  "--"
5594
5594
  ])) {
5595
- deletedPaths.add(path33);
5595
+ deletedPaths.add(path34);
5596
5596
  }
5597
5597
  descriptions.push("staged");
5598
5598
  }
@@ -5625,9 +5625,9 @@ var MAX_PACKAGE_FILES = 64;
5625
5625
  var MAX_CONFIG_BYTES = 4 * 1024 * 1024;
5626
5626
  var MAX_PACKAGE_BYTES = 1 * 1024 * 1024;
5627
5627
  function repositoryRelative(cwd, target) {
5628
- const absolute = path32__namespace.isAbsolute(target) ? target : path32__namespace.resolve(cwd, target);
5629
- const relative20 = path32__namespace.relative(cwd, absolute).replace(/\\/g, "/");
5630
- return relative20.length === 0 || relative20 !== ".." && !relative20.startsWith(".." + path32__namespace.sep) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20) ? relative20 : null;
5628
+ const absolute = path33__namespace.isAbsolute(target) ? target : path33__namespace.resolve(cwd, target);
5629
+ const relative21 = path33__namespace.relative(cwd, absolute).replace(/\\/g, "/");
5630
+ return relative21.length === 0 || relative21 !== ".." && !relative21.startsWith(".." + path33__namespace.sep) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21) ? relative21 : null;
5631
5631
  }
5632
5632
  function insideCwd(cwd, file) {
5633
5633
  return repositoryRelative(cwd, file);
@@ -5658,7 +5658,7 @@ function normalizeTarget(raw) {
5658
5658
  if (trimmed.length === 0) return null;
5659
5659
  const withoutPrefix = trimmed.replace(/^\.\//, "");
5660
5660
  if (withoutPrefix.startsWith("/") || /^[A-Za-z]:\//.test(withoutPrefix)) return null;
5661
- const normalized = path32__namespace.posix.normalize(withoutPrefix);
5661
+ const normalized = path33__namespace.posix.normalize(withoutPrefix);
5662
5662
  if (normalized === ".." || normalized.startsWith("../")) return null;
5663
5663
  return normalized;
5664
5664
  }
@@ -5683,8 +5683,8 @@ function parseImports(value) {
5683
5683
  return Object.entries(record).filter(([key]) => key.startsWith("#")).map(([pattern, target]) => ({ pattern, targets: targetList(target) }));
5684
5684
  }
5685
5685
  function readPackageJson(cwd, packageDir) {
5686
- const relative20 = packageDir.length === 0 ? "package.json" : packageDir + "/package.json";
5687
- const parsed = asRecord(readJson(cwd, relative20, MAX_PACKAGE_BYTES));
5686
+ const relative21 = packageDir.length === 0 ? "package.json" : packageDir + "/package.json";
5687
+ const parsed = asRecord(readJson(cwd, relative21, MAX_PACKAGE_BYTES));
5688
5688
  if (parsed === null) return null;
5689
5689
  const exportsMap = parseExports(parsed.exports);
5690
5690
  if (exportsMap.length === 0) {
@@ -5725,9 +5725,9 @@ function parsePnpmWorkspace(cwd) {
5725
5725
  return patterns;
5726
5726
  }
5727
5727
  function listChildDirectories(cwd, relativeDir) {
5728
- const absolute = path32__namespace.resolve(cwd, relativeDir);
5729
- const relative20 = repositoryRelative(cwd, absolute);
5730
- if (relative20 === null) return [];
5728
+ const absolute = path33__namespace.resolve(cwd, relativeDir);
5729
+ const relative21 = repositoryRelative(cwd, absolute);
5730
+ if (relative21 === null) return [];
5731
5731
  let entries;
5732
5732
  try {
5733
5733
  entries = fs27__namespace.readdirSync(absolute === cwd ? cwd : absolute, { withFileTypes: true });
@@ -5737,7 +5737,7 @@ function listChildDirectories(cwd, relativeDir) {
5737
5737
  const out = [];
5738
5738
  for (const entry of entries) {
5739
5739
  if (!entry.isDirectory()) continue;
5740
- const child = relative20.length === 0 ? entry.name : relative20 + "/" + entry.name;
5740
+ const child = relative21.length === 0 ? entry.name : relative21 + "/" + entry.name;
5741
5741
  if (child.split("/").includes("node_modules")) continue;
5742
5742
  out.push(child);
5743
5743
  }
@@ -5750,15 +5750,15 @@ function expandWorkspacePattern(cwd, rawPattern) {
5750
5750
  if (pattern.endsWith("/*")) {
5751
5751
  const base = pattern.slice(0, -2);
5752
5752
  return listChildDirectories(cwd, base).filter(
5753
- (dir) => fs27__namespace.existsSync(path32__namespace.join(cwd, dir, "package.json"))
5753
+ (dir) => fs27__namespace.existsSync(path33__namespace.join(cwd, dir, "package.json"))
5754
5754
  );
5755
5755
  }
5756
5756
  if (pattern.includes("*")) {
5757
- const base = path32__namespace.posix.dirname(pattern);
5757
+ const base = path33__namespace.posix.dirname(pattern);
5758
5758
  const direct = listChildDirectories(cwd, base === "." ? "" : base);
5759
- return direct.filter((dir) => fs27__namespace.existsSync(path32__namespace.join(cwd, dir, "package.json")));
5759
+ return direct.filter((dir) => fs27__namespace.existsSync(path33__namespace.join(cwd, dir, "package.json")));
5760
5760
  }
5761
- return fs27__namespace.existsSync(path32__namespace.join(cwd, pattern, "package.json")) ? [pattern] : [];
5761
+ return fs27__namespace.existsSync(path33__namespace.join(cwd, pattern, "package.json")) ? [pattern] : [];
5762
5762
  }
5763
5763
  function workspaceDirectories(cwd, files) {
5764
5764
  const root = asRecord(readJson(cwd, "package.json", MAX_PACKAGE_BYTES));
@@ -5782,7 +5782,7 @@ function workspaceDirectories(cwd, files) {
5782
5782
  for (const relativePath of files) {
5783
5783
  if (!relativePath.endsWith("package.json")) continue;
5784
5784
  if (relativePath.split("/").includes("node_modules")) continue;
5785
- const dir = path32__namespace.posix.dirname(relativePath);
5785
+ const dir = path33__namespace.posix.dirname(relativePath);
5786
5786
  directories.add(dir === "." ? "" : dir);
5787
5787
  }
5788
5788
  return [...directories].slice(0, MAX_PACKAGE_FILES);
@@ -5790,7 +5790,7 @@ function workspaceDirectories(cwd, files) {
5790
5790
  function parseWorkspaceConfig(cwd, relativePath) {
5791
5791
  const read = readConfinedText(cwd, relativePath, MAX_CONFIG_BYTES);
5792
5792
  if (!read.ok) return null;
5793
- const absolutePath = path32__namespace.resolve(cwd, relativePath);
5793
+ const absolutePath = path33__namespace.resolve(cwd, relativePath);
5794
5794
  const parsed = ts2__default.default.parseConfigFileTextToJson(absolutePath, read.text);
5795
5795
  if (parsed.error !== void 0) return null;
5796
5796
  const parseHost = {
@@ -5813,15 +5813,15 @@ function parseWorkspaceConfig(cwd, relativePath) {
5813
5813
  options = ts2__default.default.parseJsonConfigFileContent(
5814
5814
  parsed.config,
5815
5815
  parseHost,
5816
- path32__namespace.dirname(absolutePath),
5816
+ path33__namespace.dirname(absolutePath),
5817
5817
  void 0,
5818
5818
  absolutePath
5819
5819
  ).options;
5820
5820
  } catch {
5821
5821
  return null;
5822
5822
  }
5823
- const configDir = path32__namespace.posix.dirname(relativePath).replace(/^\.$/, "");
5824
- const baseUrl = typeof options.baseUrl === "string" ? repositoryRelative(cwd, path32__namespace.resolve(path32__namespace.dirname(absolutePath), options.baseUrl)) : null;
5823
+ const configDir = path33__namespace.posix.dirname(relativePath).replace(/^\.$/, "");
5824
+ const baseUrl = typeof options.baseUrl === "string" ? repositoryRelative(cwd, path33__namespace.resolve(path33__namespace.dirname(absolutePath), options.baseUrl)) : null;
5825
5825
  const paths = [];
5826
5826
  if (options.paths !== void 0) {
5827
5827
  for (const [pattern, targets] of Object.entries(options.paths)) {
@@ -5832,8 +5832,8 @@ function parseWorkspaceConfig(cwd, relativePath) {
5832
5832
  });
5833
5833
  }
5834
5834
  }
5835
- const rootDir = typeof options.rootDir === "string" ? repositoryRelative(cwd, path32__namespace.resolve(path32__namespace.dirname(absolutePath), options.rootDir)) : void 0;
5836
- const outDir = typeof options.outDir === "string" ? repositoryRelative(cwd, path32__namespace.resolve(path32__namespace.dirname(absolutePath), options.outDir)) : void 0;
5835
+ const rootDir = typeof options.rootDir === "string" ? repositoryRelative(cwd, path33__namespace.resolve(path33__namespace.dirname(absolutePath), options.rootDir)) : void 0;
5836
+ const outDir = typeof options.outDir === "string" ? repositoryRelative(cwd, path33__namespace.resolve(path33__namespace.dirname(absolutePath), options.outDir)) : void 0;
5837
5837
  if (baseUrl === null && paths.length === 0 && rootDir === void 0 && outDir === void 0) {
5838
5838
  return null;
5839
5839
  }
@@ -5851,29 +5851,29 @@ function configCandidates(cwd, files, packageDirs) {
5851
5851
  const candidates = /* @__PURE__ */ new Set(["tsconfig.json", "jsconfig.json"]);
5852
5852
  for (const relativePath of files) {
5853
5853
  if (relativePath.split("/").includes("node_modules")) continue;
5854
- const base = path32__namespace.posix.basename(relativePath);
5854
+ const base = path33__namespace.posix.basename(relativePath);
5855
5855
  if (base === "tsconfig.json" || base === "jsconfig.json") candidates.add(relativePath);
5856
5856
  }
5857
5857
  for (const dir of packageDirs) {
5858
5858
  for (const base of ["tsconfig.json", "jsconfig.json"]) {
5859
5859
  const candidate = dir.length === 0 ? base : dir + "/" + base;
5860
- if (fs27__namespace.existsSync(path32__namespace.join(cwd, candidate))) candidates.add(candidate);
5860
+ if (fs27__namespace.existsSync(path33__namespace.join(cwd, candidate))) candidates.add(candidate);
5861
5861
  }
5862
5862
  }
5863
5863
  for (const relativePath of files) {
5864
5864
  if (relativePath.split("/").includes("node_modules")) continue;
5865
- let dir = path32__namespace.posix.dirname(relativePath);
5865
+ let dir = path33__namespace.posix.dirname(relativePath);
5866
5866
  while (dir !== "." && dir.length > 0) {
5867
5867
  for (const base of ["tsconfig.json", "jsconfig.json"]) {
5868
5868
  const candidate = dir + "/" + base;
5869
- if (fs27__namespace.existsSync(path32__namespace.join(cwd, candidate))) candidates.add(candidate);
5869
+ if (fs27__namespace.existsSync(path33__namespace.join(cwd, candidate))) candidates.add(candidate);
5870
5870
  }
5871
- dir = path32__namespace.posix.dirname(dir);
5871
+ dir = path33__namespace.posix.dirname(dir);
5872
5872
  }
5873
5873
  }
5874
5874
  return [...candidates].filter((relativePath) => {
5875
- if (!fs27__namespace.existsSync(path32__namespace.join(cwd, relativePath))) return false;
5876
- const stat = fs27__namespace.lstatSync(path32__namespace.join(cwd, relativePath));
5875
+ if (!fs27__namespace.existsSync(path33__namespace.join(cwd, relativePath))) return false;
5876
+ const stat = fs27__namespace.lstatSync(path33__namespace.join(cwd, relativePath));
5877
5877
  return stat.isFile() && !stat.isSymbolicLink();
5878
5878
  }).slice(0, MAX_CONFIG_FILES * 2);
5879
5879
  }
@@ -5883,7 +5883,7 @@ function collectWorkspaceConfigs(cwd, files, packageDirs) {
5883
5883
  const entry = parseWorkspaceConfig(cwd, candidate);
5884
5884
  if (entry === null) continue;
5885
5885
  const existing = byDirectory.get(entry.configDir);
5886
- if (existing === void 0 || path32__namespace.posix.basename(candidate) === "tsconfig.json") {
5886
+ if (existing === void 0 || path33__namespace.posix.basename(candidate) === "tsconfig.json") {
5887
5887
  byDirectory.set(entry.configDir, entry);
5888
5888
  }
5889
5889
  if (byDirectory.size >= MAX_CONFIG_FILES) break;
@@ -5957,13 +5957,13 @@ function buildImportResolver(files, options = {}) {
5957
5957
  const normalized = relativePath.replace(/\\/g, "/");
5958
5958
  rememberFirst(byPath, normalized, normalized);
5959
5959
  if (CASE_INSENSITIVE_FILESYSTEM) rememberFirst(byPathFolded, normalized.toLowerCase(), normalized);
5960
- const extension = path32__namespace.posix.extname(normalized);
5960
+ const extension = path33__namespace.posix.extname(normalized);
5961
5961
  if (!SOURCE_EXTENSIONS.has(extension)) return;
5962
5962
  const stem = normalized.slice(0, -extension.length);
5963
5963
  rememberFirst(byStem, stem, normalized);
5964
5964
  if (CASE_INSENSITIVE_FILESYSTEM) rememberFirst(byStemFolded, stem.toLowerCase(), normalized);
5965
- if (path32__namespace.posix.basename(stem) === "index") {
5966
- const directory = path32__namespace.posix.dirname(stem);
5965
+ if (path33__namespace.posix.basename(stem) === "index") {
5966
+ const directory = path33__namespace.posix.dirname(stem);
5967
5967
  rememberFirst(byStem, directory, normalized);
5968
5968
  if (CASE_INSENSITIVE_FILESYSTEM) rememberFirst(byStemFolded, directory.toLowerCase(), normalized);
5969
5969
  }
@@ -6032,7 +6032,7 @@ function resolvePackageImport(fromFile, specifier, resolver, lookupPath) {
6032
6032
  if (captured === null) continue;
6033
6033
  for (const target of rule.targets) {
6034
6034
  const substituted = target.split("*").join(captured);
6035
- const joined = path32__namespace.posix.normalize(path32__namespace.posix.join(entry.packageDir, substituted));
6035
+ const joined = path33__namespace.posix.normalize(path33__namespace.posix.join(entry.packageDir, substituted));
6036
6036
  const hit = lookupPath(joined);
6037
6037
  if (hit !== null) return hit;
6038
6038
  }
@@ -6042,25 +6042,25 @@ function resolvePackageImport(fromFile, specifier, resolver, lookupPath) {
6042
6042
  }
6043
6043
  function mapBuiltExport(packageEntry, target, lookupPath) {
6044
6044
  const normalized = target.replace(/^\.\//, "");
6045
- const direct = lookupPath(path32__namespace.posix.normalize(path32__namespace.posix.join(packageEntry.packageDir, normalized)));
6045
+ const direct = lookupPath(path33__namespace.posix.normalize(path33__namespace.posix.join(packageEntry.packageDir, normalized)));
6046
6046
  if (direct !== null) return direct;
6047
6047
  if (packageEntry.outDir !== void 0 && packageEntry.rootDir !== void 0) {
6048
- const repoTarget = path32__namespace.posix.normalize(
6049
- path32__namespace.posix.join(packageEntry.packageDir, normalized)
6048
+ const repoTarget = path33__namespace.posix.normalize(
6049
+ path33__namespace.posix.join(packageEntry.packageDir, normalized)
6050
6050
  );
6051
6051
  const outPrefix = packageEntry.outDir.length === 0 ? "" : packageEntry.outDir + "/";
6052
6052
  if (outPrefix.length > 0 && repoTarget.startsWith(outPrefix)) {
6053
- const mapped = path32__namespace.posix.join(packageEntry.rootDir, repoTarget.slice(outPrefix.length));
6053
+ const mapped = path33__namespace.posix.join(packageEntry.rootDir, repoTarget.slice(outPrefix.length));
6054
6054
  const withoutDeclaration = mapped.replace(/\.d\.[cm]?ts$/, "");
6055
- const hit = lookupPath(path32__namespace.posix.normalize(withoutDeclaration));
6055
+ const hit = lookupPath(path33__namespace.posix.normalize(withoutDeclaration));
6056
6056
  if (hit !== null) return hit;
6057
6057
  }
6058
6058
  }
6059
6059
  for (const prefix of ["dist/", "lib/", "build/"]) {
6060
6060
  if (normalized.startsWith(prefix)) {
6061
- const mapped = path32__namespace.posix.join(packageEntry.packageDir, "src", normalized.slice(prefix.length));
6061
+ const mapped = path33__namespace.posix.join(packageEntry.packageDir, "src", normalized.slice(prefix.length));
6062
6062
  const withoutDeclaration = mapped.replace(/\.d\.[cm]?ts$/, "").replace(/\.(?:[cm]?[jt]sx?)$/, "");
6063
- const hit = lookupPath(path32__namespace.posix.normalize(withoutDeclaration));
6063
+ const hit = lookupPath(path33__namespace.posix.normalize(withoutDeclaration));
6064
6064
  if (hit !== null) return hit;
6065
6065
  }
6066
6066
  }
@@ -6084,7 +6084,7 @@ function resolveWorkspacePackage(specifier, resolver, lookupPath) {
6084
6084
  }
6085
6085
  if (subpath === ".") {
6086
6086
  for (const fallback of ["src/index.ts", "src/index.tsx", "index.ts", "index.tsx"]) {
6087
- const hit = lookupPath(path32__namespace.posix.join(entry.packageDir, fallback));
6087
+ const hit = lookupPath(path33__namespace.posix.join(entry.packageDir, fallback));
6088
6088
  if (hit !== null) return hit;
6089
6089
  }
6090
6090
  } else {
@@ -6095,7 +6095,7 @@ function resolveWorkspacePackage(specifier, resolver, lookupPath) {
6095
6095
  "src/" + rest + "/index.ts",
6096
6096
  "src/" + rest + "/index.tsx"
6097
6097
  ]) {
6098
- const hit = lookupPath(path32__namespace.posix.join(entry.packageDir, fallback));
6098
+ const hit = lookupPath(path33__namespace.posix.join(entry.packageDir, fallback));
6099
6099
  if (hit !== null) return hit;
6100
6100
  }
6101
6101
  }
@@ -6103,34 +6103,34 @@ function resolveWorkspacePackage(specifier, resolver, lookupPath) {
6103
6103
  return null;
6104
6104
  }
6105
6105
  function resolveSpecifierDetailed(fromFile, specifier, resolver) {
6106
- const extension = path32__namespace.posix.extname(fromFile).toLowerCase();
6106
+ const extension = path33__namespace.posix.extname(fromFile).toLowerCase();
6107
6107
  const { exact, firstOf, lookupPath } = lookupFunctions(resolver);
6108
6108
  if (PYTHON_EXTENSIONS.has(extension) && specifier.startsWith(".")) {
6109
6109
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
6110
6110
  const rest = specifier.slice(dots).replace(/\./g, "/");
6111
- let base = path32__namespace.posix.dirname(fromFile);
6112
- for (let up = 1; up < dots; up += 1) base = path32__namespace.posix.dirname(base);
6113
- const joined = rest ? path32__namespace.posix.normalize(path32__namespace.posix.join(base, rest)) : base;
6111
+ let base = path33__namespace.posix.dirname(fromFile);
6112
+ for (let up = 1; up < dots; up += 1) base = path33__namespace.posix.dirname(base);
6113
+ const joined = rest ? path33__namespace.posix.normalize(path33__namespace.posix.join(base, rest)) : base;
6114
6114
  const target = firstOf([joined, ...PYTHON_SUFFIXES.map((suffix) => joined + suffix)]);
6115
6115
  return target === null ? null : { target, provenance: "relative-import" };
6116
6116
  }
6117
6117
  if (RUBY_EXTENSIONS.has(extension) && specifier.startsWith("./")) {
6118
- const joined = path32__namespace.posix.normalize(path32__namespace.posix.join(path32__namespace.posix.dirname(fromFile), specifier));
6118
+ const joined = path33__namespace.posix.normalize(path33__namespace.posix.join(path33__namespace.posix.dirname(fromFile), specifier));
6119
6119
  const target = firstOf([joined + ".rb", joined]);
6120
6120
  return target === null ? null : { target, provenance: "relative-import" };
6121
6121
  }
6122
6122
  if (C_EXTENSIONS.has(extension) && specifier.startsWith("./")) {
6123
- const joined = path32__namespace.posix.normalize(path32__namespace.posix.join(path32__namespace.posix.dirname(fromFile), specifier));
6123
+ const joined = path33__namespace.posix.normalize(path33__namespace.posix.join(path33__namespace.posix.dirname(fromFile), specifier));
6124
6124
  const target = exact(joined);
6125
6125
  return target === null ? null : { target, provenance: "relative-import" };
6126
6126
  }
6127
6127
  if (extension === ".dart" && !specifier.includes(":")) {
6128
- const joined = path32__namespace.posix.normalize(path32__namespace.posix.join(path32__namespace.posix.dirname(fromFile), specifier));
6128
+ const joined = path33__namespace.posix.normalize(path33__namespace.posix.join(path33__namespace.posix.dirname(fromFile), specifier));
6129
6129
  const target = firstOf([joined, joined + ".dart"]);
6130
6130
  return target === null ? null : { target, provenance: "relative-import" };
6131
6131
  }
6132
6132
  if (RELATIVE_SPECIFIER.test(specifier)) {
6133
- const joined = path32__namespace.posix.normalize(path32__namespace.posix.join(path32__namespace.posix.dirname(fromFile), specifier));
6133
+ const joined = path33__namespace.posix.normalize(path33__namespace.posix.join(path33__namespace.posix.dirname(fromFile), specifier));
6134
6134
  const target = lookupPath(joined);
6135
6135
  return target === null ? null : { target, provenance: "relative-import" };
6136
6136
  }
@@ -6148,7 +6148,7 @@ function resolveSpecifierDetailed(fromFile, specifier, resolver) {
6148
6148
  const base = config.baseUrl ?? config.pathsBasePath ?? config.configDir;
6149
6149
  for (const target of rule.targets) {
6150
6150
  const substituted = target.split("*").join(captured);
6151
- const joined = path32__namespace.posix.normalize(path32__namespace.posix.join(base, substituted));
6151
+ const joined = path33__namespace.posix.normalize(path33__namespace.posix.join(base, substituted));
6152
6152
  const hit = lookupPath(joined);
6153
6153
  if (hit !== null) return { target: hit, provenance: "tsconfig-alias" };
6154
6154
  }
@@ -6156,7 +6156,7 @@ function resolveSpecifierDetailed(fromFile, specifier, resolver) {
6156
6156
  }
6157
6157
  for (const config of configs) {
6158
6158
  if (config.baseUrl === null) continue;
6159
- const hit = lookupPath(path32__namespace.posix.normalize(path32__namespace.posix.join(config.baseUrl, specifier)));
6159
+ const hit = lookupPath(path33__namespace.posix.normalize(path33__namespace.posix.join(config.baseUrl, specifier)));
6160
6160
  if (hit !== null) return { target: hit, provenance: "tsconfig-alias" };
6161
6161
  }
6162
6162
  const workspaceHit = resolveWorkspacePackage(specifier, resolver, lookupPath);
@@ -6947,9 +6947,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
6947
6947
  var jvmProfile = {
6948
6948
  id: "jvm",
6949
6949
  extensions: [".java", ".kt", ".kts", ".scala"],
6950
- summarize(path33, content) {
6950
+ summarize(path34, content) {
6951
6951
  const summary = emptySummary();
6952
- const lower = path33.toLowerCase();
6952
+ const lower = path34.toLowerCase();
6953
6953
  const isJava = lower.endsWith(".java");
6954
6954
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
6955
6955
  eachLine(content, (line) => {
@@ -7172,9 +7172,9 @@ var rubyProfile = {
7172
7172
  eachLine(content, (line) => {
7173
7173
  const trimmed = line.trim();
7174
7174
  if (!trimmed || trimmed.startsWith("#")) return;
7175
- const relative20 = REQUIRE_RELATIVE.exec(trimmed);
7176
- if (relative20) {
7177
- summary.imports.push(`./${relative20[1]}`);
7175
+ const relative21 = REQUIRE_RELATIVE.exec(trimmed);
7176
+ if (relative21) {
7177
+ summary.imports.push(`./${relative21[1]}`);
7178
7178
  return;
7179
7179
  }
7180
7180
  const required = REQUIRE.exec(trimmed);
@@ -7270,17 +7270,17 @@ var rustProfile = {
7270
7270
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script(?:\s[^>]*)?>/gi;
7271
7271
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
7272
7272
  var ASTRO_FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?=\r?\n|$)/;
7273
- function componentName(path33) {
7274
- const base = path33.split("/").pop() ?? path33;
7273
+ function componentName(path34) {
7274
+ const base = path34.split("/").pop() ?? path34;
7275
7275
  return base.replace(/\.[^.]+$/, "");
7276
7276
  }
7277
7277
  var sfcProfile = {
7278
7278
  id: "sfc",
7279
7279
  extensions: [".vue", ".svelte", ".astro"],
7280
- summarize(path33, content) {
7280
+ summarize(path34, content) {
7281
7281
  let script = "";
7282
- let usesJsx = path33.toLowerCase().endsWith(".astro");
7283
- if (path33.toLowerCase().endsWith(".astro")) {
7282
+ let usesJsx = path34.toLowerCase().endsWith(".astro");
7283
+ if (path34.toLowerCase().endsWith(".astro")) {
7284
7284
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
7285
7285
  if (frontmatter) script += `${frontmatter[1]}
7286
7286
  `;
@@ -7290,7 +7290,7 @@ var sfcProfile = {
7290
7290
  script += `${match[2]}
7291
7291
  `;
7292
7292
  }
7293
- const name = componentName(path33);
7293
+ const name = componentName(path34);
7294
7294
  if (!script.trim()) {
7295
7295
  const summary2 = emptySummary();
7296
7296
  if (name) {
@@ -7481,15 +7481,15 @@ for (const profile of LANGUAGE_PROFILES) {
7481
7481
  BY_EXTENSION.set(extension.toLowerCase(), profile);
7482
7482
  }
7483
7483
  }
7484
- function profileForPath(path33) {
7485
- const lower = path33.toLowerCase();
7484
+ function profileForPath(path34) {
7485
+ const lower = path34.toLowerCase();
7486
7486
  const dot = lower.lastIndexOf(".");
7487
7487
  if (dot === -1) return null;
7488
7488
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
7489
7489
  }
7490
- function summarizeWithProfile(path33, content) {
7491
- const profile = profileForPath(path33);
7492
- return profile ? profile.summarize(path33, content) : null;
7490
+ function summarizeWithProfile(path34, content) {
7491
+ const profile = profileForPath(path34);
7492
+ return profile ? profile.summarize(path34, content) : null;
7493
7493
  }
7494
7494
  var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
7495
7495
  ".png",
@@ -7534,7 +7534,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
7534
7534
  ".so"
7535
7535
  ]);
7536
7536
  function isBinaryExtension(filePath) {
7537
- const ext = path32__namespace.extname(filePath).toLowerCase();
7537
+ const ext = path33__namespace.extname(filePath).toLowerCase();
7538
7538
  return BINARY_EXTENSIONS.has(ext);
7539
7539
  }
7540
7540
  function countControlBytes(buffer) {
@@ -7764,16 +7764,16 @@ function maskedPath(value, secretRules) {
7764
7764
  }
7765
7765
  function confineToDirectory(directory, filename) {
7766
7766
  if (filename.includes("\0")) return null;
7767
- if (path32__namespace.isAbsolute(filename)) return null;
7768
- const base = path32__namespace.resolve(directory);
7769
- const resolved = path32__namespace.resolve(base, filename);
7767
+ if (path33__namespace.isAbsolute(filename)) return null;
7768
+ const base = path33__namespace.resolve(directory);
7769
+ const resolved = path33__namespace.resolve(base, filename);
7770
7770
  const caseInsensitive = process.platform === "win32" || process.platform === "darwin";
7771
- const prefix = caseInsensitive ? `${base}${path32__namespace.sep}`.toLowerCase() : `${base}${path32__namespace.sep}`;
7771
+ const prefix = caseInsensitive ? `${base}${path33__namespace.sep}`.toLowerCase() : `${base}${path33__namespace.sep}`;
7772
7772
  const candidate = caseInsensitive ? resolved.toLowerCase() : resolved;
7773
7773
  return candidate.startsWith(prefix) ? resolved : null;
7774
7774
  }
7775
7775
  function findStagingDirectory(config) {
7776
- const tmpDir = path32__namespace.resolve(config.cwd, config.tmpDir);
7776
+ const tmpDir = path33__namespace.resolve(config.cwd, config.tmpDir);
7777
7777
  let entries;
7778
7778
  try {
7779
7779
  entries = fs27__namespace.readdirSync(tmpDir);
@@ -7782,11 +7782,11 @@ function findStagingDirectory(config) {
7782
7782
  }
7783
7783
  const runs = entries.filter((name) => name.startsWith("run-")).sort();
7784
7784
  const newest = runs[runs.length - 1];
7785
- return newest ? path32__namespace.join(tmpDir, newest) : null;
7785
+ return newest ? path33__namespace.join(tmpDir, newest) : null;
7786
7786
  }
7787
7787
  function describeMissingManifest(config, manifestPath) {
7788
- const outDir = path32__namespace.resolve(config.cwd, config.outDir);
7789
- const markerPath = path32__namespace.join(outDir, ".codebase-snapshot");
7788
+ const outDir = path33__namespace.resolve(config.cwd, config.outDir);
7789
+ const markerPath = path33__namespace.join(outDir, ".codebase-snapshot");
7790
7790
  let marker2 = null;
7791
7791
  try {
7792
7792
  if (fs27__namespace.existsSync(markerPath)) {
@@ -7825,7 +7825,7 @@ function sha256Hex(buffer) {
7825
7825
  return crypto__namespace.createHash("sha256").update(buffer).digest("hex");
7826
7826
  }
7827
7827
  function wouldNowBeIncluded(cwd, relativePath) {
7828
- const absolutePath = path32__namespace.join(cwd, relativePath);
7828
+ const absolutePath = path33__namespace.join(cwd, relativePath);
7829
7829
  try {
7830
7830
  const stats = fs27__namespace.statSync(absolutePath);
7831
7831
  if (!stats.isFile()) return false;
@@ -7843,7 +7843,7 @@ var TRUNCATION_REASONS = /* @__PURE__ */ new Set([
7843
7843
  ]);
7844
7844
  function isConfinedRelative(value) {
7845
7845
  if (value.length === 0 || value.includes("\0") || value.includes("\\")) return false;
7846
- if (path32__namespace.isAbsolute(value)) return false;
7846
+ if (path33__namespace.isAbsolute(value)) return false;
7847
7847
  return !value.split("/").includes("..");
7848
7848
  }
7849
7849
  function describeManifestShapeProblem(value) {
@@ -8052,7 +8052,7 @@ function describeManifestShapeProblem(value) {
8052
8052
  if (typeof filename !== "string" || filename.trim() === "") {
8053
8053
  return 'a "parts" entry has no "filename"';
8054
8054
  }
8055
- if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path32__namespace.isAbsolute(filename)) {
8055
+ if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path33__namespace.isAbsolute(filename)) {
8056
8056
  return 'a "parts" entry "filename" must be a bare filename inside parts/';
8057
8057
  }
8058
8058
  if (currentSchema) {
@@ -8105,7 +8105,7 @@ function describeManifestShapeProblem(value) {
8105
8105
  function validateSnapshot(configInput) {
8106
8106
  assertUsableConfigInput(configInput);
8107
8107
  const config = isResolvedConfig(configInput) ? normalizeResolvedConfig(configInput) : resolveConfig(configInput);
8108
- const manifestPath = path32__namespace.resolve(config.cwd, config.outDir, "manifest.json");
8108
+ const manifestPath = path33__namespace.resolve(config.cwd, config.outDir, "manifest.json");
8109
8109
  if (!fs27__namespace.existsSync(manifestPath)) {
8110
8110
  return {
8111
8111
  valid: false,
@@ -8116,7 +8116,7 @@ function validateSnapshot(configInput) {
8116
8116
  };
8117
8117
  }
8118
8118
  let manifest;
8119
- const read = readConfinedText(path32__namespace.dirname(manifestPath), path32__namespace.basename(manifestPath), 64 * 1024 * 1024);
8119
+ const read = readConfinedText(path33__namespace.dirname(manifestPath), path33__namespace.basename(manifestPath), 64 * 1024 * 1024);
8120
8120
  if (!read.ok) {
8121
8121
  return {
8122
8122
  valid: false,
@@ -8151,7 +8151,7 @@ function validateSnapshot(configInput) {
8151
8151
  }
8152
8152
  const drift = emptyDrift();
8153
8153
  const warnings = [];
8154
- const snapshotDir = path32__namespace.resolve(config.cwd, config.outDir);
8154
+ const snapshotDir = path33__namespace.resolve(config.cwd, config.outDir);
8155
8155
  const unreadableSkips = manifest.skipped.filter(
8156
8156
  (entry) => entry.reason === "missing" || entry.reason === "read-error"
8157
8157
  );
@@ -8177,25 +8177,25 @@ function validateSnapshot(configInput) {
8177
8177
  const incompleteness = /* @__PURE__ */ new Map();
8178
8178
  for (const record of incompleteRecords) {
8179
8179
  incompleteness.set(record.relativePath, record);
8180
- const label = maskedPath(record.relativePath, config.secretRules);
8180
+ const label2 = maskedPath(record.relativePath, config.secretRules);
8181
8181
  const file = manifestFilesByPath.get(record.relativePath);
8182
8182
  if (file === void 0) {
8183
8183
  drift.partIssues.push({
8184
8184
  part: "(manifest)",
8185
- issue: `${label} is in incomplete[] but not in files[]`
8185
+ issue: `${label2} is in incomplete[] but not in files[]`
8186
8186
  });
8187
8187
  continue;
8188
8188
  }
8189
8189
  if (file.part !== record.part) {
8190
8190
  drift.partIssues.push({
8191
8191
  part: "(manifest)",
8192
- issue: `${label} is recorded in part ${String(record.part)} in incomplete[] and part ${String(file.part)} in files[]`
8192
+ issue: `${label2} is recorded in part ${String(record.part)} in incomplete[] and part ${String(file.part)} in files[]`
8193
8193
  });
8194
8194
  }
8195
8195
  if (file.truncationReason !== record.reason) {
8196
8196
  drift.partIssues.push({
8197
8197
  part: "(manifest)",
8198
- issue: `${label} records truncationReason ${String(file.truncationReason)} in files[] and reason ${String(record.reason)} in incomplete[]`
8198
+ issue: `${label2} records truncationReason ${String(file.truncationReason)} in files[] and reason ${String(record.reason)} in incomplete[]`
8199
8199
  });
8200
8200
  }
8201
8201
  const recordedRanges = file.omittedRanges ?? [];
@@ -8205,7 +8205,7 @@ function validateSnapshot(configInput) {
8205
8205
  if (!rangesAgree || file.includedLines !== record.includedLines || file.lines !== record.lines) {
8206
8206
  drift.partIssues.push({
8207
8207
  part: "(manifest)",
8208
- issue: `${label} records different omission numbers in files[] and incomplete[]`
8208
+ issue: `${label2} records different omission numbers in files[] and incomplete[]`
8209
8209
  });
8210
8210
  }
8211
8211
  }
@@ -8276,7 +8276,7 @@ function validateSnapshot(configInput) {
8276
8276
  );
8277
8277
  return importsChangedFile(
8278
8278
  diskFile,
8279
- importsOfFile(diskFile, path32__namespace.join(config.cwd, diskFile)),
8279
+ importsOfFile(diskFile, path33__namespace.join(config.cwd, diskFile)),
8280
8280
  unchangedScope,
8281
8281
  dependentResolver
8282
8282
  );
@@ -8298,9 +8298,9 @@ function validateSnapshot(configInput) {
8298
8298
  // own output directory as a set of files missing from the snapshot, so a correct
8299
8299
  // snapshot was reported as drifting.
8300
8300
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
8301
- (directory) => path32__namespace.relative(config.cwd, path32__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8301
+ (directory) => path33__namespace.relative(config.cwd, path33__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8302
8302
  ).filter(
8303
- (relative20) => relative20.length > 0 && relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20)
8303
+ (relative21) => relative21.length > 0 && relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21)
8304
8304
  )
8305
8305
  });
8306
8306
  const discovered = new Set(collection.files);
@@ -8320,7 +8320,7 @@ function validateSnapshot(configInput) {
8320
8320
  const baseHash = deltaBaseHashes.get(diskFile);
8321
8321
  if (baseHash !== void 0) {
8322
8322
  try {
8323
- const diskHash2 = sha256Hex(fs27__namespace.readFileSync(path32__namespace.join(config.cwd, diskFile)));
8323
+ const diskHash2 = sha256Hex(fs27__namespace.readFileSync(path33__namespace.join(config.cwd, diskFile)));
8324
8324
  if (diskHash2 !== baseHash) drift.missingInSnapshot.push(diskFile);
8325
8325
  } catch {
8326
8326
  drift.unreadable.push(diskFile);
@@ -8342,7 +8342,7 @@ function validateSnapshot(configInput) {
8342
8342
  let diskHash;
8343
8343
  try {
8344
8344
  const stagedBlob = recordedStaged && stagedScope?.has(diskFile) === true ? readStagedBlob(config.cwd, diskFile) : null;
8345
- diskHash = sha256Hex(stagedBlob ?? fs27__namespace.readFileSync(path32__namespace.join(config.cwd, diskFile)));
8345
+ diskHash = sha256Hex(stagedBlob ?? fs27__namespace.readFileSync(path33__namespace.join(config.cwd, diskFile)));
8346
8346
  } catch (err) {
8347
8347
  if (err.code === "ENOENT") {
8348
8348
  drift.missingOnDisk.push(diskFile);
@@ -8357,9 +8357,9 @@ function validateSnapshot(configInput) {
8357
8357
  }
8358
8358
  if (delta !== void 0 && Array.isArray(delta.unchanged)) {
8359
8359
  for (const relativePath of delta.unchanged) {
8360
- const full = path32__namespace.resolve(config.cwd, relativePath);
8361
- const rel = path32__namespace.relative(config.cwd, full);
8362
- if (rel === "" || rel === ".." || rel.startsWith(".." + path32__namespace.sep) || path32__namespace.isAbsolute(rel)) {
8360
+ const full = path33__namespace.resolve(config.cwd, relativePath);
8361
+ const rel = path33__namespace.relative(config.cwd, full);
8362
+ if (rel === "" || rel === ".." || rel.startsWith(".." + path33__namespace.sep) || path33__namespace.isAbsolute(rel)) {
8363
8363
  continue;
8364
8364
  }
8365
8365
  let stats = null;
@@ -8440,7 +8440,7 @@ function validateSnapshot(configInput) {
8440
8440
  ...Object.values(config.budgets.byLayer)
8441
8441
  );
8442
8442
  const partNames = /* @__PURE__ */ new Set();
8443
- const partsDir = path32__namespace.join(snapshotDir, "parts");
8443
+ const partsDir = path33__namespace.join(snapshotDir, "parts");
8444
8444
  for (const part of manifest.parts) {
8445
8445
  if (!part || typeof part.filename !== "string") continue;
8446
8446
  partNames.add(part.filename);
@@ -8453,7 +8453,7 @@ function validateSnapshot(configInput) {
8453
8453
  });
8454
8454
  continue;
8455
8455
  }
8456
- const partRead = readConfinedBytes(snapshotDir, path32__namespace.posix.join("parts", part.filename));
8456
+ const partRead = readConfinedBytes(snapshotDir, path33__namespace.posix.join("parts", part.filename));
8457
8457
  if (!partRead.ok) {
8458
8458
  drift.partIssues.push({
8459
8459
  part: part.filename,
@@ -8708,9 +8708,9 @@ function validateSnapshot(configInput) {
8708
8708
  drift.configMismatches.push("manifest does not record the effective configuration");
8709
8709
  }
8710
8710
  const totalsMismatches = drift.totalsMismatches;
8711
- const expectEqual = (label, recordedValue, actual) => {
8711
+ const expectEqual = (label2, recordedValue, actual) => {
8712
8712
  if (recordedValue !== actual) {
8713
- totalsMismatches.push(`${label}: manifest ${String(recordedValue)} vs actual ${actual}`);
8713
+ totalsMismatches.push(`${label2}: manifest ${String(recordedValue)} vs actual ${actual}`);
8714
8714
  }
8715
8715
  };
8716
8716
  const counts = manifest.counts ?? {};
@@ -8851,12 +8851,12 @@ function validateSnapshot(configInput) {
8851
8851
  for (const match of buffer.toString("utf8").matchAll(/\]\(([^)\s]+)\)/g)) {
8852
8852
  const target = match[1].split("#")[0];
8853
8853
  if (target.length === 0 || /^[a-z][a-z0-9+.-]*:/i.test(target)) continue;
8854
- const resolved = path32__namespace.resolve(snapshotDir, "reports", target);
8855
- const relative20 = path32__namespace.relative(snapshotDir, resolved);
8856
- const linkTarget = relative20.split(path32__namespace.sep).join("/");
8857
- const escapes = relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || relative20.startsWith("../") || path32__namespace.isAbsolute(relative20);
8858
- const partsRelative = path32__namespace.relative(path32__namespace.join(snapshotDir, "parts"), resolved);
8859
- const pointsIntoParts = partsRelative === "" || partsRelative !== ".." && !partsRelative.startsWith(`..${path32__namespace.sep}`) && !partsRelative.startsWith("../") && !path32__namespace.isAbsolute(partsRelative);
8854
+ const resolved = path33__namespace.resolve(snapshotDir, "reports", target);
8855
+ const relative21 = path33__namespace.relative(snapshotDir, resolved);
8856
+ const linkTarget = relative21.split(path33__namespace.sep).join("/");
8857
+ const escapes = relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || relative21.startsWith("../") || path33__namespace.isAbsolute(relative21);
8858
+ const partsRelative = path33__namespace.relative(path33__namespace.join(snapshotDir, "parts"), resolved);
8859
+ const pointsIntoParts = partsRelative === "" || partsRelative !== ".." && !partsRelative.startsWith(`..${path33__namespace.sep}`) && !partsRelative.startsWith("../") && !path33__namespace.isAbsolute(partsRelative);
8860
8860
  const expectedToBeAbsent = !config.artifacts.parts && pointsIntoParts;
8861
8861
  if (escapes || !expectedToBeAbsent && !confinedFileExists(snapshotDir, linkTarget)) {
8862
8862
  drift.partIssues.push({
@@ -8915,9 +8915,9 @@ function validateSnapshot(configInput) {
8915
8915
  `${drift.configMismatches.length} configuration mismatch(es) between the manifest and this run.`
8916
8916
  );
8917
8917
  }
8918
- const signaturePath = path32__namespace.join(path32__namespace.dirname(manifestPath), "signature.json");
8918
+ const signaturePath = path33__namespace.join(path33__namespace.dirname(manifestPath), "signature.json");
8919
8919
  if (fs27__namespace.existsSync(signaturePath)) {
8920
- const outcome = verifySnapshotSignature(path32__namespace.dirname(manifestPath));
8920
+ const outcome = verifySnapshotSignature(path33__namespace.dirname(manifestPath));
8921
8921
  if (!outcome.ok) errors.push("signature: " + outcome.reason + ".");
8922
8922
  }
8923
8923
  if (manifest.delta !== void 0) {
@@ -8973,8 +8973,8 @@ function describeLayerChanges(before, after, secretRules) {
8973
8973
  const was = before[name] ?? 0;
8974
8974
  const now = after[name] ?? 0;
8975
8975
  if (was === now) continue;
8976
- const label = findSecretInPath(name, secretRules)?.masked ?? name;
8977
- changes.push(`layer "${label}": ${was} file(s) \u2192 ${now} file(s)`);
8976
+ const label2 = findSecretInPath(name, secretRules)?.masked ?? name;
8977
+ changes.push(`layer "${label2}": ${was} file(s) \u2192 ${now} file(s)`);
8978
8978
  }
8979
8979
  return changes;
8980
8980
  }
@@ -8988,12 +8988,12 @@ function describePartChanges(before, after, secretRules) {
8988
8988
  };
8989
8989
  const left = index(before);
8990
8990
  const right = index(after);
8991
- const label = (filename) => findSecretInPath(filename, secretRules)?.masked ?? filename;
8991
+ const label2 = (filename) => findSecretInPath(filename, secretRules)?.masked ?? filename;
8992
8992
  const changes = [];
8993
8993
  for (const [filename, part] of right) {
8994
8994
  const previous = left.get(filename);
8995
8995
  if (previous === void 0) {
8996
- changes.push(`part added: ${label(filename)}`);
8996
+ changes.push(`part added: ${label2(filename)}`);
8997
8997
  continue;
8998
8998
  }
8999
8999
  const moved = [];
@@ -9009,10 +9009,10 @@ function describePartChanges(before, after, secretRules) {
9009
9009
  if (previous.fileCount !== part.fileCount) {
9010
9010
  moved.push(`fileCount ${previous.fileCount} \u2192 ${part.fileCount}`);
9011
9011
  }
9012
- if (moved.length > 0) changes.push(`part ${label(filename)}: ${moved.join(", ")}`);
9012
+ if (moved.length > 0) changes.push(`part ${label2(filename)}: ${moved.join(", ")}`);
9013
9013
  }
9014
9014
  for (const filename of left.keys()) {
9015
- if (!right.has(filename)) changes.push(`part removed: ${label(filename)}`);
9015
+ if (!right.has(filename)) changes.push(`part removed: ${label2(filename)}`);
9016
9016
  }
9017
9017
  return changes;
9018
9018
  }
@@ -9126,10 +9126,10 @@ function comparableProblem(value) {
9126
9126
  if (typeof candidate.generatedAt !== "string") return 'no "generatedAt"';
9127
9127
  return null;
9128
9128
  }
9129
- function assertUsableManifest(value, label) {
9129
+ function assertUsableManifest(value, label2) {
9130
9130
  const problem = comparableProblem(value);
9131
9131
  if (problem) {
9132
- throw new Error(`The ${label} manifest is not a snapshot manifest: ${problem}.`);
9132
+ throw new Error(`The ${label2} manifest is not a snapshot manifest: ${problem}.`);
9133
9133
  }
9134
9134
  }
9135
9135
  function compareManifests(before, after, secretRules) {
@@ -9171,7 +9171,7 @@ function loadManifest(target) {
9171
9171
  } catch {
9172
9172
  throw new Error(`No snapshot found at ${target}: the path does not exist.`);
9173
9173
  }
9174
- const manifestPath = isDirectory ? path32__namespace.join(target, "manifest.json") : target;
9174
+ const manifestPath = isDirectory ? path33__namespace.join(target, "manifest.json") : target;
9175
9175
  let raw;
9176
9176
  try {
9177
9177
  raw = fs27__namespace.readFileSync(manifestPath, "utf8");
@@ -9880,17 +9880,17 @@ function diffSectionPaths(body) {
9880
9880
  continue;
9881
9881
  }
9882
9882
  if (line.startsWith("+++ ")) {
9883
- const path33 = wholeLinePath(line.slice(4), "b/");
9884
- if (path33 !== null) paths.add(path33);
9883
+ const path34 = wholeLinePath(line.slice(4), "b/");
9884
+ if (path34 !== null) paths.add(path34);
9885
9885
  continue;
9886
9886
  }
9887
9887
  if (line.startsWith("--- ")) {
9888
- const path33 = wholeLinePath(line.slice(4), "a/");
9889
- if (path33 !== null) paths.add(path33);
9888
+ const path34 = wholeLinePath(line.slice(4), "a/");
9889
+ if (path34 !== null) paths.add(path34);
9890
9890
  }
9891
9891
  }
9892
9892
  if (paths.size === 0 && header2 !== null) {
9893
- for (const path33 of headerPaths(header2)) paths.add(path33);
9893
+ for (const path34 of headerPaths(header2)) paths.add(path34);
9894
9894
  }
9895
9895
  return [...paths];
9896
9896
  }
@@ -9905,7 +9905,7 @@ function filterAndRedactDiff(raw, secretRules, options = {}) {
9905
9905
  omittedUnparseable += 1;
9906
9906
  continue;
9907
9907
  }
9908
- if (paths.some((path33) => isSensitivePath(path33) || options.excluded?.(path33) === true)) {
9908
+ if (paths.some((path34) => isSensitivePath(path34) || options.excluded?.(path34) === true)) {
9909
9909
  omittedSensitive += 1;
9910
9910
  continue;
9911
9911
  }
@@ -9948,7 +9948,7 @@ function generateDiffReport(cwd, options = {}) {
9948
9948
  omittedUnparseable += 1;
9949
9949
  continue;
9950
9950
  }
9951
- const blocked = paths2.some((path33) => isSensitivePath(path33) || options.excluded?.(path33) === true);
9951
+ const blocked = paths2.some((path34) => isSensitivePath(path34) || options.excluded?.(path34) === true);
9952
9952
  if (blocked) {
9953
9953
  omittedSensitive += 1;
9954
9954
  continue;
@@ -9983,7 +9983,7 @@ function generateDiffReport(cwd, options = {}) {
9983
9983
  }
9984
9984
  if (sections.length === 0) return null;
9985
9985
  const paths = /* @__PURE__ */ new Set();
9986
- for (const section of sections) for (const path33 of diffSectionPaths(section)) paths.add(path33);
9986
+ for (const section of sections) for (const path34 of diffSectionPaths(section)) paths.add(path34);
9987
9987
  const joined = [
9988
9988
  "# Uncommitted changes",
9989
9989
  "",
@@ -10094,10 +10094,10 @@ function internalSpecifier(specifier, resolver) {
10094
10094
  }
10095
10095
  function manifestLabel(cwd, manifestPath) {
10096
10096
  if (manifestPath === void 0) return "manifest.json";
10097
- const relative20 = path32__namespace.relative(cwd, manifestPath).replace(/\\/g, "/");
10098
- if (relative20.length === 0) return "manifest.json";
10099
- if (relative20.startsWith("../") || path32__namespace.isAbsolute(relative20)) return path32__namespace.basename(manifestPath);
10100
- return relative20;
10097
+ const relative21 = path33__namespace.relative(cwd, manifestPath).replace(/\\/g, "/");
10098
+ if (relative21.length === 0) return "manifest.json";
10099
+ if (relative21.startsWith("../") || path33__namespace.isAbsolute(relative21)) return path33__namespace.basename(manifestPath);
10100
+ return relative21;
10101
10101
  }
10102
10102
  function isPureBarrel(summary, file) {
10103
10103
  if (summary.parseErrors !== void 0 && summary.parseErrors > 0) return false;
@@ -10349,7 +10349,7 @@ function computeImpact(input) {
10349
10349
  );
10350
10350
  const skippedByPath = new Map(manifest.skipped.map((skip) => [skip.path, skip]));
10351
10351
  const changed = input.changes.paths.map((changedPath) => {
10352
- const deleted2 = !fs27__namespace.existsSync(path32__namespace.resolve(input.cwd, changedPath));
10352
+ const deleted2 = !fs27__namespace.existsSync(path33__namespace.resolve(input.cwd, changedPath));
10353
10353
  const direct = filesByPath.get(changedPath);
10354
10354
  if (direct !== void 0) return { path: direct.relativePath, inSnapshot: true, deleted: deleted2 };
10355
10355
  const folded = filesByFoldedPath.get(changedPath.toLowerCase());
@@ -10494,8 +10494,8 @@ function computeImpact(input) {
10494
10494
  }
10495
10495
  }
10496
10496
  const impacted = /* @__PURE__ */ new Set([...changedSet, ...affected.keys()]);
10497
- for (const path33 of visitedSymbols.keys()) {
10498
- if (!isTestPath(path33) && !isTestSupportPath(path33)) impacted.add(path33);
10497
+ for (const path34 of visitedSymbols.keys()) {
10498
+ if (!isTestPath(path34) && !isTestSupportPath(path34)) impacted.add(path34);
10499
10499
  }
10500
10500
  const tests = [...testHits.entries()].map(([testPath, hit]) => ({
10501
10501
  path: testPath,
@@ -10699,6 +10699,208 @@ function renderImpactText(report2) {
10699
10699
  for (const warning of report2.warnings) lines.push("Warning: " + safeDisplay(warning));
10700
10700
  return lines.join("\n");
10701
10701
  }
10702
+ var MAX_CONSUMERS = 10;
10703
+ var MAX_TESTS = 5;
10704
+ var MAX_ROUTES = 5;
10705
+ var MAX_HOOK_CHARS = 1200;
10706
+ function take(values, limit) {
10707
+ return { taken: values.slice(0, limit), omitted: Math.max(0, values.length - limit) };
10708
+ }
10709
+ function toGap(entry) {
10710
+ return {
10711
+ kind: "consumer",
10712
+ path: entry.path,
10713
+ distance: entry.distance,
10714
+ via: entry.via,
10715
+ ...entry.confidence === void 0 ? {} : { confidence: entry.confidence }
10716
+ };
10717
+ }
10718
+ function testGap(entry) {
10719
+ return { kind: "test", path: entry.path, covers: [...entry.covers] };
10720
+ }
10721
+ function routeGap(entry) {
10722
+ return { kind: "route", path: entry.path, methods: [...entry.methods] };
10723
+ }
10724
+ function buildGuardReport(impact) {
10725
+ const changed = impact.changed.filter((entry) => entry.deleted !== true).map((entry) => entry.path);
10726
+ const changedSet = new Set(changed);
10727
+ const consumers = impact.affected.filter((entry) => !changedSet.has(entry.path));
10728
+ const tests = impact.tests.filter((entry) => !changedSet.has(entry.path));
10729
+ const routes = (impact.routesAffected ?? []).filter((entry) => !changedSet.has(entry.path));
10730
+ const consumerPart = take(consumers, MAX_CONSUMERS);
10731
+ const testPart = take(tests, MAX_TESTS);
10732
+ const routePart = take(routes, MAX_ROUTES);
10733
+ const gaps = [
10734
+ ...consumerPart.taken.map(toGap),
10735
+ ...testPart.taken.map(testGap),
10736
+ ...routePart.taken.map(routeGap)
10737
+ ];
10738
+ return {
10739
+ schemaVersion: 1,
10740
+ changed,
10741
+ gaps,
10742
+ trust: impact.trust,
10743
+ truncated: impact.truncated || consumerPart.omitted > 0 || testPart.omitted > 0 || routePart.omitted > 0,
10744
+ omitted: {
10745
+ consumers: consumerPart.omitted,
10746
+ tests: testPart.omitted,
10747
+ routes: routePart.omitted
10748
+ }
10749
+ };
10750
+ }
10751
+ function label(gap) {
10752
+ if (gap.kind === "test") return "test";
10753
+ if (gap.kind === "route") return "route";
10754
+ return "consumer";
10755
+ }
10756
+ function renderGuardText(report2) {
10757
+ if (report2.gaps.length === 0) {
10758
+ return "Change Guard: no gaps in this change.\n changed: " + report2.changed.length + " file(s); coverage: " + report2.trust.coverage + "\n";
10759
+ }
10760
+ const lines = [];
10761
+ lines.push("Change Guard: " + report2.gaps.length + " gap(s) in this change");
10762
+ for (const gap of report2.gaps) {
10763
+ const parts = [gap.path];
10764
+ if (gap.kind === "consumer") {
10765
+ const meta = [];
10766
+ if (gap.distance !== void 0) meta.push(gap.distance + " hop" + (gap.distance === 1 ? "" : "s"));
10767
+ if (gap.confidence !== void 0) meta.push(gap.confidence);
10768
+ if (gap.via !== void 0) meta.push("via " + gap.via);
10769
+ if (meta.length > 0) parts.push("(" + meta.join(", ") + ")");
10770
+ } else if (gap.kind === "test") {
10771
+ parts.push("(test" + (gap.covers && gap.covers.length > 0 ? ": " + gap.covers.join(", ") : "") + ")");
10772
+ } else {
10773
+ parts.push("(route" + (gap.methods && gap.methods.length > 0 ? ": " + gap.methods.join(", ") : "") + ")");
10774
+ }
10775
+ lines.push(" " + label(gap).padEnd(9) + parts.join(" "));
10776
+ }
10777
+ if (report2.truncated) {
10778
+ const omitted = report2.omitted;
10779
+ lines.push(
10780
+ " \u2026 truncated: " + omitted.consumers + " consumer(s), " + omitted.tests + " test(s), " + omitted.routes + " route(s) omitted"
10781
+ );
10782
+ }
10783
+ lines.push(" coverage: " + report2.trust.coverage + " \xB7 confidence: symbol-pruned");
10784
+ return lines.join("\n");
10785
+ }
10786
+ function truncateGuardText(text2, maxChars) {
10787
+ if (text2.length <= maxChars) return text2;
10788
+ const marker2 = "\n\u2026 run codebase-snapshot guard --changed for the full list";
10789
+ const room = Math.max(0, maxChars - marker2.length);
10790
+ return text2.slice(0, room).trimEnd() + marker2;
10791
+ }
10792
+ function renderGuardHookText(report2, maxChars = MAX_HOOK_CHARS) {
10793
+ if (report2.gaps.length === 0) return "";
10794
+ const lines = ["[change-guard] " + report2.gaps.length + " gap(s) in this change:"];
10795
+ for (const gap of report2.gaps) {
10796
+ if (gap.kind === "consumer") {
10797
+ lines.push(
10798
+ " " + gap.path + (gap.distance === void 0 ? "" : " (" + gap.distance + " hop" + (gap.distance === 1 ? "" : "s") + ")")
10799
+ );
10800
+ } else if (gap.kind === "test") {
10801
+ lines.push(" test " + gap.path);
10802
+ } else {
10803
+ lines.push(" route " + gap.path + (gap.methods && gap.methods.length > 0 ? " (" + gap.methods.join(", ") + ")" : ""));
10804
+ }
10805
+ }
10806
+ lines.push("coverage: " + report2.trust.coverage + " \xB7 confidence: symbol-pruned");
10807
+ lines.push("run: npx codebase-snapshot brief --diff HEAD");
10808
+ return truncateGuardText(lines.join("\n"), maxChars);
10809
+ }
10810
+ function renderGuardHook(report2, client, event, maxChars = MAX_HOOK_CHARS) {
10811
+ const text2 = renderGuardHookText(report2, maxChars);
10812
+ if (text2.length === 0) return "{}";
10813
+ if (client === "claude") {
10814
+ return JSON.stringify({
10815
+ hookSpecificOutput: {
10816
+ hookEventName: event,
10817
+ additionalContext: text2
10818
+ }
10819
+ });
10820
+ }
10821
+ return JSON.stringify({ additionalContext: text2 });
10822
+ }
10823
+ function normalizePath(cwd, raw) {
10824
+ const value = raw.trim();
10825
+ if (value.length === 0 || value.includes("\0")) return null;
10826
+ const absolute = path33__namespace.isAbsolute(value) ? value : path33__namespace.resolve(cwd, value);
10827
+ const relative21 = path33__namespace.relative(cwd, absolute).split(path33__namespace.sep).join("/");
10828
+ if (relative21 === "" || relative21 === ".." || relative21.startsWith("../") || path33__namespace.isAbsolute(relative21)) {
10829
+ return null;
10830
+ }
10831
+ return relative21;
10832
+ }
10833
+ function collectPaths(value, out, depth = 0) {
10834
+ if (depth > 6 || value === null || typeof value !== "object") return;
10835
+ if (Array.isArray(value)) {
10836
+ for (const item of value) collectPaths(item, out, depth + 1);
10837
+ return;
10838
+ }
10839
+ const record = value;
10840
+ for (const [key, item] of Object.entries(record)) {
10841
+ if (typeof item === "string" && /^(file_path|filePath|path|file|filename|fileName)$/i.test(key)) {
10842
+ out.add(item);
10843
+ continue;
10844
+ }
10845
+ if (Array.isArray(item) && /^(files|paths|file_paths|filePaths)$/i.test(key)) {
10846
+ for (const entry of item) if (typeof entry === "string") out.add(entry);
10847
+ continue;
10848
+ }
10849
+ if (typeof item === "object" && item !== null) collectPaths(item, out, depth + 1);
10850
+ }
10851
+ }
10852
+ function parseGuardHookInput(client, raw, cwd) {
10853
+ let payload;
10854
+ try {
10855
+ payload = JSON.parse(raw);
10856
+ } catch {
10857
+ throw new Error("guard --hook expects one JSON object on stdin.");
10858
+ }
10859
+ if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
10860
+ throw new Error("guard --hook expects one JSON object on stdin.");
10861
+ }
10862
+ const record = payload;
10863
+ const candidates = /* @__PURE__ */ new Set();
10864
+ if (client === "claude") {
10865
+ const toolInput = record.tool_input;
10866
+ if (toolInput !== null && typeof toolInput === "object") collectPaths(toolInput, candidates);
10867
+ const toolResponse = record.tool_response;
10868
+ if (toolResponse !== null && typeof toolResponse === "object") collectPaths(toolResponse, candidates);
10869
+ if (typeof record.file_path === "string") candidates.add(record.file_path);
10870
+ } else if (client === "copilot") {
10871
+ if (typeof record.toolArgs === "string") {
10872
+ try {
10873
+ collectPaths(JSON.parse(record.toolArgs), candidates);
10874
+ } catch {
10875
+ }
10876
+ } else if (record.toolArgs !== null && typeof record.toolArgs === "object") {
10877
+ collectPaths(record.toolArgs, candidates);
10878
+ }
10879
+ if (record.tool_input !== null && typeof record.tool_input === "object") {
10880
+ collectPaths(record.tool_input, candidates);
10881
+ }
10882
+ } else {
10883
+ if (record.tool_input !== null && typeof record.tool_input === "object") {
10884
+ collectPaths(record.tool_input, candidates);
10885
+ }
10886
+ if (record.toolArgs !== null && typeof record.toolArgs === "object") {
10887
+ collectPaths(record.toolArgs, candidates);
10888
+ }
10889
+ if (typeof record.path === "string") candidates.add(record.path);
10890
+ }
10891
+ const paths = [];
10892
+ for (const candidate of candidates) {
10893
+ const normalized = normalizePath(cwd, candidate);
10894
+ if (normalized !== null) paths.push(normalized);
10895
+ }
10896
+ const sessionId = typeof record.session_id === "string" ? record.session_id : typeof record.sessionId === "string" ? record.sessionId : void 0;
10897
+ const event = typeof record.hook_event_name === "string" ? record.hook_event_name : typeof record.hookEventName === "string" ? record.hookEventName : "PostToolUse";
10898
+ return {
10899
+ paths: [...new Set(paths)].sort((left, right) => left.localeCompare(right)),
10900
+ ...sessionId === void 0 ? {} : { sessionId },
10901
+ event
10902
+ };
10903
+ }
10702
10904
  var hookStdoutScope = new async_hooks.AsyncLocalStorage();
10703
10905
  var captureScope = new async_hooks.AsyncLocalStorage();
10704
10906
  var installs = 0;
@@ -11359,12 +11561,12 @@ function planForQuestion(manifest, question, options = {}) {
11359
11561
  const scored = [];
11360
11562
  for (const file of manifest.files) {
11361
11563
  if (isTest(file) && !wantsTests) continue;
11362
- const path33 = file.relativePath.toLowerCase();
11363
- const words = path33.split(/[^a-z0-9_]+/).filter((word) => word.length >= 3);
11564
+ const path34 = file.relativePath.toLowerCase();
11565
+ const words = path34.split(/[^a-z0-9_]+/).filter((word) => word.length >= 3);
11364
11566
  let score = 0;
11365
11567
  const reasons = [];
11366
11568
  for (const term of terms) {
11367
- if (path33.includes(term)) {
11569
+ if (path34.includes(term)) {
11368
11570
  score += 8;
11369
11571
  reasons.push("path:" + term);
11370
11572
  continue;
@@ -11421,7 +11623,7 @@ function planForQuestion(manifest, question, options = {}) {
11421
11623
  const chosen = /* @__PURE__ */ new Map();
11422
11624
  const skipped = [];
11423
11625
  let used = 0;
11424
- const take = (file, why, mode) => {
11626
+ const take2 = (file, why, mode) => {
11425
11627
  const existing = chosen.get(file.relativePath);
11426
11628
  if (existing !== void 0) return false;
11427
11629
  const tokens = tokensOf(file);
@@ -11442,11 +11644,11 @@ function planForQuestion(manifest, question, options = {}) {
11442
11644
  for (const item of scored) {
11443
11645
  const tokens = tokensOf(item.file);
11444
11646
  if (used + tokens <= budget) {
11445
- take(item.file, item.why, "full");
11647
+ take2(item.file, item.why, "full");
11446
11648
  continue;
11447
11649
  }
11448
11650
  if (tokens <= budget * 2 && used + Math.ceil(tokens / 2) <= budget) {
11449
- take(item.file, item.why, "head");
11651
+ take2(item.file, item.why, "head");
11450
11652
  continue;
11451
11653
  }
11452
11654
  skipped.push({ path: item.file.relativePath, reason: "does not fit the remaining budget" });
@@ -11459,8 +11661,8 @@ function planForQuestion(manifest, question, options = {}) {
11459
11661
  const target = byPath.get(targetPath2);
11460
11662
  if (target === void 0 || chosen.has(target.relativePath)) continue;
11461
11663
  if (isTest(target) && !wantsTests) continue;
11462
- if (!take(target, "imported by " + seed.path, "full")) {
11463
- if (!take(target, "imported by " + seed.path, "head")) {
11664
+ if (!take2(target, "imported by " + seed.path, "full")) {
11665
+ if (!take2(target, "imported by " + seed.path, "head")) {
11464
11666
  skipped.push({ path: target.relativePath, reason: "does not fit the remaining budget" });
11465
11667
  }
11466
11668
  }
@@ -11474,9 +11676,9 @@ function planForQuestion(manifest, question, options = {}) {
11474
11676
  const file = byPath.get(caller);
11475
11677
  if (file === void 0) continue;
11476
11678
  if (isTest(file) && !wantsTests) continue;
11477
- if (take(file, "imports " + seed.path, "full")) {
11679
+ if (take2(file, "imports " + seed.path, "full")) {
11478
11680
  callerBudget -= 1;
11479
- } else if (take(file, "imports " + seed.path, "head")) {
11681
+ } else if (take2(file, "imports " + seed.path, "head")) {
11480
11682
  callerBudget -= 1;
11481
11683
  }
11482
11684
  }
@@ -11834,7 +12036,7 @@ function systemSection(manifest, code, brief, escape, sawManifest) {
11834
12036
  " A change here reaches the most call sites; read it before judging anything that uses it."
11835
12037
  );
11836
12038
  }
11837
- const entryPoints = manifest.files.map((file) => file.relativePath).filter((path33) => ENTRY_POINT.test(path33)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
12039
+ const entryPoints = manifest.files.map((file) => file.relativePath).filter((path34) => ENTRY_POINT.test(path34)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
11838
12040
  out.push(
11839
12041
  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"
11840
12042
  );
@@ -12069,8 +12271,8 @@ function ownerNotesSection(brief, code, text2) {
12069
12271
  }
12070
12272
  return out;
12071
12273
  }
12072
- function ownerBlock(body, path33, code, escape) {
12073
- return ["> Written by the project owner in " + code(path33) + ", not generated.", "", escape(body)];
12274
+ function ownerBlock(body, path34, code, escape) {
12275
+ return ["> Written by the project owner in " + code(path34) + ", not generated.", "", escape(body)];
12074
12276
  }
12075
12277
  function snapshotSection(manifest, code, partsWritten) {
12076
12278
  const out = ["## This snapshot", ""];
@@ -12354,8 +12556,8 @@ function generateProjectTree(filePaths) {
12354
12556
  const isLast = frame.index === frame.keys.length;
12355
12557
  const child = frame.node.children.get(key);
12356
12558
  const isDirectory = child.children.size > 0;
12357
- const label = escapeControls(key);
12358
- lines.push(`${frame.prefix}${isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 "}${label}${isDirectory ? "/" : ""}`);
12559
+ const label2 = escapeControls(key);
12560
+ lines.push(`${frame.prefix}${isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 "}${label2}${isDirectory ? "/" : ""}`);
12359
12561
  if (lines.length >= MAX_TREE_LINES) {
12360
12562
  truncatedAt = lines.length;
12361
12563
  break;
@@ -12408,8 +12610,8 @@ function readProjectOverview(cwd) {
12408
12610
  releases: readReleases(cwd)
12409
12611
  };
12410
12612
  }
12411
- function readText(cwd, relative20) {
12412
- const read = readConfinedText(cwd, relative20);
12613
+ function readText(cwd, relative21) {
12614
+ const read = readConfinedText(cwd, relative21);
12413
12615
  return read.ok ? read.text : null;
12414
12616
  }
12415
12617
  function readDescription(cwd) {
@@ -12521,10 +12723,10 @@ var LANGUAGE_BY_BASENAME = {
12521
12723
  };
12522
12724
  function detectLanguage(filePath) {
12523
12725
  const normalized = filePath.replace(/\\/g, "/");
12524
- const base = path32__namespace.posix.basename(normalized);
12726
+ const base = path33__namespace.posix.basename(normalized);
12525
12727
  if (LANGUAGE_BY_BASENAME[base]) return LANGUAGE_BY_BASENAME[base];
12526
12728
  if (base === ".env" || base.startsWith(".env.")) return "dotenv";
12527
- const ext = path32__namespace.posix.extname(base).toLowerCase();
12729
+ const ext = path33__namespace.posix.extname(base).toLowerCase();
12528
12730
  return LANGUAGE_BY_EXTENSION[ext] ?? "text";
12529
12731
  }
12530
12732
  var HOST_PATTERN = /^(?:[a-z0-9.-]+|\[[0-9a-f:.]+\])$/i;
@@ -12638,7 +12840,7 @@ function parseRemoteSource(input, options = {}) {
12638
12840
  const directory = url.fileURLToPath(url2);
12639
12841
  return {
12640
12842
  ok: true,
12641
- source: { kind: "file", url: trimmed, host: "file", owner: "", repo: path32__namespace.basename(directory), ref: null }
12843
+ source: { kind: "file", url: trimmed, host: "file", owner: "", repo: path33__namespace.basename(directory), ref: null }
12642
12844
  };
12643
12845
  }
12644
12846
  let url$1;
@@ -12693,7 +12895,7 @@ async function assertPublicHost(host, allowPrivate) {
12693
12895
  }
12694
12896
  }
12695
12897
  function runGitAsync(args, options) {
12696
- return new Promise((resolve21) => {
12898
+ return new Promise((resolve22) => {
12697
12899
  let child;
12698
12900
  try {
12699
12901
  child = childProcess.spawn("git", args, {
@@ -12702,7 +12904,7 @@ function runGitAsync(args, options) {
12702
12904
  stdio: ["ignore", "pipe", "pipe"]
12703
12905
  });
12704
12906
  } catch (error) {
12705
- resolve21({
12907
+ resolve22({
12706
12908
  status: null,
12707
12909
  stdout: "",
12708
12910
  stderr: "",
@@ -12727,7 +12929,7 @@ function runGitAsync(args, options) {
12727
12929
  settled = true;
12728
12930
  if (timer !== void 0) clearTimeout(timer);
12729
12931
  if (killTimer !== void 0) clearTimeout(killTimer);
12730
- resolve21({ status, stdout, stderr, timedOut, error });
12932
+ resolve22({ status, stdout, stderr, timedOut, error });
12731
12933
  };
12732
12934
  child.stdout?.on("data", (chunk) => {
12733
12935
  stdout = append(stdout, chunk);
@@ -12774,7 +12976,7 @@ function gitEnvironment(token, host) {
12774
12976
  async function cloneRepository(source, options) {
12775
12977
  const log = options.log ?? (() => {
12776
12978
  });
12777
- const dest = path32__namespace.resolve(options.dest);
12979
+ const dest = path33__namespace.resolve(options.dest);
12778
12980
  fs27__namespace.rmSync(dest, { recursive: true, force: true });
12779
12981
  fs27__namespace.mkdirSync(dest, { recursive: true });
12780
12982
  try {
@@ -12857,7 +13059,7 @@ function directorySize(root) {
12857
13059
  continue;
12858
13060
  }
12859
13061
  for (const entry of entries) {
12860
- const full = path32__namespace.join(current, entry.name);
13062
+ const full = path33__namespace.join(current, entry.name);
12861
13063
  if (entry.isDirectory()) stack.push(full);
12862
13064
  else if (entry.isFile()) {
12863
13065
  try {
@@ -12870,7 +13072,7 @@ function directorySize(root) {
12870
13072
  return total;
12871
13073
  }
12872
13074
  function makeCloneDirectory() {
12873
- return fs27__namespace.mkdtempSync(path32__namespace.join(os2__namespace.tmpdir(), "codebase-snapshot-clone-"));
13075
+ return fs27__namespace.mkdtempSync(path33__namespace.join(os2__namespace.tmpdir(), "codebase-snapshot-clone-"));
12874
13076
  }
12875
13077
 
12876
13078
  // src/mcp/instructions.ts
@@ -13083,8 +13285,8 @@ function safeRegularFile(cwd, absolute) {
13083
13285
  if (!fs27__namespace.lstatSync(absolute).isFile()) return false;
13084
13286
  const root = fs27__namespace.realpathSync(cwd);
13085
13287
  const real = fs27__namespace.realpathSync(absolute);
13086
- const relative20 = path32__namespace.relative(root, real);
13087
- return relative20 !== ".." && !relative20.startsWith(".." + path32__namespace.sep) && !path32__namespace.isAbsolute(relative20);
13288
+ const relative21 = path33__namespace.relative(root, real);
13289
+ return relative21 !== ".." && !relative21.startsWith(".." + path33__namespace.sep) && !path33__namespace.isAbsolute(relative21);
13088
13290
  } catch {
13089
13291
  return false;
13090
13292
  }
@@ -13098,32 +13300,32 @@ function describeMatcher(matcher) {
13098
13300
  return String(matcher);
13099
13301
  }
13100
13302
  function normalizeTarget2(cwd, target) {
13101
- const resolvedCwd = path32__namespace.resolve(cwd);
13102
- const absolute = path32__namespace.resolve(resolvedCwd, target);
13103
- const relative20 = path32__namespace.relative(resolvedCwd, absolute);
13104
- if (relative20 === "" || relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || path32__namespace.isAbsolute(relative20)) {
13303
+ const resolvedCwd = path33__namespace.resolve(cwd);
13304
+ const absolute = path33__namespace.resolve(resolvedCwd, target);
13305
+ const relative21 = path33__namespace.relative(resolvedCwd, absolute);
13306
+ if (relative21 === "" || relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || path33__namespace.isAbsolute(relative21)) {
13105
13307
  return { relative: target.replace(/\\/g, "/"), outsideRoot: true };
13106
13308
  }
13107
- return { relative: relative20.split(path32__namespace.sep).join("/"), outsideRoot: false };
13309
+ return { relative: relative21.split(path33__namespace.sep).join("/"), outsideRoot: false };
13108
13310
  }
13109
13311
  function findRuleMatch(rules, relativePath) {
13110
13312
  return rules.find(
13111
13313
  (rule) => matchRule(relativePath, rule.match)
13112
13314
  );
13113
13315
  }
13114
- function findRecordedAncestor(skipped, relative20, maskedPath2) {
13316
+ function findRecordedAncestor(skipped, relative21, maskedPath2) {
13115
13317
  let nearest;
13116
13318
  for (const record of skipped) {
13117
13319
  const ancestorPath = record.path;
13118
13320
  if (ancestorPath.length === 0) continue;
13119
- const isAncestor = relative20.startsWith(`${ancestorPath}/`) || maskedPath2.startsWith(`${ancestorPath}/`);
13321
+ const isAncestor = relative21.startsWith(`${ancestorPath}/`) || maskedPath2.startsWith(`${ancestorPath}/`);
13120
13322
  if (!isAncestor) continue;
13121
13323
  if (!nearest || ancestorPath.length > nearest.path.length) nearest = record;
13122
13324
  }
13123
13325
  return nearest;
13124
13326
  }
13125
13327
  function readManifest2(config) {
13126
- const manifestPath = path32__namespace.resolve(config.cwd, config.outDir, "manifest.json");
13328
+ const manifestPath = path33__namespace.resolve(config.cwd, config.outDir, "manifest.json");
13127
13329
  try {
13128
13330
  return JSON.parse(fs27__namespace.readFileSync(manifestPath, "utf8"));
13129
13331
  } catch {
@@ -13132,8 +13334,8 @@ function readManifest2(config) {
13132
13334
  }
13133
13335
  function explainPath(config, target) {
13134
13336
  const normalized = normalizeTarget2(config.cwd, target);
13135
- const relative20 = normalized.relative;
13136
- const maskedPath2 = findSecretInPath(relative20, config.secretRules)?.masked ?? relative20;
13337
+ const relative21 = normalized.relative;
13338
+ const maskedPath2 = findSecretInPath(relative21, config.secretRules)?.masked ?? relative21;
13137
13339
  if (normalized.outsideRoot) {
13138
13340
  return {
13139
13341
  path: maskedPath2,
@@ -13143,8 +13345,8 @@ function explainPath(config, target) {
13143
13345
  detail: "path resolves outside the configured repository root and was not inspected"
13144
13346
  };
13145
13347
  }
13146
- const absolute = path32__namespace.join(config.cwd, relative20);
13147
- const stagedBlob = config.staged === true ? readStagedBlob(config.cwd, relative20) : null;
13348
+ const absolute = path33__namespace.join(config.cwd, relative21);
13349
+ const stagedBlob = config.staged === true ? readStagedBlob(config.cwd, relative21) : null;
13148
13350
  const result = {
13149
13351
  path: maskedPath2,
13150
13352
  // `existsSync` follows a symlink, so an in-repo link to /etc/passwd answered "exists" for a
@@ -13163,18 +13365,18 @@ function explainPath(config, target) {
13163
13365
  discovery: config.discovery,
13164
13366
  // A staged file that is absent from the working tree is still a candidate: `generate --staged`
13165
13367
  // reads its index blob, and `explain --staged` has to explain that same selection.
13166
- ...stagedBlob === null ? {} : { extraPaths: [relative20] },
13368
+ ...stagedBlob === null ? {} : { extraPaths: [relative21] },
13167
13369
  // Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
13168
13370
  // that is only missing because the walker dropped the tool's own output directory.
13169
13371
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
13170
- (directory) => path32__namespace.relative(config.cwd, path32__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
13372
+ (directory) => path33__namespace.relative(config.cwd, path33__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
13171
13373
  ).filter(
13172
- (relative21) => relative21.length > 0 && relative21 !== ".." && !relative21.startsWith(`..${path32__namespace.sep}`) && !relative21.startsWith("../") && !path32__namespace.isAbsolute(relative21)
13374
+ (relative22) => relative22.length > 0 && relative22 !== ".." && !relative22.startsWith(`..${path33__namespace.sep}`) && !relative22.startsWith("../") && !path33__namespace.isAbsolute(relative22)
13173
13375
  )
13174
13376
  });
13175
- if (!collection.files.includes(relative20)) {
13377
+ if (!collection.files.includes(relative21)) {
13176
13378
  const record = collection.skipped.find(
13177
- (entry2) => entry2.path === relative20 || entry2.path === maskedPath2
13379
+ (entry2) => entry2.path === relative21 || entry2.path === maskedPath2
13178
13380
  );
13179
13381
  if (record) {
13180
13382
  result.reason = record.reason;
@@ -13183,7 +13385,7 @@ function explainPath(config, target) {
13183
13385
  result.reason = "missing";
13184
13386
  result.detail = "no such file or directory, relative to the configured cwd";
13185
13387
  } else {
13186
- const ancestor = findRecordedAncestor(collection.skipped, relative20, maskedPath2);
13388
+ const ancestor = findRecordedAncestor(collection.skipped, relative21, maskedPath2);
13187
13389
  if (ancestor) {
13188
13390
  result.reason = ancestor.reason;
13189
13391
  result.detail = ancestor.detail ? `${ancestor.detail} \u2014 inherited from the skipped directory \`${ancestor.path}\`` : `inside the skipped directory \`${ancestor.path}\``;
@@ -13203,12 +13405,12 @@ function explainPath(config, target) {
13203
13405
  ...config.changedSince === void 0 ? {} : { changedSince: config.changedSince },
13204
13406
  ...config.staged === true ? { staged: true } : {}
13205
13407
  });
13206
- inScope = scope.paths.has(relative20);
13408
+ inScope = scope.paths.has(relative21);
13207
13409
  if (!inScope && config.withDependents === true) {
13208
13410
  const workspace = workspaceResolutionFor(config.cwd, collection.files);
13209
- const imports = stagedBlob !== null ? importsOfText(relative20, decodeText(stagedBlob).text) : importsOfFile(relative20, absolute);
13411
+ const imports = stagedBlob !== null ? importsOfText(relative21, decodeText(stagedBlob).text) : importsOfFile(relative21, absolute);
13210
13412
  inScope = importsChangedFile(
13211
- relative20,
13413
+ relative21,
13212
13414
  imports,
13213
13415
  scope.paths,
13214
13416
  buildImportResolver(collection.files.map((file) => ({ relativePath: file })), {
@@ -13273,15 +13475,15 @@ function explainPath(config, target) {
13273
13475
  result.bytes = buffer.length;
13274
13476
  result.lines = countLines(text2);
13275
13477
  if (decoded.encoding !== "utf-8") result.encoding = decoded.encoding;
13276
- const { findings } = scanAndRedactSecrets(text2, config.secretRules, relative20);
13478
+ const { findings } = scanAndRedactSecrets(text2, config.secretRules, relative21);
13277
13479
  result.secretCount = findings.length;
13278
13480
  result.secrets = findings.slice(0, 20).map((finding) => ({ rules: finding.rules, line: finding.line }));
13279
13481
  let inclusionMode = "full";
13280
- if (config.skeleton === true && isSkeletonizable(relative20)) {
13281
- const skeleton = skeletonizeTypeScript(text2, relative20);
13482
+ if (config.skeleton === true && isSkeletonizable(relative21)) {
13483
+ const skeleton = skeletonizeTypeScript(text2, relative21);
13282
13484
  if (skeleton.collapsed > 0) inclusionMode = "signatures";
13283
13485
  }
13284
- if (inclusionMode === "full" && config.stripComments === true && isCommentStrippable(relative20) && stripComments2(text2, relative20).removed > 0) {
13486
+ if (inclusionMode === "full" && config.stripComments === true && isCommentStrippable(relative21) && stripComments2(text2, relative21).removed > 0) {
13285
13487
  inclusionMode = "comments-stripped";
13286
13488
  }
13287
13489
  if (inclusionMode !== "signatures" && buffer.length > config.largeFileBytes) {
@@ -13290,18 +13492,18 @@ function explainPath(config, target) {
13290
13492
  }
13291
13493
  result.inclusionMode = inclusionMode;
13292
13494
  }
13293
- result.layer = classifyLayer(relative20, config.layers);
13294
- result.kind = classifyKind(relative20, config.kinds);
13295
- result.language = detectLanguage(relative20);
13296
- const layerRule = findRuleMatch(config.layers, relative20);
13495
+ result.layer = classifyLayer(relative21, config.layers);
13496
+ result.kind = classifyKind(relative21, config.kinds);
13497
+ result.language = detectLanguage(relative21);
13498
+ const layerRule = findRuleMatch(config.layers, relative21);
13297
13499
  if (layerRule) result.layerMatch = describeMatcher(layerRule.match);
13298
- const kindRule = findRuleMatch(config.kinds, relative20);
13500
+ const kindRule = findRuleMatch(config.kinds, relative21);
13299
13501
  if (kindRule) result.kindMatch = describeMatcher(kindRule.match);
13300
13502
  const manifest = readManifest2(config);
13301
- const entry = Array.isArray(manifest?.files) ? manifest.files.find((file) => file.relativePath === relative20) : void 0;
13503
+ const entry = Array.isArray(manifest?.files) ? manifest.files.find((file) => file.relativePath === relative21) : void 0;
13302
13504
  result.part = entry?.part ?? null;
13303
13505
  if (entry === void 0) {
13304
- const record = manifest?.skipped?.find((skip) => skip.path === relative20);
13506
+ const record = manifest?.skipped?.find((skip) => skip.path === relative21);
13305
13507
  if (record !== void 0 && (record.reason === "not-selected" || record.reason === "unchanged")) {
13306
13508
  result.included = false;
13307
13509
  for (const key of [
@@ -13328,7 +13530,7 @@ function explainPath(config, target) {
13328
13530
  }
13329
13531
  function renderExplainText(result) {
13330
13532
  const lines = [escapeControls(result.path), ""];
13331
- const row = (label, value) => ` ${label.padEnd(11)}${escapeControls(value)}`;
13533
+ const row = (label2, value) => ` ${label2.padEnd(11)}${escapeControls(value)}`;
13332
13534
  if (!result.included) {
13333
13535
  lines.push(row("included", "no"));
13334
13536
  lines.push(row("reason", result.reason ?? "unknown"));
@@ -13361,51 +13563,51 @@ function renderExplainText(result) {
13361
13563
  return lines.join("\n");
13362
13564
  }
13363
13565
  var requireFromHere = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
13364
- var TYPESCRIPT_LIB_DIR = path32__namespace.dirname(requireFromHere.resolve("typescript"));
13566
+ var TYPESCRIPT_LIB_DIR = path33__namespace.dirname(requireFromHere.resolve("typescript"));
13365
13567
  var DEFAULT_MAX_PROGRAM_FILES = 2500;
13366
13568
  var DEFAULT_TIMEOUT_MS = 4e3;
13367
13569
  var MAX_REFERENCES = 5e3;
13368
13570
  var SOURCE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
13369
13571
  var CASE_INSENSITIVE_PATHS = process.platform === "win32" || process.platform === "darwin";
13370
13572
  function foldPathKey(value) {
13371
- return CASE_INSENSITIVE_PATHS ? path32__namespace.resolve(value).toLowerCase() : path32__namespace.resolve(value);
13573
+ return CASE_INSENSITIVE_PATHS ? path33__namespace.resolve(value).toLowerCase() : path33__namespace.resolve(value);
13372
13574
  }
13373
13575
  function canonicalRoot(root) {
13374
13576
  try {
13375
13577
  return fs27__namespace.realpathSync(root);
13376
13578
  } catch {
13377
- return path32__namespace.resolve(root);
13579
+ return path33__namespace.resolve(root);
13378
13580
  }
13379
13581
  }
13380
13582
  function inside(parent, child) {
13381
- const relative20 = path32__namespace.relative(foldPathKey(parent), foldPathKey(child));
13382
- return relative20 === "" || relative20 !== ".." && !relative20.startsWith(".." + path32__namespace.sep) && !path32__namespace.isAbsolute(relative20);
13583
+ const relative21 = path33__namespace.relative(foldPathKey(parent), foldPathKey(child));
13584
+ return relative21 === "" || relative21 !== ".." && !relative21.startsWith(".." + path33__namespace.sep) && !path33__namespace.isAbsolute(relative21);
13383
13585
  }
13384
13586
  function canonicalCandidate(root, candidate) {
13385
- const absolute = path32__namespace.isAbsolute(candidate) ? candidate : path32__namespace.resolve(root, candidate);
13587
+ const absolute = path33__namespace.isAbsolute(candidate) ? candidate : path33__namespace.resolve(root, candidate);
13386
13588
  if (!inside(root, absolute)) return null;
13387
13589
  try {
13388
13590
  const stat = fs27__namespace.lstatSync(absolute);
13389
13591
  if (!stat.isFile() && !stat.isSymbolicLink()) return null;
13390
13592
  const real = fs27__namespace.realpathSync(absolute);
13391
13593
  if (!inside(root, real)) return null;
13392
- const relative20 = path32__namespace.relative(root, real).replace(/\\/g, "/");
13393
- if (isSensitivePath(relative20)) return null;
13594
+ const relative21 = path33__namespace.relative(root, real).replace(/\\/g, "/");
13595
+ if (isSensitivePath(relative21)) return null;
13394
13596
  return real;
13395
13597
  } catch {
13396
13598
  return null;
13397
13599
  }
13398
13600
  }
13399
13601
  function isTypeScriptLib(file) {
13400
- const absolute = path32__namespace.isAbsolute(file) ? file : path32__namespace.resolve(TYPESCRIPT_LIB_DIR, file);
13401
- return inside(TYPESCRIPT_LIB_DIR, absolute) && /^lib(?:\.[^/\\]+)?\.d\.ts$/.test(path32__namespace.basename(absolute));
13602
+ const absolute = path33__namespace.isAbsolute(file) ? file : path33__namespace.resolve(TYPESCRIPT_LIB_DIR, file);
13603
+ return inside(TYPESCRIPT_LIB_DIR, absolute) && /^lib(?:\.[^/\\]+)?\.d\.ts$/.test(path33__namespace.basename(absolute));
13402
13604
  }
13403
13605
  function compilerOptionsFor(root) {
13404
13606
  let loaded = {};
13405
13607
  const configFile = ["tsconfig.json", "jsconfig.json"].find(
13406
13608
  (name) => readConfinedText(root, name, 4 * 1024 * 1024).ok
13407
13609
  );
13408
- const configPath = configFile === void 0 ? null : path32__namespace.join(root, configFile);
13610
+ const configPath = configFile === void 0 ? null : path33__namespace.join(root, configFile);
13409
13611
  const read = configFile === void 0 ? null : readConfinedText(root, configFile, 4 * 1024 * 1024);
13410
13612
  if (read !== null && read.ok && configPath !== null) {
13411
13613
  const parsed = ts2__default.default.parseConfigFileTextToJson(configPath, read.text);
@@ -13414,13 +13616,13 @@ function compilerOptionsFor(root) {
13414
13616
  useCaseSensitiveFileNames: ts2__default.default.sys.useCaseSensitiveFileNames,
13415
13617
  readDirectory: () => [],
13416
13618
  fileExists: (file) => {
13417
- const relative20 = path32__namespace.relative(root, file).replace(/\\/g, "/");
13418
- return relative20.length > 0 && !isSensitivePath(relative20) && readConfinedText(root, relative20).ok;
13619
+ const relative21 = path33__namespace.relative(root, file).replace(/\\/g, "/");
13620
+ return relative21.length > 0 && !isSensitivePath(relative21) && readConfinedText(root, relative21).ok;
13419
13621
  },
13420
13622
  readFile: (file) => {
13421
- const relative20 = path32__namespace.relative(root, file).replace(/\\/g, "/");
13422
- if (relative20.length === 0 || isSensitivePath(relative20)) return void 0;
13423
- const text2 = readConfinedText(root, relative20);
13623
+ const relative21 = path33__namespace.relative(root, file).replace(/\\/g, "/");
13624
+ if (relative21.length === 0 || isSensitivePath(relative21)) return void 0;
13625
+ const text2 = readConfinedText(root, relative21);
13424
13626
  return text2.ok ? text2.text : void 0;
13425
13627
  },
13426
13628
  getDirectories: () => []
@@ -13460,7 +13662,7 @@ function sourceKind(relativePath) {
13460
13662
  return ts2__default.default.ScriptKind.TS;
13461
13663
  }
13462
13664
  function isSourcePath(relativePath) {
13463
- return SOURCE_EXTENSIONS2.has(path32__namespace.posix.extname(relativePath).toLowerCase());
13665
+ return SOURCE_EXTENSIONS2.has(path33__namespace.posix.extname(relativePath).toLowerCase());
13464
13666
  }
13465
13667
  function createScopedProgram(options) {
13466
13668
  const root = canonicalRoot(options.root);
@@ -13473,7 +13675,7 @@ function createScopedProgram(options) {
13473
13675
  for (const file of options.files) {
13474
13676
  const normalized = file.relativePath.replace(/\\/g, "/").replace(/^\.\/+/, "");
13475
13677
  if (!isSourcePath(normalized) || isSensitivePath(normalized)) continue;
13476
- const absolute = path32__namespace.resolve(root, normalized);
13678
+ const absolute = path33__namespace.resolve(root, normalized);
13477
13679
  const key = foldPathKey(absolute);
13478
13680
  if (!inside(root, absolute) || seen.has(key)) continue;
13479
13681
  seen.add(key);
@@ -13500,12 +13702,12 @@ function createScopedProgram(options) {
13500
13702
  const overlaidContent = (absolute) => {
13501
13703
  const direct = overlay.get(foldPathKey(absolute));
13502
13704
  if (direct === void 0) return void 0;
13503
- const relative20 = path32__namespace.relative(root, absolute).replace(/\\/g, "/");
13504
- return isSensitivePath(relative20) ? void 0 : direct;
13705
+ const relative21 = path33__namespace.relative(root, absolute).replace(/\\/g, "/");
13706
+ return isSensitivePath(relative21) ? void 0 : direct;
13505
13707
  };
13506
13708
  const host = {
13507
13709
  getSourceFile: (fileName, languageVersion) => {
13508
- const absolute = path32__namespace.isAbsolute(fileName) ? fileName : path32__namespace.resolve(root, fileName);
13710
+ const absolute = path33__namespace.isAbsolute(fileName) ? fileName : path33__namespace.resolve(root, fileName);
13509
13711
  const content = overlaidContent(absolute) ?? (() => {
13510
13712
  if (isTypeScriptLib(fileName)) {
13511
13713
  try {
@@ -13517,9 +13719,9 @@ function createScopedProgram(options) {
13517
13719
  if (!allowed.has(foldPathKey(absolute))) return void 0;
13518
13720
  const confined = canonicalCandidate(root, absolute);
13519
13721
  if (confined === null) return void 0;
13520
- const relative20 = path32__namespace.relative(root, confined).replace(/\\/g, "/");
13521
- if (isSensitivePath(relative20)) return void 0;
13522
- const read = readConfinedText(root, relative20);
13722
+ const relative21 = path33__namespace.relative(root, confined).replace(/\\/g, "/");
13723
+ if (isSensitivePath(relative21)) return void 0;
13724
+ const read = readConfinedText(root, relative21);
13523
13725
  return read.ok ? read.text : void 0;
13524
13726
  })();
13525
13727
  if (content === void 0) return void 0;
@@ -13531,14 +13733,14 @@ function createScopedProgram(options) {
13531
13733
  sourceKind(absolute)
13532
13734
  );
13533
13735
  },
13534
- getDefaultLibFileName: (compilerOptions2) => path32__namespace.join(TYPESCRIPT_LIB_DIR, ts2__default.default.getDefaultLibFileName(compilerOptions2)),
13736
+ getDefaultLibFileName: (compilerOptions2) => path33__namespace.join(TYPESCRIPT_LIB_DIR, ts2__default.default.getDefaultLibFileName(compilerOptions2)),
13535
13737
  writeFile: () => void 0,
13536
13738
  getCurrentDirectory: () => root,
13537
13739
  getCanonicalFileName,
13538
13740
  useCaseSensitiveFileNames: () => ts2__default.default.sys.useCaseSensitiveFileNames,
13539
13741
  getNewLine: () => "\n",
13540
13742
  fileExists: (fileName) => {
13541
- const absolute = path32__namespace.isAbsolute(fileName) ? fileName : path32__namespace.resolve(root, fileName);
13743
+ const absolute = path33__namespace.isAbsolute(fileName) ? fileName : path33__namespace.resolve(root, fileName);
13542
13744
  if (overlaidContent(absolute) !== void 0) return true;
13543
13745
  if (isTypeScriptLib(fileName)) {
13544
13746
  try {
@@ -13547,13 +13749,13 @@ function createScopedProgram(options) {
13547
13749
  return false;
13548
13750
  }
13549
13751
  }
13550
- const relative20 = path32__namespace.relative(root, absolute).replace(/\\/g, "/");
13551
- if (isSensitivePath(relative20)) return false;
13752
+ const relative21 = path33__namespace.relative(root, absolute).replace(/\\/g, "/");
13753
+ if (isSensitivePath(relative21)) return false;
13552
13754
  if (!allowed.has(foldPathKey(absolute))) return false;
13553
13755
  return canonicalCandidate(root, absolute) !== null;
13554
13756
  },
13555
13757
  readFile: (fileName) => {
13556
- const absolute = path32__namespace.isAbsolute(fileName) ? fileName : path32__namespace.resolve(root, fileName);
13758
+ const absolute = path33__namespace.isAbsolute(fileName) ? fileName : path33__namespace.resolve(root, fileName);
13557
13759
  const overlaid = overlaidContent(absolute);
13558
13760
  if (overlaid !== void 0) return overlaid;
13559
13761
  if (isTypeScriptLib(fileName)) {
@@ -13566,26 +13768,26 @@ function createScopedProgram(options) {
13566
13768
  if (!allowed.has(foldPathKey(absolute))) return void 0;
13567
13769
  const confined = canonicalCandidate(root, absolute);
13568
13770
  if (confined === null) return void 0;
13569
- const relative20 = path32__namespace.relative(root, confined).replace(/\\/g, "/");
13570
- if (isSensitivePath(relative20)) return void 0;
13571
- const read = readConfinedText(root, relative20);
13771
+ const relative21 = path33__namespace.relative(root, confined).replace(/\\/g, "/");
13772
+ if (isSensitivePath(relative21)) return void 0;
13773
+ const read = readConfinedText(root, relative21);
13572
13774
  return read.ok ? read.text : void 0;
13573
13775
  },
13574
13776
  readDirectory: (directory, extensions) => {
13575
- const absolute = path32__namespace.resolve(directory);
13777
+ const absolute = path33__namespace.resolve(directory);
13576
13778
  if (!inside(root, absolute)) return [];
13577
13779
  const result = [];
13578
13780
  for (const file of rootNames) {
13579
13781
  if (!inside(absolute, file)) continue;
13580
- const extension = path32__namespace.extname(file);
13782
+ const extension = path33__namespace.extname(file);
13581
13783
  if (!extensions.includes(extension)) continue;
13582
- if (isSensitivePath(path32__namespace.relative(root, file).replace(/\\/g, "/"))) continue;
13784
+ if (isSensitivePath(path33__namespace.relative(root, file).replace(/\\/g, "/"))) continue;
13583
13785
  result.push(file);
13584
13786
  }
13585
13787
  return result.sort();
13586
13788
  },
13587
13789
  directoryExists: (directory) => {
13588
- const absolute = path32__namespace.isAbsolute(directory) ? directory : path32__namespace.resolve(root, directory);
13790
+ const absolute = path33__namespace.isAbsolute(directory) ? directory : path33__namespace.resolve(root, directory);
13589
13791
  if (isTypeScriptLib(directory)) return true;
13590
13792
  if (!inside(root, absolute)) return false;
13591
13793
  try {
@@ -13670,7 +13872,7 @@ function sameRelativePath(left, right) {
13670
13872
  return CASE_INSENSITIVE_PATHS ? left.toLowerCase() === right.toLowerCase() : left === right;
13671
13873
  }
13672
13874
  function relativeInRoot(root, fileName) {
13673
- return path32__namespace.relative(root, path32__namespace.resolve(fileName)).replace(/\\/g, "/");
13875
+ return path33__namespace.relative(root, path33__namespace.resolve(fileName)).replace(/\\/g, "/");
13674
13876
  }
13675
13877
  function symbolKey(checker, symbol, fileKeyCache) {
13676
13878
  if ((symbol.flags & ts2__default.default.SymbolFlags.Alias) === 0 && symbol.declarations?.[0]?.getSourceFile().isDeclarationFile === true) {
@@ -13718,8 +13920,8 @@ function resolveTargetSymbolKey(checker, program, root, target) {
13718
13920
  const normalizedTarget = target.targetPath?.replace(/\\/g, "/").replace(/^\.\/+/, "");
13719
13921
  for (const sourceFile of program.getSourceFiles()) {
13720
13922
  if (sourceFile.isDeclarationFile) continue;
13721
- const relative20 = relativeInRoot(root, sourceFile.fileName);
13722
- if (normalizedTarget !== void 0 && !sameRelativePath(relative20, normalizedTarget)) continue;
13923
+ const relative21 = relativeInRoot(root, sourceFile.fileName);
13924
+ if (normalizedTarget !== void 0 && !sameRelativePath(relative21, normalizedTarget)) continue;
13723
13925
  const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
13724
13926
  if (moduleSymbol !== void 0) {
13725
13927
  for (const exported of checker.getExportsOfModule(moduleSymbol)) {
@@ -13807,7 +14009,7 @@ function findMultipleSymbolReferences(options) {
13807
14009
  reasons.push("Symbol reference search exceeded its deadline; results are partial");
13808
14010
  break;
13809
14011
  }
13810
- const relative20 = relativeInRoot(roots.root, sourceFile.fileName);
14012
+ const relative21 = relativeInRoot(roots.root, sourceFile.fileName);
13811
14013
  const visit = (node) => {
13812
14014
  if (totalRefs >= maxResults) {
13813
14015
  truncated = true;
@@ -13826,7 +14028,7 @@ function findMultipleSymbolReferences(options) {
13826
14028
  const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
13827
14029
  const parent = node.parent;
13828
14030
  const ref = {
13829
- path: relative20,
14031
+ path: relative21,
13830
14032
  line: position.line + 1,
13831
14033
  column: position.character + 1,
13832
14034
  name: node.text,
@@ -13960,8 +14162,8 @@ function findSection(sections, relativePath) {
13960
14162
  if (exact) return exact;
13961
14163
  const foldedPath = rendered.toLowerCase();
13962
14164
  const folded = sections.filter((section) => {
13963
- const path33 = section.path.toLowerCase();
13964
- return path33 === relativePath.toLowerCase() || path33 === foldedPath;
14165
+ const path34 = section.path.toLowerCase();
14166
+ return path34 === relativePath.toLowerCase() || path34 === foldedPath;
13965
14167
  });
13966
14168
  return folded.length === 1 ? folded[0] : null;
13967
14169
  }
@@ -13986,7 +14188,7 @@ function windowText(body, fromLine, lineCount) {
13986
14188
  };
13987
14189
  }
13988
14190
  function workerEntry(directory, isCjs) {
13989
- const entry = path32__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
14191
+ const entry = path33__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
13990
14192
  return { path: entry, url: url.pathToFileURL(entry).href };
13991
14193
  }
13992
14194
  var WORKER_SOURCE = `
@@ -14057,7 +14259,7 @@ var WORKER_SOURCE = `
14057
14259
  })();
14058
14260
  `;
14059
14261
  function generateInWorker(cwd, cliOptions, options = {}) {
14060
- return new Promise((resolve21) => {
14262
+ return new Promise((resolve22) => {
14061
14263
  let settled = false;
14062
14264
  let worker = null;
14063
14265
  const finish = (result) => {
@@ -14068,11 +14270,11 @@ function generateInWorker(cwd, cliOptions, options = {}) {
14068
14270
  if (!result.ok && options.runId !== void 0 && options.lockRoots !== void 0) {
14069
14271
  releaseAbandonedRun(options.lockRoots, options.runId);
14070
14272
  }
14071
- resolve21(result);
14273
+ resolve22(result);
14072
14274
  });
14073
14275
  };
14074
14276
  const isCjs = typeof __dirname !== "undefined";
14075
- const directory = isCjs ? __dirname : path32__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
14277
+ const directory = isCjs ? __dirname : path33__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
14076
14278
  try {
14077
14279
  worker = new worker_threads.Worker(WORKER_SOURCE, {
14078
14280
  eval: true,
@@ -14182,7 +14384,7 @@ var WORKER_SOURCE2 = `
14182
14384
  })();
14183
14385
  `;
14184
14386
  function analysisInWorker(request) {
14185
- return new Promise((resolve21) => {
14387
+ return new Promise((resolve22) => {
14186
14388
  let settled = false;
14187
14389
  let worker = null;
14188
14390
  const timer = setTimeout(() => {
@@ -14194,10 +14396,10 @@ function analysisInWorker(request) {
14194
14396
  settled = true;
14195
14397
  clearTimeout(timer);
14196
14398
  const terminated = worker === null ? Promise.resolve(void 0) : worker.terminate();
14197
- void terminated.catch(() => void 0).then(() => resolve21(result));
14399
+ void terminated.catch(() => void 0).then(() => resolve22(result));
14198
14400
  };
14199
14401
  const isCjs = typeof __dirname !== "undefined";
14200
- const directory = isCjs ? __dirname : path32__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
14402
+ const directory = isCjs ? __dirname : path33__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
14201
14403
  try {
14202
14404
  worker = new worker_threads.Worker(WORKER_SOURCE2, {
14203
14405
  eval: true,
@@ -14226,7 +14428,7 @@ function foldForComparison(value) {
14226
14428
  return process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
14227
14429
  }
14228
14430
  function canonicalPath(value) {
14229
- const absolute = path32__namespace.resolve(value);
14431
+ const absolute = path33__namespace.resolve(value);
14230
14432
  try {
14231
14433
  return fs27__namespace.realpathSync(absolute);
14232
14434
  } catch {
@@ -14236,37 +14438,37 @@ function canonicalPath(value) {
14236
14438
  function isInside3(parent, child) {
14237
14439
  const foldedParent = foldForComparison(parent);
14238
14440
  const foldedChild = foldForComparison(child);
14239
- return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path32__namespace.sep}`);
14441
+ return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path33__namespace.sep}`);
14240
14442
  }
14241
14443
  function resolveThroughExistingAncestor(target) {
14242
14444
  let existing = target;
14243
14445
  const missing = [];
14244
14446
  while (!fs27__namespace.existsSync(existing)) {
14245
- missing.unshift(path32__namespace.basename(existing));
14246
- const parent = path32__namespace.dirname(existing);
14447
+ missing.unshift(path33__namespace.basename(existing));
14448
+ const parent = path33__namespace.dirname(existing);
14247
14449
  if (parent === existing) break;
14248
14450
  existing = parent;
14249
14451
  }
14250
14452
  const resolved = canonicalPath(existing);
14251
- return missing.length === 0 ? resolved : path32__namespace.join(resolved, ...missing);
14453
+ return missing.length === 0 ? resolved : path33__namespace.join(resolved, ...missing);
14252
14454
  }
14253
- function configuredOutputProblem(root, requested, permitted, label) {
14254
- const resolved = resolveThroughExistingAncestor(path32__namespace.resolve(root, requested));
14455
+ function configuredOutputProblem(root, requested, permitted, label2) {
14456
+ const resolved = resolveThroughExistingAncestor(path33__namespace.resolve(root, requested));
14255
14457
  if (permitted.some((allowed) => isInside3(canonicalPath(allowed), resolved))) return null;
14256
14458
  const shown = permitted.map((allowed) => canonicalPath(allowed)).join(", ");
14257
- return `"${label}" must resolve inside the repository this server serves (${shown}). A configuration file in the repository may not place snapshot output or staging outside the served root; move the directory inside the repository, or run the CLI directly.`;
14459
+ return `"${label2}" must resolve inside the repository this server serves (${shown}). A configuration file in the repository may not place snapshot output or staging outside the served root; move the directory inside the repository, or run the CLI directly.`;
14258
14460
  }
14259
14461
  function resolveRoot(requested, context) {
14260
14462
  if (requested !== void 0 && (typeof requested !== "string" || requested.trim().length === 0)) {
14261
14463
  return { ok: false, message: '"root" must be a non-empty string when provided.' };
14262
14464
  }
14263
14465
  const wanted = typeof requested === "string" ? requested.trim() : context.cwd;
14264
- const absolute = path32__namespace.resolve(context.cwd, wanted);
14466
+ const absolute = path33__namespace.resolve(context.cwd, wanted);
14265
14467
  const outside = () => ({
14266
14468
  ok: false,
14267
14469
  message: `"${wanted}" resolves outside the directories this server may read (${context.roots.join(", ")}). The server reads the directory it was started for; restart it with --cwd <directory> to serve a different repository.`
14268
14470
  });
14269
- const lexicalRoots = context.roots.map((allowed) => path32__namespace.resolve(allowed));
14471
+ const lexicalRoots = context.roots.map((allowed) => path33__namespace.resolve(allowed));
14270
14472
  if (!lexicalRoots.some((allowed) => isInside3(allowed, absolute))) return outside();
14271
14473
  let linkStats;
14272
14474
  try {
@@ -14338,7 +14540,7 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
14338
14540
  }
14339
14541
  const requested = overrides.outDir.trim();
14340
14542
  const permitted = allowedRoots !== void 0 && allowedRoots.length > 0 ? allowedRoots : [root];
14341
- const resolved = resolveThroughExistingAncestor(path32__namespace.resolve(root, requested));
14543
+ const resolved = resolveThroughExistingAncestor(path33__namespace.resolve(root, requested));
14342
14544
  if (!permitted.some((allowed) => isInside3(canonicalPath(allowed), resolved))) {
14343
14545
  const shown = permitted.map((allowed) => canonicalPath(allowed)).join(", ");
14344
14546
  return {
@@ -14378,11 +14580,11 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
14378
14580
  try {
14379
14581
  const config = resolveConfig(loaded.config, cliOptions, root);
14380
14582
  const permitted = allowedRoots !== void 0 && allowedRoots.length > 0 ? allowedRoots : [root];
14381
- for (const [label, value] of [
14583
+ for (const [label2, value] of [
14382
14584
  ["outDir", config.outDir],
14383
14585
  ["tmpDir", config.tmpDir]
14384
14586
  ]) {
14385
- const problem = configuredOutputProblem(root, value, permitted, label);
14587
+ const problem = configuredOutputProblem(root, value, permitted, label2);
14386
14588
  if (problem !== null) return { ok: false, message: problem };
14387
14589
  }
14388
14590
  return {
@@ -14409,14 +14611,14 @@ async function readLiveManifest(workspace, options = {}) {
14409
14611
  });
14410
14612
  }
14411
14613
  function manifestPathFor(workspace) {
14412
- return path32__namespace.resolve(workspace.root, workspace.config.outDir, "manifest.json");
14614
+ return path33__namespace.resolve(workspace.root, workspace.config.outDir, "manifest.json");
14413
14615
  }
14414
14616
  function partPathFor(workspace, filename) {
14415
14617
  if (filename.length === 0 || filename.includes("\0")) return null;
14416
- const partsDir = path32__namespace.resolve(workspace.root, workspace.config.outDir, "parts");
14417
- const resolved = path32__namespace.resolve(partsDir, filename);
14418
- const relative20 = path32__namespace.relative(partsDir, resolved);
14419
- if (relative20.length === 0 || relative20.includes(path32__namespace.sep) || relative20.includes("/") || relative20.includes("\\") || path32__namespace.isAbsolute(relative20)) {
14618
+ const partsDir = path33__namespace.resolve(workspace.root, workspace.config.outDir, "parts");
14619
+ const resolved = path33__namespace.resolve(partsDir, filename);
14620
+ const relative21 = path33__namespace.relative(partsDir, resolved);
14621
+ if (relative21.length === 0 || relative21.includes(path33__namespace.sep) || relative21.includes("/") || relative21.includes("\\") || path33__namespace.isAbsolute(relative21)) {
14420
14622
  return null;
14421
14623
  }
14422
14624
  let stats;
@@ -14427,12 +14629,12 @@ function partPathFor(workspace, filename) {
14427
14629
  }
14428
14630
  if (!stats.isFile()) return null;
14429
14631
  try {
14430
- const snapshotReal = fs27__namespace.realpathSync(path32__namespace.resolve(workspace.root, workspace.config.outDir));
14632
+ const snapshotReal = fs27__namespace.realpathSync(path33__namespace.resolve(workspace.root, workspace.config.outDir));
14431
14633
  const partsReal = fs27__namespace.realpathSync(partsDir);
14432
14634
  const resolvedReal = fs27__namespace.realpathSync(resolved);
14433
14635
  if (!isInside3(snapshotReal, partsReal)) return null;
14434
14636
  if (!isInside3(partsReal, resolvedReal)) return null;
14435
- if (path32__namespace.dirname(resolvedReal) !== partsReal) return null;
14637
+ if (path33__namespace.dirname(resolvedReal) !== partsReal) return null;
14436
14638
  } catch {
14437
14639
  return null;
14438
14640
  }
@@ -14450,8 +14652,8 @@ function sensitiveSnapshotProblem(manifest) {
14450
14652
  }
14451
14653
  function readManifest3(workspace) {
14452
14654
  const file = manifestPathFor(workspace);
14453
- const shown = path32__namespace.relative(workspace.root, file).split(path32__namespace.sep).join("/") || file;
14454
- const confined = readConfinedText(path32__namespace.dirname(file), path32__namespace.basename(file), MAX_MANIFEST_BYTES);
14655
+ const shown = path33__namespace.relative(workspace.root, file).split(path33__namespace.sep).join("/") || file;
14656
+ const confined = readConfinedText(path33__namespace.dirname(file), path33__namespace.basename(file), MAX_MANIFEST_BYTES);
14455
14657
  if (!confined.ok) {
14456
14658
  if (confined.reason === "missing") {
14457
14659
  return {
@@ -14588,7 +14790,7 @@ function formatBytes(bytes) {
14588
14790
  return (bytes / (1024 * 1024)).toFixed(1) + " MB";
14589
14791
  }
14590
14792
  function relativeFor(workspace, absolute) {
14591
- return path32__namespace.relative(workspace.root, absolute).split(path32__namespace.sep).join("/");
14793
+ return path33__namespace.relative(workspace.root, absolute).split(path33__namespace.sep).join("/");
14592
14794
  }
14593
14795
  function capped(values, limit = 20) {
14594
14796
  return { count: values.length, sample: values.slice(0, limit) };
@@ -14607,13 +14809,13 @@ function summarizeDrift(drift) {
14607
14809
  function toRelativePath(root, value) {
14608
14810
  const cleaned = value.trim();
14609
14811
  if (cleaned.length === 0 || cleaned.includes("\0")) return null;
14610
- const resolvedRoot = path32__namespace.resolve(root);
14611
- const absolute = path32__namespace.resolve(resolvedRoot, cleaned);
14612
- const relative20 = path32__namespace.relative(resolvedRoot, absolute);
14613
- if (relative20 === "" || relative20 === ".." || relative20.startsWith(".." + path32__namespace.sep) || path32__namespace.isAbsolute(relative20)) {
14812
+ const resolvedRoot = path33__namespace.resolve(root);
14813
+ const absolute = path33__namespace.resolve(resolvedRoot, cleaned);
14814
+ const relative21 = path33__namespace.relative(resolvedRoot, absolute);
14815
+ if (relative21 === "" || relative21 === ".." || relative21.startsWith(".." + path33__namespace.sep) || path33__namespace.isAbsolute(relative21)) {
14614
14816
  return null;
14615
14817
  }
14616
- return relative20.split(path32__namespace.sep).join("/");
14818
+ return relative21.split(path33__namespace.sep).join("/");
14617
14819
  }
14618
14820
  function symbolsOf(entry) {
14619
14821
  const summary = entry.summary;
@@ -14938,16 +15140,16 @@ var contextTool = {
14938
15140
  }
14939
15141
  }
14940
15142
  for (const wanted of wantedFiles) {
14941
- const relative20 = toRelativePath(workspace.root, wanted);
14942
- if (relative20 === null) {
15143
+ const relative21 = toRelativePath(workspace.root, wanted);
15144
+ if (relative21 === null) {
14943
15145
  preOmitted.push({ path: wanted, reason: "outside the served repository" });
14944
15146
  continue;
14945
15147
  }
14946
- if (isSensitivePath(relative20)) {
14947
- preOmitted.push({ path: relative20, reason: "sensitive-file" });
15148
+ if (isSensitivePath(relative21)) {
15149
+ preOmitted.push({ path: relative21, reason: "sensitive-file" });
14948
15150
  continue;
14949
15151
  }
14950
- targets.set(relative20, "requested file");
15152
+ targets.set(relative21, "requested file");
14951
15153
  }
14952
15154
  for (const symbol of wantedSymbols) {
14953
15155
  const needle = symbol.toLowerCase();
@@ -15456,7 +15658,7 @@ var validateTool = {
15456
15658
  const analysis2 = await analysisInWorker({
15457
15659
  task: "health",
15458
15660
  options: {
15459
- snapshotDir: path32__namespace.resolve(workspace.root, workspace.config.outDir),
15661
+ snapshotDir: path33__namespace.resolve(workspace.root, workspace.config.outDir),
15460
15662
  repoDir: workspace.root,
15461
15663
  // Only the project's own rules: `auditSnapshot` adds the built-in set itself for the
15462
15664
  // section scan. Passing all 32 here re-scans every raw part under its Markdown path,
@@ -15503,7 +15705,7 @@ var validateTool = {
15503
15705
  ["setting(s) changed since the snapshot", result.drift.configMismatches.length],
15504
15706
  ["internal count(s) disagreeing", result.drift.totalsMismatches.length]
15505
15707
  ];
15506
- for (const [label, count] of observations) if (count > 0) lines.push(" - " + count + " " + label);
15708
+ for (const [label2, count] of observations) if (count > 0) lines.push(" - " + count + " " + label2);
15507
15709
  for (const error of result.errors.slice(0, 5)) lines.push(" - " + error);
15508
15710
  lines.push("Run snapshot_generate to refresh it.");
15509
15711
  }
@@ -15664,7 +15866,7 @@ var generateTool = {
15664
15866
  const summary = result.summary;
15665
15867
  if (!dryRun) forgetManifest(manifestPathFor(workspace));
15666
15868
  const validationFailed = summary.validationStatus === "failed";
15667
- const written = relativeFor(workspace, path32__namespace.resolve(workspace.root, workspace.config.outDir));
15869
+ const written = relativeFor(workspace, path33__namespace.resolve(workspace.root, workspace.config.outDir));
15668
15870
  const lines = dryRun ? [
15669
15871
  "Dry run \u2014 nothing was written.",
15670
15872
  "Would include " + summary.totalFiles + " file(s) in " + summary.partsCount + " part(s).",
@@ -16005,6 +16207,25 @@ var COMMAND_OPTION_SCOPE = {
16005
16207
  "help",
16006
16208
  "version"
16007
16209
  ],
16210
+ guard: [
16211
+ "hook",
16212
+ "changed",
16213
+ "max-chars",
16214
+ "diff",
16215
+ "paths",
16216
+ "depth",
16217
+ "max-results",
16218
+ "no-cache",
16219
+ "no-live",
16220
+ "cwd",
16221
+ "out-dir",
16222
+ "no-config",
16223
+ "format",
16224
+ "mode",
16225
+ "no-update-check",
16226
+ "help",
16227
+ "version"
16228
+ ],
16008
16229
  brief: [
16009
16230
  "diff",
16010
16231
  "paths",
@@ -16157,6 +16378,7 @@ var COMMAND_ORDER = [
16157
16378
  "health",
16158
16379
  "report",
16159
16380
  "impact",
16381
+ "guard",
16160
16382
  "brief",
16161
16383
  "explain",
16162
16384
  "update",
@@ -16379,6 +16601,13 @@ function buildAgentContract() {
16379
16601
  positionals: [],
16380
16602
  exits: [0, 1, 2]
16381
16603
  },
16604
+ {
16605
+ name: "guard",
16606
+ aliases: [],
16607
+ summary: "Check whether a change is complete: untouched consumers, candidate tests, affected routes, and a trust stamp, in one small report. With --hook <claude|copilot|codex|raw>, read one hook payload from stdin and emit the host-shaped additionalContext, or an empty object when there is nothing to say. Defaults to the working tree against HEAD.",
16608
+ positionals: [],
16609
+ exits: [0, 1, 2]
16610
+ },
16382
16611
  {
16383
16612
  name: "brief",
16384
16613
  aliases: [],
@@ -16540,6 +16769,27 @@ function buildAgentContract() {
16540
16769
  appliesTo: optionAppliesTo("include-cycles"),
16541
16770
  summary: "impact only: include import cycles in the impacted subgraph."
16542
16771
  },
16772
+ {
16773
+ flag: "--hook",
16774
+ type: "string",
16775
+ default: "unset",
16776
+ appliesTo: optionAppliesTo("hook"),
16777
+ summary: "guard only: read one hook payload from stdin and shape the response for claude, copilot, codex, or raw. Fail-open: an error returns an empty object and a stderr note."
16778
+ },
16779
+ {
16780
+ flag: "--changed",
16781
+ type: "boolean",
16782
+ default: false,
16783
+ appliesTo: optionAppliesTo("changed"),
16784
+ summary: "guard only: check the working tree against HEAD. This is the default when --hook is not given."
16785
+ },
16786
+ {
16787
+ flag: "--max-chars",
16788
+ type: "number",
16789
+ default: 1200,
16790
+ appliesTo: optionAppliesTo("max-chars"),
16791
+ summary: "guard only: cap on the model-facing hook text (minimum 200, maximum 10000)."
16792
+ },
16543
16793
  {
16544
16794
  flag: "--copy",
16545
16795
  type: "boolean",
@@ -17445,12 +17695,12 @@ function buildResourceProvider() {
17445
17695
  }
17446
17696
  ];
17447
17697
  const workspace = await workspaceFor(context);
17448
- const reportsDir = "error" in workspace ? null : path32__namespace.resolve(workspace.root, workspace.config.outDir, "reports");
17698
+ const reportsDir = "error" in workspace ? null : path33__namespace.resolve(workspace.root, workspace.config.outDir, "reports");
17449
17699
  if ("error" in workspace) return resources;
17450
17700
  const read = readManifest3(workspace);
17451
17701
  if (!read.ok) return resources;
17452
17702
  for (const [uri, report2] of REPORT_URIS) {
17453
- const present = reportsDir !== null && fs27__namespace.existsSync(path32__namespace.join(reportsDir, report2.file));
17703
+ const present = reportsDir !== null && fs27__namespace.existsSync(path33__namespace.join(reportsDir, report2.file));
17454
17704
  if (!present) continue;
17455
17705
  resources.push({
17456
17706
  uri,
@@ -17514,7 +17764,7 @@ function buildResourceProvider() {
17514
17764
  "The repository could not be opened, so this resource is unavailable: " + workspace.error
17515
17765
  );
17516
17766
  }
17517
- const snapshotDir = path32__namespace.resolve(workspace.root, workspace.config.outDir);
17767
+ const snapshotDir = path33__namespace.resolve(workspace.root, workspace.config.outDir);
17518
17768
  if (uri === PROMPT_URI || REPORT_URIS.has(uri)) {
17519
17769
  const read = readManifest3(workspace);
17520
17770
  if (!read.ok) {
@@ -17537,7 +17787,7 @@ function buildResourceProvider() {
17537
17787
  }
17538
17788
  const report2 = REPORT_URIS.get(uri);
17539
17789
  if (report2) {
17540
- const read = readConfinedText(snapshotDir, path32__namespace.posix.join("reports", report2.file));
17790
+ const read = readConfinedText(snapshotDir, path33__namespace.posix.join("reports", report2.file));
17541
17791
  if (!read.ok) {
17542
17792
  throw new ResourceNotFoundError(
17543
17793
  uri,
@@ -17555,7 +17805,7 @@ function buildResourceProvider() {
17555
17805
  if (!read.ok) {
17556
17806
  throw new ResourceNotFoundError(uri, read.message);
17557
17807
  }
17558
- const confined = readConfinedText(path32__namespace.dirname(read.file), path32__namespace.basename(read.file));
17808
+ const confined = readConfinedText(path33__namespace.dirname(read.file), path33__namespace.basename(read.file));
17559
17809
  if (!confined.ok) {
17560
17810
  throw new ResourceNotFoundError(
17561
17811
  uri,
@@ -17629,41 +17879,41 @@ function validateArguments(schema, value) {
17629
17879
  }
17630
17880
  return problems;
17631
17881
  }
17632
- function checkValue(path33, schema, value) {
17882
+ function checkValue(path34, schema, value) {
17633
17883
  if (schema.enum && !schema.enum.includes(value)) {
17634
- return [`"${path33}" must be one of: ${schema.enum.join(", ")}`];
17884
+ return [`"${path34}" must be one of: ${schema.enum.join(", ")}`];
17635
17885
  }
17636
17886
  const declared = schema.type === void 0 ? [] : Array.isArray(schema.type) ? schema.type : [schema.type];
17637
17887
  if (declared.length > 0 && !declared.some((type) => matchesType(type, value))) {
17638
17888
  if (declared.length === 1 && declared[0] === "integer" && typeof value !== "number") {
17639
- return [`"${path33}" must be a number`];
17889
+ return [`"${path34}" must be a number`];
17640
17890
  }
17641
17891
  const article = (type) => type === "integer" || type === "object" || type === "array" ? `an ${type}` : `a ${type}`;
17642
- return [`"${path33}" must be ${declared.map(article).join(" or ")}`];
17892
+ return [`"${path34}" must be ${declared.map(article).join(" or ")}`];
17643
17893
  }
17644
17894
  const problems = [];
17645
17895
  if (declared.includes("string") && typeof value === "string") {
17646
17896
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
17647
- problems.push(`"${path33}" must be at least ${schema.minLength} character(s)`);
17897
+ problems.push(`"${path34}" must be at least ${schema.minLength} character(s)`);
17648
17898
  }
17649
17899
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
17650
- problems.push(`"${path33}" must be at most ${schema.maxLength} character(s)`);
17900
+ problems.push(`"${path34}" must be at most ${schema.maxLength} character(s)`);
17651
17901
  }
17652
17902
  }
17653
17903
  if ((declared.includes("number") || declared.includes("integer")) && typeof value === "number" && !Number.isNaN(value)) {
17654
17904
  if (declared.includes("integer") && !declared.includes("number") && !Number.isInteger(value)) {
17655
- problems.push(`"${path33}" must be an integer`);
17905
+ problems.push(`"${path34}" must be an integer`);
17656
17906
  }
17657
17907
  if (schema.minimum !== void 0 && value < schema.minimum) {
17658
- problems.push(`"${path33}" must be >= ${schema.minimum}`);
17908
+ problems.push(`"${path34}" must be >= ${schema.minimum}`);
17659
17909
  }
17660
17910
  if (schema.maximum !== void 0 && value > schema.maximum) {
17661
- problems.push(`"${path33}" must be <= ${schema.maximum}`);
17911
+ problems.push(`"${path34}" must be <= ${schema.maximum}`);
17662
17912
  }
17663
17913
  }
17664
17914
  if (declared.includes("array") && Array.isArray(value) && schema.items) {
17665
17915
  value.forEach((item, index) => {
17666
- problems.push(...checkValue(`${path33}[${index}]`, schema.items, item));
17916
+ problems.push(...checkValue(`${path34}[${index}]`, schema.items, item));
17667
17917
  });
17668
17918
  }
17669
17919
  return problems;
@@ -18060,11 +18310,11 @@ var MAX_LINE_BYTES = 32 * 1024 * 1024;
18060
18310
  function createWriter(output) {
18061
18311
  return {
18062
18312
  write(value) {
18063
- return new Promise((resolve21, reject) => {
18313
+ return new Promise((resolve22, reject) => {
18064
18314
  output.write(`${JSON.stringify(value)}
18065
18315
  `, (error) => {
18066
18316
  if (error) reject(error);
18067
- else resolve21();
18317
+ else resolve22();
18068
18318
  });
18069
18319
  });
18070
18320
  }
@@ -18209,8 +18459,8 @@ async function runStdioServer(options) {
18209
18459
  let inFlight = 0;
18210
18460
  let inputEnded = false;
18211
18461
  let resolveDone = () => void 0;
18212
- const finished = new Promise((resolve21) => {
18213
- resolveDone = resolve21;
18462
+ const finished = new Promise((resolve22) => {
18463
+ resolveDone = resolve22;
18214
18464
  });
18215
18465
  const finishIfIdle = () => {
18216
18466
  if (inputEnded && inFlight === 0) resolveDone(0);
@@ -19134,11 +19384,11 @@ async function startHttpTransport(options) {
19134
19384
  }
19135
19385
  send(405, { error: "method not allowed" }, { ...cors, allow: "POST, GET, OPTIONS, DELETE" });
19136
19386
  });
19137
- await new Promise((resolve21, reject) => {
19387
+ await new Promise((resolve22, reject) => {
19138
19388
  httpServer.once("error", reject);
19139
19389
  httpServer.listen(port, host, () => {
19140
19390
  httpServer.removeListener("error", reject);
19141
- resolve21();
19391
+ resolve22();
19142
19392
  });
19143
19393
  });
19144
19394
  const address = httpServer.address();
@@ -19151,8 +19401,8 @@ async function startHttpTransport(options) {
19151
19401
  token,
19152
19402
  close: async () => {
19153
19403
  await mcp.close();
19154
- await new Promise((resolve21) => {
19155
- httpServer.close(() => resolve21());
19404
+ await new Promise((resolve22) => {
19405
+ httpServer.close(() => resolve22());
19156
19406
  httpServer.closeAllConnections();
19157
19407
  });
19158
19408
  }
@@ -19190,10 +19440,10 @@ function walkFiles(root, prefix = "") {
19190
19440
  const stack = [prefix];
19191
19441
  while (stack.length > 0) {
19192
19442
  const current = stack.pop();
19193
- for (const entry of fs27__namespace.readdirSync(path32__namespace.join(root, current), { withFileTypes: true })) {
19194
- const relative20 = current === "" ? entry.name : current + "/" + entry.name;
19195
- if (entry.isDirectory()) stack.push(relative20);
19196
- else if (entry.isFile()) files.push(relative20);
19443
+ for (const entry of fs27__namespace.readdirSync(path33__namespace.join(root, current), { withFileTypes: true })) {
19444
+ const relative21 = current === "" ? entry.name : current + "/" + entry.name;
19445
+ if (entry.isDirectory()) stack.push(relative21);
19446
+ else if (entry.isFile()) files.push(relative21);
19197
19447
  }
19198
19448
  }
19199
19449
  return files;
@@ -19207,16 +19457,16 @@ function writeZip(options) {
19207
19457
  }
19208
19458
  if (options.directory !== void 0) {
19209
19459
  const root = options.directory;
19210
- for (const relative20 of walkFiles(root)) {
19211
- if (options.skip !== void 0 && options.skip(relative20)) continue;
19212
- const full = path32__namespace.join(root, relative20);
19460
+ for (const relative21 of walkFiles(root)) {
19461
+ if (options.skip !== void 0 && options.skip(relative21)) continue;
19462
+ const full = path33__namespace.join(root, relative21);
19213
19463
  const stat = fs27__namespace.statSync(full);
19214
19464
  if (totalBytes + stat.size > maxTotalBytes) {
19215
19465
  throw new Error("zip: uncompressed content exceeds " + maxTotalBytes + " bytes");
19216
19466
  }
19217
19467
  const content = fs27__namespace.readFileSync(full);
19218
19468
  totalBytes += content.length;
19219
- entries.push({ name: relative20, content, mtime: stat.mtime });
19469
+ entries.push({ name: relative21, content, mtime: stat.mtime });
19220
19470
  }
19221
19471
  }
19222
19472
  if (entries.length > 65535) {
@@ -19497,7 +19747,7 @@ async function startWebServer(options) {
19497
19747
  const pendingClones = /* @__PURE__ */ new Set();
19498
19748
  let closing = false;
19499
19749
  let generateJobs = 0;
19500
- const allowedRoots = [path32__namespace.resolve(options.cwd)];
19750
+ const allowedRoots = [path33__namespace.resolve(options.cwd)];
19501
19751
  const snapshotRepoRoots = /* @__PURE__ */ new Map();
19502
19752
  const canonical = (candidate) => {
19503
19753
  try {
@@ -19510,32 +19760,32 @@ async function startWebServer(options) {
19510
19760
  const inside2 = (resolved) => allowedRoots.some((root) => {
19511
19761
  const canonicalRoot2 = canonical(root);
19512
19762
  if (canonicalRoot2 === null) return false;
19513
- const relative20 = path32__namespace.relative(fold(canonicalRoot2), fold(resolved));
19514
- return relative20 === "" || !relative20.startsWith(`..${path32__namespace.sep}`) && relative20 !== ".." && !path32__namespace.isAbsolute(relative20);
19763
+ const relative21 = path33__namespace.relative(fold(canonicalRoot2), fold(resolved));
19764
+ return relative21 === "" || !relative21.startsWith(`..${path33__namespace.sep}`) && relative21 !== ".." && !path33__namespace.isAbsolute(relative21);
19515
19765
  });
19516
19766
  const insideAllowedRoots = (candidate) => {
19517
19767
  const resolved = canonical(candidate);
19518
19768
  return resolved === null ? false : inside2(resolved);
19519
19769
  };
19520
19770
  const lexicallyInside = (candidate) => {
19521
- const resolved = fold(path32__namespace.resolve(candidate));
19771
+ const resolved = fold(path33__namespace.resolve(candidate));
19522
19772
  return allowedRoots.some((root) => {
19523
- const resolvedRoot = fold(path32__namespace.resolve(root));
19524
- return resolved === resolvedRoot || resolved.startsWith(resolvedRoot + path32__namespace.sep);
19773
+ const resolvedRoot = fold(path33__namespace.resolve(root));
19774
+ return resolved === resolvedRoot || resolved.startsWith(resolvedRoot + path33__namespace.sep);
19525
19775
  });
19526
19776
  };
19527
19777
  const insideAllowedRootsForWrite = (candidate) => {
19528
- let existing = path32__namespace.resolve(candidate);
19778
+ let existing = path33__namespace.resolve(candidate);
19529
19779
  const tail = [];
19530
19780
  while (!fs27__namespace.existsSync(existing)) {
19531
- tail.unshift(path32__namespace.basename(existing));
19532
- const parent = path32__namespace.dirname(existing);
19781
+ tail.unshift(path33__namespace.basename(existing));
19782
+ const parent = path33__namespace.dirname(existing);
19533
19783
  if (parent === existing) break;
19534
19784
  existing = parent;
19535
19785
  }
19536
19786
  const resolved = canonical(existing);
19537
19787
  if (resolved === null) return false;
19538
- return inside2(tail.length === 0 ? resolved : path32__namespace.join(resolved, ...tail));
19788
+ return inside2(tail.length === 0 ? resolved : path33__namespace.join(resolved, ...tail));
19539
19789
  };
19540
19790
  const authorized = (request) => {
19541
19791
  if (token === null) return true;
@@ -19725,7 +19975,7 @@ async function startWebServer(options) {
19725
19975
  return;
19726
19976
  }
19727
19977
  } else {
19728
- target = path32__namespace.resolve(options.cwd, source);
19978
+ target = path33__namespace.resolve(options.cwd, source);
19729
19979
  if (!lexicallyInside(target)) {
19730
19980
  send(403, { error: "outside the served directory: " + target });
19731
19981
  return;
@@ -19767,13 +20017,13 @@ async function startWebServer(options) {
19767
20017
  hooks: {}
19768
20018
  } : loaded.config ?? {};
19769
20019
  const configuredOutDir = typeof runConfig.outDir === "string" && runConfig.outDir.trim() !== "" ? runConfig.outDir : "snapshot";
19770
- const snapshotDir = path32__namespace.resolve(target, configuredOutDir);
20020
+ const snapshotDir = path33__namespace.resolve(target, configuredOutDir);
19771
20021
  if (!insideAllowedRootsForWrite(snapshotDir)) {
19772
20022
  send(403, { error: "the configured outDir resolves outside the served directory" });
19773
20023
  return;
19774
20024
  }
19775
20025
  const configuredTmpDir = typeof runConfig.tmpDir === "string" && runConfig.tmpDir.trim() !== "" ? runConfig.tmpDir : "snapshot.tmp";
19776
- const stagingDir = path32__namespace.resolve(target, configuredTmpDir);
20026
+ const stagingDir = path33__namespace.resolve(target, configuredTmpDir);
19777
20027
  if (!insideAllowedRootsForWrite(stagingDir)) {
19778
20028
  send(403, { error: "the configured tmpDir resolves outside the served directory" });
19779
20029
  return;
@@ -19808,8 +20058,8 @@ async function startWebServer(options) {
19808
20058
  }
19809
20059
  const seconds = ((Date.now() - started) / 1e3).toFixed(2);
19810
20060
  snapshotRepoRoots.set(
19811
- canonical(snapshotDir) ?? path32__namespace.resolve(snapshotDir),
19812
- path32__namespace.resolve(target)
20061
+ canonical(snapshotDir) ?? path33__namespace.resolve(snapshotDir),
20062
+ path33__namespace.resolve(target)
19813
20063
  );
19814
20064
  const audit = await analysisInWorker({
19815
20065
  task: "health",
@@ -19854,7 +20104,7 @@ async function startWebServer(options) {
19854
20104
  return;
19855
20105
  }
19856
20106
  if (request.method === "GET" && request.url?.startsWith("/api/health?") === true) {
19857
- const target = path32__namespace.resolve(options.cwd, url.searchParams.get("path") ?? options.cwd);
20107
+ const target = path33__namespace.resolve(options.cwd, url.searchParams.get("path") ?? options.cwd);
19858
20108
  if (!lexicallyInside(target)) {
19859
20109
  send(403, { error: "outside the served directory: " + target });
19860
20110
  return;
@@ -19867,12 +20117,12 @@ async function startWebServer(options) {
19867
20117
  send(403, { error: "outside the served directory: " + target });
19868
20118
  return;
19869
20119
  }
19870
- const repoDir = snapshotRepoRoots.get(canonical(target) ?? path32__namespace.resolve(target)) ?? path32__namespace.resolve(options.cwd);
20120
+ const repoDir = snapshotRepoRoots.get(canonical(target) ?? path33__namespace.resolve(target)) ?? path33__namespace.resolve(options.cwd);
19871
20121
  if (!insideAllowedRoots(repoDir)) {
19872
20122
  send(403, { error: "the repository root for this snapshot is outside the served directory" });
19873
20123
  return;
19874
20124
  }
19875
- if (!fs27__namespace.existsSync(path32__namespace.join(target, "manifest.json"))) {
20125
+ if (!fs27__namespace.existsSync(path33__namespace.join(target, "manifest.json"))) {
19876
20126
  send(404, { error: "no manifest.json under " + target });
19877
20127
  return;
19878
20128
  }
@@ -19892,7 +20142,7 @@ async function startWebServer(options) {
19892
20142
  return;
19893
20143
  }
19894
20144
  if (request.method === "GET" && (request.url?.startsWith("/api/snapshot?") === true || request.url === "/api/snapshot")) {
19895
- const target = path32__namespace.resolve(options.cwd, url.searchParams.get("path") ?? options.cwd);
20145
+ const target = path33__namespace.resolve(options.cwd, url.searchParams.get("path") ?? options.cwd);
19896
20146
  if (!lexicallyInside(target)) {
19897
20147
  send(403, { error: "outside the served directory: " + target });
19898
20148
  return;
@@ -19945,7 +20195,7 @@ async function startWebServer(options) {
19945
20195
  return;
19946
20196
  }
19947
20197
  if (request.method === "GET" && request.url?.startsWith("/api/snapshot.zip") === true) {
19948
- const target = path32__namespace.resolve(options.cwd, url.searchParams.get("path") ?? options.cwd);
20198
+ const target = path33__namespace.resolve(options.cwd, url.searchParams.get("path") ?? options.cwd);
19949
20199
  if (!lexicallyInside(target)) {
19950
20200
  send(403, { error: "outside the served directory: " + target });
19951
20201
  return;
@@ -19989,15 +20239,15 @@ async function startWebServer(options) {
19989
20239
  }
19990
20240
  }
19991
20241
  const artifactRecord = zipManifest.artifacts ?? {};
19992
- for (const [key, relative20] of Object.entries(ARTIFACT_PATHS)) {
19993
- if (artifactRecord[key] !== void 0 && artifactRecord[key] !== null) wanted.add(relative20);
20242
+ for (const [key, relative21] of Object.entries(ARTIFACT_PATHS)) {
20243
+ if (artifactRecord[key] !== void 0 && artifactRecord[key] !== null) wanted.add(relative21);
19994
20244
  }
19995
20245
  wanted.add("signature.json");
19996
20246
  const entries = [];
19997
- for (const relative20 of wanted) {
19998
- const read = readConfinedBytes(target, relative20, 256 * 1024 * 1024);
20247
+ for (const relative21 of wanted) {
20248
+ const read = readConfinedBytes(target, relative21, 256 * 1024 * 1024);
19999
20249
  if (!read.ok) continue;
20000
- entries.push({ name: relative20, content: read.bytes, mtime: read.stats.mtime });
20250
+ entries.push({ name: relative21, content: read.bytes, mtime: read.stats.mtime });
20001
20251
  }
20002
20252
  if (entries.length === 0) {
20003
20253
  send(404, { error: "the snapshot manifest declares no readable files" });
@@ -20019,11 +20269,11 @@ async function startWebServer(options) {
20019
20269
  }
20020
20270
  send(404, { error: "not found" });
20021
20271
  });
20022
- await new Promise((resolve21, reject) => {
20272
+ await new Promise((resolve22, reject) => {
20023
20273
  server.once("error", reject);
20024
20274
  server.listen(port, host, () => {
20025
20275
  server.removeListener("error", reject);
20026
- resolve21();
20276
+ resolve22();
20027
20277
  });
20028
20278
  });
20029
20279
  const address = server.address();
@@ -20040,7 +20290,7 @@ async function startWebServer(options) {
20040
20290
  await mcp.close();
20041
20291
  const deadline = Date.now() + 5e3;
20042
20292
  while (pendingClones.size > 0 && Date.now() < deadline) {
20043
- await new Promise((resolve21) => setTimeout(resolve21, 50));
20293
+ await new Promise((resolve22) => setTimeout(resolve22, 50));
20044
20294
  }
20045
20295
  for (const directory of [...pendingClones, ...temporaryClones]) {
20046
20296
  try {
@@ -20049,8 +20299,8 @@ async function startWebServer(options) {
20049
20299
  }
20050
20300
  }
20051
20301
  server.closeAllConnections();
20052
- await new Promise((resolve21) => {
20053
- server.close(() => resolve21());
20302
+ await new Promise((resolve22) => {
20303
+ server.close(() => resolve22());
20054
20304
  });
20055
20305
  }
20056
20306
  };
@@ -20103,17 +20353,17 @@ function isNewer(candidate, current) {
20103
20353
  }
20104
20354
  function cacheDirectory(env = process.env, platform = process.platform) {
20105
20355
  if (platform === "win32") {
20106
- const base2 = env.LOCALAPPDATA ?? path32__namespace.join(os2__namespace.homedir(), "AppData", "Local");
20107
- return path32__namespace.join(base2, "codebase-snapshot");
20356
+ const base2 = env.LOCALAPPDATA ?? path33__namespace.join(os2__namespace.homedir(), "AppData", "Local");
20357
+ return path33__namespace.join(base2, "codebase-snapshot");
20108
20358
  }
20109
20359
  if (platform === "darwin") {
20110
- return path32__namespace.join(os2__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
20360
+ return path33__namespace.join(os2__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
20111
20361
  }
20112
- const base = env.XDG_CACHE_HOME ?? path32__namespace.join(os2__namespace.homedir(), ".cache");
20113
- return path32__namespace.join(base, "codebase-snapshot");
20362
+ const base = env.XDG_CACHE_HOME ?? path33__namespace.join(os2__namespace.homedir(), ".cache");
20363
+ return path33__namespace.join(base, "codebase-snapshot");
20114
20364
  }
20115
20365
  function cacheFilePath(env = process.env) {
20116
- return path32__namespace.join(cacheDirectory(env), "update-check.json");
20366
+ return path33__namespace.join(cacheDirectory(env), "update-check.json");
20117
20367
  }
20118
20368
  function shouldCheck(argv, env) {
20119
20369
  const disabled = ["1", "true", "yes"].includes(
@@ -20160,21 +20410,21 @@ function readCache(file) {
20160
20410
  }
20161
20411
  function writeCache(file, entry) {
20162
20412
  try {
20163
- fs27__namespace.mkdirSync(path32__namespace.dirname(file), { recursive: true });
20413
+ fs27__namespace.mkdirSync(path33__namespace.dirname(file), { recursive: true });
20164
20414
  fs27__namespace.writeFileSync(file, `${JSON.stringify(entry)}
20165
20415
  `, "utf8");
20166
20416
  } catch {
20167
20417
  }
20168
20418
  }
20169
20419
  function fetchLatestVersion(url = PACKAGE_LATEST_URL, timeoutMs = REQUEST_TIMEOUT_MS) {
20170
- return new Promise((resolve21) => {
20420
+ return new Promise((resolve22) => {
20171
20421
  let settled = false;
20172
20422
  let request = null;
20173
20423
  const finish = (value) => {
20174
20424
  if (settled) return;
20175
20425
  settled = true;
20176
20426
  clearTimeout(deadline);
20177
- resolve21(value);
20427
+ resolve22(value);
20178
20428
  };
20179
20429
  const deadline = setTimeout(() => {
20180
20430
  request?.destroy();
@@ -20276,16 +20526,16 @@ var TEXT_ARTIFACT = /\.(md|json|txt|sarif|xml)$/i;
20276
20526
  function sha256(buffer) {
20277
20527
  return crypto.createHash("sha256").update(buffer).digest("hex");
20278
20528
  }
20279
- function snapshotText(snapshotDir, relative20) {
20280
- const read = readConfinedText(snapshotDir, relative20);
20529
+ function snapshotText(snapshotDir, relative21) {
20530
+ const read = readConfinedText(snapshotDir, relative21);
20281
20531
  return read.ok ? read.text : null;
20282
20532
  }
20283
- function snapshotBytes(snapshotDir, relative20) {
20284
- const read = readConfinedBytes(snapshotDir, relative20);
20533
+ function snapshotBytes(snapshotDir, relative21) {
20534
+ const read = readConfinedBytes(snapshotDir, relative21);
20285
20535
  return read.ok ? read.bytes : null;
20286
20536
  }
20287
20537
  function readJson2(file) {
20288
- const confined = readConfinedText(path32__namespace.dirname(file), path32__namespace.basename(file));
20538
+ const confined = readConfinedText(path33__namespace.dirname(file), path33__namespace.basename(file));
20289
20539
  const text2 = confined.ok ? confined.text : null;
20290
20540
  if (text2 === null) return null;
20291
20541
  try {
@@ -20303,9 +20553,9 @@ function walk(dir, prefix = "") {
20303
20553
  }
20304
20554
  const files = [];
20305
20555
  for (const entry of entries) {
20306
- const relative20 = prefix === "" ? entry.name : prefix + "/" + entry.name;
20307
- if (entry.isDirectory()) files.push(...walk(path32__namespace.join(dir, entry.name), relative20));
20308
- else if (entry.isFile()) files.push(relative20);
20556
+ const relative21 = prefix === "" ? entry.name : prefix + "/" + entry.name;
20557
+ if (entry.isDirectory()) files.push(...walk(path33__namespace.join(dir, entry.name), relative21));
20558
+ else if (entry.isFile()) files.push(relative21);
20309
20559
  }
20310
20560
  return files;
20311
20561
  }
@@ -20347,9 +20597,9 @@ function readArtifactTexts(snapshotDir, maxBytes = 32 * 1024 * 1024) {
20347
20597
  const texts = [];
20348
20598
  let bytes = 0;
20349
20599
  let truncated = false;
20350
- for (const relative20 of walk(snapshotDir)) {
20351
- if (!TEXT_ARTIFACT.test(relative20)) continue;
20352
- const full = path32__namespace.join(snapshotDir, relative20);
20600
+ for (const relative21 of walk(snapshotDir)) {
20601
+ if (!TEXT_ARTIFACT.test(relative21)) continue;
20602
+ const full = path33__namespace.join(snapshotDir, relative21);
20353
20603
  let size2;
20354
20604
  try {
20355
20605
  size2 = fs27__namespace.statSync(full).size;
@@ -20360,7 +20610,7 @@ function readArtifactTexts(snapshotDir, maxBytes = 32 * 1024 * 1024) {
20360
20610
  truncated = true;
20361
20611
  continue;
20362
20612
  }
20363
- const text2 = snapshotText(snapshotDir, relative20);
20613
+ const text2 = snapshotText(snapshotDir, relative21);
20364
20614
  if (text2 !== null) {
20365
20615
  texts.push(text2);
20366
20616
  bytes += Buffer.byteLength(text2, "utf8");
@@ -20381,11 +20631,11 @@ function findHostPaths(snapshotDir, repoDir, maxBytes = 32 * 1024 * 1024) {
20381
20631
  const hits = /* @__PURE__ */ new Set();
20382
20632
  let scanned = 0;
20383
20633
  let truncated = false;
20384
- for (const relative20 of walk(snapshotDir)) {
20385
- if (!TEXT_ARTIFACT.test(relative20)) continue;
20634
+ for (const relative21 of walk(snapshotDir)) {
20635
+ if (!TEXT_ARTIFACT.test(relative21)) continue;
20386
20636
  let size2;
20387
20637
  try {
20388
- size2 = fs27__namespace.statSync(path32__namespace.join(snapshotDir, relative20)).size;
20638
+ size2 = fs27__namespace.statSync(path33__namespace.join(snapshotDir, relative21)).size;
20389
20639
  } catch {
20390
20640
  continue;
20391
20641
  }
@@ -20393,14 +20643,14 @@ function findHostPaths(snapshotDir, repoDir, maxBytes = 32 * 1024 * 1024) {
20393
20643
  truncated = true;
20394
20644
  continue;
20395
20645
  }
20396
- const text2 = snapshotText(snapshotDir, relative20);
20646
+ const text2 = snapshotText(snapshotDir, relative21);
20397
20647
  if (text2 === null) continue;
20398
20648
  scanned += Buffer.byteLength(text2, "utf8");
20399
20649
  for (const pattern of patterns) {
20400
- for (const match of text2.match(pattern) ?? []) hits.add(relative20 + ": " + match);
20650
+ for (const match of text2.match(pattern) ?? []) hits.add(relative21 + ": " + match);
20401
20651
  }
20402
20652
  repoPattern.lastIndex = 0;
20403
- if (repoPattern.test(text2)) hits.add(relative20 + ": the repository absolute path");
20653
+ if (repoPattern.test(text2)) hits.add(relative21 + ": the repository absolute path");
20404
20654
  }
20405
20655
  return { hits: [...hits], truncated };
20406
20656
  }
@@ -20458,13 +20708,13 @@ function summaryClaims(summary) {
20458
20708
  }
20459
20709
  return summary.headings.map((heading) => ({ field: "headings", value: heading }));
20460
20710
  }
20461
- function reportNumber(text2, label) {
20462
- const match = new RegExp("\\*\\*" + escapeRegExp(label) + ":\\*\\* `([0-9][0-9,]*)`").exec(text2);
20711
+ function reportNumber(text2, label2) {
20712
+ const match = new RegExp("\\*\\*" + escapeRegExp(label2) + ":\\*\\* `([0-9][0-9,]*)`").exec(text2);
20463
20713
  return match === null ? null : Number(match[1].replace(/,/g, ""));
20464
20714
  }
20465
- function reportMib(text2, label) {
20715
+ function reportMib(text2, label2) {
20466
20716
  const match = new RegExp(
20467
- "\\*\\*" + escapeRegExp(label) + ":\\*\\* `([0-9]+(?:\\.[0-9]+)?) MiB`"
20717
+ "\\*\\*" + escapeRegExp(label2) + ":\\*\\* `([0-9]+(?:\\.[0-9]+)?) MiB`"
20468
20718
  ).exec(text2);
20469
20719
  return match === null ? null : Number(match[1]);
20470
20720
  }
@@ -20550,10 +20800,10 @@ function markdownPackBodies(text2) {
20550
20800
  return bodies.size === 0 ? null : bodies;
20551
20801
  }
20552
20802
  function auditSnapshot(options) {
20553
- const snapshotDir = path32__namespace.resolve(options.snapshotDir);
20554
- const repoDir = path32__namespace.resolve(options.repoDir);
20803
+ const snapshotDir = path33__namespace.resolve(options.snapshotDir);
20804
+ const repoDir = path33__namespace.resolve(options.repoDir);
20555
20805
  const checks = [];
20556
- const manifestFile = path32__namespace.join(snapshotDir, "manifest.json");
20806
+ const manifestFile = path33__namespace.join(snapshotDir, "manifest.json");
20557
20807
  const raw = readJson2(manifestFile);
20558
20808
  const problem = raw === null ? "the file is missing or is not valid JSON" : describeManifestShapeProblem(raw);
20559
20809
  if (raw === null || problem !== null) {
@@ -20647,13 +20897,13 @@ function auditSnapshot(options) {
20647
20897
  let artifactCount = 0;
20648
20898
  for (const [key, value] of Object.entries(artifacts)) {
20649
20899
  if (value === null || value === void 0) continue;
20650
- const relative20 = ARTIFACT_FILES[key];
20651
- if (relative20 === void 0) continue;
20900
+ const relative21 = ARTIFACT_FILES[key];
20901
+ if (relative21 === void 0) continue;
20652
20902
  artifactCount += 1;
20653
- const bytes = snapshotBytes(snapshotDir, relative20);
20654
- if (bytes === null) artifactProblems.push(relative20 + " is missing");
20903
+ const bytes = snapshotBytes(snapshotDir, relative21);
20904
+ if (bytes === null) artifactProblems.push(relative21 + " is missing");
20655
20905
  else if (typeof value.sha256 === "string" && sha256(bytes) !== value.sha256) {
20656
- artifactProblems.push(relative20 + " changed");
20906
+ artifactProblems.push(relative21 + " changed");
20657
20907
  }
20658
20908
  }
20659
20909
  checks.push(
@@ -20697,7 +20947,7 @@ function auditSnapshot(options) {
20697
20947
  unexpected.length + " unexpected path(s): " + sample(unexpected)
20698
20948
  )
20699
20949
  );
20700
- const signaturePath = path32__namespace.join(snapshotDir, "signature.json");
20950
+ const signaturePath = path33__namespace.join(snapshotDir, "signature.json");
20701
20951
  if (fs27__namespace.existsSync(signaturePath)) {
20702
20952
  const outcome = verifySnapshotSignature(snapshotDir);
20703
20953
  checks.push(
@@ -20814,19 +21064,19 @@ function auditSnapshot(options) {
20814
21064
  );
20815
21065
  const reportProblems = [];
20816
21066
  let reportClaims = 0;
20817
- const compareNumber = (label, actual, expected) => {
21067
+ const compareNumber = (label2, actual, expected) => {
20818
21068
  if (actual === null) return;
20819
21069
  reportClaims += 1;
20820
21070
  if (actual !== expected) {
20821
- reportProblems.push(label + " says " + actual + ", the manifest says " + expected);
21071
+ reportProblems.push(label2 + " says " + actual + ", the manifest says " + expected);
20822
21072
  }
20823
21073
  };
20824
- const compareMib = (label, actual, bytes) => {
21074
+ const compareMib = (label2, actual, bytes) => {
20825
21075
  if (actual === null) return;
20826
21076
  reportClaims += 1;
20827
21077
  const expected = Number((bytes / (1024 * 1024)).toFixed(2));
20828
21078
  if (Math.abs(actual - expected) > 0.011) {
20829
- reportProblems.push(label + " says " + actual + " MiB, the manifest says " + expected);
21079
+ reportProblems.push(label2 + " says " + actual + " MiB, the manifest says " + expected);
20830
21080
  }
20831
21081
  };
20832
21082
  if (manifest.artifacts?.readme != null) {
@@ -21072,8 +21322,8 @@ function auditSnapshot(options) {
21072
21322
  for (const file of manifest.files) {
21073
21323
  if (!packed.has(file.relativePath)) problems.push(file.relativePath + " is in the manifest but not the pack");
21074
21324
  }
21075
- for (const path33 of packed) {
21076
- if (!known2.has(path33)) problems.push(path33 + " is in the pack but not the manifest");
21325
+ for (const path34 of packed) {
21326
+ if (!known2.has(path34)) problems.push(path34 + " is in the pack but not the manifest");
21077
21327
  }
21078
21328
  }
21079
21329
  }
@@ -21325,7 +21575,7 @@ function auditSnapshot(options) {
21325
21575
  )
21326
21576
  );
21327
21577
  }
21328
- const indexParent = path32__namespace.dirname(snapshotDir);
21578
+ const indexParent = path33__namespace.dirname(snapshotDir);
21329
21579
  const indexRead = readConfinedText(indexParent, "WORKSPACE.json");
21330
21580
  if (indexRead.ok) {
21331
21581
  let members = [];
@@ -21337,7 +21587,7 @@ function auditSnapshot(options) {
21337
21587
  } catch {
21338
21588
  problem2 = "it is not valid JSON";
21339
21589
  }
21340
- const memberName = path32__namespace.basename(snapshotDir);
21590
+ const memberName = path33__namespace.basename(snapshotDir);
21341
21591
  const member = members.find((entry) => entry.name === memberName);
21342
21592
  if (problem2 !== null) {
21343
21593
  checks.push(check(
@@ -21364,9 +21614,9 @@ function auditSnapshot(options) {
21364
21614
  let sourceGone = null;
21365
21615
  if (typeof member.path === "string") {
21366
21616
  const memberPath = member.path;
21367
- const candidates = [path32__namespace.dirname(indexParent), repoDir].map((anchor) => path32__namespace.resolve(anchor, memberPath)).filter((candidate) => {
21368
- const relative20 = path32__namespace.relative(repoDir, candidate);
21369
- return relative20 !== ".." && !relative20.startsWith(".." + path32__namespace.sep) && !path32__namespace.isAbsolute(relative20);
21617
+ const candidates = [path33__namespace.dirname(indexParent), repoDir].map((anchor) => path33__namespace.resolve(anchor, memberPath)).filter((candidate) => {
21618
+ const relative21 = path33__namespace.relative(repoDir, candidate);
21619
+ return relative21 !== ".." && !relative21.startsWith(".." + path33__namespace.sep) && !path33__namespace.isAbsolute(relative21);
21370
21620
  });
21371
21621
  const resolved = candidates.find((candidate) => fs27__namespace.existsSync(candidate)) ?? candidates[0];
21372
21622
  if (resolved === void 0) {
@@ -21378,8 +21628,8 @@ function auditSnapshot(options) {
21378
21628
  } catch {
21379
21629
  canonical = null;
21380
21630
  }
21381
- const canonicalRelative = canonical === null ? null : path32__namespace.relative(repoDir, canonical);
21382
- const canonicalInside = canonical !== null && (canonicalRelative === "" || canonicalRelative !== null && canonicalRelative !== ".." && !canonicalRelative.startsWith(`..${path32__namespace.sep}`) && !canonicalRelative.startsWith("../") && !path32__namespace.isAbsolute(canonicalRelative));
21631
+ const canonicalRelative = canonical === null ? null : path33__namespace.relative(repoDir, canonical);
21632
+ const canonicalInside = canonical !== null && (canonicalRelative === "" || canonicalRelative !== null && canonicalRelative !== ".." && !canonicalRelative.startsWith(`..${path33__namespace.sep}`) && !canonicalRelative.startsWith("../") && !path33__namespace.isAbsolute(canonicalRelative));
21383
21633
  if (canonical !== null && !canonicalInside) {
21384
21634
  sourceGone = "Member " + memberName + " source directory resolves outside the repository; not inspected.";
21385
21635
  } else if (canonical === null || !fs27__namespace.existsSync(resolved)) {
@@ -21409,12 +21659,12 @@ function auditSnapshot(options) {
21409
21659
  const leakHits = [];
21410
21660
  let scannedBytes = 0;
21411
21661
  let skippedArtifacts = 0;
21412
- for (const relative20 of walk(snapshotDir)) {
21413
- if (!TEXT_ARTIFACT.test(relative20)) continue;
21414
- if (relative20 === SIGNATURE_FILE) continue;
21662
+ for (const relative21 of walk(snapshotDir)) {
21663
+ if (!TEXT_ARTIFACT.test(relative21)) continue;
21664
+ if (relative21 === SIGNATURE_FILE) continue;
21415
21665
  let size2;
21416
21666
  try {
21417
- size2 = fs27__namespace.statSync(path32__namespace.join(snapshotDir, relative20)).size;
21667
+ size2 = fs27__namespace.statSync(path33__namespace.join(snapshotDir, relative21)).size;
21418
21668
  } catch {
21419
21669
  continue;
21420
21670
  }
@@ -21422,11 +21672,11 @@ function auditSnapshot(options) {
21422
21672
  skippedArtifacts += 1;
21423
21673
  continue;
21424
21674
  }
21425
- const text2 = snapshotText(snapshotDir, relative20);
21675
+ const text2 = snapshotText(snapshotDir, relative21);
21426
21676
  if (text2 === null) continue;
21427
21677
  scannedBytes += Buffer.byteLength(text2, "utf8");
21428
21678
  let findingCount = 0;
21429
- if (/^parts[\\/].*\.md$/i.test(relative20)) {
21679
+ if (/^parts[\\/].*\.md$/i.test(relative21)) {
21430
21680
  const lines = text2.split("\n");
21431
21681
  const sections = parsePartSections(text2);
21432
21682
  for (const section of sections) {
@@ -21438,18 +21688,18 @@ function auditSnapshot(options) {
21438
21688
  }
21439
21689
  }
21440
21690
  const headerText = lines.join("\n");
21441
- findingCount += scanAndRedactSecrets(headerText, rules, relative20).findings.length;
21691
+ findingCount += scanAndRedactSecrets(headerText, rules, relative21).findings.length;
21442
21692
  if ((options.secretRules ?? []).length > 0) {
21443
- findingCount += scanAndRedactSecrets(text2, options.secretRules ?? [], relative20).findings.length;
21693
+ findingCount += scanAndRedactSecrets(text2, options.secretRules ?? [], relative21).findings.length;
21444
21694
  }
21445
21695
  } else {
21446
- findingCount = scanAndRedactSecrets(text2, rules, relative20).findings.length;
21696
+ findingCount = scanAndRedactSecrets(text2, rules, relative21).findings.length;
21447
21697
  }
21448
21698
  if (findingCount > 0) {
21449
- leakHits.push(relative20 + " (" + findingCount + " line(s))");
21699
+ leakHits.push(relative21 + " (" + findingCount + " line(s))");
21450
21700
  }
21451
21701
  }
21452
- const signatureRecordPath = path32__namespace.join(snapshotDir, SIGNATURE_FILE);
21702
+ const signatureRecordPath = path33__namespace.join(snapshotDir, SIGNATURE_FILE);
21453
21703
  if (fs27__namespace.existsSync(signatureRecordPath)) {
21454
21704
  const recordText = snapshotText(snapshotDir, SIGNATURE_FILE);
21455
21705
  if (recordText !== null) {
@@ -21503,7 +21753,7 @@ function auditSnapshot(options) {
21503
21753
  for (const record of skippedSensitive.slice(0, 40)) {
21504
21754
  if (record.path.includes("[REDACTED") || compared > 400) continue;
21505
21755
  try {
21506
- if (fs27__namespace.statSync(path32__namespace.join(repoDir, record.path)).size > scanBudget) continue;
21756
+ if (fs27__namespace.statSync(path33__namespace.join(repoDir, record.path)).size > scanBudget) continue;
21507
21757
  } catch {
21508
21758
  continue;
21509
21759
  }
@@ -21711,7 +21961,7 @@ function canonicalIgnorePattern(line) {
21711
21961
  function appendGitignoreEntries(cwd, entries) {
21712
21962
  const wanted = [...new Set(entries)].filter((entry) => entry.trim().length > 0);
21713
21963
  if (wanted.length === 0) return { added: [], note: null };
21714
- const ignorePath = path32__namespace.join(cwd, ".gitignore");
21964
+ const ignorePath = path33__namespace.join(cwd, ".gitignore");
21715
21965
  const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
21716
21966
  let decoded = { text: "", bom: Buffer.alloc(0), encoding: "utf8" };
21717
21967
  try {
@@ -21728,8 +21978,8 @@ function appendGitignoreEntries(cwd, entries) {
21728
21978
  }
21729
21979
  const rootReal = fs27__namespace.realpathSync(cwd);
21730
21980
  const fileReal = fs27__namespace.realpathSync(ignorePath);
21731
- const relative20 = path32__namespace.relative(rootReal, fileReal);
21732
- if (relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || path32__namespace.isAbsolute(relative20)) {
21981
+ const relative21 = path33__namespace.relative(rootReal, fileReal);
21982
+ if (relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || path33__namespace.isAbsolute(relative21)) {
21733
21983
  return {
21734
21984
  added: [],
21735
21985
  note: `${ignorePath} resolves outside the repository, so it was not updated. ${manual}`
@@ -21774,7 +22024,7 @@ function appendGitignoreEntries(cwd, entries) {
21774
22024
  return { added, note: null };
21775
22025
  }
21776
22026
  function gitignorePath(cwd, filePath) {
21777
- return path32__namespace.relative(cwd, filePath).split(path32__namespace.sep).join("/");
22027
+ return path33__namespace.relative(cwd, filePath).split(path33__namespace.sep).join("/");
21778
22028
  }
21779
22029
 
21780
22030
  // src/wizard/brief-template.ts
@@ -22218,7 +22468,7 @@ function keyReader(input) {
22218
22468
  next() {
22219
22469
  const queued = queue.shift();
22220
22470
  if (queued) return Promise.resolve(queued);
22221
- return new Promise((resolve21) => waiters.push(resolve21));
22471
+ return new Promise((resolve22) => waiters.push(resolve22));
22222
22472
  },
22223
22473
  close() {
22224
22474
  input.off("keypress", onKey);
@@ -22444,7 +22694,7 @@ function parsePackageJson(raw) {
22444
22694
  }
22445
22695
  function readPackageJson2(cwd) {
22446
22696
  try {
22447
- return parsePackageJson(fs27__namespace.readFileSync(path32__namespace.join(cwd, "package.json"), "utf8"));
22697
+ return parsePackageJson(fs27__namespace.readFileSync(path33__namespace.join(cwd, "package.json"), "utf8"));
22448
22698
  } catch {
22449
22699
  return null;
22450
22700
  }
@@ -22562,7 +22812,7 @@ function serializePackageJson(raw, value) {
22562
22812
  return `${bom}${text2}${raw.endsWith("\n") ? crlf ? "\r\n" : "\n" : ""}`;
22563
22813
  }
22564
22814
  function updatePackageJson(cwd, notes) {
22565
- const packagePath = path32__namespace.join(cwd, "package.json");
22815
+ const packagePath = path33__namespace.join(cwd, "package.json");
22566
22816
  const unchanged = {
22567
22817
  scripts: [],
22568
22818
  dependency: { name: GENERATOR_NAME, range: null, added: false }
@@ -22649,11 +22899,11 @@ function gitignoreEntriesFor(cwd, outDir, tmpDir) {
22649
22899
  const entries = [];
22650
22900
  for (const directory of [outDir, tmpDir]) {
22651
22901
  if (directory === null) continue;
22652
- const relative20 = path32__namespace.relative(cwd, path32__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
22653
- if (relative20 === "" || relative20 === "." || relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || relative20.startsWith("../") || path32__namespace.isAbsolute(relative20)) {
22902
+ const relative21 = path33__namespace.relative(cwd, path33__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
22903
+ if (relative21 === "" || relative21 === "." || relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || relative21.startsWith("../") || path33__namespace.isAbsolute(relative21)) {
22654
22904
  continue;
22655
22905
  }
22656
- entries.push(`/${relative20}/`);
22906
+ entries.push(`/${relative21}/`);
22657
22907
  }
22658
22908
  return [...new Set(entries)];
22659
22909
  }
@@ -22921,7 +23171,7 @@ async function runInit(options) {
22921
23171
  }
22922
23172
  const preferredName = chooseConfigFileName(options.cwd);
22923
23173
  const presentConfigs = CONFIG_CANDIDATES.filter(
22924
- (name) => fs27__namespace.existsSync(path32__namespace.join(options.cwd, name))
23174
+ (name) => fs27__namespace.existsSync(path33__namespace.join(options.cwd, name))
22925
23175
  );
22926
23176
  const present = presentConfigs[0] ?? null;
22927
23177
  if (presentConfigs.length > 1) {
@@ -22930,7 +23180,7 @@ async function runInit(options) {
22930
23180
  );
22931
23181
  }
22932
23182
  const configName = present !== null && options.force ? present : preferredName;
22933
- const configPath = path32__namespace.join(options.cwd, configName);
23183
+ const configPath = path33__namespace.join(options.cwd, configName);
22934
23184
  const configText = configName.endsWith(".json") || configName === ".snapshotrc" ? renderJsonConfig(answers) : renderConfig(answers);
22935
23185
  const reused = present !== null && options.force !== true && options.reuseConfig === true;
22936
23186
  if (reused) notes.push(`Kept the existing ${present} instead of writing a new one.`);
@@ -22948,7 +23198,7 @@ async function runInit(options) {
22948
23198
  dependency: { name: GENERATOR_NAME, range: `^${GENERATOR_VERSION}`, added: false },
22949
23199
  notes,
22950
23200
  outDir: answers.outDir,
22951
- briefPath: path32__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE),
23201
+ briefPath: path33__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE),
22952
23202
  briefWritten: false
22953
23203
  };
22954
23204
  }
@@ -22972,7 +23222,7 @@ async function runInit(options) {
22972
23222
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
22973
23223
  }
22974
23224
  if (!reused) writeFileOrExplain(configPath, configText);
22975
- const briefPath = path32__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE);
23225
+ const briefPath = path33__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE);
22976
23226
  let briefWritten = false;
22977
23227
  if (!fs27__namespace.existsSync(briefPath)) {
22978
23228
  writeFileOrExplain(briefPath, BRIEF_SCAFFOLD);
@@ -23002,12 +23252,12 @@ async function runInit(options) {
23002
23252
  };
23003
23253
  }
23004
23254
  function describeTarget(cwd) {
23005
- const relative20 = path32__namespace.relative(process.cwd(), cwd);
23006
- if (relative20 === "") return "this directory";
23007
- if (relative20 === ".." || relative20.startsWith(`..${path32__namespace.sep}`) || relative20.startsWith("../") || path32__namespace.isAbsolute(relative20)) {
23255
+ const relative21 = path33__namespace.relative(process.cwd(), cwd);
23256
+ if (relative21 === "") return "this directory";
23257
+ if (relative21 === ".." || relative21.startsWith(`..${path33__namespace.sep}`) || relative21.startsWith("../") || path33__namespace.isAbsolute(relative21)) {
23008
23258
  return cwd;
23009
23259
  }
23010
- return relative20;
23260
+ return relative21;
23011
23261
  }
23012
23262
  function firstRunMessage(reason, cwd) {
23013
23263
  const where = describeTarget(cwd);
@@ -23038,7 +23288,7 @@ function isEffectivelyEmpty(cwd) {
23038
23288
  function hasPriorSnapshot(cwd, outDir) {
23039
23289
  let parsed;
23040
23290
  try {
23041
- parsed = JSON.parse(fs27__namespace.readFileSync(path32__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
23291
+ parsed = JSON.parse(fs27__namespace.readFileSync(path33__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
23042
23292
  } catch {
23043
23293
  return false;
23044
23294
  }
@@ -23086,7 +23336,7 @@ fi
23086
23336
  `;
23087
23337
  }
23088
23338
  function gitDirectory(cwd) {
23089
- const dotGit = path32__namespace.join(cwd, ".git");
23339
+ const dotGit = path33__namespace.join(cwd, ".git");
23090
23340
  let stats;
23091
23341
  try {
23092
23342
  stats = fs27__namespace.statSync(dotGit);
@@ -23100,42 +23350,42 @@ function gitDirectory(cwd) {
23100
23350
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
23101
23351
  if (!match) return null;
23102
23352
  const target = match[1];
23103
- const resolved = path32__namespace.isAbsolute(target.trim()) ? target.trim() : path32__namespace.join(cwd, target.trim());
23353
+ const resolved = path33__namespace.isAbsolute(target.trim()) ? target.trim() : path33__namespace.join(cwd, target.trim());
23104
23354
  const cwdReal = canonicalForWrite(cwd);
23105
23355
  const resolvedReal = canonicalForWrite(resolved);
23106
23356
  if (cwdReal === null || resolvedReal === null || !fs27__namespace.statSync(resolvedReal).isDirectory()) {
23107
23357
  return null;
23108
23358
  }
23109
23359
  if (isInside4(cwdReal, resolvedReal)) return resolvedReal;
23110
- return isRegisteredWorktree(path32__namespace.resolve(resolved), cwd) ? resolvedReal : null;
23360
+ return isRegisteredWorktree(path33__namespace.resolve(resolved), cwd) ? resolvedReal : null;
23111
23361
  } catch {
23112
23362
  return null;
23113
23363
  }
23114
23364
  }
23115
23365
  function isInside4(parent, child) {
23116
- const relative20 = path32__namespace.relative(parent, child);
23117
- return relative20 === "" || relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20);
23366
+ const relative21 = path33__namespace.relative(parent, child);
23367
+ return relative21 === "" || relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21);
23118
23368
  }
23119
23369
  function canonicalForWrite(target) {
23120
- let existing = path32__namespace.resolve(target);
23370
+ let existing = path33__namespace.resolve(target);
23121
23371
  const tail = [];
23122
23372
  while (!fs27__namespace.existsSync(existing)) {
23123
- tail.unshift(path32__namespace.basename(existing));
23124
- const parent = path32__namespace.dirname(existing);
23373
+ tail.unshift(path33__namespace.basename(existing));
23374
+ const parent = path33__namespace.dirname(existing);
23125
23375
  if (parent === existing) break;
23126
23376
  existing = parent;
23127
23377
  }
23128
23378
  try {
23129
23379
  const real = fs27__namespace.realpathSync(existing);
23130
- return tail.length === 0 ? real : path32__namespace.join(real, ...tail);
23380
+ return tail.length === 0 ? real : path33__namespace.join(real, ...tail);
23131
23381
  } catch {
23132
23382
  return null;
23133
23383
  }
23134
23384
  }
23135
23385
  function isRegisteredWorktree(gitDir, cwd) {
23136
23386
  try {
23137
- const back = fs27__namespace.readFileSync(path32__namespace.join(gitDir, "gitdir"), "utf8").trim();
23138
- return path32__namespace.resolve(gitDir, back) === path32__namespace.join(path32__namespace.resolve(cwd), ".git");
23387
+ const back = fs27__namespace.readFileSync(path33__namespace.join(gitDir, "gitdir"), "utf8").trim();
23388
+ return path33__namespace.resolve(gitDir, back) === path33__namespace.join(path33__namespace.resolve(cwd), ".git");
23139
23389
  } catch {
23140
23390
  return false;
23141
23391
  }
@@ -23156,9 +23406,9 @@ function gitOutput(cwd, args) {
23156
23406
  function configuredHooksDirectory(cwd) {
23157
23407
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
23158
23408
  if (hooks === null) return null;
23159
- const resolved = path32__namespace.resolve(cwd, hooks);
23409
+ const resolved = path33__namespace.resolve(cwd, hooks);
23160
23410
  const common = gitOutput(cwd, ["rev-parse", "--git-common-dir"]);
23161
- const commonDir = common === null ? null : canonicalForWrite(path32__namespace.resolve(cwd, common));
23411
+ const commonDir = common === null ? null : canonicalForWrite(path33__namespace.resolve(cwd, common));
23162
23412
  const cwdReal = canonicalForWrite(cwd);
23163
23413
  const hooksReal = canonicalForWrite(resolved);
23164
23414
  if (hooksReal === null || cwdReal === null) {
@@ -23187,7 +23437,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
23187
23437
  ]
23188
23438
  };
23189
23439
  }
23190
- const hooksDirRaw = configured === null ? path32__namespace.join(gitDir, "hooks") : configured.dir;
23440
+ const hooksDirRaw = configured === null ? path33__namespace.join(gitDir, "hooks") : configured.dir;
23191
23441
  const hooksDir = canonicalForWrite(hooksDirRaw);
23192
23442
  if (hooksDir === null) {
23193
23443
  return {
@@ -23196,7 +23446,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
23196
23446
  notes: [`Refusing to write the hooks directory: ${hooksDirRaw} could not be resolved.`]
23197
23447
  };
23198
23448
  }
23199
- const hookPath = path32__namespace.join(hooksDir, "pre-commit");
23449
+ const hookPath = path33__namespace.join(hooksDir, "pre-commit");
23200
23450
  try {
23201
23451
  const existingStats = fs27__namespace.lstatSync(hookPath);
23202
23452
  if (existingStats.isSymbolicLink()) {
@@ -23468,14 +23718,14 @@ function foldPath(value) {
23468
23718
  return CASE_INSENSITIVE_PATHS2 ? value.toLowerCase() : value;
23469
23719
  }
23470
23720
  function insideDirectory(root, candidate) {
23471
- const normalizedRoot = foldPath(path32__namespace.resolve(root));
23472
- const normalizedCandidate = foldPath(path32__namespace.resolve(candidate));
23473
- return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(normalizedRoot + path32__namespace.sep);
23721
+ const normalizedRoot = foldPath(path33__namespace.resolve(root));
23722
+ const normalizedCandidate = foldPath(path33__namespace.resolve(candidate));
23723
+ return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(normalizedRoot + path33__namespace.sep);
23474
23724
  }
23475
- function confinedFile(cwd, relative20) {
23725
+ function confinedFile(cwd, relative21) {
23476
23726
  try {
23477
23727
  const realRoot = fs27__namespace.realpathSync(cwd);
23478
- const candidate = path32__namespace.resolve(cwd, relative20);
23728
+ const candidate = path33__namespace.resolve(cwd, relative21);
23479
23729
  if (!insideDirectory(cwd, candidate)) return null;
23480
23730
  const stat = fs27__namespace.lstatSync(candidate);
23481
23731
  if (!stat.isFile()) return null;
@@ -23487,14 +23737,14 @@ function confinedFile(cwd, relative20) {
23487
23737
  }
23488
23738
  }
23489
23739
  function hasPackage(cwd, name) {
23490
- return confinedFile(cwd, path32__namespace.join("node_modules", name, "package.json")) !== null;
23740
+ return confinedFile(cwd, path33__namespace.join("node_modules", name, "package.json")) !== null;
23491
23741
  }
23492
23742
  function sanitizePaths(cwd, paths) {
23493
- const root = path32__namespace.resolve(cwd);
23743
+ const root = path33__namespace.resolve(cwd);
23494
23744
  return paths.map((value) => value.replace(/\\/g, "/").replace(/^\.\/+/, "")).filter((value) => {
23495
23745
  if (value.length === 0 || value.startsWith("/") || /^[A-Za-z]:\//.test(value)) return false;
23496
23746
  if (value.split("/").includes("..")) return false;
23497
- return insideDirectory(root, path32__namespace.resolve(root, value));
23747
+ return insideDirectory(root, path33__namespace.resolve(root, value));
23498
23748
  }).map((value) => value.startsWith("-") ? "./" + value : value);
23499
23749
  }
23500
23750
  function unsupportedCustomScript(script) {
@@ -23514,7 +23764,7 @@ function planTestRun(cwd, input) {
23514
23764
  const testScript = typeof scripts === "object" && scripts !== null && !Array.isArray(scripts) ? scripts.test : void 0;
23515
23765
  const script = typeof testScript === "string" ? testScript : "";
23516
23766
  if (hasPackage(cwd, "vitest") || /\bvitest\b/.test(script)) {
23517
- const entry = ["node_modules/vitest/vitest.mjs", "node_modules/vitest/dist/cli.js"].map((relative20) => confinedFile(cwd, relative20)).find((resolved) => resolved !== null);
23767
+ const entry = ["node_modules/vitest/vitest.mjs", "node_modules/vitest/dist/cli.js"].map((relative21) => confinedFile(cwd, relative21)).find((resolved) => resolved !== null);
23518
23768
  if (entry !== void 0) {
23519
23769
  if (changed.length === 0) {
23520
23770
  return {
@@ -23606,16 +23856,16 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
23606
23856
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
23607
23857
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
23608
23858
  var fileDerivationBytes = 0;
23609
- function takeDerivation(path33, relativePath, hash, settings) {
23610
- const key = path33 + "\0" + relativePath;
23859
+ function takeDerivation(path34, relativePath, hash, settings) {
23860
+ const key = path34 + "\0" + relativePath;
23611
23861
  const cached = FILE_DERIVATIONS.get(key);
23612
23862
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
23613
23863
  FILE_DERIVATIONS.delete(key);
23614
23864
  FILE_DERIVATIONS.set(key, cached);
23615
23865
  return cached;
23616
23866
  }
23617
- function rememberDerivation(path33, relativePath, hash, settings, derivation) {
23618
- const key = path33 + "\0" + relativePath;
23867
+ function rememberDerivation(path34, relativePath, hash, settings, derivation) {
23868
+ const key = path34 + "\0" + relativePath;
23619
23869
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
23620
23870
  const bytes = bodyBytes * 2 + 512;
23621
23871
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
@@ -23919,15 +24169,15 @@ function verifyInMemory(files, parts, unaccounted) {
23919
24169
  return errors;
23920
24170
  }
23921
24171
  function resolveSafeOutputDirs(config) {
23922
- const cwd = path32__namespace.resolve(config.cwd);
23923
- const outDir = path32__namespace.resolve(cwd, config.outDir);
23924
- const tmpDir = path32__namespace.resolve(cwd, config.tmpDir);
23925
- const root = path32__namespace.parse(cwd).root;
24172
+ const cwd = path33__namespace.resolve(config.cwd);
24173
+ const outDir = path33__namespace.resolve(cwd, config.outDir);
24174
+ const tmpDir = path33__namespace.resolve(cwd, config.tmpDir);
24175
+ const root = path33__namespace.parse(cwd).root;
23926
24176
  const fold = (value) => process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
23927
24177
  const contains = (parent, child) => {
23928
24178
  const foldedParent = fold(parent);
23929
24179
  const foldedChild = fold(child);
23930
- return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path32__namespace.sep}`);
24180
+ return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path33__namespace.sep}`);
23931
24181
  };
23932
24182
  const reject = (reason) => {
23933
24183
  throw new Error(
@@ -24022,9 +24272,9 @@ function listEntries(dir) {
24022
24272
  return;
24023
24273
  }
24024
24274
  for (const child of children) {
24025
- const relative20 = prefix === "" ? child.name : `${prefix}/${child.name}`;
24026
- entries.push(relative20);
24027
- if (child.isDirectory()) walk2(path32__namespace.join(absolute, child.name), relative20);
24275
+ const relative21 = prefix === "" ? child.name : `${prefix}/${child.name}`;
24276
+ entries.push(relative21);
24277
+ if (child.isDirectory()) walk2(path33__namespace.join(absolute, child.name), relative21);
24028
24278
  }
24029
24279
  };
24030
24280
  walk2(dir, "");
@@ -24036,7 +24286,7 @@ function markerInventory(dir, written) {
24036
24286
  for (const entry of entries) {
24037
24287
  if (entry === OWNERSHIP_MARKER) continue;
24038
24288
  if (isIgnorableEntry(entry)) continue;
24039
- const full = path32__namespace.join(dir, ...entry.split("/"));
24289
+ const full = path33__namespace.join(dir, ...entry.split("/"));
24040
24290
  let stats;
24041
24291
  try {
24042
24292
  stats = fs27__namespace.lstatSync(full);
@@ -24073,7 +24323,7 @@ function markerPayload(dir, state, id, createdAt, written, runId) {
24073
24323
  entries,
24074
24324
  files
24075
24325
  };
24076
- const manifestPath = path32__namespace.join(dir, "manifest.json");
24326
+ const manifestPath = path33__namespace.join(dir, "manifest.json");
24077
24327
  if (fs27__namespace.existsSync(manifestPath)) {
24078
24328
  marker2.manifestSha256 = sha256Hex2(fs27__namespace.readFileSync(manifestPath));
24079
24329
  }
@@ -24081,7 +24331,7 @@ function markerPayload(dir, state, id, createdAt, written, runId) {
24081
24331
  }
24082
24332
  function writeOwnershipMarker(dir, marker2) {
24083
24333
  fs27__namespace.writeFileSync(
24084
- path32__namespace.join(dir, OWNERSHIP_MARKER),
24334
+ path33__namespace.join(dir, OWNERSHIP_MARKER),
24085
24335
  `${JSON.stringify(marker2, null, 2)}
24086
24336
  `,
24087
24337
  "utf8"
@@ -24093,7 +24343,7 @@ function markerBelongsTo(dir, id) {
24093
24343
  return evidence.marker.id === id;
24094
24344
  }
24095
24345
  function readOwnershipMarker(dir) {
24096
- const markerPath = path32__namespace.join(dir, OWNERSHIP_MARKER);
24346
+ const markerPath = path33__namespace.join(dir, OWNERSHIP_MARKER);
24097
24347
  if (!fs27__namespace.existsSync(markerPath)) {
24098
24348
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
24099
24349
  }
@@ -24200,7 +24450,7 @@ function verifyMarkerInventory(dir, entries, files) {
24200
24450
  for (const entry of entries) {
24201
24451
  if (entry === OWNERSHIP_MARKER) continue;
24202
24452
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
24203
- const full = path32__namespace.join(dir, ...entry.split("/"));
24453
+ const full = path33__namespace.join(dir, ...entry.split("/"));
24204
24454
  let stats;
24205
24455
  try {
24206
24456
  stats = fs27__namespace.lstatSync(full);
@@ -24249,7 +24499,7 @@ function assessSnapshotDirectory(dir) {
24249
24499
  marker: marker2
24250
24500
  };
24251
24501
  }
24252
- const manifestPath = path32__namespace.join(dir, "manifest.json");
24502
+ const manifestPath = path33__namespace.join(dir, "manifest.json");
24253
24503
  const hasManifest = fs27__namespace.existsSync(manifestPath);
24254
24504
  if (hasManifest) {
24255
24505
  let raw;
@@ -24361,7 +24611,7 @@ function containsNoFiles(dir) {
24361
24611
  }
24362
24612
  for (const entry of entries) {
24363
24613
  if (entry.isDirectory()) {
24364
- pending.push(path32__namespace.join(current, entry.name));
24614
+ pending.push(path33__namespace.join(current, entry.name));
24365
24615
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
24366
24616
  return false;
24367
24617
  }
@@ -24369,11 +24619,11 @@ function containsNoFiles(dir) {
24369
24619
  }
24370
24620
  return true;
24371
24621
  }
24372
- function assertReplaceable(target, label, secretRules) {
24622
+ function assertReplaceable(target, label2, secretRules) {
24373
24623
  if (!fs27__namespace.existsSync(target)) return;
24374
24624
  if (!fs27__namespace.statSync(target).isDirectory()) {
24375
24625
  throw new Error(
24376
- `Refusing to write into ${label} ${target}: it exists but is not a directory.`
24626
+ `Refusing to write into ${label2} ${target}: it exists but is not a directory.`
24377
24627
  );
24378
24628
  }
24379
24629
  const entries = fs27__namespace.readdirSync(target);
@@ -24387,12 +24637,12 @@ function assertReplaceable(target, label, secretRules) {
24387
24637
  const shownEntries = entries.map((name) => maskPathText(name, secretRules));
24388
24638
  if (verdict.foreignEntries.length > 0) {
24389
24639
  throw new Error(
24390
- `Refusing to replace ${label} ${target}: it carries this generator's ownership marker, but these entries are not part of the snapshot it recorded: ${describeEntries(shownForeign)}. Remove them yourself, or point ${label} at a new or empty directory.`
24640
+ `Refusing to replace ${label2} ${target}: it carries this generator's ownership marker, but these entries are not part of the snapshot it recorded: ${describeEntries(shownForeign)}. Remove them yourself, or point ${label2} at a new or empty directory.`
24391
24641
  );
24392
24642
  }
24393
24643
  const reason = verdict.problem ?? problem ?? "it does not look like a snapshot this generator wrote";
24394
24644
  throw new Error(
24395
- `Refusing to replace ${label} ${target}: ${reason} (found ${describeEntries(shownEntries)}). Remove the directory yourself, or point ${label} at a new or empty directory.`
24645
+ `Refusing to replace ${label2} ${target}: ${reason} (found ${describeEntries(shownEntries)}). Remove the directory yourself, or point ${label2} at a new or empty directory.`
24396
24646
  );
24397
24647
  }
24398
24648
  function assertStagingRootUsable(tmpDir, secretRules) {
@@ -24403,7 +24653,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
24403
24653
  const entries = fs27__namespace.readdirSync(tmpDir);
24404
24654
  if (entries.length === 0) return;
24405
24655
  const foreign = entries.filter((name) => {
24406
- const full = path32__namespace.join(tmpDir, name);
24656
+ const full = path33__namespace.join(tmpDir, name);
24407
24657
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
24408
24658
  let stats;
24409
24659
  try {
@@ -24436,7 +24686,7 @@ function cleanStaleRunDirs(tmpDir) {
24436
24686
  }
24437
24687
  for (const name of entries) {
24438
24688
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
24439
- const full = path32__namespace.join(tmpDir, name);
24689
+ const full = path33__namespace.join(tmpDir, name);
24440
24690
  const { marker: marker2 } = readOwnershipMarker(full);
24441
24691
  if (marker2) {
24442
24692
  const created = Date.parse(marker2.createdAt);
@@ -24462,18 +24712,18 @@ function removeIfEmpty(dir) {
24462
24712
  } catch {
24463
24713
  }
24464
24714
  }
24465
- function ensureParentDirectory(target, label) {
24466
- const parent = path32__namespace.dirname(target);
24715
+ function ensureParentDirectory(target, label2) {
24716
+ const parent = path33__namespace.dirname(target);
24467
24717
  if (fs27__namespace.existsSync(parent) && !fs27__namespace.statSync(parent).isDirectory()) {
24468
24718
  throw new Error(
24469
- `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
24719
+ `Refusing to create ${label2} ${target}: ${parent} exists but is not a directory.`
24470
24720
  );
24471
24721
  }
24472
24722
  try {
24473
24723
  fs27__namespace.mkdirSync(parent, { recursive: true });
24474
24724
  } catch (err) {
24475
24725
  throw new Error(
24476
- `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
24726
+ `Refusing to create ${label2} ${target}: its parent ${parent} could not be created (${err.message}).`
24477
24727
  );
24478
24728
  }
24479
24729
  }
@@ -24564,22 +24814,22 @@ function lockKeyFor(stagingRoot) {
24564
24814
  return sha256Hex2(key).slice(0, 16);
24565
24815
  }
24566
24816
  function canonicalLockTarget(targetPath2) {
24567
- const resolved = path32__namespace.resolve(targetPath2);
24817
+ const resolved = path33__namespace.resolve(targetPath2);
24568
24818
  let existing = resolved;
24569
24819
  const tail = [];
24570
24820
  for (; ; ) {
24571
24821
  try {
24572
- return path32__namespace.join(fs27__namespace.realpathSync(existing), ...tail);
24822
+ return path33__namespace.join(fs27__namespace.realpathSync(existing), ...tail);
24573
24823
  } catch {
24574
- const parent = path32__namespace.dirname(existing);
24824
+ const parent = path33__namespace.dirname(existing);
24575
24825
  if (parent === existing) return resolved;
24576
- tail.unshift(path32__namespace.basename(existing));
24826
+ tail.unshift(path33__namespace.basename(existing));
24577
24827
  existing = parent;
24578
24828
  }
24579
24829
  }
24580
24830
  }
24581
24831
  function lockPathFor(stagingRoot) {
24582
- return path32__namespace.join(os2__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
24832
+ return path33__namespace.join(os2__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
24583
24833
  }
24584
24834
  function releaseAbandonedRun(stagingRoots, runId) {
24585
24835
  if (runId.length === 0) return;
@@ -24598,7 +24848,7 @@ function releaseAbandonedRun(stagingRoots, runId) {
24598
24848
  }
24599
24849
  for (const name of entries) {
24600
24850
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
24601
- const directory = path32__namespace.join(root, name);
24851
+ const directory = path33__namespace.join(root, name);
24602
24852
  const { marker: marker2 } = readOwnershipMarker(directory);
24603
24853
  if (marker2?.runId !== runId) continue;
24604
24854
  try {
@@ -24693,8 +24943,8 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap, onStagingPreserved) {
24693
24943
  }
24694
24944
  function recoverInterruptedPublish(outDir) {
24695
24945
  if (fs27__namespace.existsSync(outDir)) return;
24696
- const parent = path32__namespace.dirname(outDir);
24697
- const base = path32__namespace.basename(outDir);
24946
+ const parent = path33__namespace.dirname(outDir);
24947
+ const base = path33__namespace.basename(outDir);
24698
24948
  let backups;
24699
24949
  try {
24700
24950
  backups = fs27__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
@@ -24702,7 +24952,7 @@ function recoverInterruptedPublish(outDir) {
24702
24952
  return;
24703
24953
  }
24704
24954
  if (backups.length !== 1) return;
24705
- const backupDir = path32__namespace.join(parent, backups[0]);
24955
+ const backupDir = path33__namespace.join(parent, backups[0]);
24706
24956
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
24707
24957
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
24708
24958
  try {
@@ -24946,9 +25196,9 @@ function generateSnapshot(configInput, options) {
24946
25196
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
24947
25197
  // output — but only at these exact paths, not at every directory that shares the name.
24948
25198
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
24949
- (directory) => path32__namespace.relative(config.cwd, path32__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
25199
+ (directory) => path33__namespace.relative(config.cwd, path33__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
24950
25200
  ).filter(
24951
- (relative20) => relative20.length > 0 && relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20)
25201
+ (relative21) => relative21.length > 0 && relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21)
24952
25202
  ),
24953
25203
  // A staged path can be absent from the working tree while its index blob exists. Discovery
24954
25204
  // lists the working tree, so those paths would never reach the scan at all.
@@ -24977,7 +25227,7 @@ function generateSnapshot(configInput, options) {
24977
25227
  let totalSizeBytes = 0;
24978
25228
  let largeFileCount = 0;
24979
25229
  for (const relativePath of candidateFiles) {
24980
- const absolutePath = path32__namespace.join(config.cwd, relativePath);
25230
+ const absolutePath = path33__namespace.join(config.cwd, relativePath);
24981
25231
  const fromIndex = stagedPaths.has(relativePath);
24982
25232
  let buffer;
24983
25233
  let sizeBytes;
@@ -25010,7 +25260,7 @@ function generateSnapshot(configInput, options) {
25010
25260
  try {
25011
25261
  stats = fs27__namespace.statSync(absolutePath);
25012
25262
  if (!stats.isFile()) {
25013
- const nestedRepository = stats.isDirectory() && fs27__namespace.existsSync(path32__namespace.join(absolutePath, ".git"));
25263
+ const nestedRepository = stats.isDirectory() && fs27__namespace.existsSync(path33__namespace.join(absolutePath, ".git"));
25014
25264
  skipped.push(
25015
25265
  nestedRepository ? {
25016
25266
  path: relativePath,
@@ -25163,14 +25413,14 @@ function generateSnapshot(configInput, options) {
25163
25413
  }
25164
25414
  retain(secretFindings, (finding) => finding.path === void 0 || keep.has(finding.path));
25165
25415
  retain(encodingNotes, (note) => keep.has(note.path));
25166
- retain(oversizeSummaryPaths, (path33) => keep.has(path33));
25167
- retain(previewSummaryPaths, (path33) => keep.has(path33));
25416
+ retain(oversizeSummaryPaths, (path34) => keep.has(path34));
25417
+ retain(previewSummaryPaths, (path34) => keep.has(path34));
25168
25418
  retain(fileWarnings, (warning) => keep.has(warning.path));
25169
- for (const path33 of [...monolithBodies.keys()]) {
25170
- if (!keep.has(path33)) monolithBodies.delete(path33);
25419
+ for (const path34 of [...monolithBodies.keys()]) {
25420
+ if (!keep.has(path34)) monolithBodies.delete(path34);
25171
25421
  }
25172
- for (const path33 of [...skippedSummaryImports.keys()]) {
25173
- if (!keep.has(path33)) skippedSummaryImports.delete(path33);
25422
+ for (const path34 of [...skippedSummaryImports.keys()]) {
25423
+ if (!keep.has(path34)) skippedSummaryImports.delete(path34);
25174
25424
  }
25175
25425
  };
25176
25426
  if (changedScope !== null && changedPaths !== null && config.withDependents === true) {
@@ -25794,7 +26044,7 @@ function generateSnapshot(configInput, options) {
25794
26044
  cleanStaleRunDirs(tmpDir);
25795
26045
  const snapshotId = crypto__namespace.randomUUID();
25796
26046
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
25797
- stagingDir = path32__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
26047
+ stagingDir = path33__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
25798
26048
  fs27__namespace.mkdirSync(stagingDir);
25799
26049
  writeOwnershipMarker(stagingDir, {
25800
26050
  generator: GENERATOR_NAME,
@@ -25806,17 +26056,17 @@ function generateSnapshot(configInput, options) {
25806
26056
  runId,
25807
26057
  pid: process.pid
25808
26058
  });
25809
- const partsDir = path32__namespace.join(stagingDir, "parts");
25810
- const reportsDir = path32__namespace.join(stagingDir, "reports");
26059
+ const partsDir = path33__namespace.join(stagingDir, "parts");
26060
+ const reportsDir = path33__namespace.join(stagingDir, "reports");
25811
26061
  if (artifacts.parts) fs27__namespace.mkdirSync(partsDir, { recursive: true });
25812
26062
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || artifacts.diff || artifacts.log || artifacts.tokenTree || config.sarif === true) {
25813
26063
  fs27__namespace.mkdirSync(reportsDir, { recursive: true });
25814
26064
  }
25815
26065
  const writtenArtifacts = /* @__PURE__ */ new Map();
25816
- const ledgerRoot = (targetDir) => stagingDir !== null && (targetDir === stagingDir || targetDir.startsWith(stagingDir + path32__namespace.sep)) ? stagingDir : outDir;
25817
- const ledgerEntry = (targetDir, relativeEntry) => path32__namespace.relative(ledgerRoot(targetDir), path32__namespace.join(targetDir, ...relativeEntry.split("/"))).split(path32__namespace.sep).join("/");
26066
+ const ledgerRoot = (targetDir) => stagingDir !== null && (targetDir === stagingDir || targetDir.startsWith(stagingDir + path33__namespace.sep)) ? stagingDir : outDir;
26067
+ const ledgerEntry = (targetDir, relativeEntry) => path33__namespace.relative(ledgerRoot(targetDir), path33__namespace.join(targetDir, ...relativeEntry.split("/"))).split(path33__namespace.sep).join("/");
25818
26068
  const writeArtifact = (targetDir, relativeEntry, data) => {
25819
- const full = path32__namespace.join(targetDir, ...relativeEntry.split("/"));
26069
+ const full = path33__namespace.join(targetDir, ...relativeEntry.split("/"));
25820
26070
  fs27__namespace.writeFileSync(full, data, "utf8");
25821
26071
  const stats = fs27__namespace.statSync(full);
25822
26072
  const entry = ledgerEntry(targetDir, relativeEntry);
@@ -25826,7 +26076,7 @@ function generateSnapshot(configInput, options) {
25826
26076
  });
25827
26077
  };
25828
26078
  const recordArtifact = (targetDir, relativeEntry) => {
25829
- const full = path32__namespace.join(targetDir, ...relativeEntry.split("/"));
26079
+ const full = path33__namespace.join(targetDir, ...relativeEntry.split("/"));
25830
26080
  const stats = fs27__namespace.statSync(full);
25831
26081
  const entry = ledgerEntry(targetDir, relativeEntry);
25832
26082
  writtenArtifacts.set(entry, {
@@ -25882,7 +26132,7 @@ function generateSnapshot(configInput, options) {
25882
26132
  "Refusing to sign: manifest.json is disabled for this run. Signing covers the manifest, so enable the manifest artifact or drop --sign."
25883
26133
  );
25884
26134
  }
25885
- const record = signManifest(path32__namespace.join(stagingDir, "manifest.json"), {
26135
+ const record = signManifest(path33__namespace.join(stagingDir, "manifest.json"), {
25886
26136
  key: options.sign.key ?? null
25887
26137
  });
25888
26138
  writeArtifact(stagingDir, SIGNATURE_FILE, JSON.stringify(record, null, 2) + "\n");
@@ -25914,10 +26164,10 @@ function generateSnapshot(configInput, options) {
25914
26164
  const shipHookState = () => {
25915
26165
  if (!markerBelongsTo(outDir, snapshotId)) return;
25916
26166
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
25917
- writeManifestAtomically(path32__namespace.join(outDir, "manifest.json"), manifest);
26167
+ writeManifestAtomically(path33__namespace.join(outDir, "manifest.json"), manifest);
25918
26168
  recordArtifact(outDir, "manifest.json");
25919
26169
  if (options?.sign !== void 0) {
25920
- const record = signManifest(path32__namespace.join(outDir, "manifest.json"), {
26170
+ const record = signManifest(path33__namespace.join(outDir, "manifest.json"), {
25921
26171
  key: options.sign.key ?? null
25922
26172
  });
25923
26173
  writeArtifact(outDir, SIGNATURE_FILE, JSON.stringify(record, null, 2) + "\n");
@@ -25984,11 +26234,11 @@ function sha256Hex3(input) {
25984
26234
  return crypto__namespace.createHash("sha256").update(input).digest("hex");
25985
26235
  }
25986
26236
  function manifestPathFor2(config) {
25987
- return path32__namespace.resolve(config.cwd, config.outDir, "manifest.json");
26237
+ return path33__namespace.resolve(config.cwd, config.outDir, "manifest.json");
25988
26238
  }
25989
26239
  function readBaseline(config) {
25990
26240
  const file = manifestPathFor2(config);
25991
- const read = readConfinedText(path32__namespace.dirname(file), path32__namespace.basename(file), MAX_MANIFEST_BYTES2);
26241
+ const read = readConfinedText(path33__namespace.dirname(file), path33__namespace.basename(file), MAX_MANIFEST_BYTES2);
25992
26242
  if (!read.ok) return null;
25993
26243
  let parsed;
25994
26244
  try {
@@ -26063,28 +26313,28 @@ function collectStatStamps(config, manifest, gitState) {
26063
26313
  if (manifest.files.length > 500) return [];
26064
26314
  for (const file of manifest.files) {
26065
26315
  candidates.add(file.relativePath);
26066
- let dir = path32__namespace.posix.dirname(file.relativePath);
26316
+ let dir = path33__namespace.posix.dirname(file.relativePath);
26067
26317
  while (dir !== "." && dir !== "/" && dir.length > 0) {
26068
26318
  candidates.add(dir);
26069
- const parent = path32__namespace.posix.dirname(dir);
26319
+ const parent = path33__namespace.posix.dirname(dir);
26070
26320
  if (parent === dir) break;
26071
26321
  dir = parent;
26072
26322
  }
26073
26323
  }
26074
26324
  }
26075
26325
  const stamps = [];
26076
- for (const relative20 of [...candidates].sort((left, right) => left.localeCompare(right))) {
26077
- const target = relative20.length === 0 ? config.cwd : path32__namespace.join(config.cwd, relative20);
26326
+ for (const relative21 of [...candidates].sort((left, right) => left.localeCompare(right))) {
26327
+ const target = relative21.length === 0 ? config.cwd : path33__namespace.join(config.cwd, relative21);
26078
26328
  try {
26079
26329
  const stat = fs27__namespace.lstatSync(target);
26080
26330
  stamps.push({
26081
- path: relative20,
26331
+ path: relative21,
26082
26332
  exists: true,
26083
26333
  mtimeMs: stat.mtimeMs,
26084
26334
  size: stat.size
26085
26335
  });
26086
26336
  } catch {
26087
- stamps.push({ path: relative20, exists: false, mtimeMs: 0, size: 0 });
26337
+ stamps.push({ path: relative21, exists: false, mtimeMs: 0, size: 0 });
26088
26338
  }
26089
26339
  }
26090
26340
  return stamps;
@@ -26092,7 +26342,7 @@ function collectStatStamps(config, manifest, gitState) {
26092
26342
  function stampsMatch(cwd, stamps) {
26093
26343
  if (stamps.length === 0) return false;
26094
26344
  for (const stamp of stamps) {
26095
- const target = stamp.path.length === 0 ? cwd : path32__namespace.join(cwd, stamp.path);
26345
+ const target = stamp.path.length === 0 ? cwd : path33__namespace.join(cwd, stamp.path);
26096
26346
  try {
26097
26347
  const stat = fs27__namespace.lstatSync(target);
26098
26348
  if (!stamp.exists || stat.mtimeMs !== stamp.mtimeMs || stat.size !== stamp.size) {
@@ -26106,7 +26356,7 @@ function stampsMatch(cwd, stamps) {
26106
26356
  }
26107
26357
  function liveIndexCachePath(config) {
26108
26358
  const key = sha256Hex3(config.cwd.replace(/\\/g, "/") + "\0" + config.outDir);
26109
- return path32__namespace.join(cacheDirectory(), "live-index", key + ".json");
26359
+ return path33__namespace.join(cacheDirectory(), "live-index", key + ".json");
26110
26360
  }
26111
26361
  function isStatStamp(value) {
26112
26362
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
@@ -26155,7 +26405,7 @@ function readCache2(config) {
26155
26405
  function writeCache2(config, payload) {
26156
26406
  try {
26157
26407
  const file = liveIndexCachePath(config);
26158
- fs27__namespace.mkdirSync(path32__namespace.dirname(file), { recursive: true, mode: 448 });
26408
+ fs27__namespace.mkdirSync(path33__namespace.dirname(file), { recursive: true, mode: 448 });
26159
26409
  const temporary = file + "." + process.pid + "." + Date.now() + ".tmp";
26160
26410
  fs27__namespace.writeFileSync(temporary, JSON.stringify(payload), { encoding: "utf8", mode: 384 });
26161
26411
  fs27__namespace.renameSync(temporary, file);
@@ -26332,16 +26582,16 @@ var LEGACY_AGENTS_MARKER = "<!-- codebase-snapshot:skill:start -->";
26332
26582
  function targetPath(cwd, target) {
26333
26583
  switch (target) {
26334
26584
  case "agents":
26335
- return path32__namespace.join(cwd, ".agents", "skills", SKILL_NAME, "SKILL.md");
26585
+ return path33__namespace.join(cwd, ".agents", "skills", SKILL_NAME, "SKILL.md");
26336
26586
  case "claude":
26337
- return path32__namespace.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
26587
+ return path33__namespace.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
26338
26588
  case "cursor":
26339
- return path32__namespace.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
26589
+ return path33__namespace.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
26340
26590
  }
26341
26591
  }
26342
26592
  function assertWritableInsideRepository(cwd, filePath) {
26343
26593
  const root = fs27__namespace.realpathSync(cwd);
26344
- const shown = path32__namespace.relative(root, filePath) || filePath;
26594
+ const shown = path33__namespace.relative(root, filePath) || filePath;
26345
26595
  let stat = null;
26346
26596
  try {
26347
26597
  stat = fs27__namespace.lstatSync(filePath);
@@ -26361,14 +26611,14 @@ function assertWritableInsideRepository(cwd, filePath) {
26361
26611
  let existing = filePath;
26362
26612
  const missing = [];
26363
26613
  while (!fs27__namespace.existsSync(existing)) {
26364
- missing.unshift(path32__namespace.basename(existing));
26365
- const parent = path32__namespace.dirname(existing);
26614
+ missing.unshift(path33__namespace.basename(existing));
26615
+ const parent = path33__namespace.dirname(existing);
26366
26616
  if (parent === existing) break;
26367
26617
  existing = parent;
26368
26618
  }
26369
26619
  const realAncestor = fs27__namespace.realpathSync(existing);
26370
- const resolved = missing.length === 0 ? realAncestor : path32__namespace.join(realAncestor, ...missing);
26371
- if (resolved !== root && !resolved.startsWith(`${root}${path32__namespace.sep}`)) {
26620
+ const resolved = missing.length === 0 ? realAncestor : path33__namespace.join(realAncestor, ...missing);
26621
+ if (resolved !== root && !resolved.startsWith(`${root}${path33__namespace.sep}`)) {
26372
26622
  throw new Error(
26373
26623
  `${REFUSED}: ${shown} resolves outside the repository (${resolved}). Move it back inside ${root}, or remove the link, and run again.`
26374
26624
  );
@@ -26377,12 +26627,12 @@ function assertWritableInsideRepository(cwd, filePath) {
26377
26627
  function writeIfChanged(target, filePath, content) {
26378
26628
  const existing = fs27__namespace.existsSync(filePath) ? fs27__namespace.readFileSync(filePath, "utf8") : null;
26379
26629
  if (existing === content) return { target, path: filePath, action: "unchanged" };
26380
- fs27__namespace.mkdirSync(path32__namespace.dirname(filePath), { recursive: true });
26630
+ fs27__namespace.mkdirSync(path33__namespace.dirname(filePath), { recursive: true });
26381
26631
  fs27__namespace.writeFileSync(filePath, content, "utf8");
26382
26632
  return { target, path: filePath, action: existing === null ? "created" : "updated" };
26383
26633
  }
26384
26634
  function legacyAgentsNote(cwd) {
26385
- const filePath = path32__namespace.join(cwd, "AGENTS.md");
26635
+ const filePath = path33__namespace.join(cwd, "AGENTS.md");
26386
26636
  try {
26387
26637
  if (!fs27__namespace.existsSync(filePath)) return null;
26388
26638
  if (!fs27__namespace.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
@@ -26399,7 +26649,7 @@ function installSkill(cwd, target = "all", options = {}) {
26399
26649
  for (const item of wanted) assertWritableInsideRepository(cwd, targetPath(cwd, item));
26400
26650
  const createsSomething = wanted.some((item) => !fs27__namespace.existsSync(targetPath(cwd, item)));
26401
26651
  if (createsSomething) {
26402
- assertWritableInsideRepository(cwd, path32__namespace.join(cwd, ".gitignore"));
26652
+ assertWritableInsideRepository(cwd, path33__namespace.join(cwd, ".gitignore"));
26403
26653
  }
26404
26654
  const pendingMcp = options.withMcp === true ? prepareMcpConfig(cwd) : null;
26405
26655
  for (const item of wanted) {
@@ -26421,7 +26671,7 @@ function installSkill(cwd, target = "all", options = {}) {
26421
26671
  return { cwd, written, gitignored: ignore.added, notes, ...mcp === void 0 ? {} : { mcp } };
26422
26672
  }
26423
26673
  function prepareMcpConfig(cwd) {
26424
- const filePath = path32__namespace.join(cwd, ".mcp.json");
26674
+ const filePath = path33__namespace.join(cwd, ".mcp.json");
26425
26675
  assertWritableInsideRepository(cwd, filePath);
26426
26676
  const desired = { command: "npx", args: ["-y", "codebase-snapshot@latest", "mcp"] };
26427
26677
  let parsed = {};
@@ -26476,6 +26726,7 @@ var COMMAND_ALIASES = /* @__PURE__ */ new Map([
26476
26726
  ["health", "health"],
26477
26727
  ["report", "report"],
26478
26728
  ["impact", "impact"],
26729
+ ["guard", "guard"],
26479
26730
  ["brief", "brief"],
26480
26731
  ["init", "init"],
26481
26732
  ["setup", "setup"],
@@ -26493,6 +26744,7 @@ var COMMAND_ARITY = {
26493
26744
  health: 0,
26494
26745
  report: 0,
26495
26746
  impact: 0,
26747
+ guard: 0,
26496
26748
  brief: 1,
26497
26749
  init: 0,
26498
26750
  setup: 0,
@@ -26539,6 +26791,9 @@ var CLI_OPTIONS = {
26539
26791
  "changed-since": { type: "string" },
26540
26792
  diff: { type: "string" },
26541
26793
  paths: { type: "string" },
26794
+ hook: { type: "string" },
26795
+ changed: { type: "boolean" },
26796
+ "max-chars": { type: "string" },
26542
26797
  depth: { type: "string" },
26543
26798
  "max-results": { type: "string" },
26544
26799
  "no-cache": { type: "boolean" },
@@ -26613,6 +26868,7 @@ Commands:
26613
26868
  init Generate a starter snapshot.config file
26614
26869
  report Print codebase health, layer metrics, and secret audit
26615
26870
  impact Report changed files, transitive importers, routes and candidate tests
26871
+ guard Check a change for untouched consumers, tests and routes (hook-aware)
26616
26872
  brief One redacted review pack: impact, diff hunks and bounded source windows
26617
26873
  explain <path> Show how one path would be treated: layer, kind, part, skips
26618
26874
  diff <a> <b> Compare two snapshots (directories or manifest.json files)
@@ -26708,6 +26964,11 @@ Options:
26708
26964
  --tests-paths Print candidate test paths, one per line
26709
26965
  --run Run the detected test runner (text format only)
26710
26966
  --precise Add bounded compiler-resolved symbol references
26967
+
26968
+ guard only:
26969
+ --hook <client> Read one hook payload from stdin: claude | copilot | codex | raw
26970
+ --changed Check the working tree against HEAD (default when no --hook)
26971
+ --max-chars <n> Cap the model-facing hook text (default 1200, max 10000)
26711
26972
  --include-imports Include outgoing imports of changed files
26712
26973
  --include-cycles Include import cycles in the impacted subgraph
26713
26974
  --no-live Require the persisted snapshot instead of the live index
@@ -26778,6 +27039,9 @@ function parseCountOption(raw, optionName, minimum = 0) {
26778
27039
  }
26779
27040
  return value;
26780
27041
  }
27042
+ function isGuardClient(value) {
27043
+ return value === "claude" || value === "copilot" || value === "codex" || value === "raw";
27044
+ }
26781
27045
  function parsePromptTask(value) {
26782
27046
  if (value === void 0) return void 0;
26783
27047
  if (value === "audit" || value === "review" || value === "explain") return value;
@@ -26944,6 +27208,26 @@ function parseCliArgs(argv) {
26944
27208
  );
26945
27209
  }
26946
27210
  }
27211
+ const rawHook = values.hook === void 0 ? void 0 : String(values.hook);
27212
+ if (rawHook !== void 0 && !isGuardClient(rawHook)) {
27213
+ throw new UsageError(
27214
+ `--hook must be one of: claude, copilot, codex, raw (received "${rawHook}").`
27215
+ );
27216
+ }
27217
+ if (rawHook !== void 0) {
27218
+ if (paths !== void 0 || rawDiff !== void 0) {
27219
+ throw new UsageError(
27220
+ "guard --hook reads the changed paths from its stdin payload; do not pass --paths or --diff."
27221
+ );
27222
+ }
27223
+ if (values.changed === true) {
27224
+ throw new UsageError("guard --hook already runs on the payload; do not pass --changed.");
27225
+ }
27226
+ }
27227
+ const maxChars = parseCountOption(values["max-chars"], "max-chars", 200);
27228
+ if (maxChars !== void 0 && maxChars > 1e4) {
27229
+ throw new UsageError(`--max-chars must be at most 10000, received ${maxChars}.`);
27230
+ }
26947
27231
  if (command === "impact" || command === "brief") {
26948
27232
  if (rawDiff !== void 0 && paths !== void 0) {
26949
27233
  throw new UsageError("impact accepts either --diff <ref> or --paths <a,b>, not both.");
@@ -27062,7 +27346,7 @@ function parseCliArgs(argv) {
27062
27346
  install: values.install === true,
27063
27347
  noInstall: values["no-install"] === true,
27064
27348
  target: values.target === void 0 ? void 0 : String(values.target),
27065
- cwd: values.cwd === void 0 ? process.cwd() : path32__namespace.resolve(String(values.cwd)),
27349
+ cwd: values.cwd === void 0 ? process.cwd() : path33__namespace.resolve(String(values.cwd)),
27066
27350
  outDir: values["out-dir"] === void 0 ? void 0 : String(values["out-dir"]),
27067
27351
  includeMonolith: values["include-monolith"] === true || onlyNamesMonolith === true ? true : void 0,
27068
27352
  includeSensitiveFiles: values["include-sensitive-files"] === true ? true : void 0,
@@ -27105,6 +27389,9 @@ function parseCliArgs(argv) {
27105
27389
  changedSince: values["changed-since"] === void 0 ? void 0 : String(values["changed-since"]),
27106
27390
  diff: rawDiff,
27107
27391
  paths,
27392
+ hook: rawHook === void 0 ? void 0 : rawHook,
27393
+ changed: values.changed === true,
27394
+ maxChars,
27108
27395
  depth,
27109
27396
  maxResults,
27110
27397
  // `undefined` when the flag was not given, never `false`.
@@ -27242,20 +27529,20 @@ function renderImpactMarkdown(report2) {
27242
27529
  }
27243
27530
  function realPathInside(realRoot, candidate) {
27244
27531
  const fold = (value) => process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
27245
- const relative20 = path32__namespace.relative(fold(realRoot), fold(candidate));
27246
- return relative20.length === 0 || relative20 !== ".." && !relative20.startsWith(".." + path32__namespace.sep) && !path32__namespace.isAbsolute(relative20);
27532
+ const relative21 = path33__namespace.relative(fold(realRoot), fold(candidate));
27533
+ return relative21.length === 0 || relative21 !== ".." && !relative21.startsWith(".." + path33__namespace.sep) && !path33__namespace.isAbsolute(relative21);
27247
27534
  }
27248
- function writeInside(root, relative20, content) {
27249
- const target = path32__namespace.resolve(root, relative20);
27250
- const rel = path32__namespace.relative(path32__namespace.resolve(root), target);
27251
- if (rel.length === 0 || rel === ".." || rel.startsWith(".." + path32__namespace.sep) || path32__namespace.isAbsolute(rel)) {
27535
+ function writeInside(root, relative21, content) {
27536
+ const target = path33__namespace.resolve(root, relative21);
27537
+ const rel = path33__namespace.relative(path33__namespace.resolve(root), target);
27538
+ if (rel.length === 0 || rel === ".." || rel.startsWith(".." + path33__namespace.sep) || path33__namespace.isAbsolute(rel)) {
27252
27539
  throw new Error("--out must resolve inside the repository.");
27253
27540
  }
27254
- const parent = path32__namespace.dirname(target);
27541
+ const parent = path33__namespace.dirname(target);
27255
27542
  const realRoot = fs27__namespace.realpathSync(root);
27256
27543
  let existingAncestor = parent;
27257
27544
  while (!fs27__namespace.existsSync(existingAncestor)) {
27258
- const next = path32__namespace.dirname(existingAncestor);
27545
+ const next = path33__namespace.dirname(existingAncestor);
27259
27546
  if (next === existingAncestor) break;
27260
27547
  existingAncestor = next;
27261
27548
  }
@@ -27274,7 +27561,7 @@ function writeInside(root, relative20, content) {
27274
27561
  } catch (error) {
27275
27562
  if (error.code !== "ENOENT") throw error;
27276
27563
  }
27277
- const temporary = path32__namespace.join(parent, "." + path32__namespace.basename(target) + ".tmp-" + process.pid + "-" + Math.random().toString(16).slice(2));
27564
+ const temporary = path33__namespace.join(parent, "." + path33__namespace.basename(target) + ".tmp-" + process.pid + "-" + Math.random().toString(16).slice(2));
27278
27565
  fs27__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx", mode: 384 });
27279
27566
  try {
27280
27567
  fs27__namespace.renameSync(temporary, target);
@@ -27303,10 +27590,10 @@ function splitList(value) {
27303
27590
  return value.split(",").map((entry) => entry.trim()).filter(Boolean);
27304
27591
  }
27305
27592
  function displayOutPath(cwd, outDir, ...segments) {
27306
- const absolute = path32__namespace.resolve(cwd, outDir, ...segments);
27307
- const relative20 = path32__namespace.relative(cwd, absolute);
27308
- if (relative20 !== "" && relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20)) {
27309
- return relative20;
27593
+ const absolute = path33__namespace.resolve(cwd, outDir, ...segments);
27594
+ const relative21 = path33__namespace.relative(cwd, absolute);
27595
+ if (relative21 !== "" && relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21)) {
27596
+ return relative21;
27310
27597
  }
27311
27598
  return absolute;
27312
27599
  }
@@ -27315,7 +27602,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
27315
27602
  if (!hasScript) {
27316
27603
  try {
27317
27604
  const parsed = JSON.parse(
27318
- stripJsonComments(fs27__namespace.readFileSync(path32__namespace.join(cwd, "package.json"), "utf8"))
27605
+ stripJsonComments(fs27__namespace.readFileSync(path33__namespace.join(cwd, "package.json"), "utf8"))
27319
27606
  );
27320
27607
  hasScript = typeof parsed.scripts?.snapshot === "string";
27321
27608
  } catch {
@@ -27323,7 +27610,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
27323
27610
  }
27324
27611
  }
27325
27612
  if (!hasScript) return `npx ${GENERATOR_NAME} generate`;
27326
- const bin = path32__namespace.join(cwd, "node_modules", ".bin", "codebase-snapshot");
27613
+ const bin = path33__namespace.join(cwd, "node_modules", ".bin", "codebase-snapshot");
27327
27614
  const installed = fs27__namespace.existsSync(bin) || fs27__namespace.existsSync(`${bin}.cmd`);
27328
27615
  return installed ? "npm run snapshot" : "npm install && npm run snapshot";
27329
27616
  }
@@ -27360,7 +27647,7 @@ async function runInitCommand(invocation) {
27360
27647
  if (hook) for (const note of hook.notes) info(` ${note}`);
27361
27648
  return 0;
27362
27649
  }
27363
- info(`\u2705 Created ${path32__namespace.basename(result.configPath)} (${presetSummary(result)})`);
27650
+ info(`\u2705 Created ${path33__namespace.basename(result.configPath)} (${presetSummary(result)})`);
27364
27651
  if (result.scripts.length > 0) info(` Added npm scripts: ${result.scripts.join(", ")}`);
27365
27652
  if (result.dependency.added && result.dependency.range !== null) {
27366
27653
  info(` Added devDependency: ${result.dependency.name} ${result.dependency.range}`);
@@ -27370,10 +27657,10 @@ async function runInitCommand(invocation) {
27370
27657
  }
27371
27658
  if (result.briefWritten) {
27372
27659
  info(
27373
- ` Wrote ${path32__namespace.basename(result.briefPath)}: a scaffold for the half of PROMPT.md only you can write. Fill it in, then set brief: ${JSON.stringify(path32__namespace.basename(result.briefPath))} in the config to merge it.`
27660
+ ` Wrote ${path33__namespace.basename(result.briefPath)}: a scaffold for the half of PROMPT.md only you can write. Fill it in, then set brief: ${JSON.stringify(path33__namespace.basename(result.briefPath))} in the config to merge it.`
27374
27661
  );
27375
27662
  } else if (fs27__namespace.existsSync(result.briefPath)) {
27376
- info(` Kept ${path32__namespace.basename(result.briefPath)}: it already exists, and is never overwritten.`);
27663
+ info(` Kept ${path33__namespace.basename(result.briefPath)}: it already exists, and is never overwritten.`);
27377
27664
  }
27378
27665
  for (const note of result.notes) info(` \u26A0 ${note}`);
27379
27666
  if (hook) for (const note of hook.notes) info(` ${note}`);
@@ -27410,18 +27697,18 @@ function renderHealthText(report2) {
27410
27697
  function generatorOrigin(cwd) {
27411
27698
  try {
27412
27699
  const pkg = JSON.parse(
27413
- stripJsonComments(fs27__namespace.readFileSync(path32__namespace.join(cwd, "package.json"), "utf8"))
27700
+ stripJsonComments(fs27__namespace.readFileSync(path33__namespace.join(cwd, "package.json"), "utf8"))
27414
27701
  );
27415
27702
  const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
27416
27703
  if (typeof spec === "string") return `project dependency ${spec}`;
27417
27704
  } catch {
27418
27705
  }
27419
27706
  const entry = process.argv[1] ?? "";
27420
- if (entry.includes("_npx") || entry.includes(`${path32__namespace.sep}npx${path32__namespace.sep}`)) return "via npx";
27707
+ if (entry.includes("_npx") || entry.includes(`${path33__namespace.sep}npx${path33__namespace.sep}`)) return "via npx";
27421
27708
  return "global or direct install";
27422
27709
  }
27423
27710
  function detectPackageManager(cwd) {
27424
- const has = (name) => fs27__namespace.existsSync(path32__namespace.join(cwd, name));
27711
+ const has = (name) => fs27__namespace.existsSync(path33__namespace.join(cwd, name));
27425
27712
  if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
27426
27713
  if (has("pnpm-lock.yaml")) return { name: "pnpm", command: "pnpm", args: ["install"] };
27427
27714
  if (has("yarn.lock")) return { name: "yarn", command: "yarn", args: ["install"] };
@@ -27538,7 +27825,7 @@ async function runSetupCommand(invocation, options = {}) {
27538
27825
  }
27539
27826
  info("\n\u{1F9EA} Dry run \u2014 setup would:");
27540
27827
  info(
27541
- ` 1. ${init.reused ? `keep ${path32__namespace.basename(keptConfigPath)}` : `write ${path32__namespace.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
27828
+ ` 1. ${init.reused ? `keep ${path33__namespace.basename(keptConfigPath)}` : `write ${path33__namespace.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
27542
27829
  );
27543
27830
  info(" 2. add the npm scripts, the devDependency and the .gitignore entries");
27544
27831
  if (manager !== null) info(` 3. install with ${manager}`);
@@ -27551,9 +27838,9 @@ async function runSetupCommand(invocation, options = {}) {
27551
27838
  if (invocation.format !== "json") {
27552
27839
  if (!interactive) info(`\u{1F680} Setup for: ${invocation.cwd}`);
27553
27840
  if (init.reused) {
27554
- info(`\u267B Keeping ${path32__namespace.basename(keptConfigPath)}`);
27841
+ info(`\u267B Keeping ${path33__namespace.basename(keptConfigPath)}`);
27555
27842
  } else {
27556
- info(`\u2705 Created ${path32__namespace.basename(keptConfigPath)} (${presetSummary(init)})`);
27843
+ info(`\u2705 Created ${path33__namespace.basename(keptConfigPath)} (${presetSummary(init)})`);
27557
27844
  }
27558
27845
  if (init.scripts.length > 0) info(` Added npm scripts: ${init.scripts.join(", ")}`);
27559
27846
  if (init.dependency.added && init.dependency.range !== null) {
@@ -27564,7 +27851,7 @@ async function runSetupCommand(invocation, options = {}) {
27564
27851
  }
27565
27852
  if (init.briefWritten) {
27566
27853
  info(
27567
- ` Wrote ${path32__namespace.basename(init.briefPath)}: a scaffold for the half of PROMPT.md only you can write. Fill it in, then set brief: ${JSON.stringify(path32__namespace.basename(init.briefPath))} in the config to merge it.`
27854
+ ` Wrote ${path33__namespace.basename(init.briefPath)}: a scaffold for the half of PROMPT.md only you can write. Fill it in, then set brief: ${JSON.stringify(path33__namespace.basename(init.briefPath))} in the config to merge it.`
27568
27855
  );
27569
27856
  }
27570
27857
  if (hook) for (const note of hook.notes) info(` ${note}`);
@@ -27572,7 +27859,7 @@ async function runSetupCommand(invocation, options = {}) {
27572
27859
  info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
27573
27860
  }
27574
27861
  }
27575
- const hasManifest = fs27__namespace.existsSync(path32__namespace.join(invocation.cwd, "package.json"));
27862
+ const hasManifest = fs27__namespace.existsSync(path33__namespace.join(invocation.cwd, "package.json"));
27576
27863
  let install = null;
27577
27864
  if (invocation.noInstall) {
27578
27865
  if (invocation.format !== "json") info(" Skipped the install (--no-install)");
@@ -27737,7 +28024,7 @@ function runSkillCommand(invocation) {
27737
28024
  }
27738
28025
  info(`\u2705 Agent skill installed (${SKILL_NAME}):`);
27739
28026
  for (const item of result.written) {
27740
- const shown = path32__namespace.relative(invocation.cwd, item.path) || item.path;
28027
+ const shown = path33__namespace.relative(invocation.cwd, item.path) || item.path;
27741
28028
  info(` - ${item.action.padEnd(9)} ${shown}`);
27742
28029
  }
27743
28030
  if (result.gitignored.length > 0) {
@@ -27746,7 +28033,7 @@ function runSkillCommand(invocation) {
27746
28033
  info(" These files are this tool's own documentation, so they stay out of git.");
27747
28034
  }
27748
28035
  if (result.mcp !== void 0) {
27749
- const shown = path32__namespace.relative(invocation.cwd, result.mcp.path) || result.mcp.path;
28036
+ const shown = path33__namespace.relative(invocation.cwd, result.mcp.path) || result.mcp.path;
27750
28037
  info(` - ${result.mcp.action.padEnd(9)} ${shown} (codebase-snapshot MCP entry)`);
27751
28038
  }
27752
28039
  for (const note of result.notes) info(` \u26A0 ${note}`);
@@ -27817,6 +28104,78 @@ function guardClosedStdout() {
27817
28104
  throw error;
27818
28105
  });
27819
28106
  }
28107
+ async function readStdin(limit = 1024 * 1024) {
28108
+ const chunks = [];
28109
+ let size2 = 0;
28110
+ for await (const chunk of process.stdin) {
28111
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
28112
+ size2 += buffer.length;
28113
+ if (size2 > limit) throw new Error("the hook payload exceeds 1 MiB");
28114
+ chunks.push(buffer);
28115
+ }
28116
+ return Buffer.concat(chunks).toString("utf8");
28117
+ }
28118
+ async function runGuardCommand(invocation, resolved) {
28119
+ const client = invocation.hook;
28120
+ try {
28121
+ let paths = invocation.paths;
28122
+ let event = "PostToolUse";
28123
+ if (client !== void 0) {
28124
+ const parsed = parseGuardHookInput(client, await readStdin(), resolved.cwd);
28125
+ paths = parsed.paths;
28126
+ event = parsed.event;
28127
+ if (paths.length === 0) {
28128
+ process.stdout.write("{}\n");
28129
+ return 0;
28130
+ }
28131
+ }
28132
+ const changes = resolveImpactChanges(resolved.cwd, {
28133
+ ...paths === void 0 ? { diff: invocation.diff ?? "HEAD" } : { paths }
28134
+ });
28135
+ const manifestPath = path33__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28136
+ let manifest;
28137
+ let trust;
28138
+ if (invocation.noLive) {
28139
+ if (!fs27__namespace.existsSync(manifestPath)) {
28140
+ if (client !== void 0) {
28141
+ warn("guard: no snapshot manifest; the hook was skipped.");
28142
+ process.stdout.write("{}\n");
28143
+ return 0;
28144
+ }
28145
+ return fail(
28146
+ invocation.format,
28147
+ "Manifest not found at " + manifestPath + ". Run generate first, or omit --no-live."
28148
+ );
28149
+ }
28150
+ manifest = loadManifest(manifestPath);
28151
+ } else {
28152
+ const live = await buildLiveIndex(resolved, { useDiskCache: !invocation.noCache });
28153
+ manifest = live.manifest;
28154
+ trust = live.trust;
28155
+ }
28156
+ const impact = computeImpact({
28157
+ manifest,
28158
+ cwd: resolved.cwd,
28159
+ changes,
28160
+ manifestPath,
28161
+ ...trust === void 0 ? {} : { trust }
28162
+ });
28163
+ const report2 = buildGuardReport(impact);
28164
+ if (client !== void 0) {
28165
+ process.stdout.write(renderGuardHook(report2, client, event, invocation.maxChars ?? 1200) + "\n");
28166
+ return 0;
28167
+ }
28168
+ emit(invocation.format, report2, () => info(renderGuardText(report2)));
28169
+ return 0;
28170
+ } catch (err) {
28171
+ if (client !== void 0) {
28172
+ warn("guard: " + err.message + " (hook skipped)");
28173
+ process.stdout.write("{}\n");
28174
+ return 0;
28175
+ }
28176
+ return fail(invocation.format, err.message);
28177
+ }
28178
+ }
27820
28179
  async function main(argv = process.argv.slice(2)) {
27821
28180
  guardClosedStdout();
27822
28181
  const pending = process.stdout.isTTY === true && shouldCheck(argv, process.env) ? checkForUpdate({ current: GENERATOR_VERSION, cacheFile: cacheFilePath() }) : null;
@@ -27904,7 +28263,7 @@ ${USAGE}
27904
28263
  }
27905
28264
  if (invocation.command === "serve") {
27906
28265
  const server = await startWebServer({
27907
- cwd: path32__namespace.resolve(invocation.cwd),
28266
+ cwd: path33__namespace.resolve(invocation.cwd),
27908
28267
  ...invocation.host === void 0 ? {} : { host: invocation.host },
27909
28268
  ...invocation.port === void 0 ? {} : { port: invocation.port },
27910
28269
  ...tokenOption,
@@ -27919,9 +28278,9 @@ ${USAGE}
27919
28278
  } else {
27920
28279
  warn(" WARNING: --no-auth is on. Any page on this machine can read the repository.");
27921
28280
  }
27922
- await new Promise((resolve21) => {
28281
+ await new Promise((resolve22) => {
27923
28282
  const stop = () => {
27924
- void server.close().then(resolve21);
28283
+ void server.close().then(resolve22);
27925
28284
  };
27926
28285
  process.once("SIGINT", stop);
27927
28286
  process.once("SIGTERM", stop);
@@ -27931,7 +28290,7 @@ ${USAGE}
27931
28290
  if (invocation.command === "mcp") {
27932
28291
  if (invocation.http === true) {
27933
28292
  const transport = await startHttpTransport({
27934
- cwd: path32__namespace.resolve(invocation.cwd),
28293
+ cwd: path33__namespace.resolve(invocation.cwd),
27935
28294
  noConfig: invocation.noConfig,
27936
28295
  ...invocation.host === void 0 ? {} : { host: invocation.host },
27937
28296
  ...invocation.port === void 0 ? {} : { port: invocation.port },
@@ -27947,9 +28306,9 @@ ${USAGE}
27947
28306
  } else {
27948
28307
  warn(" WARNING: --no-auth is on. Any page on this machine can read the repository.");
27949
28308
  }
27950
- await new Promise((resolve21) => {
28309
+ await new Promise((resolve22) => {
27951
28310
  const stop = () => {
27952
- void transport.close().then(resolve21);
28311
+ void transport.close().then(resolve22);
27953
28312
  };
27954
28313
  process.once("SIGINT", stop);
27955
28314
  process.once("SIGTERM", stop);
@@ -27957,7 +28316,7 @@ ${USAGE}
27957
28316
  return 0;
27958
28317
  }
27959
28318
  return await runStdioServer({
27960
- cwd: path32__namespace.resolve(invocation.cwd),
28319
+ cwd: path33__namespace.resolve(invocation.cwd),
27961
28320
  noConfig: invocation.noConfig
27962
28321
  });
27963
28322
  }
@@ -27987,7 +28346,7 @@ ${USAGE}
27987
28346
  log: (line) => info(" " + line)
27988
28347
  });
27989
28348
  sourceProvenance = clone.provenance;
27990
- const outDir = path32__namespace.resolve(invocation.cwd, invocation.outDir ?? "snapshot");
28349
+ const outDir = path33__namespace.resolve(invocation.cwd, invocation.outDir ?? "snapshot");
27991
28350
  invocation = { ...invocation, cwd: clone.directory, outDir, noConfig: true };
27992
28351
  info(
27993
28352
  " Source: " + parsed.source.owner + "/" + parsed.source.repo + "@" + clone.commit.slice(0, 12) + " (fetched " + clone.provenance.fetchedAt + ")"
@@ -28017,7 +28376,7 @@ ${USAGE}
28017
28376
  );
28018
28377
  }
28019
28378
  for (const warning of loaded.warnings) warn(`\u26A0 Config: ${warning}`);
28020
- if (loaded.file) info(`\u2699 Using config ${path32__namespace.relative(process.cwd(), loaded.file) || loaded.file}`);
28379
+ if (loaded.file) info(`\u2699 Using config ${path33__namespace.relative(process.cwd(), loaded.file) || loaded.file}`);
28021
28380
  let resolved;
28022
28381
  try {
28023
28382
  resolved = resolveConfig(
@@ -28028,6 +28387,9 @@ ${USAGE}
28028
28387
  } catch (err) {
28029
28388
  return fail(invocation.format, err.message);
28030
28389
  }
28390
+ if (invocation.command === "guard") {
28391
+ return await runGuardCommand(invocation, resolved);
28392
+ }
28031
28393
  if (invocation.command === "validate") {
28032
28394
  const result = validateSnapshot(resolved);
28033
28395
  emit(invocation.format, result, () => renderValidateText(result));
@@ -28035,8 +28397,8 @@ ${USAGE}
28035
28397
  }
28036
28398
  if (invocation.command === "health") {
28037
28399
  if (invocation.allMembers === true) {
28038
- const outRoot = path32__namespace.resolve(resolved.cwd, resolved.outDir);
28039
- const indexPath = path32__namespace.join(outRoot, "WORKSPACE.json");
28400
+ const outRoot = path33__namespace.resolve(resolved.cwd, resolved.outDir);
28401
+ const indexPath = path33__namespace.join(outRoot, "WORKSPACE.json");
28040
28402
  if (!fs27__namespace.existsSync(indexPath)) {
28041
28403
  return fail(
28042
28404
  invocation.format,
@@ -28055,15 +28417,15 @@ ${USAGE}
28055
28417
  }
28056
28418
  const rows = [];
28057
28419
  const insidePath = (parent, child) => {
28058
- const relative20 = path32__namespace.relative(parent, child);
28059
- return relative20 === "" || relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !relative20.startsWith("../") && !path32__namespace.isAbsolute(relative20);
28420
+ const relative21 = path33__namespace.relative(parent, child);
28421
+ return relative21 === "" || relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !relative21.startsWith("../") && !path33__namespace.isAbsolute(relative21);
28060
28422
  };
28061
28423
  for (const member of index.members ?? []) {
28062
28424
  const name = member.name ?? "?";
28063
- const snapshotDir2 = path32__namespace.resolve(outRoot, name);
28425
+ const snapshotDir2 = path33__namespace.resolve(outRoot, name);
28064
28426
  const repoPath = member.path ?? name;
28065
- const repoDir = path32__namespace.resolve(resolved.cwd, repoPath);
28066
- if (name.length === 0 || path32__namespace.isAbsolute(name) || name.split(/[\\/]/).includes("..") || !insidePath(outRoot, snapshotDir2) || path32__namespace.isAbsolute(repoPath) || repoPath.split(/[\\/]/).includes("..") || !insidePath(resolved.cwd, repoDir)) {
28427
+ const repoDir = path33__namespace.resolve(resolved.cwd, repoPath);
28428
+ if (name.length === 0 || path33__namespace.isAbsolute(name) || name.split(/[\\/]/).includes("..") || !insidePath(outRoot, snapshotDir2) || path33__namespace.isAbsolute(repoPath) || repoPath.split(/[\\/]/).includes("..") || !insidePath(resolved.cwd, repoDir)) {
28067
28429
  rows.push({
28068
28430
  name,
28069
28431
  score: 0,
@@ -28094,7 +28456,7 @@ ${USAGE}
28094
28456
  canonicalSnapshot = snapshotDir2;
28095
28457
  canonicalRepo = repoDir;
28096
28458
  }
28097
- if (!fs27__namespace.existsSync(path32__namespace.join(snapshotDir2, "manifest.json"))) {
28459
+ if (!fs27__namespace.existsSync(path33__namespace.join(snapshotDir2, "manifest.json"))) {
28098
28460
  rows.push({ name, score: 0, counts: { pass: 0, warn: 0, fail: 1 }, failed: [], error: "no snapshot at " + snapshotDir2 });
28099
28461
  continue;
28100
28462
  }
@@ -28141,7 +28503,7 @@ ${USAGE}
28141
28503
  if (invocation.strict === true && totals.warn > 0) return 1;
28142
28504
  return 0;
28143
28505
  }
28144
- const snapshotDir = path32__namespace.resolve(resolved.cwd, resolved.outDir);
28506
+ const snapshotDir = path33__namespace.resolve(resolved.cwd, resolved.outDir);
28145
28507
  const report2 = auditSnapshot({
28146
28508
  snapshotDir,
28147
28509
  repoDir: resolved.cwd,
@@ -28154,7 +28516,7 @@ ${USAGE}
28154
28516
  return 0;
28155
28517
  }
28156
28518
  if (invocation.command === "report") {
28157
- const manifestPath = path32__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28519
+ const manifestPath = path33__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28158
28520
  if (!fs27__namespace.existsSync(manifestPath)) {
28159
28521
  return fail(invocation.format, `Manifest not found at ${manifestPath}. Run generate first.`);
28160
28522
  }
@@ -28217,7 +28579,7 @@ ${USAGE}
28217
28579
  if (manifest.delta !== void 0) {
28218
28580
  const delta = manifest.delta;
28219
28581
  info("\n Selection (delta):");
28220
- info(` - Against: ${path32__namespace.basename(delta.base.path)} (${delta.base.fingerprint.slice(0, 12)})`);
28582
+ info(` - Against: ${path33__namespace.basename(delta.base.path)} (${delta.base.fingerprint.slice(0, 12)})`);
28221
28583
  info(
28222
28584
  ` - Changed: ${delta.changed.length} changed, ${delta.added.length} added, ${delta.removed.length} removed, ${delta.unchanged.length} unchanged`
28223
28585
  );
@@ -28227,7 +28589,7 @@ ${USAGE}
28227
28589
  }
28228
28590
  if (invocation.command === "impact") {
28229
28591
  try {
28230
- const manifestPath = path32__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28592
+ const manifestPath = path33__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28231
28593
  let manifest;
28232
28594
  let live = null;
28233
28595
  if (invocation.noLive) {
@@ -28349,7 +28711,7 @@ ${USAGE}
28349
28711
  }
28350
28712
  if (invocation.command === "brief") {
28351
28713
  try {
28352
- const manifestPath = path32__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28714
+ const manifestPath = path33__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
28353
28715
  let manifest;
28354
28716
  let live = null;
28355
28717
  if (invocation.noLive) {
@@ -28405,10 +28767,10 @@ ${USAGE}
28405
28767
  if (isSensitivePath(relativePath)) return null;
28406
28768
  const file = manifest.files.find((candidate) => candidate.relativePath === relativePath);
28407
28769
  if (file === void 0) return null;
28408
- const snapshotDir = path32__namespace.resolve(resolved.cwd, resolved.outDir);
28770
+ const snapshotDir = path33__namespace.resolve(resolved.cwd, resolved.outDir);
28409
28771
  const read = readConfinedText(
28410
28772
  snapshotDir,
28411
- path32__namespace.posix.join("parts", file.part),
28773
+ path33__namespace.posix.join("parts", file.part),
28412
28774
  16 * 1024 * 1024
28413
28775
  );
28414
28776
  if (!read.ok) return null;
@@ -28433,7 +28795,7 @@ ${USAGE}
28433
28795
  });
28434
28796
  if (invocation.out !== void 0) {
28435
28797
  const written = writeInside(resolved.cwd, invocation.out, brief.markdown);
28436
- info("Wrote " + path32__namespace.relative(resolved.cwd, written));
28798
+ info("Wrote " + path33__namespace.relative(resolved.cwd, written));
28437
28799
  } else if (invocation.format !== "json") {
28438
28800
  process.stdout.write(brief.markdown);
28439
28801
  }
@@ -28509,10 +28871,10 @@ ${USAGE}
28509
28871
  "--workspace writes one snapshot per member; --remote, --delta, --slice, --budget-tokens and --sign do not combine with it."
28510
28872
  );
28511
28873
  }
28512
- const outRoot = path32__namespace.resolve(invocation.cwd, invocation.outDir ?? "snapshot");
28513
- const workspaceCwd = path32__namespace.resolve(invocation.cwd);
28514
- const outRootRelative = path32__namespace.relative(outRoot, workspaceCwd);
28515
- if (outRootRelative === "" || outRootRelative !== ".." && !outRootRelative.startsWith(`..${path32__namespace.sep}`) && !outRootRelative.startsWith("../") && !path32__namespace.isAbsolute(outRootRelative)) {
28874
+ const outRoot = path33__namespace.resolve(invocation.cwd, invocation.outDir ?? "snapshot");
28875
+ const workspaceCwd = path33__namespace.resolve(invocation.cwd);
28876
+ const outRootRelative = path33__namespace.relative(outRoot, workspaceCwd);
28877
+ if (outRootRelative === "" || outRootRelative !== ".." && !outRootRelative.startsWith(`..${path33__namespace.sep}`) && !outRootRelative.startsWith("../") && !path33__namespace.isAbsolute(outRootRelative)) {
28516
28878
  return fail(
28517
28879
  invocation.format,
28518
28880
  `--workspace refuses --out-dir ${outRoot}: it is the working directory or one of its ancestors.`
@@ -28520,8 +28882,8 @@ ${USAGE}
28520
28882
  }
28521
28883
  const plannedNames = /* @__PURE__ */ new Map();
28522
28884
  for (const member of members) {
28523
- const directory = path32__namespace.resolve(invocation.cwd, member);
28524
- const name = path32__namespace.basename(directory);
28885
+ const directory = path33__namespace.resolve(invocation.cwd, member);
28886
+ const name = path33__namespace.basename(directory);
28525
28887
  const previous = plannedNames.get(name);
28526
28888
  if (previous !== void 0) {
28527
28889
  return fail(
@@ -28534,8 +28896,8 @@ ${USAGE}
28534
28896
  const records = [];
28535
28897
  let failed = 0;
28536
28898
  for (const member of members) {
28537
- const directory = path32__namespace.resolve(invocation.cwd, member);
28538
- const name = path32__namespace.basename(directory);
28899
+ const directory = path33__namespace.resolve(invocation.cwd, member);
28900
+ const name = path33__namespace.basename(directory);
28539
28901
  let stat;
28540
28902
  try {
28541
28903
  stat = fs27__namespace.statSync(directory);
@@ -28555,7 +28917,7 @@ ${USAGE}
28555
28917
  {
28556
28918
  ...generateCliOptions(invocation),
28557
28919
  cwd: directory,
28558
- outDir: path32__namespace.join(outRoot, name)
28920
+ outDir: path33__namespace.join(outRoot, name)
28559
28921
  },
28560
28922
  directory
28561
28923
  );
@@ -28582,10 +28944,10 @@ ${USAGE}
28582
28944
  for (const entry of record.imports) {
28583
28945
  for (const specifier of entry.imports) {
28584
28946
  if (!specifier.startsWith(".")) continue;
28585
- const resolved2 = path32__namespace.resolve(record.path, path32__namespace.dirname(entry.path), specifier);
28947
+ const resolved2 = path33__namespace.resolve(record.path, path33__namespace.dirname(entry.path), specifier);
28586
28948
  for (const other of records) {
28587
28949
  if (other === record) continue;
28588
- const prefix = other.path + path32__namespace.sep;
28950
+ const prefix = other.path + path33__namespace.sep;
28589
28951
  if (!resolved2.startsWith(prefix) && resolved2 !== other.path) continue;
28590
28952
  const bucket = counts.get(other.name) ?? { count: 0, examples: [] };
28591
28953
  bucket.count += 1;
@@ -28610,12 +28972,12 @@ ${USAGE}
28610
28972
  // Store the member path relative to the workspace cwd, as manifest paths already are.
28611
28973
  members: records.map(({ imports: _imports, ...rest }) => ({
28612
28974
  ...rest,
28613
- path: path32__namespace.relative(workspaceCwd, rest.path).split(path32__namespace.sep).join("/") || "."
28975
+ path: path33__namespace.relative(workspaceCwd, rest.path).split(path33__namespace.sep).join("/") || "."
28614
28976
  })),
28615
28977
  links
28616
28978
  };
28617
28979
  if (!invocation.dryRun) {
28618
- const workspacePath = path32__namespace.join(outRoot, "WORKSPACE.json");
28980
+ const workspacePath = path33__namespace.join(outRoot, "WORKSPACE.json");
28619
28981
  try {
28620
28982
  const stats = fs27__namespace.lstatSync(workspacePath);
28621
28983
  if (stats.isSymbolicLink() || !stats.isFile()) {
@@ -28658,8 +29020,8 @@ ${USAGE}
28658
29020
  try {
28659
29021
  let deltaBase;
28660
29022
  if (invocation.delta !== void 0) {
28661
- const basePath = path32__namespace.resolve(invocation.cwd, invocation.delta);
28662
- const manifestPath = fs27__namespace.existsSync(basePath) && fs27__namespace.statSync(basePath).isDirectory() ? path32__namespace.join(basePath, "manifest.json") : basePath;
29023
+ const basePath = path33__namespace.resolve(invocation.cwd, invocation.delta);
29024
+ const manifestPath = fs27__namespace.existsSync(basePath) && fs27__namespace.statSync(basePath).isDirectory() ? path33__namespace.join(basePath, "manifest.json") : basePath;
28663
29025
  if (!fs27__namespace.existsSync(manifestPath)) {
28664
29026
  return fail(invocation.format, "No manifest at " + manifestPath + ". Point --delta at a snapshot directory or its manifest.json.");
28665
29027
  }
@@ -28673,8 +29035,8 @@ ${USAGE}
28673
29035
  if (shape !== null) {
28674
29036
  return fail(invocation.format, manifestPath + " is not a snapshot manifest: " + shape);
28675
29037
  }
28676
- const relativeBase = path32__namespace.relative(invocation.cwd, manifestPath).split(path32__namespace.sep).join("/");
28677
- const recordedBase = relativeBase === "" || relativeBase === ".." || relativeBase.startsWith(`..${path32__namespace.sep}`) || relativeBase.startsWith("../") || path32__namespace.isAbsolute(relativeBase) ? path32__namespace.basename(manifestPath) : relativeBase;
29038
+ const relativeBase = path33__namespace.relative(invocation.cwd, manifestPath).split(path33__namespace.sep).join("/");
29039
+ const recordedBase = relativeBase === "" || relativeBase === ".." || relativeBase.startsWith(`..${path33__namespace.sep}`) || relativeBase.startsWith("../") || path33__namespace.isAbsolute(relativeBase) ? path33__namespace.basename(manifestPath) : relativeBase;
28678
29040
  deltaBase = { manifest: base, path: recordedBase };
28679
29041
  info(" Delta base: " + recordedBase + " (" + base.files.length + " files, fingerprint " + base.fingerprint.slice(0, 12) + ")");
28680
29042
  }
@@ -28692,7 +29054,7 @@ ${USAGE}
28692
29054
  ...invocation.sign === true && !invocation.dryRun ? { sign: { key: loadSigningKey() } } : {}
28693
29055
  });
28694
29056
  if (invocation.sign === true && !invocation.dryRun) {
28695
- const signaturePath = path32__namespace.resolve(resolved.cwd, resolved.outDir, SIGNATURE_FILE);
29057
+ const signaturePath = path33__namespace.resolve(resolved.cwd, resolved.outDir, SIGNATURE_FILE);
28696
29058
  try {
28697
29059
  const record = JSON.parse(fs27__namespace.readFileSync(signaturePath, "utf8"));
28698
29060
  info(
@@ -28847,19 +29209,19 @@ function finishWatchRun(state, now) {
28847
29209
  };
28848
29210
  }
28849
29211
  function comparablePath(value) {
28850
- const absolute = path32__namespace.resolve(value);
29212
+ const absolute = path33__namespace.resolve(value);
28851
29213
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
28852
29214
  }
28853
29215
  function isSameOrInside(parent, candidate) {
28854
- const relative20 = path32__namespace.relative(parent, candidate);
28855
- return relative20 === "" || relative20 !== ".." && !relative20.startsWith(`..${path32__namespace.sep}`) && !path32__namespace.isAbsolute(relative20);
29216
+ const relative21 = path33__namespace.relative(parent, candidate);
29217
+ return relative21 === "" || relative21 !== ".." && !relative21.startsWith(`..${path33__namespace.sep}`) && !path33__namespace.isAbsolute(relative21);
28856
29218
  }
28857
29219
  function isGeneratedWatchPath(candidate, paths) {
28858
- const absolute = comparablePath(path32__namespace.resolve(paths.cwd, candidate));
28859
- const outDir = comparablePath(path32__namespace.resolve(paths.cwd, paths.outDir));
28860
- const tmpDir = comparablePath(path32__namespace.resolve(paths.cwd, paths.tmpDir));
29220
+ const absolute = comparablePath(path33__namespace.resolve(paths.cwd, candidate));
29221
+ const outDir = comparablePath(path33__namespace.resolve(paths.cwd, paths.outDir));
29222
+ const tmpDir = comparablePath(path33__namespace.resolve(paths.cwd, paths.tmpDir));
28861
29223
  if (isSameOrInside(outDir, absolute) || isSameOrInside(tmpDir, absolute)) return true;
28862
- const offsets = [path32__namespace.basename(outDir), path32__namespace.basename(tmpDir)].filter((name) => name.length > 0);
29224
+ const offsets = [path33__namespace.basename(outDir), path33__namespace.basename(tmpDir)].filter((name) => name.length > 0);
28863
29225
  const leftover = absolute.split(/[\\/]+/).some(
28864
29226
  (segment) => offsets.some(
28865
29227
  (name) => segment.startsWith(`${name}.backup-`) || segment.startsWith(`${name}.partial-`)
@@ -28882,8 +29244,8 @@ function decideWatchEvent(state, event, paths) {
28882
29244
  function watchPathsFor(config) {
28883
29245
  return {
28884
29246
  cwd: config.cwd,
28885
- outDir: path32__namespace.resolve(config.cwd, config.outDir),
28886
- tmpDir: path32__namespace.resolve(config.cwd, config.tmpDir)
29247
+ outDir: path33__namespace.resolve(config.cwd, config.outDir),
29248
+ tmpDir: path33__namespace.resolve(config.cwd, config.tmpDir)
28887
29249
  };
28888
29250
  }
28889
29251
  function watchSupportProblem(platform = process.platform, version = process.versions.node) {
@@ -28961,7 +29323,7 @@ async function runWatchLoop(invocation, resolved, options) {
28961
29323
  const decision = decideWatchEvent(
28962
29324
  state,
28963
29325
  {
28964
- path: filename ? path32__namespace.resolve(resolved.cwd, filename.toString()) : null,
29326
+ path: filename ? path33__namespace.resolve(resolved.cwd, filename.toString()) : null,
28965
29327
  now: performance.now()
28966
29328
  },
28967
29329
  paths
@@ -28987,12 +29349,12 @@ async function runWatchLoop(invocation, resolved, options) {
28987
29349
  info(`\u26A0 Watch error: ${err.message}`);
28988
29350
  info(" The watcher may have missed changes. Restart with Ctrl+C if they stop arriving.");
28989
29351
  });
28990
- await new Promise((resolve21) => {
29352
+ await new Promise((resolve22) => {
28991
29353
  const stop = () => {
28992
29354
  stopped = true;
28993
29355
  if (timer) clearTimeout(timer);
28994
29356
  watcher.close();
28995
- resolve21();
29357
+ resolve22();
28996
29358
  };
28997
29359
  process.once("SIGINT", stop);
28998
29360
  process.once("SIGTERM", stop);
@@ -29002,12 +29364,12 @@ async function runWatchLoop(invocation, resolved, options) {
29002
29364
  var entryFile = process.argv[1] ?? "";
29003
29365
  var sameFile = (left, right) => {
29004
29366
  try {
29005
- return fs27__namespace.realpathSync(path32__namespace.resolve(left)) === fs27__namespace.realpathSync(path32__namespace.resolve(right));
29367
+ return fs27__namespace.realpathSync(path33__namespace.resolve(left)) === fs27__namespace.realpathSync(path33__namespace.resolve(right));
29006
29368
  } catch {
29007
29369
  return false;
29008
29370
  }
29009
29371
  };
29010
- var entryName = path32__namespace.basename(entryFile).toLowerCase();
29372
+ var entryName = path33__namespace.basename(entryFile).toLowerCase();
29011
29373
  var invokedDirectly = (entryName === "cli.js" || entryName === "cli.cjs") && entryFile.length > 0 && sameFile(entryFile, url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
29012
29374
  if (invokedDirectly) {
29013
29375
  void main().then(