codebase-snapshot 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3,9 +3,9 @@
3
3
  var crypto2 = require('crypto');
4
4
  var worker_threads = require('worker_threads');
5
5
  var async_hooks = require('async_hooks');
6
- var fs15 = require('fs');
6
+ var fs16 = require('fs');
7
7
  var os = require('os');
8
- var path16 = require('path');
8
+ var path17 = require('path');
9
9
  var ts = require('typescript');
10
10
  var module$1 = require('module');
11
11
  var url = require('url');
@@ -35,9 +35,9 @@ function _interopNamespace(e) {
35
35
  }
36
36
 
37
37
  var crypto2__namespace = /*#__PURE__*/_interopNamespace(crypto2);
38
- var fs15__namespace = /*#__PURE__*/_interopNamespace(fs15);
38
+ var fs16__namespace = /*#__PURE__*/_interopNamespace(fs16);
39
39
  var os__namespace = /*#__PURE__*/_interopNamespace(os);
40
- var path16__namespace = /*#__PURE__*/_interopNamespace(path16);
40
+ var path17__namespace = /*#__PURE__*/_interopNamespace(path17);
41
41
  var ts__default = /*#__PURE__*/_interopDefault(ts);
42
42
  var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
43
43
  var http__namespace = /*#__PURE__*/_interopNamespace(http);
@@ -412,9 +412,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
412
412
  var jvmProfile = {
413
413
  id: "jvm",
414
414
  extensions: [".java", ".kt", ".kts", ".scala"],
415
- summarize(path17, content) {
415
+ summarize(path18, content) {
416
416
  const summary = emptySummary();
417
- const lower = path17.toLowerCase();
417
+ const lower = path18.toLowerCase();
418
418
  const isJava = lower.endsWith(".java");
419
419
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
420
420
  eachLine(content, (line) => {
@@ -1022,17 +1022,17 @@ function summarizeTypeScriptSource(relativePath, content) {
1022
1022
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script>/gi;
1023
1023
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
1024
1024
  var ASTRO_FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?=\r?\n|$)/;
1025
- function componentName(path17) {
1026
- const base = path17.split("/").pop() ?? path17;
1025
+ function componentName(path18) {
1026
+ const base = path18.split("/").pop() ?? path18;
1027
1027
  return base.replace(/\.[^.]+$/, "");
1028
1028
  }
1029
1029
  var sfcProfile = {
1030
1030
  id: "sfc",
1031
1031
  extensions: [".vue", ".svelte", ".astro"],
1032
- summarize(path17, content) {
1032
+ summarize(path18, content) {
1033
1033
  let script = "";
1034
- let usesJsx = path17.toLowerCase().endsWith(".astro");
1035
- if (path17.toLowerCase().endsWith(".astro")) {
1034
+ let usesJsx = path18.toLowerCase().endsWith(".astro");
1035
+ if (path18.toLowerCase().endsWith(".astro")) {
1036
1036
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
1037
1037
  if (frontmatter) script += `${frontmatter[1]}
1038
1038
  `;
@@ -1042,7 +1042,7 @@ var sfcProfile = {
1042
1042
  script += `${match[2]}
1043
1043
  `;
1044
1044
  }
1045
- const name = componentName(path17);
1045
+ const name = componentName(path18);
1046
1046
  if (!script.trim()) {
1047
1047
  const summary2 = emptySummary();
1048
1048
  if (name) {
@@ -1233,15 +1233,15 @@ for (const profile of LANGUAGE_PROFILES) {
1233
1233
  BY_EXTENSION.set(extension.toLowerCase(), profile);
1234
1234
  }
1235
1235
  }
1236
- function profileForPath(path17) {
1237
- const lower = path17.toLowerCase();
1236
+ function profileForPath(path18) {
1237
+ const lower = path18.toLowerCase();
1238
1238
  const dot = lower.lastIndexOf(".");
1239
1239
  if (dot === -1) return null;
1240
1240
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
1241
1241
  }
1242
- function summarizeWithProfile(path17, content) {
1243
- const profile = profileForPath(path17);
1244
- return profile ? profile.summarize(path17, content) : null;
1242
+ function summarizeWithProfile(path18, content) {
1243
+ const profile = profileForPath(path18);
1244
+ return profile ? profile.summarize(path18, content) : null;
1245
1245
  }
1246
1246
  var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
1247
1247
  ".png",
@@ -1286,7 +1286,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
1286
1286
  ".so"
1287
1287
  ]);
1288
1288
  function isBinaryExtension(filePath) {
1289
- const ext = path16__namespace.extname(filePath).toLowerCase();
1289
+ const ext = path17__namespace.extname(filePath).toLowerCase();
1290
1290
  return BINARY_EXTENSIONS.has(ext);
1291
1291
  }
1292
1292
  function isBinaryBuffer(buffer) {
@@ -1456,13 +1456,13 @@ function isBinaryFile(absolutePath) {
1456
1456
  if (isBinaryExtension(absolutePath)) return true;
1457
1457
  let fd;
1458
1458
  try {
1459
- fd = fs15__namespace.openSync(absolutePath, "r");
1459
+ fd = fs16__namespace.openSync(absolutePath, "r");
1460
1460
  const buffer = Buffer.alloc(CHUNK);
1461
1461
  let sample;
1462
1462
  let position = 0;
1463
1463
  while (position < BINARY_SCAN_BYTES) {
1464
1464
  const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
1465
- const bytesRead = fs15__namespace.readSync(fd, buffer, 0, wanted, position);
1465
+ const bytesRead = fs16__namespace.readSync(fd, buffer, 0, wanted, position);
1466
1466
  if (bytesRead === 0) return false;
1467
1467
  const chunk = buffer.subarray(0, bytesRead);
1468
1468
  if (sample === void 0) {
@@ -1480,7 +1480,7 @@ function isBinaryFile(absolutePath) {
1480
1480
  } finally {
1481
1481
  if (fd !== void 0) {
1482
1482
  try {
1483
- fs15__namespace.closeSync(fd);
1483
+ fs16__namespace.closeSync(fd);
1484
1484
  } catch {
1485
1485
  }
1486
1486
  }
@@ -1502,9 +1502,9 @@ function importsOfText(relativePath, text2) {
1502
1502
  function importsOfFile(relativePath, absolutePath) {
1503
1503
  let buffer;
1504
1504
  try {
1505
- const stats = fs15__namespace.statSync(absolutePath);
1505
+ const stats = fs16__namespace.statSync(absolutePath);
1506
1506
  if (!stats.isFile() || stats.size > SUMMARY_MAX_SOURCE_BYTES) return [];
1507
- buffer = fs15__namespace.readFileSync(absolutePath);
1507
+ buffer = fs16__namespace.readFileSync(absolutePath);
1508
1508
  } catch {
1509
1509
  return [];
1510
1510
  }
@@ -1750,6 +1750,77 @@ function isSkeletonizable(filePath) {
1750
1750
  }
1751
1751
  return lower.endsWith(".ts") || lower.endsWith(".tsx") || lower.endsWith(".mts") || lower.endsWith(".cts") || lower.endsWith(".js") || lower.endsWith(".jsx") || lower.endsWith(".mjs") || lower.endsWith(".cjs");
1752
1752
  }
1753
+ var OWNER_SECTIONS = ["Stakes", "The system", "What came before", "The bar", "Calibration"];
1754
+ var RESERVED_SECTIONS = [
1755
+ "The job",
1756
+ "What you have",
1757
+ "Coverage",
1758
+ "What a useful answer contains",
1759
+ "This snapshot",
1760
+ "Attaching this",
1761
+ "Your task"
1762
+ ];
1763
+ function parseOwnerBrief(filePath, text2) {
1764
+ const problems = [];
1765
+ const source = text2.replace(/^\uFEFF/, "");
1766
+ const preamble = [];
1767
+ const sections = [];
1768
+ let current = null;
1769
+ for (const line of source.split(/\r?\n/)) {
1770
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
1771
+ if (heading) {
1772
+ current = { heading: heading[1], body: [] };
1773
+ sections.push(current);
1774
+ continue;
1775
+ }
1776
+ if (current) current.body.push(line);
1777
+ else preamble.push(line);
1778
+ }
1779
+ const recognised = {};
1780
+ const notes = [];
1781
+ const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
1782
+ const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
1783
+ const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
1784
+ const seen = /* @__PURE__ */ new Set();
1785
+ for (const section of sections) {
1786
+ const body = section.body.join("\n").trim();
1787
+ const key = canonical(section.heading);
1788
+ if (seen.has(key)) {
1789
+ problems.push(
1790
+ `the brief defines "${section.heading}" twice; a section cannot say two things.`
1791
+ );
1792
+ continue;
1793
+ }
1794
+ seen.add(key);
1795
+ if (canonicalReserved.has(key)) {
1796
+ problems.push(
1797
+ `the brief may not define "${section.heading}": that section is rendered from the manifest, and letting prose overwrite a measured section would make the document lie.`
1798
+ );
1799
+ continue;
1800
+ }
1801
+ const ownerName = canonicalOwner.get(key);
1802
+ if (ownerName !== void 0) {
1803
+ recognised[ownerName] = body;
1804
+ continue;
1805
+ }
1806
+ notes.push({ heading: section.heading, body });
1807
+ }
1808
+ const preambleText = preamble.join("\n").trim();
1809
+ return {
1810
+ brief: {
1811
+ path: filePath,
1812
+ digest: crypto2.createHash("sha256").update(text2, "utf8").digest("hex"),
1813
+ ...recognised["Stakes"] ? { stakes: recognised["Stakes"] } : {},
1814
+ ...recognised["The system"] ? { system: recognised["The system"] } : {},
1815
+ ...recognised["What came before"] ? { history: recognised["What came before"] } : {},
1816
+ ...recognised["The bar"] ? { bar: recognised["The bar"] } : {},
1817
+ ...recognised["Calibration"] ? { calibration: recognised["Calibration"] } : {},
1818
+ notes,
1819
+ ...preambleText.length > 0 ? { preamble: preambleText } : {}
1820
+ },
1821
+ problems
1822
+ };
1823
+ }
1753
1824
  var MANIFEST_FILES = [
1754
1825
  "package.json",
1755
1826
  "pyproject.toml",
@@ -1796,15 +1867,15 @@ var SKIPPED_WALK_DIRS = /* @__PURE__ */ new Set([
1796
1867
  ]);
1797
1868
  function readSmallFile(fullPath) {
1798
1869
  try {
1799
- const stats = fs15__namespace.statSync(fullPath);
1870
+ const stats = fs16__namespace.statSync(fullPath);
1800
1871
  if (!stats.isFile() || stats.size > MANIFEST_MAX_BYTES) return null;
1801
- return fs15__namespace.readFileSync(fullPath, "utf8");
1872
+ return fs16__namespace.readFileSync(fullPath, "utf8");
1802
1873
  } catch {
1803
1874
  return null;
1804
1875
  }
1805
1876
  }
1806
1877
  function readManifest(cwd, name) {
1807
- return readSmallFile(path16__namespace.join(cwd, name));
1878
+ return readSmallFile(path17__namespace.join(cwd, name));
1808
1879
  }
1809
1880
  function dependenciesFromPackageJson(raw) {
1810
1881
  const names = /* @__PURE__ */ new Set();
@@ -1864,7 +1935,7 @@ function pnpmWorkspacePatterns(raw) {
1864
1935
  function childDirectories(cwd, parent) {
1865
1936
  let entries;
1866
1937
  try {
1867
- entries = fs15__namespace.readdirSync(path16__namespace.join(cwd, parent), { withFileTypes: true });
1938
+ entries = fs16__namespace.readdirSync(path17__namespace.join(cwd, parent), { withFileTypes: true });
1868
1939
  } catch {
1869
1940
  return [];
1870
1941
  }
@@ -1900,12 +1971,12 @@ function scanWorkspacePackages(cwd, patterns) {
1900
1971
  const files = /* @__PURE__ */ new Set();
1901
1972
  const dependencies = /* @__PURE__ */ new Set();
1902
1973
  for (const relative11 of workspacePackageDirs(cwd, patterns)) {
1903
- const full = path16__namespace.join(cwd, relative11);
1974
+ const full = path17__namespace.join(cwd, relative11);
1904
1975
  try {
1905
- for (const entry of fs15__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
1976
+ for (const entry of fs16__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
1906
1977
  } catch {
1907
1978
  }
1908
- const raw = readSmallFile(path16__namespace.join(full, "package.json"));
1979
+ const raw = readSmallFile(path17__namespace.join(full, "package.json"));
1909
1980
  if (raw !== null) {
1910
1981
  for (const name of dependenciesFromPackageJson(raw)) dependencies.add(name);
1911
1982
  }
@@ -1915,7 +1986,7 @@ function scanWorkspacePackages(cwd, patterns) {
1915
1986
  var SNAPSHOT_MARKER = ".codebase-snapshot";
1916
1987
  function isToolOwnedDirectory(dir) {
1917
1988
  try {
1918
- return fs15__namespace.statSync(dir).isDirectory() && fs15__namespace.existsSync(path16__namespace.join(dir, SNAPSHOT_MARKER));
1989
+ return fs16__namespace.statSync(dir).isDirectory() && fs16__namespace.existsSync(path17__namespace.join(dir, SNAPSHOT_MARKER));
1919
1990
  } catch {
1920
1991
  return false;
1921
1992
  }
@@ -1930,7 +2001,7 @@ function countMarkdownFiles(cwd) {
1930
2001
  directoriesSeen += 1;
1931
2002
  let entries;
1932
2003
  try {
1933
- entries = fs15__namespace.readdirSync(current.dir, { withFileTypes: true });
2004
+ entries = fs16__namespace.readdirSync(current.dir, { withFileTypes: true });
1934
2005
  } catch {
1935
2006
  continue;
1936
2007
  }
@@ -1941,7 +2012,7 @@ function countMarkdownFiles(cwd) {
1941
2012
  }
1942
2013
  if (!entry.isDirectory() || current.depth >= 2) continue;
1943
2014
  if (entry.name.startsWith(".") || SKIPPED_WALK_DIRS.has(entry.name)) continue;
1944
- const child = path16__namespace.join(current.dir, entry.name);
2015
+ const child = path17__namespace.join(current.dir, entry.name);
1945
2016
  if (isToolOwnedDirectory(child)) continue;
1946
2017
  queue.push({ dir: child, depth: current.depth + 1 });
1947
2018
  }
@@ -1952,7 +2023,7 @@ function buildPresetContext(cwd) {
1952
2023
  const files = /* @__PURE__ */ new Set();
1953
2024
  const dirs = /* @__PURE__ */ new Set();
1954
2025
  try {
1955
- for (const entry of fs15__namespace.readdirSync(cwd, { withFileTypes: true })) {
2026
+ for (const entry of fs16__namespace.readdirSync(cwd, { withFileTypes: true })) {
1956
2027
  if (entry.isDirectory()) dirs.add(entry.name);
1957
2028
  else if (entry.isFile()) files.add(entry.name);
1958
2029
  }
@@ -1969,7 +2040,7 @@ function buildPresetContext(cwd) {
1969
2040
  const isWorkspace = files.has("pnpm-workspace.yaml") || files.has("nx.json") || files.has("turbo.json") || files.has("lerna.json") || packageJson !== void 0 && packageJson.includes('"workspaces"') || declaredWorkspaces.length > 0;
1970
2041
  let workspace = { files: /* @__PURE__ */ new Set(), dependencies: /* @__PURE__ */ new Set() };
1971
2042
  if (isWorkspace) {
1972
- const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path16__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
2043
+ const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path17__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
1973
2044
  const declared = pnpmRaw === null ? [] : pnpmWorkspacePatterns(pnpmRaw);
1974
2045
  const patterns = declared.length > 0 ? declared : declaredWorkspaces.length > 0 ? declaredWorkspaces : DEFAULT_WORKSPACE_PATTERNS;
1975
2046
  workspace = scanWorkspacePackages(cwd, patterns);
@@ -3923,7 +3994,7 @@ function applySpansKeepingQuotes(line, spans) {
3923
3994
 
3924
3995
  // src/version.ts
3925
3996
  var GENERATOR_NAME = "codebase-snapshot";
3926
- var GENERATOR_VERSION = "0.11.0";
3997
+ var GENERATOR_VERSION = "0.12.1";
3927
3998
  var SCHEMA_VERSION = "3.0.0";
3928
3999
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
3929
4000
  function isOurGeneratorName(name) {
@@ -3940,14 +4011,14 @@ var PRESET_IGNORES = new Set(
3940
4011
  );
3941
4012
  function readLinkTarget(linkPath, fallback) {
3942
4013
  try {
3943
- return fs15__namespace.readlinkSync(linkPath);
4014
+ return fs16__namespace.readlinkSync(linkPath);
3944
4015
  } catch {
3945
4016
  return fallback;
3946
4017
  }
3947
4018
  }
3948
4019
  function brokenLinkRecord(linkPath, relativePath, rootReal) {
3949
4020
  const rawTarget = readLinkTarget(linkPath, linkPath);
3950
- const resolvedFallback = path16__namespace.resolve(path16__namespace.dirname(linkPath), rawTarget);
4021
+ const resolvedFallback = path17__namespace.resolve(path17__namespace.dirname(linkPath), rawTarget);
3951
4022
  return isInside(rootReal, resolvedFallback) ? { path: relativePath, reason: "read-error", detail: "broken symlink" } : {
3952
4023
  path: relativePath,
3953
4024
  reason: "outside-root",
@@ -3955,8 +4026,8 @@ function brokenLinkRecord(linkPath, relativePath, rootReal) {
3955
4026
  };
3956
4027
  }
3957
4028
  function isInside(root, candidate) {
3958
- const relative11 = path16__namespace.relative(root, candidate);
3959
- return relative11 === "" || !relative11.startsWith(`..${path16__namespace.sep}`) && relative11 !== ".." && !path16__namespace.isAbsolute(relative11);
4029
+ const relative11 = path17__namespace.relative(root, candidate);
4030
+ return relative11 === "" || !relative11.startsWith(`..${path17__namespace.sep}`) && relative11 !== ".." && !path17__namespace.isAbsolute(relative11);
3960
4031
  }
3961
4032
  var GIT_OUTPUT_LIMIT = 68157440;
3962
4033
  function getGitInfo(cwd, fallbackBranch = "main") {
@@ -4214,10 +4285,10 @@ function trimUnescapedTrailingSpaces(line) {
4214
4285
  return line.slice(0, end);
4215
4286
  }
4216
4287
  function readGitignoreRules(dir) {
4217
- const gitignorePath2 = path16__namespace.join(dir, ".gitignore");
4288
+ const gitignorePath2 = path17__namespace.join(dir, ".gitignore");
4218
4289
  let raw;
4219
4290
  try {
4220
- raw = fs15__namespace.readFileSync(gitignorePath2, "utf8");
4291
+ raw = fs16__namespace.readFileSync(gitignorePath2, "utf8");
4221
4292
  } catch {
4222
4293
  return [];
4223
4294
  }
@@ -4371,11 +4442,23 @@ function defaultIgnoreReason(relativePath, toolDirNames = DEFAULT_TOOL_DIR_NAMES
4371
4442
  }
4372
4443
  return null;
4373
4444
  }
4374
- function recentCommitSubjects(cwd, limit = 10) {
4445
+ var COMMIT_BODY_LIMIT = 400;
4446
+ function truncateAtSentence(text2, limit) {
4447
+ if (text2.length <= limit) return text2;
4448
+ const window = text2.slice(0, limit);
4449
+ const sentence = Math.max(window.lastIndexOf(". "), window.lastIndexOf("; "));
4450
+ if (sentence > limit / 3) return window.slice(0, sentence + 1).trim();
4451
+ const space = window.lastIndexOf(" ");
4452
+ if (space > limit / 3) return window.slice(0, space).trim() + "\u2026";
4453
+ return window.trim() + "\u2026";
4454
+ }
4455
+ function recentCommits(cwd, limit = 10) {
4375
4456
  try {
4376
4457
  const stdout = childProcess__namespace.execFileSync(
4377
4458
  "git",
4378
- ["log", "-n", String(limit), "--pretty=%s", "--no-color"],
4459
+ // \x1f between fields and \x1e between records: neither can appear in a commit message, so
4460
+ // the parse cannot be confused by a message that contains a newline or a dash.
4461
+ ["log", "-n", String(limit), "--pretty=format:%s%x1f%b%x1e", "--no-color"],
4379
4462
  {
4380
4463
  cwd,
4381
4464
  stdio: ["ignore", "pipe", "ignore"],
@@ -4383,7 +4466,16 @@ function recentCommitSubjects(cwd, limit = 10) {
4383
4466
  maxBuffer: GIT_OUTPUT_LIMIT
4384
4467
  }
4385
4468
  );
4386
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
4469
+ return stdout.split("").map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
4470
+ const separator = record.indexOf("");
4471
+ const subject = separator === -1 ? record : record.slice(0, separator);
4472
+ const rawBody = separator === -1 ? "" : record.slice(separator + 1);
4473
+ const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ").replace(/\s*\|\s*/g, " ").replace(/\s+/g, " ").trim();
4474
+ return {
4475
+ subject: subject.trim(),
4476
+ body: truncateAtSentence(body, COMMIT_BODY_LIMIT)
4477
+ };
4478
+ }).filter((commit) => commit.subject.length > 0);
4387
4479
  } catch {
4388
4480
  return [];
4389
4481
  }
@@ -4407,7 +4499,7 @@ function listIgnoredPaths(cwd) {
4407
4499
  }
4408
4500
  function hasSnapshotMarker(target) {
4409
4501
  try {
4410
- return fs15__namespace.statSync(target).isDirectory() && fs15__namespace.existsSync(path16__namespace.join(target, ".codebase-snapshot"));
4502
+ return fs16__namespace.statSync(target).isDirectory() && fs16__namespace.existsSync(path17__namespace.join(target, ".codebase-snapshot"));
4411
4503
  } catch {
4412
4504
  return false;
4413
4505
  }
@@ -4416,7 +4508,7 @@ var IGNORABLE_DIRECTORY_ENTRIES = /* @__PURE__ */ new Set([".DS_Store"]);
4416
4508
  function isToolOwnedDirectory2(dir) {
4417
4509
  let raw;
4418
4510
  try {
4419
- raw = fs15__namespace.readFileSync(path16__namespace.join(dir, ".codebase-snapshot"), "utf8");
4511
+ raw = fs16__namespace.readFileSync(path17__namespace.join(dir, ".codebase-snapshot"), "utf8");
4420
4512
  } catch {
4421
4513
  return false;
4422
4514
  }
@@ -4443,7 +4535,7 @@ function isToolOwnedDirectory2(dir) {
4443
4535
  }
4444
4536
  let entries;
4445
4537
  try {
4446
- entries = fs15__namespace.readdirSync(dir);
4538
+ entries = fs16__namespace.readdirSync(dir);
4447
4539
  } catch {
4448
4540
  return false;
4449
4541
  }
@@ -4460,7 +4552,7 @@ function makeToolOwnedDecider(cwd, toolOwnedPaths) {
4460
4552
  const prefix = parts.slice(0, depth).join("/");
4461
4553
  let hasMarker = markers.get(prefix);
4462
4554
  if (hasMarker === void 0) {
4463
- hasMarker = isToolOwnedDirectory2(path16__namespace.join(cwd, prefix));
4555
+ hasMarker = isToolOwnedDirectory2(path17__namespace.join(cwd, prefix));
4464
4556
  markers.set(prefix, hasMarker);
4465
4557
  }
4466
4558
  if (hasMarker) return true;
@@ -4475,7 +4567,7 @@ function makeLinkProbe() {
4475
4567
  let known = cache.get(absolutePath);
4476
4568
  if (known === void 0) {
4477
4569
  try {
4478
- known = fs15__namespace.lstatSync(absolutePath).isSymbolicLink();
4570
+ known = fs16__namespace.lstatSync(absolutePath).isSymbolicLink();
4479
4571
  } catch {
4480
4572
  known = false;
4481
4573
  }
@@ -4488,7 +4580,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4488
4580
  const isLink = makeLinkProbe();
4489
4581
  let rootReal = cwd;
4490
4582
  try {
4491
- rootReal = fs15__namespace.realpathSync(cwd);
4583
+ rootReal = fs16__namespace.realpathSync(cwd);
4492
4584
  } catch {
4493
4585
  }
4494
4586
  const reported = /* @__PURE__ */ new Set();
@@ -4503,7 +4595,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4503
4595
  let linkedPath = null;
4504
4596
  for (let depth = 1; depth <= parts.length; depth += 1) {
4505
4597
  const prefix = parts.slice(0, depth).join("/");
4506
- if (isLink(path16__namespace.join(cwd, prefix))) {
4598
+ if (isLink(path17__namespace.join(cwd, prefix))) {
4507
4599
  linkedPath = prefix;
4508
4600
  break;
4509
4601
  }
@@ -4512,11 +4604,11 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4512
4604
  kept.push(candidate);
4513
4605
  continue;
4514
4606
  }
4515
- const absolute = path16__namespace.join(cwd, linkedPath);
4607
+ const absolute = path17__namespace.join(cwd, linkedPath);
4516
4608
  const rawTarget = readLinkTarget(absolute, absolute);
4517
4609
  let targetReal = null;
4518
4610
  try {
4519
- targetReal = fs15__namespace.realpathSync(absolute);
4611
+ targetReal = fs16__namespace.realpathSync(absolute);
4520
4612
  } catch {
4521
4613
  targetReal = null;
4522
4614
  }
@@ -4534,7 +4626,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4534
4626
  }
4535
4627
  let stats = null;
4536
4628
  try {
4537
- stats = fs15__namespace.statSync(absolute);
4629
+ stats = fs16__namespace.statSync(absolute);
4538
4630
  } catch {
4539
4631
  stats = null;
4540
4632
  }
@@ -4622,7 +4714,7 @@ function collectFiles(cwd, options = {}) {
4622
4714
  "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."
4623
4715
  );
4624
4716
  }
4625
- if (fs15__namespace.existsSync(path16__namespace.join(cwd, ".git"))) {
4717
+ if (fs16__namespace.existsSync(path17__namespace.join(cwd, ".git"))) {
4626
4718
  throw new Error(
4627
4719
  "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."
4628
4720
  );
@@ -4690,7 +4782,7 @@ function collectFiles(cwd, options = {}) {
4690
4782
  }
4691
4783
  function rootRealFor(root) {
4692
4784
  try {
4693
- return fs15__namespace.realpathSync(root);
4785
+ return fs16__namespace.realpathSync(root);
4694
4786
  } catch {
4695
4787
  return root;
4696
4788
  }
@@ -4699,18 +4791,18 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4699
4791
  const results = { files: [], skipped: [] };
4700
4792
  const stack = [];
4701
4793
  const toolDirNames = toolDirNamesFor(reservedPaths);
4702
- const relativeToBase = (target) => path16__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
4794
+ const relativeToBase = (target) => path17__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
4703
4795
  const enter = (current, layers) => {
4704
4796
  if (visited.has(current)) return false;
4705
4797
  visited.add(current);
4706
4798
  const localRules = readGitignoreRules(current);
4707
4799
  const gitignoreLayers = localRules.length === 0 ? layers : [
4708
4800
  ...layers,
4709
- { prefix: path16__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
4801
+ { prefix: path17__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
4710
4802
  ];
4711
4803
  let entries;
4712
4804
  try {
4713
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
4805
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
4714
4806
  } catch {
4715
4807
  results.skipped.push({
4716
4808
  path: relativeToBase(current),
@@ -4732,8 +4824,8 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4732
4824
  }
4733
4825
  const entry = frame.entries[frame.index];
4734
4826
  frame.index += 1;
4735
- const fullPath = path16__namespace.join(frame.dir, entry.name);
4736
- const relPath = path16__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
4827
+ const fullPath = path17__namespace.join(frame.dir, entry.name);
4828
+ const relPath = path17__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
4737
4829
  if (reservedPaths.has(relPath)) continue;
4738
4830
  if (entry.isDirectory() && DEFAULT_IGNORED_DIRS.includes(entry.name)) {
4739
4831
  results.skipped.push({
@@ -4766,14 +4858,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4766
4858
  if (entry.isSymbolicLink()) {
4767
4859
  let targetReal;
4768
4860
  try {
4769
- targetReal = fs15__namespace.realpathSync(fullPath);
4861
+ targetReal = fs16__namespace.realpathSync(fullPath);
4770
4862
  } catch {
4771
4863
  results.skipped.push(brokenLinkRecord(fullPath, relPath, rootReal));
4772
4864
  continue;
4773
4865
  }
4774
4866
  let stats;
4775
4867
  try {
4776
- stats = fs15__namespace.statSync(fullPath);
4868
+ stats = fs16__namespace.statSync(fullPath);
4777
4869
  } catch {
4778
4870
  results.skipped.push({ path: relPath, reason: "read-error", detail: "unreadable symlink" });
4779
4871
  continue;
@@ -4803,7 +4895,7 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4803
4895
  });
4804
4896
  continue;
4805
4897
  }
4806
- const targetRelative = path16__namespace.relative(rootReal, targetReal).split(path16__namespace.sep).join("/");
4898
+ const targetRelative = path17__namespace.relative(rootReal, targetReal).split(path17__namespace.sep).join("/");
4807
4899
  if (isSensitivePath(targetRelative)) {
4808
4900
  results.skipped.push({
4809
4901
  path: relPath,
@@ -4916,6 +5008,8 @@ function normalizeResolvedConfig(config) {
4916
5008
  // is re-validated because the number reaches a rendered artifact.
4917
5009
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
4918
5010
  maxParts: resolveMaxParts(config.maxParts),
5011
+ promptTask: resolvePromptTask(config.promptTask),
5012
+ ...config.brief === void 0 ? {} : { brief: config.brief },
4919
5013
  includeMonolith: artifacts.monolith,
4920
5014
  secretRules: compileSecretRules(config.secretRules),
4921
5015
  artifacts,
@@ -4986,6 +5080,7 @@ var CONFIG_KEY_NAMES = [
4986
5080
  "artifacts",
4987
5081
  "attachmentSlots",
4988
5082
  "branch",
5083
+ "brief",
4989
5084
  "budgets",
4990
5085
  "changedSince",
4991
5086
  "cwd",
@@ -5007,6 +5102,7 @@ var CONFIG_KEY_NAMES = [
5007
5102
  "outDir",
5008
5103
  "preset",
5009
5104
  "previewHeadLines",
5105
+ "promptTask",
5010
5106
  "staged",
5011
5107
  "previewTailLines",
5012
5108
  "secretRules",
@@ -5057,10 +5153,10 @@ function readConfigExport(exported, file) {
5057
5153
  var lastModuleConfig = null;
5058
5154
  function moduleConfigKey(fullPath) {
5059
5155
  try {
5060
- return crypto2.createHash("sha256").update(fs15__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
5156
+ return crypto2.createHash("sha256").update(fs16__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
5061
5157
  } catch {
5062
5158
  try {
5063
- const stats = fs15__namespace.statSync(fullPath);
5159
+ const stats = fs16__namespace.statSync(fullPath);
5064
5160
  return `stat-${stats.mtimeMs}-${stats.size}`;
5065
5161
  } catch {
5066
5162
  return "unreadable";
@@ -5086,7 +5182,7 @@ async function importConfigModule(fullPath) {
5086
5182
  function attachConfigDir(config, filePath) {
5087
5183
  if (typeof config === "object" && config !== null) {
5088
5184
  Object.defineProperty(config, CONFIG_DIR_SYMBOL, {
5089
- value: path16__namespace.dirname(filePath),
5185
+ value: path17__namespace.dirname(filePath),
5090
5186
  enumerable: false,
5091
5187
  configurable: true
5092
5188
  });
@@ -5098,12 +5194,12 @@ async function loadConfigFileDetailed(cwd, options = {}) {
5098
5194
  const errors = [];
5099
5195
  const configDirectories = [];
5100
5196
  for (const filename of CONFIG_FILENAMES) {
5101
- const fullPath = path16__namespace.join(cwd, filename);
5197
+ const fullPath = path17__namespace.join(cwd, filename);
5102
5198
  let candidateStats = null;
5103
5199
  try {
5104
- candidateStats = fs15__namespace.statSync(fullPath);
5200
+ candidateStats = fs16__namespace.statSync(fullPath);
5105
5201
  } catch {
5106
- if (!fs15__namespace.existsSync(fullPath)) continue;
5202
+ if (!fs16__namespace.existsSync(fullPath)) continue;
5107
5203
  }
5108
5204
  if (candidateStats !== null && !candidateStats.isFile()) {
5109
5205
  configDirectories.push(fullPath);
@@ -5111,7 +5207,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
5111
5207
  }
5112
5208
  if (filename.endsWith(".json") || filename === ".snapshotrc") {
5113
5209
  try {
5114
- const config = parseJsonish(fs15__namespace.readFileSync(fullPath, "utf8"), fullPath);
5210
+ const config = parseJsonish(fs16__namespace.readFileSync(fullPath, "utf8"), fullPath);
5115
5211
  if (config === null || typeof config !== "object" || Array.isArray(config)) {
5116
5212
  throw new Error(
5117
5213
  `${fullPath} does not hold a configuration object (received ${describeValue2(config)}).`
@@ -5151,10 +5247,10 @@ async function loadConfigFileDetailed(cwd, options = {}) {
5151
5247
  continue;
5152
5248
  }
5153
5249
  }
5154
- const pkgJsonPath = path16__namespace.join(cwd, "package.json");
5155
- if (fs15__namespace.existsSync(pkgJsonPath)) {
5250
+ const pkgJsonPath = path17__namespace.join(cwd, "package.json");
5251
+ if (fs16__namespace.existsSync(pkgJsonPath)) {
5156
5252
  try {
5157
- const parsed = parseJsonish(fs15__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
5253
+ const parsed = parseJsonish(fs16__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
5158
5254
  const snapshotKey = parsed.snapshot;
5159
5255
  if (snapshotKey && typeof snapshotKey === "object" && !Array.isArray(snapshotKey)) {
5160
5256
  assertKnownConfigKeys(
@@ -5298,6 +5394,38 @@ function resolveMaxParts(value) {
5298
5394
  }
5299
5395
  return value;
5300
5396
  }
5397
+ function resolvePromptTask(value) {
5398
+ if (value === void 0 || value === null) return "audit";
5399
+ if (value === "audit" || value === "review" || value === "explain") return value;
5400
+ throw new Error(
5401
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
5402
+ );
5403
+ }
5404
+ function readConfiguredBrief(cwd, value) {
5405
+ if (value === void 0 || value === null) return void 0;
5406
+ if (typeof value !== "string" || value.trim().length === 0) {
5407
+ throw new Error(
5408
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
5409
+ );
5410
+ }
5411
+ const filePath = path17__namespace.resolve(cwd, value);
5412
+ let text2;
5413
+ try {
5414
+ if (!fs16__namespace.statSync(filePath).isFile()) throw new Error("not a file");
5415
+ text2 = fs16__namespace.readFileSync(filePath, "utf8");
5416
+ } catch {
5417
+ throw new Error(
5418
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
5419
+ );
5420
+ }
5421
+ const parsed = parseOwnerBrief(value, text2);
5422
+ if (parsed.problems.length > 0) {
5423
+ throw new Error(
5424
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
5425
+ );
5426
+ }
5427
+ return parsed.brief;
5428
+ }
5301
5429
  function strictPositiveInteger(value, fallback, label) {
5302
5430
  if (value === void 0) return fallback;
5303
5431
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -5390,9 +5518,9 @@ function resolveKindRules(value) {
5390
5518
  function outputExcludePatterns(cwd, outDir, tmpDir) {
5391
5519
  const patterns = [];
5392
5520
  for (const dir of [outDir, tmpDir]) {
5393
- const absolute = path16__namespace.resolve(cwd, dir);
5394
- const relative11 = path16__namespace.relative(cwd, absolute);
5395
- if (!relative11 || relative11 === ".." || relative11.startsWith(`..${path16__namespace.sep}`) || path16__namespace.isAbsolute(relative11)) {
5521
+ const absolute = path17__namespace.resolve(cwd, dir);
5522
+ const relative11 = path17__namespace.relative(cwd, absolute);
5523
+ if (!relative11 || relative11 === ".." || relative11.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative11)) {
5396
5524
  continue;
5397
5525
  }
5398
5526
  patterns.push(`${relative11.replace(/\\/g, "/")}/**`);
@@ -5525,11 +5653,11 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
5525
5653
  );
5526
5654
  }
5527
5655
  const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
5528
- const resolved = path16__namespace.resolve(candidate);
5529
- if (!fs15__namespace.existsSync(resolved)) {
5656
+ const resolved = path17__namespace.resolve(candidate);
5657
+ if (!fs16__namespace.existsSync(resolved)) {
5530
5658
  throw new Error(`Working directory does not exist: ${resolved}`);
5531
5659
  }
5532
- if (!fs15__namespace.statSync(resolved).isDirectory()) {
5660
+ if (!fs16__namespace.statSync(resolved).isDirectory()) {
5533
5661
  throw new Error(`Working directory is not a directory: ${resolved}`);
5534
5662
  }
5535
5663
  return resolved;
@@ -5657,6 +5785,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
5657
5785
  configuredSensitiveFiles,
5658
5786
  "`includeSensitiveFiles`"
5659
5787
  );
5788
+ const configuredBrief = readConfiguredBrief(
5789
+ cwd,
5790
+ cliOptions?.brief ?? userConfig?.brief
5791
+ );
5660
5792
  const presetExclude = [
5661
5793
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
5662
5794
  ];
@@ -5680,6 +5812,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
5680
5812
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
5681
5813
  ),
5682
5814
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
5815
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
5816
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
5683
5817
  ...changedSince === void 0 ? {} : { changedSince },
5684
5818
  ...staged ? { staged } : {},
5685
5819
  ...withDependents ? { withDependents } : {},
@@ -5765,6 +5899,12 @@ function configDigest(config) {
5765
5899
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
5766
5900
  // material would change the digest of every snapshot taken before the setting existed.
5767
5901
  ...config.maxParts === null ? {} : { maxParts: config.maxParts },
5902
+ // The default value is omitted for the same reason: a snapshot taken before the setting
5903
+ // existed kept the audit job, so it must keep the digest it was written with.
5904
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
5905
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
5906
+ // reader to do, so a changed brief is drift exactly like a changed budget.
5907
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
5768
5908
  artifacts: config.artifacts,
5769
5909
  include: config.include,
5770
5910
  excludePatterns: config.excludePatterns,
@@ -6736,9 +6876,15 @@ var UNLIMITED_SLOTS = 0;
6736
6876
  var ENTRY_POINT = /(^|\/)(index|cli|main|bin|server|app|mod)\.[cm]?[jt]sx?$/;
6737
6877
  var TEST_PATH = /(^|\/)(tests?|__tests__)\//;
6738
6878
  var TEST_FILE = /\.(test|spec)\.[^.]+$/;
6739
- function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMENT_SLOTS, history = []) {
6879
+ function generatePrompt(manifest, artifacts, context = {}) {
6880
+ const slots = context.slots ?? DEFAULT_ATTACHMENT_SLOTS;
6881
+ const task = context.task ?? "audit";
6882
+ const history = context.history ?? [];
6883
+ const overview = context.overview ?? { releases: [] };
6884
+ const brief = context.brief;
6740
6885
  const wrote = (name) => artifacts?.[name] !== false;
6741
6886
  const code = (value) => inlineCode(escapeControls(value));
6887
+ const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
6742
6888
  const lines = [
6743
6889
  "# PROMPT.md",
6744
6890
  "",
@@ -6754,30 +6900,22 @@ function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMEN
6754
6900
  "You are working on a codebase you cannot clone, run or grep. Everything you know about it comes",
6755
6901
  "from the snapshot that follows this instruction. Where these notes and the snapshot disagree,",
6756
6902
  "the snapshot is what exists.",
6757
- "",
6758
- "## The job",
6759
- "",
6760
- "Find what is still wrong or will break. How you read the code is yours to decide - by",
6761
- "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
6762
- "honest account of what you covered and what you did not.",
6763
- "",
6764
- history.length > 0 ? "Another pass of the same findings is worth nothing. This repository carries a record of" : "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
6765
- history.length > 0 ? "what was already fixed, below. Verify that those fixes hold instead of rediscovering them," : "so you cannot tell what has already been tried. Do not assume this is the first attempt.",
6766
- history.length > 0 ? "and treat a variant of one at a different call site as a new finding." : "Every finding you report has to stand on the code alone.",
6767
- "",
6768
- "If the task at the end asks for something narrower - explain a file, review a change, answer a",
6769
- "question - that task wins. The standard and the coverage duty below still apply to it.",
6770
6903
  ""
6771
6904
  ];
6905
+ if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
6906
+ lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
6907
+ lines.push(...stakesSection(brief, code));
6772
6908
  lines.push(...haveSection(wrote), "");
6773
- lines.push(...systemSection(manifest, code), "");
6774
- lines.push(...historySection(history), "");
6775
- lines.push(...barSection(), "");
6909
+ lines.push(...whatThisIsSection(overview), "");
6910
+ lines.push(...systemSection(manifest, code, brief), "");
6911
+ lines.push(...historySection(history, brief, code), "");
6912
+ lines.push(...barSection(brief, code), "");
6776
6913
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
6777
6914
  lines.push(...answerSection(), "");
6778
- lines.push(...calibrationSection(), "");
6915
+ lines.push(...calibrationSection(brief, code), "");
6916
+ lines.push(...ownerNotesSection(brief, code));
6779
6917
  lines.push(...snapshotSection(manifest, code), "");
6780
- lines.push(...deliverySection(manifest, wrote("parts"), attachmentSlots));
6918
+ lines.push(...deliverySection(manifest, wrote("parts"), slots));
6781
6919
  lines.push(
6782
6920
  "## Your task",
6783
6921
  "",
@@ -6854,8 +6992,11 @@ function haveSection(wrote) {
6854
6992
  out.push(...bullets);
6855
6993
  return out;
6856
6994
  }
6857
- function systemSection(manifest, code) {
6995
+ function systemSection(manifest, code, brief) {
6858
6996
  const out = ["## The system", ""];
6997
+ if (brief?.system !== void 0) {
6998
+ out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
6999
+ }
6859
7000
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
6860
7001
  if (layers.length > 0) {
6861
7002
  const shown = layers.slice(0, MAX_LAYER_ROWS).map(([name, count]) => code(name) + " " + formatNumber(count));
@@ -6870,7 +7011,7 @@ function systemSection(manifest, code) {
6870
7011
  " A change here reaches the most call sites; read it before judging anything that uses it."
6871
7012
  );
6872
7013
  }
6873
- const entryPoints = manifest.files.map((file) => file.relativePath).filter((path17) => ENTRY_POINT.test(path17)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
7014
+ const entryPoints = manifest.files.map((file) => file.relativePath).filter((path18) => ENTRY_POINT.test(path18)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
6874
7015
  out.push(
6875
7016
  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"
6876
7017
  );
@@ -6913,8 +7054,9 @@ function systemSection(manifest, code) {
6913
7054
  }
6914
7055
  return out;
6915
7056
  }
6916
- function historySection(history) {
7057
+ function historySection(history, brief, code) {
6917
7058
  const out = ["## What came before", ""];
7059
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
6918
7060
  if (history.length === 0) {
6919
7061
  out.push(
6920
7062
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -6923,15 +7065,21 @@ function historySection(history) {
6923
7065
  return out;
6924
7066
  }
6925
7067
  out.push(
6926
- "Commit subjects, newest first. They are claims by whoever wrote them, not evidence - the code",
6927
- "beside them is the evidence. If one of these fixes looks incomplete, quote the lines and say",
6928
- "which call site it missed.",
7068
+ "The last " + formatNumber(history.length) + " " + (history.length === 1 ? "commit" : "commits") + ", newest first. Subjects and bodies are claims",
7069
+ "by whoever wrote them, not evidence - the code beside them is the evidence. If one of these",
7070
+ "fixes looks incomplete, quote the lines and say which call site it missed.",
6929
7071
  ""
6930
7072
  );
6931
- for (const subject of history) out.push("- " + subject);
7073
+ for (const commit of history) {
7074
+ out.push("- " + commit.subject);
7075
+ if (commit.body.length > 0) out.push(" " + commit.body);
7076
+ }
6932
7077
  return out;
6933
7078
  }
6934
- function barSection() {
7079
+ function barSection(brief, code) {
7080
+ if (brief?.bar !== void 0) {
7081
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
7082
+ }
6935
7083
  return [
6936
7084
  "## The bar",
6937
7085
  "",
@@ -6989,7 +7137,10 @@ function answerSection() {
6989
7137
  " the gap you filled by asking instead of guessing."
6990
7138
  ];
6991
7139
  }
6992
- function calibrationSection() {
7140
+ function calibrationSection(brief, code) {
7141
+ if (brief?.calibration !== void 0) {
7142
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
7143
+ }
6993
7144
  return [
6994
7145
  "## Calibration",
6995
7146
  "",
@@ -7004,6 +7155,84 @@ function calibrationSection() {
7004
7155
  "None of these throw. All are invisible in a summary."
7005
7156
  ];
7006
7157
  }
7158
+ function jobSection(task, hasHistory) {
7159
+ const out = ["## The job", ""];
7160
+ if (task === "audit") {
7161
+ out.push(
7162
+ "Find what is still wrong or will break. How you read the code is yours to decide - by",
7163
+ "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
7164
+ "honest account of what you covered and what you did not.",
7165
+ ""
7166
+ );
7167
+ if (hasHistory) {
7168
+ out.push(
7169
+ "Another pass of the same findings is worth nothing. This repository carries a record of",
7170
+ "what was already fixed, below. Verify that those fixes hold instead of rediscovering them,",
7171
+ "and treat a variant of one at a different call site as a new finding."
7172
+ );
7173
+ } else {
7174
+ out.push(
7175
+ "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
7176
+ "so you cannot tell what has already been tried. Do not assume this is the first attempt."
7177
+ );
7178
+ }
7179
+ out.push(
7180
+ "",
7181
+ "If the task at the end asks for something narrower - explain a file, review a change, answer",
7182
+ "a question - that task wins. The standard and the coverage duty below still apply to it."
7183
+ );
7184
+ } else if (task === "review") {
7185
+ out.push(
7186
+ "Review the change or the area named in the task against this snapshot. Report what breaks,",
7187
+ "what the change claims but does not do, and what a reader would believe that the code does",
7188
+ "not support. Restating the diff is not a review; the standard and the coverage duty below",
7189
+ "still apply."
7190
+ );
7191
+ } else {
7192
+ out.push(
7193
+ "Explain how the part of the system named in the task works: the data flow, the boundaries",
7194
+ "and the invariants it depends on. Cite the lines. If the snapshot does not contain what you",
7195
+ "need, say which file you need rather than reconstructing it from the shape of the names."
7196
+ );
7197
+ }
7198
+ return out;
7199
+ }
7200
+ function stakesSection(brief, code) {
7201
+ if (brief?.stakes === void 0) return [];
7202
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
7203
+ }
7204
+ function whatThisIsSection(overview) {
7205
+ const body = [];
7206
+ if (overview.description !== void 0) {
7207
+ body.push("- Declared in `package.json`: " + overview.description);
7208
+ }
7209
+ if (overview.summary !== void 0) {
7210
+ body.push("- From the `README.md` first paragraph: " + overview.summary);
7211
+ }
7212
+ if (overview.releases.length > 0) {
7213
+ body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
7214
+ }
7215
+ if (body.length === 0) return [];
7216
+ return [
7217
+ "## What this is",
7218
+ "",
7219
+ ...body,
7220
+ "",
7221
+ "Those are the project's own claims, not evidence about the code.",
7222
+ ""
7223
+ ];
7224
+ }
7225
+ function ownerNotesSection(brief, code) {
7226
+ if (brief === void 0 || brief.notes.length === 0) return [];
7227
+ const out = ["## Owner notes", ""];
7228
+ for (const note of brief.notes) {
7229
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
7230
+ }
7231
+ return out;
7232
+ }
7233
+ function ownerBlock(text2, path18, code) {
7234
+ return ["> Written by the project owner in " + code(path18) + ", not generated.", "", text2];
7235
+ }
7007
7236
  function snapshotSection(manifest, code) {
7008
7237
  const out = ["## This snapshot", ""];
7009
7238
  out.push("- Fingerprint: " + code(manifest.fingerprint) + " - quote it verbatim in your answer.");
@@ -7102,7 +7331,8 @@ function deliverySection(manifest, partsWritten, slots) {
7102
7331
  );
7103
7332
  if (parts > 1) {
7104
7333
  out.push(
7105
- " Either raise `--max-part-bytes` to merge the parts, or set `--max-parts " + slots + "` and let the parts grow to the count instead."
7334
+ " Either raise `--max-part-bytes` to merge the parts, or set",
7335
+ " `--max-parts " + slots + "` and let the parts grow to the count instead."
7106
7336
  );
7107
7337
  }
7108
7338
  } else {
@@ -7359,7 +7589,7 @@ function resolveChangedScope(cwd, request) {
7359
7589
  const descriptions = [];
7360
7590
  if (request.changedSince !== void 0) {
7361
7591
  assertUsableRef(request.changedSince);
7362
- for (const path17 of gitPaths(cwd, [
7592
+ for (const path18 of gitPaths(cwd, [
7363
7593
  "diff",
7364
7594
  "--name-only",
7365
7595
  "-z",
@@ -7367,9 +7597,9 @@ function resolveChangedScope(cwd, request) {
7367
7597
  `${request.changedSince}...HEAD`,
7368
7598
  "--"
7369
7599
  ])) {
7370
- paths.add(path17);
7600
+ paths.add(path18);
7371
7601
  }
7372
- for (const path17 of gitPaths(cwd, [
7602
+ for (const path18 of gitPaths(cwd, [
7373
7603
  "diff",
7374
7604
  "--name-only",
7375
7605
  "-z",
@@ -7377,15 +7607,15 @@ function resolveChangedScope(cwd, request) {
7377
7607
  "HEAD",
7378
7608
  "--"
7379
7609
  ])) {
7380
- paths.add(path17);
7610
+ paths.add(path18);
7381
7611
  }
7382
- for (const path17 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
7383
- paths.add(path17);
7612
+ for (const path18 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
7613
+ paths.add(path18);
7384
7614
  }
7385
7615
  descriptions.push(`changed since ${request.changedSince}`);
7386
7616
  }
7387
7617
  if (request.staged === true) {
7388
- for (const path17 of gitPaths(cwd, [
7618
+ for (const path18 of gitPaths(cwd, [
7389
7619
  "diff",
7390
7620
  "--cached",
7391
7621
  "--name-only",
@@ -7393,10 +7623,10 @@ function resolveChangedScope(cwd, request) {
7393
7623
  "--relative",
7394
7624
  "--"
7395
7625
  ])) {
7396
- paths.add(path17);
7397
- stagedPaths.add(path17);
7626
+ paths.add(path18);
7627
+ stagedPaths.add(path18);
7398
7628
  }
7399
- for (const path17 of gitPaths(cwd, [
7629
+ for (const path18 of gitPaths(cwd, [
7400
7630
  "diff",
7401
7631
  "--cached",
7402
7632
  "--name-only",
@@ -7405,7 +7635,7 @@ function resolveChangedScope(cwd, request) {
7405
7635
  "--diff-filter=D",
7406
7636
  "--"
7407
7637
  ])) {
7408
- deletedPaths.add(path17);
7638
+ deletedPaths.add(path18);
7409
7639
  }
7410
7640
  descriptions.push("staged");
7411
7641
  }
@@ -7443,10 +7673,10 @@ var PYTHON_SUFFIXES = [".py", ".pyi", "/__init__.py", "/__init__.pyi"];
7443
7673
  var CASE_INSENSITIVE_FILESYSTEM = process.platform === "win32" || process.platform === "darwin";
7444
7674
  var TSCONFIG_CACHE = /* @__PURE__ */ new Map();
7445
7675
  function tsconfigPathsFor(cwd) {
7446
- const configPath = path16__namespace.join(cwd, "tsconfig.json");
7676
+ const configPath = path17__namespace.join(cwd, "tsconfig.json");
7447
7677
  let stats;
7448
7678
  try {
7449
- stats = fs15__namespace.statSync(configPath);
7679
+ stats = fs16__namespace.statSync(configPath);
7450
7680
  } catch (err) {
7451
7681
  if (err.code === "ENOENT") return null;
7452
7682
  return null;
@@ -7480,8 +7710,8 @@ function tsconfigPathsFor(cwd) {
7480
7710
  return value;
7481
7711
  }
7482
7712
  function repositoryRelative(cwd, target) {
7483
- const relative11 = path16__namespace.relative(cwd, target).replace(/\\/g, "/");
7484
- return relative11.length === 0 || !relative11.startsWith("..") && !path16__namespace.isAbsolute(relative11) ? relative11 : null;
7713
+ const relative11 = path17__namespace.relative(cwd, target).replace(/\\/g, "/");
7714
+ return relative11.length === 0 || !relative11.startsWith("..") && !path17__namespace.isAbsolute(relative11) ? relative11 : null;
7485
7715
  }
7486
7716
  function rememberFirst(map, key, value) {
7487
7717
  if (!map.has(key)) map.set(key, value);
@@ -7496,15 +7726,15 @@ function buildImportResolver(files, options = {}) {
7496
7726
  if (CASE_INSENSITIVE_FILESYSTEM) {
7497
7727
  rememberFirst(byPathFolded, relativePath.toLowerCase(), relativePath);
7498
7728
  }
7499
- const extension = path16__namespace.posix.extname(relativePath);
7729
+ const extension = path17__namespace.posix.extname(relativePath);
7500
7730
  if (!SOURCE_EXTENSIONS.has(extension)) return;
7501
7731
  const stem = relativePath.slice(0, -extension.length);
7502
7732
  rememberFirst(byStem, stem, relativePath);
7503
7733
  if (CASE_INSENSITIVE_FILESYSTEM) {
7504
7734
  rememberFirst(byStemFolded, stem.toLowerCase(), relativePath);
7505
7735
  }
7506
- if (path16__namespace.posix.basename(stem) === "index") {
7507
- const directory = path16__namespace.posix.dirname(stem);
7736
+ if (path17__namespace.posix.basename(stem) === "index") {
7737
+ const directory = path17__namespace.posix.dirname(stem);
7508
7738
  rememberFirst(byStem, directory, relativePath);
7509
7739
  if (CASE_INSENSITIVE_FILESYSTEM) {
7510
7740
  rememberFirst(byStemFolded, directory.toLowerCase(), relativePath);
@@ -7520,7 +7750,7 @@ function buildImportResolver(files, options = {}) {
7520
7750
  return { byPath, byPathFolded, byStem, byStemFolded, tsconfig: options.tsconfig ?? null };
7521
7751
  }
7522
7752
  function resolveSpecifier(fromFile, specifier, resolver) {
7523
- const extension = path16__namespace.posix.extname(fromFile).toLowerCase();
7753
+ const extension = path17__namespace.posix.extname(fromFile).toLowerCase();
7524
7754
  const exact = (key) => resolver.byPath.get(key) ?? (CASE_INSENSITIVE_FILESYSTEM ? resolver.byPathFolded.get(key.toLowerCase()) : void 0) ?? null;
7525
7755
  const firstOf = (candidates) => {
7526
7756
  for (const candidate of candidates) {
@@ -7543,34 +7773,34 @@ function resolveSpecifier(fromFile, specifier, resolver) {
7543
7773
  if (PYTHON_EXTENSIONS.has(extension) && specifier.startsWith(".")) {
7544
7774
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
7545
7775
  const rest = specifier.slice(dots).replace(/\./g, "/");
7546
- let base = path16__namespace.posix.dirname(fromFile);
7547
- for (let up = 1; up < dots; up += 1) base = path16__namespace.posix.dirname(base);
7548
- const joined2 = rest ? path16__namespace.posix.normalize(path16__namespace.posix.join(base, rest)) : base;
7776
+ let base = path17__namespace.posix.dirname(fromFile);
7777
+ for (let up = 1; up < dots; up += 1) base = path17__namespace.posix.dirname(base);
7778
+ const joined2 = rest ? path17__namespace.posix.normalize(path17__namespace.posix.join(base, rest)) : base;
7549
7779
  return firstOf([joined2, ...PYTHON_SUFFIXES.map((suffix) => `${joined2}${suffix}`)]);
7550
7780
  }
7551
7781
  if (RUBY_EXTENSIONS.has(extension) && specifier.startsWith("./")) {
7552
- const joined2 = path16__namespace.posix.normalize(
7553
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
7782
+ const joined2 = path17__namespace.posix.normalize(
7783
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7554
7784
  );
7555
7785
  return firstOf([`${joined2}.rb`, joined2]);
7556
7786
  }
7557
7787
  if (C_EXTENSIONS.has(extension) && specifier.startsWith("./")) {
7558
- const joined2 = path16__namespace.posix.normalize(
7559
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
7788
+ const joined2 = path17__namespace.posix.normalize(
7789
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7560
7790
  );
7561
7791
  return exact(joined2);
7562
7792
  }
7563
7793
  if (extension === ".dart" && !specifier.includes(":")) {
7564
- const joined2 = path16__namespace.posix.normalize(
7565
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
7794
+ const joined2 = path17__namespace.posix.normalize(
7795
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7566
7796
  );
7567
7797
  return firstOf([joined2, `${joined2}.dart`]);
7568
7798
  }
7569
7799
  if (!RELATIVE_SPECIFIER.test(specifier)) {
7570
7800
  return resolveTsconfigSpecifier(specifier, resolver, lookupPath);
7571
7801
  }
7572
- const joined = path16__namespace.posix.normalize(
7573
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
7802
+ const joined = path17__namespace.posix.normalize(
7803
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7574
7804
  );
7575
7805
  return lookupPath(joined);
7576
7806
  }
@@ -7594,13 +7824,13 @@ function resolveTsconfigSpecifier(specifier, resolver, lookupPath) {
7594
7824
  if (captured === null) continue;
7595
7825
  for (const target of rule.targets) {
7596
7826
  const substituted = target.split("*").join(captured);
7597
- const base = config.baseUrl === null ? substituted : path16__namespace.posix.join(config.baseUrl, substituted);
7598
- const hit = lookupPath(path16__namespace.posix.normalize(base));
7827
+ const base = config.baseUrl === null ? substituted : path17__namespace.posix.join(config.baseUrl, substituted);
7828
+ const hit = lookupPath(path17__namespace.posix.normalize(base));
7599
7829
  if (hit) return hit;
7600
7830
  }
7601
7831
  }
7602
7832
  if (config.baseUrl !== null) {
7603
- return lookupPath(path16__namespace.posix.normalize(path16__namespace.posix.join(config.baseUrl, specifier)));
7833
+ return lookupPath(path17__namespace.posix.normalize(path17__namespace.posix.join(config.baseUrl, specifier)));
7604
7834
  }
7605
7835
  return null;
7606
7836
  }
@@ -7611,6 +7841,64 @@ function importsChangedFile(importerPath, imports, changedPaths, resolver) {
7611
7841
  }
7612
7842
  return false;
7613
7843
  }
7844
+ var SUMMARY_LIMIT = 400;
7845
+ var MAX_RELEASES = 2;
7846
+ function readProjectOverview(cwd) {
7847
+ return {
7848
+ ...readDescription(cwd),
7849
+ ...readSummary(cwd),
7850
+ releases: readReleases(cwd)
7851
+ };
7852
+ }
7853
+ function readText(file) {
7854
+ try {
7855
+ return fs16__namespace.readFileSync(file, "utf8");
7856
+ } catch {
7857
+ return null;
7858
+ }
7859
+ }
7860
+ function readDescription(cwd) {
7861
+ const raw = readText(path17__namespace.join(cwd, "package.json"));
7862
+ if (raw === null) return {};
7863
+ try {
7864
+ const parsed = JSON.parse(stripJsonComments(raw));
7865
+ return typeof parsed.description === "string" && parsed.description.trim().length > 0 ? { description: parsed.description.trim() } : {};
7866
+ } catch {
7867
+ return {};
7868
+ }
7869
+ }
7870
+ function readSummary(cwd) {
7871
+ const raw = readText(path17__namespace.join(cwd, "README.md"));
7872
+ if (raw === null) return {};
7873
+ const text2 = raw.replace(/<h[1-6][^>]*>[\s\S]*?<\/h[1-6]>/gi, "\n").replace(/<\/(p|div|section|header|footer|li)>/gi, "\n").replace(/<br\s*\/?>/gi, " ").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
7874
+ const paragraph = [];
7875
+ for (const line of text2.split(/\r?\n/)) {
7876
+ const trimmed = line.trim();
7877
+ if (paragraph.length === 0) {
7878
+ if (trimmed.length === 0) continue;
7879
+ if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
7880
+ if (/^\[[^\]]+\]:/.test(trimmed)) continue;
7881
+ } else if (trimmed.length === 0 || /^#/.test(trimmed)) {
7882
+ break;
7883
+ }
7884
+ paragraph.push(trimmed);
7885
+ }
7886
+ const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
7887
+ if (summary.length === 0) return {};
7888
+ return { summary: truncate(summary, SUMMARY_LIMIT) };
7889
+ }
7890
+ function truncate(text2, limit) {
7891
+ if (text2.length <= limit) return text2;
7892
+ const window = text2.slice(0, limit);
7893
+ const space = window.lastIndexOf(" ");
7894
+ return (space > limit / 2 ? window.slice(0, space) : window).trim() + "\u2026";
7895
+ }
7896
+ function readReleases(cwd) {
7897
+ const raw = readText(path17__namespace.join(cwd, "CHANGELOG.md"));
7898
+ if (raw === null) return [];
7899
+ const headings = raw.split(/\r?\n/).map((line) => /^##\s+(.+?)\s*$/.exec(line)?.[1]?.trim()).filter((heading) => heading !== void 0 && /^v?\d+\.\d+/.test(heading));
7900
+ return headings.slice(0, MAX_RELEASES);
7901
+ }
7614
7902
  var LANGUAGE_BY_EXTENSION = {
7615
7903
  ".ts": "typescript",
7616
7904
  ".mts": "typescript",
@@ -7668,10 +7956,10 @@ var LANGUAGE_BY_BASENAME = {
7668
7956
  };
7669
7957
  function detectLanguage(filePath) {
7670
7958
  const normalized = filePath.replace(/\\/g, "/");
7671
- const base = path16__namespace.posix.basename(normalized);
7959
+ const base = path17__namespace.posix.basename(normalized);
7672
7960
  if (LANGUAGE_BY_BASENAME[base]) return LANGUAGE_BY_BASENAME[base];
7673
7961
  if (base === ".env" || base.startsWith(".env.")) return "dotenv";
7674
- const ext = path16__namespace.posix.extname(base).toLowerCase();
7962
+ const ext = path17__namespace.posix.extname(base).toLowerCase();
7675
7963
  return LANGUAGE_BY_EXTENSION[ext] ?? "text";
7676
7964
  }
7677
7965
  function maskedPath(value, secretRules) {
@@ -7679,33 +7967,33 @@ function maskedPath(value, secretRules) {
7679
7967
  }
7680
7968
  function confineToDirectory(directory, filename) {
7681
7969
  if (filename.includes("\0")) return null;
7682
- if (path16__namespace.isAbsolute(filename)) return null;
7683
- const base = path16__namespace.resolve(directory);
7684
- const resolved = path16__namespace.resolve(base, filename);
7970
+ if (path17__namespace.isAbsolute(filename)) return null;
7971
+ const base = path17__namespace.resolve(directory);
7972
+ const resolved = path17__namespace.resolve(base, filename);
7685
7973
  const caseInsensitive = process.platform === "win32" || process.platform === "darwin";
7686
- const prefix = caseInsensitive ? `${base}${path16__namespace.sep}`.toLowerCase() : `${base}${path16__namespace.sep}`;
7974
+ const prefix = caseInsensitive ? `${base}${path17__namespace.sep}`.toLowerCase() : `${base}${path17__namespace.sep}`;
7687
7975
  const candidate = caseInsensitive ? resolved.toLowerCase() : resolved;
7688
7976
  return candidate.startsWith(prefix) ? resolved : null;
7689
7977
  }
7690
7978
  function findStagingDirectory(config) {
7691
- const tmpDir = path16__namespace.resolve(config.cwd, config.tmpDir);
7979
+ const tmpDir = path17__namespace.resolve(config.cwd, config.tmpDir);
7692
7980
  let entries;
7693
7981
  try {
7694
- entries = fs15__namespace.readdirSync(tmpDir);
7982
+ entries = fs16__namespace.readdirSync(tmpDir);
7695
7983
  } catch {
7696
7984
  return null;
7697
7985
  }
7698
7986
  const runs = entries.filter((name) => name.startsWith("run-")).sort();
7699
7987
  const newest = runs[runs.length - 1];
7700
- return newest ? path16__namespace.join(tmpDir, newest) : null;
7988
+ return newest ? path17__namespace.join(tmpDir, newest) : null;
7701
7989
  }
7702
7990
  function describeMissingManifest(config, manifestPath) {
7703
- const outDir = path16__namespace.resolve(config.cwd, config.outDir);
7704
- const markerPath = path16__namespace.join(outDir, ".codebase-snapshot");
7991
+ const outDir = path17__namespace.resolve(config.cwd, config.outDir);
7992
+ const markerPath = path17__namespace.join(outDir, ".codebase-snapshot");
7705
7993
  let marker2 = null;
7706
7994
  try {
7707
- if (fs15__namespace.existsSync(markerPath)) {
7708
- const parsed = JSON.parse(fs15__namespace.readFileSync(markerPath, "utf8"));
7995
+ if (fs16__namespace.existsSync(markerPath)) {
7996
+ const parsed = JSON.parse(fs16__namespace.readFileSync(markerPath, "utf8"));
7709
7997
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
7710
7998
  marker2 = parsed;
7711
7999
  }
@@ -7740,13 +8028,13 @@ function sha256Hex(buffer) {
7740
8028
  return crypto2__namespace.createHash("sha256").update(buffer).digest("hex");
7741
8029
  }
7742
8030
  function wouldNowBeIncluded(cwd, relativePath) {
7743
- const absolutePath = path16__namespace.join(cwd, relativePath);
8031
+ const absolutePath = path17__namespace.join(cwd, relativePath);
7744
8032
  try {
7745
- const stats = fs15__namespace.statSync(absolutePath);
8033
+ const stats = fs16__namespace.statSync(absolutePath);
7746
8034
  if (!stats.isFile()) return false;
7747
8035
  if (isBinaryExtension(absolutePath)) return false;
7748
8036
  if (stats.size > BINARY_SCAN_BYTES && isBinaryFile(absolutePath)) return false;
7749
- return !decodeText(fs15__namespace.readFileSync(absolutePath)).binary;
8037
+ return !decodeText(fs16__namespace.readFileSync(absolutePath)).binary;
7750
8038
  } catch {
7751
8039
  return false;
7752
8040
  }
@@ -7758,7 +8046,7 @@ var TRUNCATION_REASONS = /* @__PURE__ */ new Set([
7758
8046
  ]);
7759
8047
  function isConfinedRelative(value) {
7760
8048
  if (value.length === 0 || value.includes("\0") || value.includes("\\")) return false;
7761
- if (path16__namespace.isAbsolute(value)) return false;
8049
+ if (path17__namespace.isAbsolute(value)) return false;
7762
8050
  return !value.split("/").includes("..");
7763
8051
  }
7764
8052
  function describeManifestShapeProblem(value) {
@@ -7926,7 +8214,7 @@ function describeManifestShapeProblem(value) {
7926
8214
  if (typeof filename !== "string" || filename.trim() === "") {
7927
8215
  return 'a "parts" entry has no "filename"';
7928
8216
  }
7929
- if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path16__namespace.isAbsolute(filename)) {
8217
+ if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path17__namespace.isAbsolute(filename)) {
7930
8218
  return 'a "parts" entry "filename" must be a bare filename inside parts/';
7931
8219
  }
7932
8220
  if (currentSchema) {
@@ -7952,8 +8240,8 @@ function describeManifestShapeProblem(value) {
7952
8240
  function validateSnapshot(configInput) {
7953
8241
  assertUsableConfigInput(configInput);
7954
8242
  const config = isResolvedConfig(configInput) ? normalizeResolvedConfig(configInput) : resolveConfig(configInput);
7955
- const manifestPath = path16__namespace.resolve(config.cwd, config.outDir, "manifest.json");
7956
- if (!fs15__namespace.existsSync(manifestPath)) {
8243
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
8244
+ if (!fs16__namespace.existsSync(manifestPath)) {
7957
8245
  return {
7958
8246
  valid: false,
7959
8247
  manifestPresent: false,
@@ -7964,7 +8252,7 @@ function validateSnapshot(configInput) {
7964
8252
  }
7965
8253
  let manifest;
7966
8254
  try {
7967
- manifest = JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
8255
+ manifest = JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
7968
8256
  } catch (err) {
7969
8257
  return {
7970
8258
  valid: false,
@@ -7986,7 +8274,7 @@ function validateSnapshot(configInput) {
7986
8274
  }
7987
8275
  const drift = emptyDrift();
7988
8276
  const warnings = [];
7989
- const snapshotDir = path16__namespace.resolve(config.cwd, config.outDir);
8277
+ const snapshotDir = path17__namespace.resolve(config.cwd, config.outDir);
7990
8278
  const unreadableSkips = manifest.skipped.filter(
7991
8279
  (entry) => entry.reason === "missing" || entry.reason === "read-error"
7992
8280
  );
@@ -8089,7 +8377,7 @@ function validateSnapshot(configInput) {
8089
8377
  );
8090
8378
  return importsChangedFile(
8091
8379
  diskFile,
8092
- importsOfFile(diskFile, path16__namespace.join(config.cwd, diskFile)),
8380
+ importsOfFile(diskFile, path17__namespace.join(config.cwd, diskFile)),
8093
8381
  unchangedScope,
8094
8382
  dependentResolver
8095
8383
  );
@@ -8107,7 +8395,7 @@ function validateSnapshot(configInput) {
8107
8395
  // own output directory as a set of files missing from the snapshot, so a correct
8108
8396
  // snapshot was reported as drifting.
8109
8397
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
8110
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8398
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8111
8399
  ).filter((relative11) => relative11.length > 0 && !relative11.startsWith(".."))
8112
8400
  });
8113
8401
  for (const diskFile of collection.files) {
@@ -8133,7 +8421,7 @@ function validateSnapshot(configInput) {
8133
8421
  }
8134
8422
  let diskHash;
8135
8423
  try {
8136
- diskHash = sha256Hex(fs15__namespace.readFileSync(path16__namespace.join(config.cwd, diskFile)));
8424
+ diskHash = sha256Hex(fs16__namespace.readFileSync(path17__namespace.join(config.cwd, diskFile)));
8137
8425
  } catch (err) {
8138
8426
  if (err.code === "ENOENT") {
8139
8427
  drift.missingOnDisk.push(diskFile);
@@ -8157,7 +8445,7 @@ function validateSnapshot(configInput) {
8157
8445
  }
8158
8446
  let statFailure = null;
8159
8447
  try {
8160
- fs15__namespace.statSync(confined);
8448
+ fs16__namespace.statSync(confined);
8161
8449
  } catch (err) {
8162
8450
  statFailure = err;
8163
8451
  }
@@ -8177,7 +8465,7 @@ function validateSnapshot(configInput) {
8177
8465
  ...Object.values(config.budgets.byLayer)
8178
8466
  );
8179
8467
  const partNames = /* @__PURE__ */ new Set();
8180
- const partsDir = path16__namespace.join(snapshotDir, "parts");
8468
+ const partsDir = path17__namespace.join(snapshotDir, "parts");
8181
8469
  for (const part of manifest.parts) {
8182
8470
  if (!part || typeof part.filename !== "string") continue;
8183
8471
  partNames.add(part.filename);
@@ -8192,7 +8480,7 @@ function validateSnapshot(configInput) {
8192
8480
  }
8193
8481
  let buffer;
8194
8482
  try {
8195
- buffer = fs15__namespace.readFileSync(partPath);
8483
+ buffer = fs16__namespace.readFileSync(partPath);
8196
8484
  } catch {
8197
8485
  drift.partIssues.push({ part: part.filename, issue: "missing from snapshot/parts" });
8198
8486
  continue;
@@ -8548,11 +8836,11 @@ function validateSnapshot(configInput) {
8548
8836
  ];
8549
8837
  for (const [key, artifact] of declaredArtifacts) {
8550
8838
  if (!artifact) continue;
8551
- const artifactPath = path16__namespace.join(snapshotDir, ...key.split("/"));
8839
+ const artifactPath = path17__namespace.join(snapshotDir, ...key.split("/"));
8552
8840
  let buffer;
8553
8841
  try {
8554
- if (!fs15__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
8555
- buffer = fs15__namespace.readFileSync(artifactPath);
8842
+ if (!fs16__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
8843
+ buffer = fs16__namespace.readFileSync(artifactPath);
8556
8844
  } catch {
8557
8845
  drift.partIssues.push({ part: key, issue: "declared artifact is missing" });
8558
8846
  continue;
@@ -8565,9 +8853,9 @@ function validateSnapshot(configInput) {
8565
8853
  for (const match of buffer.toString("utf8").matchAll(/\]\(([^)\s]+)\)/g)) {
8566
8854
  const target = match[1].split("#")[0];
8567
8855
  if (target.length === 0 || /^[a-z][a-z0-9+.-]*:/i.test(target)) continue;
8568
- const resolved = path16__namespace.resolve(snapshotDir, "reports", target);
8569
- const relative11 = path16__namespace.relative(snapshotDir, resolved);
8570
- if (relative11.startsWith("..") || path16__namespace.isAbsolute(relative11) || !fs15__namespace.existsSync(resolved)) {
8856
+ const resolved = path17__namespace.resolve(snapshotDir, "reports", target);
8857
+ const relative11 = path17__namespace.relative(snapshotDir, resolved);
8858
+ if (relative11.startsWith("..") || path17__namespace.isAbsolute(relative11) || !fs16__namespace.existsSync(resolved)) {
8571
8859
  drift.partIssues.push({
8572
8860
  part: key,
8573
8861
  issue: `links to ${maskedPath(target, config.secretRules)}, which does not exist in the snapshot`
@@ -8580,7 +8868,7 @@ function validateSnapshot(configInput) {
8580
8868
  if (sarifArtifact) {
8581
8869
  const sarifKey = "reports/audit.sarif";
8582
8870
  try {
8583
- const buffer = fs15__namespace.readFileSync(path16__namespace.join(snapshotDir, "reports", "audit.sarif"));
8871
+ const buffer = fs16__namespace.readFileSync(path17__namespace.join(snapshotDir, "reports", "audit.sarif"));
8584
8872
  if (sha256Hex(buffer) !== sarifArtifact.sha256 || buffer.length !== sarifArtifact.byteSize) {
8585
8873
  drift.partIssues.push({ part: sarifKey, issue: "artifact does not match its recorded digest" });
8586
8874
  }
@@ -8698,17 +8986,17 @@ function isNewer(candidate, current) {
8698
8986
  }
8699
8987
  function cacheDirectory(env = process.env, platform = process.platform) {
8700
8988
  if (platform === "win32") {
8701
- const base2 = env.LOCALAPPDATA ?? path16__namespace.join(os__namespace.homedir(), "AppData", "Local");
8702
- return path16__namespace.join(base2, "codebase-snapshot");
8989
+ const base2 = env.LOCALAPPDATA ?? path17__namespace.join(os__namespace.homedir(), "AppData", "Local");
8990
+ return path17__namespace.join(base2, "codebase-snapshot");
8703
8991
  }
8704
8992
  if (platform === "darwin") {
8705
- return path16__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
8993
+ return path17__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
8706
8994
  }
8707
- const base = env.XDG_CACHE_HOME ?? path16__namespace.join(os__namespace.homedir(), ".cache");
8708
- return path16__namespace.join(base, "codebase-snapshot");
8995
+ const base = env.XDG_CACHE_HOME ?? path17__namespace.join(os__namespace.homedir(), ".cache");
8996
+ return path17__namespace.join(base, "codebase-snapshot");
8709
8997
  }
8710
8998
  function cacheFilePath(env = process.env) {
8711
- return path16__namespace.join(cacheDirectory(env), "update-check.json");
8999
+ return path17__namespace.join(cacheDirectory(env), "update-check.json");
8712
9000
  }
8713
9001
  function shouldCheck(argv, env) {
8714
9002
  const disabled = ["1", "true", "yes"].includes(
@@ -8738,7 +9026,7 @@ function shouldCheck(argv, env) {
8738
9026
  function readCache(file) {
8739
9027
  let raw;
8740
9028
  try {
8741
- raw = fs15__namespace.readFileSync(file, "utf8");
9029
+ raw = fs16__namespace.readFileSync(file, "utf8");
8742
9030
  } catch {
8743
9031
  return null;
8744
9032
  }
@@ -8755,8 +9043,8 @@ function readCache(file) {
8755
9043
  }
8756
9044
  function writeCache(file, entry) {
8757
9045
  try {
8758
- fs15__namespace.mkdirSync(path16__namespace.dirname(file), { recursive: true });
8759
- fs15__namespace.writeFileSync(file, `${JSON.stringify(entry)}
9046
+ fs16__namespace.mkdirSync(path17__namespace.dirname(file), { recursive: true });
9047
+ fs16__namespace.writeFileSync(file, `${JSON.stringify(entry)}
8760
9048
  `, "utf8");
8761
9049
  } catch {
8762
9050
  }
@@ -8855,13 +9143,13 @@ function describeMatcher(matcher) {
8855
9143
  return String(matcher);
8856
9144
  }
8857
9145
  function normalizeTarget(cwd, target) {
8858
- const resolvedCwd = path16__namespace.resolve(cwd);
8859
- const absolute = path16__namespace.resolve(resolvedCwd, target);
8860
- const relative11 = path16__namespace.relative(resolvedCwd, absolute);
8861
- if (relative11 === "" || relative11 === ".." || relative11.startsWith(`..${path16__namespace.sep}`) || path16__namespace.isAbsolute(relative11)) {
9146
+ const resolvedCwd = path17__namespace.resolve(cwd);
9147
+ const absolute = path17__namespace.resolve(resolvedCwd, target);
9148
+ const relative11 = path17__namespace.relative(resolvedCwd, absolute);
9149
+ if (relative11 === "" || relative11 === ".." || relative11.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative11)) {
8862
9150
  return { relative: target.replace(/\\/g, "/"), outsideRoot: true };
8863
9151
  }
8864
- return { relative: relative11.split(path16__namespace.sep).join("/"), outsideRoot: false };
9152
+ return { relative: relative11.split(path17__namespace.sep).join("/"), outsideRoot: false };
8865
9153
  }
8866
9154
  function findRuleMatch(rules, relativePath) {
8867
9155
  return rules.find(
@@ -8880,9 +9168,9 @@ function findRecordedAncestor(skipped, relative11, maskedPath2) {
8880
9168
  return nearest;
8881
9169
  }
8882
9170
  function readManifest2(config) {
8883
- const manifestPath = path16__namespace.resolve(config.cwd, config.outDir, "manifest.json");
9171
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
8884
9172
  try {
8885
- return JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
9173
+ return JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
8886
9174
  } catch {
8887
9175
  return null;
8888
9176
  }
@@ -8900,10 +9188,10 @@ function explainPath(config, target) {
8900
9188
  detail: "path resolves outside the configured repository root and was not inspected"
8901
9189
  };
8902
9190
  }
8903
- const absolute = path16__namespace.join(config.cwd, relative11);
9191
+ const absolute = path17__namespace.join(config.cwd, relative11);
8904
9192
  const result = {
8905
9193
  path: maskedPath2,
8906
- exists: fs15__namespace.existsSync(absolute),
9194
+ exists: fs16__namespace.existsSync(absolute),
8907
9195
  included: false
8908
9196
  };
8909
9197
  const collection = collectFiles(config.cwd, {
@@ -8917,7 +9205,7 @@ function explainPath(config, target) {
8917
9205
  // Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
8918
9206
  // that is only missing because the walker dropped the tool's own output directory.
8919
9207
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
8920
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
9208
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8921
9209
  ).filter((relative12) => relative12.length > 0 && !relative12.startsWith(".."))
8922
9210
  });
8923
9211
  if (!collection.files.includes(relative11)) {
@@ -8982,7 +9270,7 @@ function explainPath(config, target) {
8982
9270
  }
8983
9271
  let sizeOnDisk = null;
8984
9272
  try {
8985
- sizeOnDisk = fs15__namespace.statSync(absolute).size;
9273
+ sizeOnDisk = fs16__namespace.statSync(absolute).size;
8986
9274
  } catch {
8987
9275
  sizeOnDisk = null;
8988
9276
  }
@@ -8992,10 +9280,10 @@ function explainPath(config, target) {
8992
9280
  result.detail = "binary content; generate skips it and records `binary` in manifest.skipped[]";
8993
9281
  return result;
8994
9282
  }
8995
- if (fs15__namespace.existsSync(absolute) && fs15__namespace.statSync(absolute).isFile()) {
9283
+ if (fs16__namespace.existsSync(absolute) && fs16__namespace.statSync(absolute).isFile()) {
8996
9284
  let buffer;
8997
9285
  try {
8998
- buffer = fs15__namespace.readFileSync(absolute);
9286
+ buffer = fs16__namespace.readFileSync(absolute);
8999
9287
  } catch (err) {
9000
9288
  result.included = false;
9001
9289
  result.reason = "read-error";
@@ -9285,14 +9573,14 @@ function compareManifests(before, after, secretRules) {
9285
9573
  function loadManifest(target) {
9286
9574
  let isDirectory;
9287
9575
  try {
9288
- isDirectory = fs15__namespace.statSync(target).isDirectory();
9576
+ isDirectory = fs16__namespace.statSync(target).isDirectory();
9289
9577
  } catch {
9290
9578
  throw new Error(`No snapshot found at ${target}: the path does not exist.`);
9291
9579
  }
9292
- const manifestPath = isDirectory ? path16__namespace.join(target, "manifest.json") : target;
9580
+ const manifestPath = isDirectory ? path17__namespace.join(target, "manifest.json") : target;
9293
9581
  let raw;
9294
9582
  try {
9295
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
9583
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
9296
9584
  } catch {
9297
9585
  throw new Error(`Could not read a manifest at ${manifestPath}.`);
9298
9586
  }
@@ -9394,15 +9682,15 @@ function canonicalIgnorePattern(line) {
9394
9682
  function appendGitignoreEntries(cwd, entries) {
9395
9683
  const wanted = [...new Set(entries)].filter((entry) => entry.trim().length > 0);
9396
9684
  if (wanted.length === 0) return { added: [], note: null };
9397
- const ignorePath = path16__namespace.join(cwd, ".gitignore");
9685
+ const ignorePath = path17__namespace.join(cwd, ".gitignore");
9398
9686
  const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
9399
9687
  let decoded = { text: "", bom: Buffer.alloc(0), encoding: "utf8" };
9400
9688
  try {
9401
- if (fs15__namespace.existsSync(ignorePath)) {
9402
- if (fs15__namespace.statSync(ignorePath).isDirectory()) {
9689
+ if (fs16__namespace.existsSync(ignorePath)) {
9690
+ if (fs16__namespace.statSync(ignorePath).isDirectory()) {
9403
9691
  return { added: [], note: `${ignorePath} is a directory, so it was not updated. ${manual}` };
9404
9692
  }
9405
- const read = decodeGitignore(fs15__namespace.readFileSync(ignorePath));
9693
+ const read = decodeGitignore(fs16__namespace.readFileSync(ignorePath));
9406
9694
  if (read === null) {
9407
9695
  return {
9408
9696
  added: [],
@@ -9424,7 +9712,7 @@ function appendGitignoreEntries(cwd, entries) {
9424
9712
  const newline = existing.includes("\r\n") ? "\r\n" : "\n";
9425
9713
  const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : newline;
9426
9714
  try {
9427
- fs15__namespace.writeFileSync(
9715
+ fs16__namespace.writeFileSync(
9428
9716
  ignorePath,
9429
9717
  encodeGitignore(decoded, `${existing}${prefix}${added.join(newline)}${newline}`)
9430
9718
  );
@@ -9434,7 +9722,7 @@ function appendGitignoreEntries(cwd, entries) {
9434
9722
  return { added, note: null };
9435
9723
  }
9436
9724
  function gitignorePath(cwd, filePath) {
9437
- return path16__namespace.relative(cwd, filePath).split(path16__namespace.sep).join("/");
9725
+ return path17__namespace.relative(cwd, filePath).split(path17__namespace.sep).join("/");
9438
9726
  }
9439
9727
 
9440
9728
  // src/wizard/config-template.ts
@@ -9590,6 +9878,10 @@ function renderConfig(answers) {
9590
9878
  // Experimental: grow the per-part budget until the snapshot fits this many parts, instead of
9591
9879
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
9592
9880
  // maxParts: 10,
9881
+ // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
9882
+ // brief: "docs/brief.md",
9883
+ // Which job the brief is written for: audit, review or explain.
9884
+ // promptTask: "audit",
9593
9885
  // afterGenerate: (manifest) => { /* write your own artifact */ }
9594
9886
  hooks: {},
9595
9887
  };
@@ -9984,7 +10276,7 @@ function parsePackageJson(raw) {
9984
10276
  }
9985
10277
  function readPackageJson(cwd) {
9986
10278
  try {
9987
- return parsePackageJson(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"));
10279
+ return parsePackageJson(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"));
9988
10280
  } catch {
9989
10281
  return null;
9990
10282
  }
@@ -10021,7 +10313,7 @@ function artifactAnswers(options) {
10021
10313
  }
10022
10314
  function topLevelDirs(cwd) {
10023
10315
  try {
10024
- return fs15__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
10316
+ return fs16__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
10025
10317
  } catch {
10026
10318
  return [];
10027
10319
  }
@@ -10036,7 +10328,7 @@ function writeFileOrExplain(target, content) {
10036
10328
  try {
10037
10329
  let stats = null;
10038
10330
  try {
10039
- stats = fs15__namespace.lstatSync(target);
10331
+ stats = fs16__namespace.lstatSync(target);
10040
10332
  } catch {
10041
10333
  stats = null;
10042
10334
  }
@@ -10051,12 +10343,12 @@ function writeFileOrExplain(target, content) {
10051
10343
  );
10052
10344
  }
10053
10345
  const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
10054
- fs15__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
10346
+ fs16__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
10055
10347
  try {
10056
- fs15__namespace.renameSync(temporary, target);
10348
+ fs16__namespace.renameSync(temporary, target);
10057
10349
  } catch (err) {
10058
10350
  try {
10059
- fs15__namespace.unlinkSync(temporary);
10351
+ fs16__namespace.unlinkSync(temporary);
10060
10352
  } catch {
10061
10353
  }
10062
10354
  throw err;
@@ -10104,19 +10396,19 @@ function serializePackageJson(raw, value) {
10104
10396
  return `${bom}${text2}${raw.endsWith("\n") ? crlf ? "\r\n" : "\n" : ""}`;
10105
10397
  }
10106
10398
  function updatePackageJson(cwd, notes) {
10107
- const packagePath = path16__namespace.join(cwd, "package.json");
10399
+ const packagePath = path17__namespace.join(cwd, "package.json");
10108
10400
  const unchanged = {
10109
10401
  scripts: [],
10110
10402
  dependency: { name: GENERATOR_NAME, range: null, added: false }
10111
10403
  };
10112
- if (!fs15__namespace.existsSync(packagePath)) {
10404
+ if (!fs16__namespace.existsSync(packagePath)) {
10113
10405
  notes.push("No package.json found, so npm scripts and the devDependency were not added.");
10114
10406
  return unchanged;
10115
10407
  }
10116
10408
  let raw;
10117
10409
  let parsed;
10118
10410
  try {
10119
- raw = fs15__namespace.readFileSync(packagePath, "utf8");
10411
+ raw = fs16__namespace.readFileSync(packagePath, "utf8");
10120
10412
  parsed = parsePackageJson(raw);
10121
10413
  } catch {
10122
10414
  notes.push("Could not parse package.json; npm scripts and the devDependency were not added.");
@@ -10191,8 +10483,8 @@ function gitignoreEntriesFor(cwd, outDir, tmpDir) {
10191
10483
  const entries = [];
10192
10484
  for (const directory of [outDir, tmpDir]) {
10193
10485
  if (directory === null) continue;
10194
- const relative11 = path16__namespace.relative(cwd, path16__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
10195
- if (relative11 === "" || relative11 === "." || relative11.startsWith("..") || path16__namespace.isAbsolute(relative11)) {
10486
+ const relative11 = path17__namespace.relative(cwd, path17__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
10487
+ if (relative11 === "" || relative11 === "." || relative11.startsWith("..") || path17__namespace.isAbsolute(relative11)) {
10196
10488
  continue;
10197
10489
  }
10198
10490
  entries.push(`/${relative11}/`);
@@ -10444,7 +10736,7 @@ async function runInit(options) {
10444
10736
  const configText = renderConfig(answers);
10445
10737
  const preferredName = chooseConfigFileName(options.cwd);
10446
10738
  const presentConfigs = CONFIG_CANDIDATES.filter(
10447
- (name) => fs15__namespace.existsSync(path16__namespace.join(options.cwd, name))
10739
+ (name) => fs16__namespace.existsSync(path17__namespace.join(options.cwd, name))
10448
10740
  );
10449
10741
  const present = presentConfigs[0] ?? null;
10450
10742
  if (presentConfigs.length > 1) {
@@ -10453,7 +10745,7 @@ async function runInit(options) {
10453
10745
  );
10454
10746
  }
10455
10747
  const configName = present !== null && options.force ? present : preferredName;
10456
- const configPath = path16__namespace.join(options.cwd, configName);
10748
+ const configPath = path17__namespace.join(options.cwd, configName);
10457
10749
  const reused = present !== null && options.force !== true && options.reuseConfig === true;
10458
10750
  if (reused) notes.push(`Kept the existing ${present} instead of writing a new one.`);
10459
10751
  if (options.dryRun) {
@@ -10487,7 +10779,7 @@ async function runInit(options) {
10487
10779
  'package.json already defines a "snapshot" config. Remove that key, or re-run with --force to write a config file that takes precedence over it.'
10488
10780
  );
10489
10781
  }
10490
- if (fs15__namespace.existsSync(configPath) && !options.force && !reused) {
10782
+ if (fs16__namespace.existsSync(configPath) && !options.force && !reused) {
10491
10783
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
10492
10784
  }
10493
10785
  if (!reused) writeFileOrExplain(configPath, configText);
@@ -10513,9 +10805,9 @@ async function runInit(options) {
10513
10805
  };
10514
10806
  }
10515
10807
  function describeTarget(cwd) {
10516
- const relative11 = path16__namespace.relative(process.cwd(), cwd);
10808
+ const relative11 = path17__namespace.relative(process.cwd(), cwd);
10517
10809
  if (relative11 === "") return "this directory";
10518
- if (relative11.startsWith("..") || path16__namespace.isAbsolute(relative11)) return cwd;
10810
+ if (relative11.startsWith("..") || path17__namespace.isAbsolute(relative11)) return cwd;
10519
10811
  return relative11;
10520
10812
  }
10521
10813
  function firstRunMessage(reason, cwd) {
@@ -10539,7 +10831,7 @@ function planFirstRun(facts) {
10539
10831
  var NOT_CONTENT = /* @__PURE__ */ new Set([".git", ".hg", ".svn", ".bzr", ".DS_Store", "Thumbs.db"]);
10540
10832
  function isEffectivelyEmpty(cwd) {
10541
10833
  try {
10542
- return fs15__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
10834
+ return fs16__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
10543
10835
  } catch {
10544
10836
  return false;
10545
10837
  }
@@ -10547,7 +10839,7 @@ function isEffectivelyEmpty(cwd) {
10547
10839
  function hasPriorSnapshot(cwd, outDir) {
10548
10840
  let parsed;
10549
10841
  try {
10550
- parsed = JSON.parse(fs15__namespace.readFileSync(path16__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
10842
+ parsed = JSON.parse(fs16__namespace.readFileSync(path17__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
10551
10843
  } catch {
10552
10844
  return false;
10553
10845
  }
@@ -10595,36 +10887,36 @@ fi
10595
10887
  `;
10596
10888
  }
10597
10889
  function gitDirectory(cwd) {
10598
- const dotGit = path16__namespace.join(cwd, ".git");
10890
+ const dotGit = path17__namespace.join(cwd, ".git");
10599
10891
  let stats;
10600
10892
  try {
10601
- stats = fs15__namespace.statSync(dotGit);
10893
+ stats = fs16__namespace.statSync(dotGit);
10602
10894
  } catch {
10603
10895
  return null;
10604
10896
  }
10605
10897
  if (stats.isDirectory()) return dotGit;
10606
10898
  if (!stats.isFile()) return null;
10607
10899
  try {
10608
- const contents = fs15__namespace.readFileSync(dotGit, "utf8");
10900
+ const contents = fs16__namespace.readFileSync(dotGit, "utf8");
10609
10901
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
10610
10902
  if (!match) return null;
10611
10903
  const target = match[1];
10612
- const resolved = path16__namespace.isAbsolute(target.trim()) ? target.trim() : path16__namespace.join(cwd, target.trim());
10613
- if (!fs15__namespace.statSync(resolved).isDirectory()) return null;
10614
- if (isInside2(path16__namespace.resolve(cwd), path16__namespace.resolve(resolved))) return resolved;
10615
- return isRegisteredWorktree(path16__namespace.resolve(resolved), cwd) ? resolved : null;
10904
+ const resolved = path17__namespace.isAbsolute(target.trim()) ? target.trim() : path17__namespace.join(cwd, target.trim());
10905
+ if (!fs16__namespace.statSync(resolved).isDirectory()) return null;
10906
+ if (isInside2(path17__namespace.resolve(cwd), path17__namespace.resolve(resolved))) return resolved;
10907
+ return isRegisteredWorktree(path17__namespace.resolve(resolved), cwd) ? resolved : null;
10616
10908
  } catch {
10617
10909
  return null;
10618
10910
  }
10619
10911
  }
10620
10912
  function isInside2(parent, child) {
10621
- const relative11 = path16__namespace.relative(parent, child);
10622
- return relative11 === "" || !relative11.startsWith("..") && !path16__namespace.isAbsolute(relative11);
10913
+ const relative11 = path17__namespace.relative(parent, child);
10914
+ return relative11 === "" || !relative11.startsWith("..") && !path17__namespace.isAbsolute(relative11);
10623
10915
  }
10624
10916
  function isRegisteredWorktree(gitDir, cwd) {
10625
10917
  try {
10626
- const back = fs15__namespace.readFileSync(path16__namespace.join(gitDir, "gitdir"), "utf8").trim();
10627
- return path16__namespace.resolve(gitDir, back) === path16__namespace.join(path16__namespace.resolve(cwd), ".git");
10918
+ const back = fs16__namespace.readFileSync(path17__namespace.join(gitDir, "gitdir"), "utf8").trim();
10919
+ return path17__namespace.resolve(gitDir, back) === path17__namespace.join(path17__namespace.resolve(cwd), ".git");
10628
10920
  } catch {
10629
10921
  return false;
10630
10922
  }
@@ -10645,10 +10937,10 @@ function gitOutput(cwd, args) {
10645
10937
  function configuredHooksDirectory(cwd) {
10646
10938
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
10647
10939
  if (hooks === null) return null;
10648
- const resolved = path16__namespace.resolve(cwd, hooks);
10940
+ const resolved = path17__namespace.resolve(cwd, hooks);
10649
10941
  const common = gitOutput(cwd, ["rev-parse", "--git-common-dir"]);
10650
- const commonDir = common === null ? null : path16__namespace.resolve(cwd, common);
10651
- if (isInside2(path16__namespace.resolve(cwd), resolved)) return { dir: resolved };
10942
+ const commonDir = common === null ? null : path17__namespace.resolve(cwd, common);
10943
+ if (isInside2(path17__namespace.resolve(cwd), resolved)) return { dir: resolved };
10652
10944
  if (commonDir !== null && isInside2(commonDir, resolved)) return { dir: resolved };
10653
10945
  return {
10654
10946
  refusal: `The hooks directory git reports (${resolved}) is outside this repository, so no hook was written. Add \`npx ${GENERATOR_NAME} validate\` to the hook manager that owns it instead.`
@@ -10669,10 +10961,10 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10669
10961
  ]
10670
10962
  };
10671
10963
  }
10672
- const hooksDir = configured === null ? path16__namespace.join(gitDir, "hooks") : configured.dir;
10673
- const hookPath = path16__namespace.join(hooksDir, "pre-commit");
10964
+ const hooksDir = configured === null ? path17__namespace.join(gitDir, "hooks") : configured.dir;
10965
+ const hookPath = path17__namespace.join(hooksDir, "pre-commit");
10674
10966
  try {
10675
- fs15__namespace.mkdirSync(hooksDir, { recursive: true });
10967
+ fs16__namespace.mkdirSync(hooksDir, { recursive: true });
10676
10968
  } catch (err) {
10677
10969
  return {
10678
10970
  path: hookPath,
@@ -10682,7 +10974,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10682
10974
  }
10683
10975
  let existing = null;
10684
10976
  try {
10685
- existing = fs15__namespace.readFileSync(hookPath, "utf8");
10977
+ existing = fs16__namespace.readFileSync(hookPath, "utf8");
10686
10978
  } catch {
10687
10979
  existing = null;
10688
10980
  }
@@ -10697,8 +10989,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10697
10989
  };
10698
10990
  }
10699
10991
  try {
10700
- fs15__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10701
- fs15__namespace.chmodSync(hookPath, 493);
10992
+ fs16__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10993
+ fs16__namespace.chmodSync(hookPath, 493);
10702
10994
  } catch (err) {
10703
10995
  return {
10704
10996
  path: hookPath,
@@ -10715,7 +11007,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10715
11007
  };
10716
11008
  }
10717
11009
  function workerEntry(directory, isCjs) {
10718
- const entry = path16__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
11010
+ const entry = path17__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10719
11011
  return { path: entry, url: url.pathToFileURL(entry).href };
10720
11012
  }
10721
11013
 
@@ -10724,23 +11016,23 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
10724
11016
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
10725
11017
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
10726
11018
  var fileDerivationBytes = 0;
10727
- function takeDerivation(path17, hash, settings) {
10728
- const cached = FILE_DERIVATIONS.get(path17);
11019
+ function takeDerivation(path18, hash, settings) {
11020
+ const cached = FILE_DERIVATIONS.get(path18);
10729
11021
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
10730
- FILE_DERIVATIONS.delete(path17);
10731
- FILE_DERIVATIONS.set(path17, cached);
11022
+ FILE_DERIVATIONS.delete(path18);
11023
+ FILE_DERIVATIONS.set(path18, cached);
10732
11024
  return cached;
10733
11025
  }
10734
- function rememberDerivation(path17, hash, settings, derivation) {
11026
+ function rememberDerivation(path18, hash, settings, derivation) {
10735
11027
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
10736
11028
  const bytes = bodyBytes * 2 + 512;
10737
11029
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
10738
- const previous = FILE_DERIVATIONS.get(path17);
11030
+ const previous = FILE_DERIVATIONS.get(path18);
10739
11031
  if (previous !== void 0) {
10740
- FILE_DERIVATIONS.delete(path17);
11032
+ FILE_DERIVATIONS.delete(path18);
10741
11033
  fileDerivationBytes -= previous.bytes;
10742
11034
  } else {
10743
- FILE_DERIVATIONS.delete(path17);
11035
+ FILE_DERIVATIONS.delete(path18);
10744
11036
  }
10745
11037
  while (fileDerivationBytes + bytes > FILE_DERIVATION_LIMIT_BYTES) {
10746
11038
  const oldest = FILE_DERIVATIONS.keys().next();
@@ -10749,7 +11041,7 @@ function rememberDerivation(path17, hash, settings, derivation) {
10749
11041
  FILE_DERIVATIONS.delete(oldest.value);
10750
11042
  if (evicted !== void 0) fileDerivationBytes -= evicted.bytes;
10751
11043
  }
10752
- FILE_DERIVATIONS.set(path17, { ...derivation, hash, settings, bytes });
11044
+ FILE_DERIVATIONS.set(path18, { ...derivation, hash, settings, bytes });
10753
11045
  fileDerivationBytes += bytes;
10754
11046
  }
10755
11047
  function derivationSettings(config) {
@@ -11000,11 +11292,11 @@ function verifyInMemory(files, parts, unaccounted) {
11000
11292
  return errors;
11001
11293
  }
11002
11294
  function resolveSafeOutputDirs(config) {
11003
- const cwd = path16__namespace.resolve(config.cwd);
11004
- const outDir = path16__namespace.resolve(cwd, config.outDir);
11005
- const tmpDir = path16__namespace.resolve(cwd, config.tmpDir);
11006
- const root = path16__namespace.parse(cwd).root;
11007
- const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path16__namespace.sep}`);
11295
+ const cwd = path17__namespace.resolve(config.cwd);
11296
+ const outDir = path17__namespace.resolve(cwd, config.outDir);
11297
+ const tmpDir = path17__namespace.resolve(cwd, config.tmpDir);
11298
+ const root = path17__namespace.parse(cwd).root;
11299
+ const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path17__namespace.sep}`);
11008
11300
  const reject = (reason) => {
11009
11301
  throw new Error(
11010
11302
  `Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
@@ -11044,6 +11336,28 @@ function maskSummaryStrings(value, secretRules) {
11044
11336
  function maskPathText(value, secretRules) {
11045
11337
  return findSecretInPath(value, secretRules)?.masked ?? value;
11046
11338
  }
11339
+ function maskOwnerBrief(brief, secretRules) {
11340
+ if (brief === void 0) return void 0;
11341
+ const mask = (value) => maskPathText(value, secretRules);
11342
+ return {
11343
+ ...brief,
11344
+ ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11345
+ ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11346
+ ...brief.history === void 0 ? {} : { history: mask(brief.history) },
11347
+ ...brief.bar === void 0 ? {} : { bar: mask(brief.bar) },
11348
+ ...brief.calibration === void 0 ? {} : { calibration: mask(brief.calibration) },
11349
+ ...brief.preamble === void 0 ? {} : { preamble: mask(brief.preamble) },
11350
+ notes: brief.notes.map((note) => ({ heading: note.heading, body: mask(note.body) }))
11351
+ };
11352
+ }
11353
+ function maskOverview(overview, secretRules) {
11354
+ const mask = (value) => maskPathText(value, secretRules);
11355
+ return {
11356
+ ...overview.description === void 0 ? {} : { description: mask(overview.description) },
11357
+ ...overview.summary === void 0 ? {} : { summary: mask(overview.summary) },
11358
+ releases: overview.releases.map(mask)
11359
+ };
11360
+ }
11047
11361
  function maskSkipRecords(records, secretRules) {
11048
11362
  return maskSkipPaths(records, secretRules);
11049
11363
  }
@@ -11064,14 +11378,14 @@ function listEntries(dir) {
11064
11378
  const walk = (absolute, prefix) => {
11065
11379
  let children;
11066
11380
  try {
11067
- children = fs15__namespace.readdirSync(absolute, { withFileTypes: true });
11381
+ children = fs16__namespace.readdirSync(absolute, { withFileTypes: true });
11068
11382
  } catch {
11069
11383
  return;
11070
11384
  }
11071
11385
  for (const child of children) {
11072
11386
  const relative11 = prefix === "" ? child.name : `${prefix}/${child.name}`;
11073
11387
  entries.push(relative11);
11074
- if (child.isDirectory()) walk(path16__namespace.join(absolute, child.name), relative11);
11388
+ if (child.isDirectory()) walk(path17__namespace.join(absolute, child.name), relative11);
11075
11389
  }
11076
11390
  };
11077
11391
  walk(dir, "");
@@ -11083,10 +11397,10 @@ function markerInventory(dir, written) {
11083
11397
  for (const entry of entries) {
11084
11398
  if (entry === OWNERSHIP_MARKER) continue;
11085
11399
  if (isIgnorableEntry(entry)) continue;
11086
- const full = path16__namespace.join(dir, ...entry.split("/"));
11400
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11087
11401
  let stats;
11088
11402
  try {
11089
- stats = fs15__namespace.lstatSync(full);
11403
+ stats = fs16__namespace.lstatSync(full);
11090
11404
  } catch {
11091
11405
  continue;
11092
11406
  }
@@ -11098,7 +11412,7 @@ function markerInventory(dir, written) {
11098
11412
  }
11099
11413
  let digest;
11100
11414
  try {
11101
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11415
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11102
11416
  } catch {
11103
11417
  continue;
11104
11418
  }
@@ -11119,15 +11433,15 @@ function markerPayload(dir, state, id, createdAt, written) {
11119
11433
  entries,
11120
11434
  files
11121
11435
  };
11122
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11123
- if (fs15__namespace.existsSync(manifestPath)) {
11124
- marker2.manifestSha256 = sha256Hex2(fs15__namespace.readFileSync(manifestPath));
11436
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11437
+ if (fs16__namespace.existsSync(manifestPath)) {
11438
+ marker2.manifestSha256 = sha256Hex2(fs16__namespace.readFileSync(manifestPath));
11125
11439
  }
11126
11440
  return marker2;
11127
11441
  }
11128
11442
  function writeOwnershipMarker(dir, marker2) {
11129
- fs15__namespace.writeFileSync(
11130
- path16__namespace.join(dir, OWNERSHIP_MARKER),
11443
+ fs16__namespace.writeFileSync(
11444
+ path17__namespace.join(dir, OWNERSHIP_MARKER),
11131
11445
  `${JSON.stringify(marker2, null, 2)}
11132
11446
  `,
11133
11447
  "utf8"
@@ -11139,13 +11453,13 @@ function markerBelongsTo(dir, id) {
11139
11453
  return evidence.marker.id === id;
11140
11454
  }
11141
11455
  function readOwnershipMarker(dir) {
11142
- const markerPath = path16__namespace.join(dir, OWNERSHIP_MARKER);
11143
- if (!fs15__namespace.existsSync(markerPath)) {
11456
+ const markerPath = path17__namespace.join(dir, OWNERSHIP_MARKER);
11457
+ if (!fs16__namespace.existsSync(markerPath)) {
11144
11458
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
11145
11459
  }
11146
11460
  let raw;
11147
11461
  try {
11148
- raw = fs15__namespace.readFileSync(markerPath, "utf8");
11462
+ raw = fs16__namespace.readFileSync(markerPath, "utf8");
11149
11463
  } catch {
11150
11464
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
11151
11465
  }
@@ -11245,10 +11559,10 @@ function verifyMarkerInventory(dir, entries, files) {
11245
11559
  for (const entry of entries) {
11246
11560
  if (entry === OWNERSHIP_MARKER) continue;
11247
11561
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
11248
- const full = path16__namespace.join(dir, ...entry.split("/"));
11562
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11249
11563
  let stats;
11250
11564
  try {
11251
- stats = fs15__namespace.lstatSync(full);
11565
+ stats = fs16__namespace.lstatSync(full);
11252
11566
  } catch {
11253
11567
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
11254
11568
  }
@@ -11273,7 +11587,7 @@ function verifyMarkerInventory(dir, entries, files) {
11273
11587
  }
11274
11588
  let digest;
11275
11589
  try {
11276
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11590
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11277
11591
  } catch {
11278
11592
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
11279
11593
  }
@@ -11294,12 +11608,12 @@ function assessSnapshotDirectory(dir) {
11294
11608
  marker: marker2
11295
11609
  };
11296
11610
  }
11297
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11298
- const hasManifest = fs15__namespace.existsSync(manifestPath);
11611
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11612
+ const hasManifest = fs16__namespace.existsSync(manifestPath);
11299
11613
  if (hasManifest) {
11300
11614
  let raw;
11301
11615
  try {
11302
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
11616
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
11303
11617
  } catch {
11304
11618
  return {
11305
11619
  owned: false,
@@ -11394,13 +11708,13 @@ function containsNoFiles(dir) {
11394
11708
  const current = pending.pop();
11395
11709
  let entries;
11396
11710
  try {
11397
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
11711
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
11398
11712
  } catch {
11399
11713
  return false;
11400
11714
  }
11401
11715
  for (const entry of entries) {
11402
11716
  if (entry.isDirectory()) {
11403
- pending.push(path16__namespace.join(current, entry.name));
11717
+ pending.push(path17__namespace.join(current, entry.name));
11404
11718
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
11405
11719
  return false;
11406
11720
  }
@@ -11409,13 +11723,13 @@ function containsNoFiles(dir) {
11409
11723
  return true;
11410
11724
  }
11411
11725
  function assertReplaceable(target, label, secretRules) {
11412
- if (!fs15__namespace.existsSync(target)) return;
11413
- if (!fs15__namespace.statSync(target).isDirectory()) {
11726
+ if (!fs16__namespace.existsSync(target)) return;
11727
+ if (!fs16__namespace.statSync(target).isDirectory()) {
11414
11728
  throw new Error(
11415
11729
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
11416
11730
  );
11417
11731
  }
11418
- const entries = fs15__namespace.readdirSync(target);
11732
+ const entries = fs16__namespace.readdirSync(target);
11419
11733
  if (entries.length === 0) return;
11420
11734
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
11421
11735
  if (containsNoFiles(target)) return;
@@ -11435,18 +11749,18 @@ function assertReplaceable(target, label, secretRules) {
11435
11749
  );
11436
11750
  }
11437
11751
  function assertStagingRootUsable(tmpDir, secretRules) {
11438
- if (!fs15__namespace.existsSync(tmpDir)) return;
11439
- if (!fs15__namespace.statSync(tmpDir).isDirectory()) {
11752
+ if (!fs16__namespace.existsSync(tmpDir)) return;
11753
+ if (!fs16__namespace.statSync(tmpDir).isDirectory()) {
11440
11754
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
11441
11755
  }
11442
- const entries = fs15__namespace.readdirSync(tmpDir);
11756
+ const entries = fs16__namespace.readdirSync(tmpDir);
11443
11757
  if (entries.length === 0) return;
11444
11758
  const foreign = entries.filter((name) => {
11445
- const full = path16__namespace.join(tmpDir, name);
11759
+ const full = path17__namespace.join(tmpDir, name);
11446
11760
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
11447
11761
  let stats;
11448
11762
  try {
11449
- stats = fs15__namespace.statSync(full);
11763
+ stats = fs16__namespace.statSync(full);
11450
11764
  } catch {
11451
11765
  return true;
11452
11766
  }
@@ -11454,7 +11768,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11454
11768
  const { marker: marker2 } = readOwnershipMarker(full);
11455
11769
  if (marker2) return false;
11456
11770
  try {
11457
- return fs15__namespace.readdirSync(full).length > 0;
11771
+ return fs16__namespace.readdirSync(full).length > 0;
11458
11772
  } catch {
11459
11773
  return true;
11460
11774
  }
@@ -11469,13 +11783,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11469
11783
  function cleanStaleRunDirs(tmpDir) {
11470
11784
  let entries;
11471
11785
  try {
11472
- entries = fs15__namespace.readdirSync(tmpDir);
11786
+ entries = fs16__namespace.readdirSync(tmpDir);
11473
11787
  } catch {
11474
11788
  return;
11475
11789
  }
11476
11790
  for (const name of entries) {
11477
11791
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
11478
- const full = path16__namespace.join(tmpDir, name);
11792
+ const full = path17__namespace.join(tmpDir, name);
11479
11793
  const { marker: marker2 } = readOwnershipMarker(full);
11480
11794
  if (marker2) {
11481
11795
  const created = Date.parse(marker2.createdAt);
@@ -11483,33 +11797,33 @@ function cleanStaleRunDirs(tmpDir) {
11483
11797
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
11484
11798
  if (aged || abandoned) {
11485
11799
  try {
11486
- fs15__namespace.rmSync(full, { recursive: true, force: true });
11800
+ fs16__namespace.rmSync(full, { recursive: true, force: true });
11487
11801
  } catch {
11488
11802
  }
11489
11803
  }
11490
11804
  continue;
11491
11805
  }
11492
11806
  try {
11493
- if (fs15__namespace.readdirSync(full).length === 0) fs15__namespace.rmSync(full, { recursive: true, force: true });
11807
+ if (fs16__namespace.readdirSync(full).length === 0) fs16__namespace.rmSync(full, { recursive: true, force: true });
11494
11808
  } catch {
11495
11809
  }
11496
11810
  }
11497
11811
  }
11498
11812
  function removeIfEmpty(dir) {
11499
11813
  try {
11500
- if (fs15__namespace.readdirSync(dir).length === 0) fs15__namespace.rmSync(dir, { recursive: true, force: true });
11814
+ if (fs16__namespace.readdirSync(dir).length === 0) fs16__namespace.rmSync(dir, { recursive: true, force: true });
11501
11815
  } catch {
11502
11816
  }
11503
11817
  }
11504
11818
  function ensureParentDirectory(target, label) {
11505
- const parent = path16__namespace.dirname(target);
11506
- if (fs15__namespace.existsSync(parent) && !fs15__namespace.statSync(parent).isDirectory()) {
11819
+ const parent = path17__namespace.dirname(target);
11820
+ if (fs16__namespace.existsSync(parent) && !fs16__namespace.statSync(parent).isDirectory()) {
11507
11821
  throw new Error(
11508
11822
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
11509
11823
  );
11510
11824
  }
11511
11825
  try {
11512
- fs15__namespace.mkdirSync(parent, { recursive: true });
11826
+ fs16__namespace.mkdirSync(parent, { recursive: true });
11513
11827
  } catch (err) {
11514
11828
  throw new Error(
11515
11829
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -11567,17 +11881,17 @@ function acquireRunLock(stagingRoot) {
11567
11881
  `;
11568
11882
  for (let attempt = 0; attempt < 2; attempt += 1) {
11569
11883
  try {
11570
- const handle = fs15__namespace.openSync(lockPath, "wx");
11884
+ const handle = fs16__namespace.openSync(lockPath, "wx");
11571
11885
  try {
11572
- fs15__namespace.writeSync(handle, payload);
11886
+ fs16__namespace.writeSync(handle, payload);
11573
11887
  } finally {
11574
- fs15__namespace.closeSync(handle);
11888
+ fs16__namespace.closeSync(handle);
11575
11889
  }
11576
11890
  const stopHeartbeat = startLockHeartbeat(lockPath);
11577
11891
  return () => {
11578
11892
  stopHeartbeat();
11579
11893
  try {
11580
- fs15__namespace.rmSync(lockPath, { force: true });
11894
+ fs16__namespace.rmSync(lockPath, { force: true });
11581
11895
  } catch {
11582
11896
  }
11583
11897
  };
@@ -11597,26 +11911,26 @@ function lockKeyFor(stagingRoot) {
11597
11911
  return sha256Hex2(key).slice(0, 16);
11598
11912
  }
11599
11913
  function canonicalLockTarget(targetPath) {
11600
- const resolved = path16__namespace.resolve(targetPath);
11914
+ const resolved = path17__namespace.resolve(targetPath);
11601
11915
  let existing = resolved;
11602
11916
  const tail = [];
11603
11917
  for (; ; ) {
11604
11918
  try {
11605
- return path16__namespace.join(fs15__namespace.realpathSync(existing), ...tail);
11919
+ return path17__namespace.join(fs16__namespace.realpathSync(existing), ...tail);
11606
11920
  } catch {
11607
- const parent = path16__namespace.dirname(existing);
11921
+ const parent = path17__namespace.dirname(existing);
11608
11922
  if (parent === existing) return resolved;
11609
- tail.unshift(path16__namespace.basename(existing));
11923
+ tail.unshift(path17__namespace.basename(existing));
11610
11924
  existing = parent;
11611
11925
  }
11612
11926
  }
11613
11927
  }
11614
11928
  function lockPathFor(stagingRoot) {
11615
- return path16__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11929
+ return path17__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11616
11930
  }
11617
11931
  function lockHeartbeatAgeMs(lockPath) {
11618
11932
  try {
11619
- return Date.now() - fs15__namespace.statSync(lockPath).mtimeMs;
11933
+ return Date.now() - fs16__namespace.statSync(lockPath).mtimeMs;
11620
11934
  } catch {
11621
11935
  return Number.POSITIVE_INFINITY;
11622
11936
  }
@@ -11624,7 +11938,7 @@ function lockHeartbeatAgeMs(lockPath) {
11624
11938
  function lockOwnerIsGone(lockPath) {
11625
11939
  let raw;
11626
11940
  try {
11627
- raw = fs15__namespace.readFileSync(lockPath, "utf8");
11941
+ raw = fs16__namespace.readFileSync(lockPath, "utf8");
11628
11942
  } catch {
11629
11943
  return false;
11630
11944
  }
@@ -11646,16 +11960,16 @@ function lockOwnerIsGone(lockPath) {
11646
11960
  function reclaimStaleLock(lockPath) {
11647
11961
  let before;
11648
11962
  try {
11649
- before = fs15__namespace.statSync(lockPath);
11963
+ before = fs16__namespace.statSync(lockPath);
11650
11964
  } catch {
11651
11965
  return true;
11652
11966
  }
11653
11967
  if (!lockOwnerIsGone(lockPath)) return false;
11654
11968
  try {
11655
- const current = fs15__namespace.statSync(lockPath);
11969
+ const current = fs16__namespace.statSync(lockPath);
11656
11970
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
11657
11971
  if (!sameFile) return false;
11658
- fs15__namespace.rmSync(lockPath, { force: true });
11972
+ fs16__namespace.rmSync(lockPath, { force: true });
11659
11973
  return true;
11660
11974
  } catch {
11661
11975
  return false;
@@ -11666,12 +11980,12 @@ function lockFileIsAncient(lockPath) {
11666
11980
  }
11667
11981
  function writeManifestAtomically(manifestPath, manifest) {
11668
11982
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
11669
- fs15__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11983
+ fs16__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11670
11984
  try {
11671
- fs15__namespace.renameSync(tempPath, manifestPath);
11985
+ fs16__namespace.renameSync(tempPath, manifestPath);
11672
11986
  } catch (err) {
11673
11987
  try {
11674
- fs15__namespace.rmSync(tempPath, { force: true });
11988
+ fs16__namespace.rmSync(tempPath, { force: true });
11675
11989
  } catch {
11676
11990
  }
11677
11991
  throw err;
@@ -11696,21 +12010,21 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap) {
11696
12010
  }
11697
12011
  }
11698
12012
  function recoverInterruptedPublish(outDir) {
11699
- if (fs15__namespace.existsSync(outDir)) return;
11700
- const parent = path16__namespace.dirname(outDir);
11701
- const base = path16__namespace.basename(outDir);
12013
+ if (fs16__namespace.existsSync(outDir)) return;
12014
+ const parent = path17__namespace.dirname(outDir);
12015
+ const base = path17__namespace.basename(outDir);
11702
12016
  let backups;
11703
12017
  try {
11704
- backups = fs15__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
12018
+ backups = fs16__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
11705
12019
  } catch {
11706
12020
  return;
11707
12021
  }
11708
12022
  if (backups.length !== 1) return;
11709
- const backupDir = path16__namespace.join(parent, backups[0]);
12023
+ const backupDir = path17__namespace.join(parent, backups[0]);
11710
12024
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
11711
12025
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
11712
12026
  try {
11713
- fs15__namespace.renameSync(backupDir, outDir);
12027
+ fs16__namespace.renameSync(backupDir, outDir);
11714
12028
  process.stderr.write(
11715
12029
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
11716
12030
  `
@@ -11720,16 +12034,16 @@ function recoverInterruptedPublish(outDir) {
11720
12034
  }
11721
12035
  function swapOnce(stagingDir, outDir, beforeSwap) {
11722
12036
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
11723
- const hadPrevious = fs15__namespace.existsSync(outDir);
12037
+ const hadPrevious = fs16__namespace.existsSync(outDir);
11724
12038
  if (hadPrevious) beforeSwap?.();
11725
12039
  let movedAside = false;
11726
12040
  if (hadPrevious) {
11727
12041
  try {
11728
- fs15__namespace.renameSync(outDir, backupDir);
12042
+ fs16__namespace.renameSync(outDir, backupDir);
11729
12043
  movedAside = true;
11730
12044
  } catch (err) {
11731
12045
  if (!isLockError(err)) throw err;
11732
- fs15__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
12046
+ fs16__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
11733
12047
  process.stderr.write(
11734
12048
  `\u26A0 ${outDir} could not be moved aside (${err.message}), so it was replaced in place. Close anything holding the old snapshot open to avoid this next time.
11735
12049
  `
@@ -11738,26 +12052,26 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11738
12052
  }
11739
12053
  try {
11740
12054
  try {
11741
- fs15__namespace.renameSync(stagingDir, outDir);
12055
+ fs16__namespace.renameSync(stagingDir, outDir);
11742
12056
  } catch (err) {
11743
12057
  if (err.code !== "EXDEV") throw err;
11744
12058
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
11745
12059
  try {
11746
- fs15__namespace.cpSync(stagingDir, partialDir, { recursive: true });
11747
- fs15__namespace.renameSync(partialDir, outDir);
11748
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12060
+ fs16__namespace.cpSync(stagingDir, partialDir, { recursive: true });
12061
+ fs16__namespace.renameSync(partialDir, outDir);
12062
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
11749
12063
  } catch (copyErr) {
11750
12064
  try {
11751
- fs15__namespace.rmSync(partialDir, { recursive: true, force: true });
12065
+ fs16__namespace.rmSync(partialDir, { recursive: true, force: true });
11752
12066
  } catch {
11753
12067
  }
11754
12068
  throw copyErr;
11755
12069
  }
11756
12070
  }
11757
12071
  } catch (err) {
11758
- if (hadPrevious && movedAside && fs15__namespace.existsSync(backupDir)) {
11759
- if (fs15__namespace.existsSync(outDir)) fs15__namespace.rmSync(outDir, { recursive: true, force: true });
11760
- fs15__namespace.renameSync(backupDir, outDir);
12072
+ if (hadPrevious && movedAside && fs16__namespace.existsSync(backupDir)) {
12073
+ if (fs16__namespace.existsSync(outDir)) fs16__namespace.rmSync(outDir, { recursive: true, force: true });
12074
+ fs16__namespace.renameSync(backupDir, outDir);
11761
12075
  } else if (hadPrevious && !movedAside) {
11762
12076
  process.stderr.write(
11763
12077
  `\u26A0 The previous snapshot at ${outDir} was removed and the new one could not be moved into place. It is complete at ${stagingDir}.
@@ -11768,7 +12082,7 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11768
12082
  }
11769
12083
  if (hadPrevious) {
11770
12084
  try {
11771
- fs15__namespace.rmSync(backupDir, { recursive: true, force: true });
12085
+ fs16__namespace.rmSync(backupDir, { recursive: true, force: true });
11772
12086
  } catch (err) {
11773
12087
  process.stderr.write(
11774
12088
  `\u26A0 The previous snapshot could not be removed from ${backupDir} (${err.message}). The new snapshot is in place; delete that directory by hand when convenient.
@@ -11926,7 +12240,7 @@ function generateSnapshot(configInput, options) {
11926
12240
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
11927
12241
  // output — but only at these exact paths, not at every directory that shares the name.
11928
12242
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
11929
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
12243
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
11930
12244
  ).filter((relative11) => relative11.length > 0 && !relative11.startsWith("..")),
11931
12245
  // A staged path can be absent from the working tree while its index blob exists. Discovery
11932
12246
  // lists the working tree, so those paths would never reach the scan at all.
@@ -11955,7 +12269,7 @@ function generateSnapshot(configInput, options) {
11955
12269
  let totalSizeBytes = 0;
11956
12270
  let largeFileCount = 0;
11957
12271
  for (const relativePath of candidateFiles) {
11958
- const absolutePath = path16__namespace.join(config.cwd, relativePath);
12272
+ const absolutePath = path17__namespace.join(config.cwd, relativePath);
11959
12273
  const fromIndex = stagedPaths.has(relativePath);
11960
12274
  let buffer;
11961
12275
  let sizeBytes;
@@ -11986,9 +12300,9 @@ function generateSnapshot(configInput, options) {
11986
12300
  } else {
11987
12301
  let stats;
11988
12302
  try {
11989
- stats = fs15__namespace.statSync(absolutePath);
12303
+ stats = fs16__namespace.statSync(absolutePath);
11990
12304
  if (!stats.isFile()) {
11991
- const nestedRepository = stats.isDirectory() && fs15__namespace.existsSync(path16__namespace.join(absolutePath, ".git"));
12305
+ const nestedRepository = stats.isDirectory() && fs16__namespace.existsSync(path17__namespace.join(absolutePath, ".git"));
11992
12306
  skipped.push(
11993
12307
  nestedRepository ? {
11994
12308
  path: relativePath,
@@ -12024,7 +12338,7 @@ function generateSnapshot(configInput, options) {
12024
12338
  continue;
12025
12339
  }
12026
12340
  try {
12027
- buffer = fs15__namespace.readFileSync(absolutePath);
12341
+ buffer = fs16__namespace.readFileSync(absolutePath);
12028
12342
  } catch (err) {
12029
12343
  const code = err.code;
12030
12344
  skipped.push({
@@ -12153,14 +12467,14 @@ function generateSnapshot(configInput, options) {
12153
12467
  (finding) => finding.path === void 0 || keep.has(finding.path)
12154
12468
  );
12155
12469
  retain(encodingNotes, (note) => keep.has(note.path));
12156
- retain(oversizeSummaryPaths, (path17) => keep.has(path17));
12157
- retain(previewSummaryPaths, (path17) => keep.has(path17));
12470
+ retain(oversizeSummaryPaths, (path18) => keep.has(path18));
12471
+ retain(previewSummaryPaths, (path18) => keep.has(path18));
12158
12472
  retain(fileWarnings, (warning) => keep.has(warning.path));
12159
- for (const path17 of [...monolithBodies.keys()]) {
12160
- if (!keep.has(path17)) monolithBodies.delete(path17);
12473
+ for (const path18 of [...monolithBodies.keys()]) {
12474
+ if (!keep.has(path18)) monolithBodies.delete(path18);
12161
12475
  }
12162
- for (const path17 of [...skippedSummaryImports.keys()]) {
12163
- if (!keep.has(path17)) skippedSummaryImports.delete(path17);
12476
+ for (const path18 of [...skippedSummaryImports.keys()]) {
12477
+ if (!keep.has(path18)) skippedSummaryImports.delete(path18);
12164
12478
  }
12165
12479
  }
12166
12480
  if (changedScope !== null) {
@@ -12299,6 +12613,8 @@ function generateSnapshot(configInput, options) {
12299
12613
  // omitted from `digest` when it is off so an existing snapshot does not start reporting
12300
12614
  // configuration drift.
12301
12615
  maxParts: config.maxParts ?? null,
12616
+ promptTask: config.promptTask,
12617
+ ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12302
12618
  discovery: config.discovery ?? "auto",
12303
12619
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12304
12620
  // describes the run has to name it.
@@ -12429,14 +12745,16 @@ function generateSnapshot(configInput, options) {
12429
12745
  if (auditText !== null) manifest.artifacts.audit = artifactRecord(auditText);
12430
12746
  const readmeText = artifacts.readme ? generateReadme(manifest, artifacts) : null;
12431
12747
  if (readmeText !== null) manifest.artifacts.readme = artifactRecord(readmeText);
12432
- const promptText = artifacts.prompt ? generatePrompt(
12433
- manifest,
12434
- artifacts,
12435
- config.attachmentSlots,
12436
- // Commit subjects are user input and reach an artifact, so they go through the same
12437
- // masking as every other name the run reproduces.
12438
- recentCommitSubjects(config.cwd).map((subject) => maskPathText(subject, config.secretRules))
12439
- ) : null;
12748
+ const promptText = artifacts.prompt ? generatePrompt(manifest, artifacts, {
12749
+ slots: config.attachmentSlots,
12750
+ task: config.promptTask,
12751
+ brief: maskOwnerBrief(config.brief, config.secretRules),
12752
+ history: recentCommits(config.cwd).map((commit) => ({
12753
+ subject: maskPathText(commit.subject, config.secretRules),
12754
+ body: maskPathText(commit.body, config.secretRules)
12755
+ })),
12756
+ overview: maskOverview(readProjectOverview(config.cwd), config.secretRules)
12757
+ }) : null;
12440
12758
  if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
12441
12759
  if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
12442
12760
  let monolithJson = null;
@@ -12512,12 +12830,12 @@ function generateSnapshot(configInput, options) {
12512
12830
  let releaseDeferred = false;
12513
12831
  try {
12514
12832
  ensureParentDirectory(outDir, "outDir");
12515
- fs15__namespace.mkdirSync(tmpDir, { recursive: true });
12833
+ fs16__namespace.mkdirSync(tmpDir, { recursive: true });
12516
12834
  cleanStaleRunDirs(tmpDir);
12517
12835
  const snapshotId = crypto2__namespace.randomUUID();
12518
12836
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
12519
- stagingDir = path16__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12520
- fs15__namespace.mkdirSync(stagingDir);
12837
+ stagingDir = path17__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12838
+ fs16__namespace.mkdirSync(stagingDir);
12521
12839
  writeOwnershipMarker(stagingDir, {
12522
12840
  generator: GENERATOR_NAME,
12523
12841
  version: GENERATOR_VERSION,
@@ -12527,30 +12845,30 @@ function generateSnapshot(configInput, options) {
12527
12845
  id: snapshotId,
12528
12846
  pid: process.pid
12529
12847
  });
12530
- const partsDir = path16__namespace.join(stagingDir, "parts");
12531
- const reportsDir = path16__namespace.join(stagingDir, "reports");
12532
- if (artifacts.parts) fs15__namespace.mkdirSync(partsDir, { recursive: true });
12848
+ const partsDir = path17__namespace.join(stagingDir, "parts");
12849
+ const reportsDir = path17__namespace.join(stagingDir, "reports");
12850
+ if (artifacts.parts) fs16__namespace.mkdirSync(partsDir, { recursive: true });
12533
12851
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || config.sarif === true) {
12534
- fs15__namespace.mkdirSync(reportsDir, { recursive: true });
12852
+ fs16__namespace.mkdirSync(reportsDir, { recursive: true });
12535
12853
  }
12536
12854
  const writtenArtifacts = /* @__PURE__ */ new Map();
12537
12855
  const writeArtifact = (targetDir, relativeEntry, data) => {
12538
- const full = path16__namespace.join(targetDir, ...relativeEntry.split("/"));
12539
- fs15__namespace.writeFileSync(full, data, "utf8");
12540
- const stats = fs15__namespace.statSync(full);
12856
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12857
+ fs16__namespace.writeFileSync(full, data, "utf8");
12858
+ const stats = fs16__namespace.statSync(full);
12541
12859
  writtenArtifacts.set(relativeEntry, {
12542
12860
  digest: { path: relativeEntry, bytes: stats.size, sha256: sha256Hex2(data) },
12543
12861
  mtimeMs: stats.mtimeMs
12544
12862
  });
12545
12863
  };
12546
12864
  const recordArtifact = (targetDir, relativeEntry) => {
12547
- const full = path16__namespace.join(targetDir, ...relativeEntry.split("/"));
12548
- const stats = fs15__namespace.statSync(full);
12865
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12866
+ const stats = fs16__namespace.statSync(full);
12549
12867
  writtenArtifacts.set(relativeEntry, {
12550
12868
  digest: {
12551
12869
  path: relativeEntry,
12552
12870
  bytes: stats.size,
12553
- sha256: sha256Hex2(fs15__namespace.readFileSync(full))
12871
+ sha256: sha256Hex2(fs16__namespace.readFileSync(full))
12554
12872
  },
12555
12873
  mtimeMs: stats.mtimeMs
12556
12874
  });
@@ -12598,7 +12916,7 @@ function generateSnapshot(configInput, options) {
12598
12916
  const shipHookState = () => {
12599
12917
  if (!markerBelongsTo(outDir, snapshotId)) return;
12600
12918
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
12601
- writeManifestAtomically(path16__namespace.join(outDir, "manifest.json"), manifest);
12919
+ writeManifestAtomically(path17__namespace.join(outDir, "manifest.json"), manifest);
12602
12920
  recordArtifact(outDir, "manifest.json");
12603
12921
  }
12604
12922
  writeOwnershipMarker(
@@ -12641,7 +12959,7 @@ function generateSnapshot(configInput, options) {
12641
12959
  } catch (err) {
12642
12960
  if (stagingDir !== null) {
12643
12961
  try {
12644
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12962
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
12645
12963
  } catch {
12646
12964
  }
12647
12965
  }