codebase-snapshot 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.0";
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,14 @@ 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 recentCommits(cwd, limit = 10) {
4375
4447
  try {
4376
4448
  const stdout = childProcess__namespace.execFileSync(
4377
4449
  "git",
4378
- ["log", "-n", String(limit), "--pretty=%s", "--no-color"],
4450
+ // \x1f between fields and \x1e between records: neither can appear in a commit message, so
4451
+ // the parse cannot be confused by a message that contains a newline or a dash.
4452
+ ["log", "-n", String(limit), "--pretty=format:%s%x1f%b%x1e", "--no-color"],
4379
4453
  {
4380
4454
  cwd,
4381
4455
  stdio: ["ignore", "pipe", "ignore"],
@@ -4383,7 +4457,16 @@ function recentCommitSubjects(cwd, limit = 10) {
4383
4457
  maxBuffer: GIT_OUTPUT_LIMIT
4384
4458
  }
4385
4459
  );
4386
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
4460
+ return stdout.split("").map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
4461
+ const separator = record.indexOf("");
4462
+ const subject = separator === -1 ? record : record.slice(0, separator);
4463
+ const rawBody = separator === -1 ? "" : record.slice(separator + 1);
4464
+ const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ");
4465
+ return {
4466
+ subject: subject.trim(),
4467
+ body: body.length > COMMIT_BODY_LIMIT ? body.slice(0, COMMIT_BODY_LIMIT - 1) + "\u2026" : body
4468
+ };
4469
+ }).filter((commit) => commit.subject.length > 0);
4387
4470
  } catch {
4388
4471
  return [];
4389
4472
  }
@@ -4407,7 +4490,7 @@ function listIgnoredPaths(cwd) {
4407
4490
  }
4408
4491
  function hasSnapshotMarker(target) {
4409
4492
  try {
4410
- return fs15__namespace.statSync(target).isDirectory() && fs15__namespace.existsSync(path16__namespace.join(target, ".codebase-snapshot"));
4493
+ return fs16__namespace.statSync(target).isDirectory() && fs16__namespace.existsSync(path17__namespace.join(target, ".codebase-snapshot"));
4411
4494
  } catch {
4412
4495
  return false;
4413
4496
  }
@@ -4416,7 +4499,7 @@ var IGNORABLE_DIRECTORY_ENTRIES = /* @__PURE__ */ new Set([".DS_Store"]);
4416
4499
  function isToolOwnedDirectory2(dir) {
4417
4500
  let raw;
4418
4501
  try {
4419
- raw = fs15__namespace.readFileSync(path16__namespace.join(dir, ".codebase-snapshot"), "utf8");
4502
+ raw = fs16__namespace.readFileSync(path17__namespace.join(dir, ".codebase-snapshot"), "utf8");
4420
4503
  } catch {
4421
4504
  return false;
4422
4505
  }
@@ -4443,7 +4526,7 @@ function isToolOwnedDirectory2(dir) {
4443
4526
  }
4444
4527
  let entries;
4445
4528
  try {
4446
- entries = fs15__namespace.readdirSync(dir);
4529
+ entries = fs16__namespace.readdirSync(dir);
4447
4530
  } catch {
4448
4531
  return false;
4449
4532
  }
@@ -4460,7 +4543,7 @@ function makeToolOwnedDecider(cwd, toolOwnedPaths) {
4460
4543
  const prefix = parts.slice(0, depth).join("/");
4461
4544
  let hasMarker = markers.get(prefix);
4462
4545
  if (hasMarker === void 0) {
4463
- hasMarker = isToolOwnedDirectory2(path16__namespace.join(cwd, prefix));
4546
+ hasMarker = isToolOwnedDirectory2(path17__namespace.join(cwd, prefix));
4464
4547
  markers.set(prefix, hasMarker);
4465
4548
  }
4466
4549
  if (hasMarker) return true;
@@ -4475,7 +4558,7 @@ function makeLinkProbe() {
4475
4558
  let known = cache.get(absolutePath);
4476
4559
  if (known === void 0) {
4477
4560
  try {
4478
- known = fs15__namespace.lstatSync(absolutePath).isSymbolicLink();
4561
+ known = fs16__namespace.lstatSync(absolutePath).isSymbolicLink();
4479
4562
  } catch {
4480
4563
  known = false;
4481
4564
  }
@@ -4488,7 +4571,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4488
4571
  const isLink = makeLinkProbe();
4489
4572
  let rootReal = cwd;
4490
4573
  try {
4491
- rootReal = fs15__namespace.realpathSync(cwd);
4574
+ rootReal = fs16__namespace.realpathSync(cwd);
4492
4575
  } catch {
4493
4576
  }
4494
4577
  const reported = /* @__PURE__ */ new Set();
@@ -4503,7 +4586,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4503
4586
  let linkedPath = null;
4504
4587
  for (let depth = 1; depth <= parts.length; depth += 1) {
4505
4588
  const prefix = parts.slice(0, depth).join("/");
4506
- if (isLink(path16__namespace.join(cwd, prefix))) {
4589
+ if (isLink(path17__namespace.join(cwd, prefix))) {
4507
4590
  linkedPath = prefix;
4508
4591
  break;
4509
4592
  }
@@ -4512,11 +4595,11 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4512
4595
  kept.push(candidate);
4513
4596
  continue;
4514
4597
  }
4515
- const absolute = path16__namespace.join(cwd, linkedPath);
4598
+ const absolute = path17__namespace.join(cwd, linkedPath);
4516
4599
  const rawTarget = readLinkTarget(absolute, absolute);
4517
4600
  let targetReal = null;
4518
4601
  try {
4519
- targetReal = fs15__namespace.realpathSync(absolute);
4602
+ targetReal = fs16__namespace.realpathSync(absolute);
4520
4603
  } catch {
4521
4604
  targetReal = null;
4522
4605
  }
@@ -4534,7 +4617,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
4534
4617
  }
4535
4618
  let stats = null;
4536
4619
  try {
4537
- stats = fs15__namespace.statSync(absolute);
4620
+ stats = fs16__namespace.statSync(absolute);
4538
4621
  } catch {
4539
4622
  stats = null;
4540
4623
  }
@@ -4622,7 +4705,7 @@ function collectFiles(cwd, options = {}) {
4622
4705
  "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
4706
  );
4624
4707
  }
4625
- if (fs15__namespace.existsSync(path16__namespace.join(cwd, ".git"))) {
4708
+ if (fs16__namespace.existsSync(path17__namespace.join(cwd, ".git"))) {
4626
4709
  throw new Error(
4627
4710
  "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
4711
  );
@@ -4690,7 +4773,7 @@ function collectFiles(cwd, options = {}) {
4690
4773
  }
4691
4774
  function rootRealFor(root) {
4692
4775
  try {
4693
- return fs15__namespace.realpathSync(root);
4776
+ return fs16__namespace.realpathSync(root);
4694
4777
  } catch {
4695
4778
  return root;
4696
4779
  }
@@ -4699,18 +4782,18 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4699
4782
  const results = { files: [], skipped: [] };
4700
4783
  const stack = [];
4701
4784
  const toolDirNames = toolDirNamesFor(reservedPaths);
4702
- const relativeToBase = (target) => path16__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
4785
+ const relativeToBase = (target) => path17__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
4703
4786
  const enter = (current, layers) => {
4704
4787
  if (visited.has(current)) return false;
4705
4788
  visited.add(current);
4706
4789
  const localRules = readGitignoreRules(current);
4707
4790
  const gitignoreLayers = localRules.length === 0 ? layers : [
4708
4791
  ...layers,
4709
- { prefix: path16__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
4792
+ { prefix: path17__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
4710
4793
  ];
4711
4794
  let entries;
4712
4795
  try {
4713
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
4796
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
4714
4797
  } catch {
4715
4798
  results.skipped.push({
4716
4799
  path: relativeToBase(current),
@@ -4732,8 +4815,8 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4732
4815
  }
4733
4816
  const entry = frame.entries[frame.index];
4734
4817
  frame.index += 1;
4735
- const fullPath = path16__namespace.join(frame.dir, entry.name);
4736
- const relPath = path16__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
4818
+ const fullPath = path17__namespace.join(frame.dir, entry.name);
4819
+ const relPath = path17__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
4737
4820
  if (reservedPaths.has(relPath)) continue;
4738
4821
  if (entry.isDirectory() && DEFAULT_IGNORED_DIRS.includes(entry.name)) {
4739
4822
  results.skipped.push({
@@ -4766,14 +4849,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4766
4849
  if (entry.isSymbolicLink()) {
4767
4850
  let targetReal;
4768
4851
  try {
4769
- targetReal = fs15__namespace.realpathSync(fullPath);
4852
+ targetReal = fs16__namespace.realpathSync(fullPath);
4770
4853
  } catch {
4771
4854
  results.skipped.push(brokenLinkRecord(fullPath, relPath, rootReal));
4772
4855
  continue;
4773
4856
  }
4774
4857
  let stats;
4775
4858
  try {
4776
- stats = fs15__namespace.statSync(fullPath);
4859
+ stats = fs16__namespace.statSync(fullPath);
4777
4860
  } catch {
4778
4861
  results.skipped.push({ path: relPath, reason: "read-error", detail: "unreadable symlink" });
4779
4862
  continue;
@@ -4803,7 +4886,7 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
4803
4886
  });
4804
4887
  continue;
4805
4888
  }
4806
- const targetRelative = path16__namespace.relative(rootReal, targetReal).split(path16__namespace.sep).join("/");
4889
+ const targetRelative = path17__namespace.relative(rootReal, targetReal).split(path17__namespace.sep).join("/");
4807
4890
  if (isSensitivePath(targetRelative)) {
4808
4891
  results.skipped.push({
4809
4892
  path: relPath,
@@ -4916,6 +4999,8 @@ function normalizeResolvedConfig(config) {
4916
4999
  // is re-validated because the number reaches a rendered artifact.
4917
5000
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
4918
5001
  maxParts: resolveMaxParts(config.maxParts),
5002
+ promptTask: resolvePromptTask(config.promptTask),
5003
+ ...config.brief === void 0 ? {} : { brief: config.brief },
4919
5004
  includeMonolith: artifacts.monolith,
4920
5005
  secretRules: compileSecretRules(config.secretRules),
4921
5006
  artifacts,
@@ -4986,6 +5071,7 @@ var CONFIG_KEY_NAMES = [
4986
5071
  "artifacts",
4987
5072
  "attachmentSlots",
4988
5073
  "branch",
5074
+ "brief",
4989
5075
  "budgets",
4990
5076
  "changedSince",
4991
5077
  "cwd",
@@ -5007,6 +5093,7 @@ var CONFIG_KEY_NAMES = [
5007
5093
  "outDir",
5008
5094
  "preset",
5009
5095
  "previewHeadLines",
5096
+ "promptTask",
5010
5097
  "staged",
5011
5098
  "previewTailLines",
5012
5099
  "secretRules",
@@ -5057,10 +5144,10 @@ function readConfigExport(exported, file) {
5057
5144
  var lastModuleConfig = null;
5058
5145
  function moduleConfigKey(fullPath) {
5059
5146
  try {
5060
- return crypto2.createHash("sha256").update(fs15__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
5147
+ return crypto2.createHash("sha256").update(fs16__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
5061
5148
  } catch {
5062
5149
  try {
5063
- const stats = fs15__namespace.statSync(fullPath);
5150
+ const stats = fs16__namespace.statSync(fullPath);
5064
5151
  return `stat-${stats.mtimeMs}-${stats.size}`;
5065
5152
  } catch {
5066
5153
  return "unreadable";
@@ -5086,7 +5173,7 @@ async function importConfigModule(fullPath) {
5086
5173
  function attachConfigDir(config, filePath) {
5087
5174
  if (typeof config === "object" && config !== null) {
5088
5175
  Object.defineProperty(config, CONFIG_DIR_SYMBOL, {
5089
- value: path16__namespace.dirname(filePath),
5176
+ value: path17__namespace.dirname(filePath),
5090
5177
  enumerable: false,
5091
5178
  configurable: true
5092
5179
  });
@@ -5098,12 +5185,12 @@ async function loadConfigFileDetailed(cwd, options = {}) {
5098
5185
  const errors = [];
5099
5186
  const configDirectories = [];
5100
5187
  for (const filename of CONFIG_FILENAMES) {
5101
- const fullPath = path16__namespace.join(cwd, filename);
5188
+ const fullPath = path17__namespace.join(cwd, filename);
5102
5189
  let candidateStats = null;
5103
5190
  try {
5104
- candidateStats = fs15__namespace.statSync(fullPath);
5191
+ candidateStats = fs16__namespace.statSync(fullPath);
5105
5192
  } catch {
5106
- if (!fs15__namespace.existsSync(fullPath)) continue;
5193
+ if (!fs16__namespace.existsSync(fullPath)) continue;
5107
5194
  }
5108
5195
  if (candidateStats !== null && !candidateStats.isFile()) {
5109
5196
  configDirectories.push(fullPath);
@@ -5111,7 +5198,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
5111
5198
  }
5112
5199
  if (filename.endsWith(".json") || filename === ".snapshotrc") {
5113
5200
  try {
5114
- const config = parseJsonish(fs15__namespace.readFileSync(fullPath, "utf8"), fullPath);
5201
+ const config = parseJsonish(fs16__namespace.readFileSync(fullPath, "utf8"), fullPath);
5115
5202
  if (config === null || typeof config !== "object" || Array.isArray(config)) {
5116
5203
  throw new Error(
5117
5204
  `${fullPath} does not hold a configuration object (received ${describeValue2(config)}).`
@@ -5151,10 +5238,10 @@ async function loadConfigFileDetailed(cwd, options = {}) {
5151
5238
  continue;
5152
5239
  }
5153
5240
  }
5154
- const pkgJsonPath = path16__namespace.join(cwd, "package.json");
5155
- if (fs15__namespace.existsSync(pkgJsonPath)) {
5241
+ const pkgJsonPath = path17__namespace.join(cwd, "package.json");
5242
+ if (fs16__namespace.existsSync(pkgJsonPath)) {
5156
5243
  try {
5157
- const parsed = parseJsonish(fs15__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
5244
+ const parsed = parseJsonish(fs16__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
5158
5245
  const snapshotKey = parsed.snapshot;
5159
5246
  if (snapshotKey && typeof snapshotKey === "object" && !Array.isArray(snapshotKey)) {
5160
5247
  assertKnownConfigKeys(
@@ -5298,6 +5385,38 @@ function resolveMaxParts(value) {
5298
5385
  }
5299
5386
  return value;
5300
5387
  }
5388
+ function resolvePromptTask(value) {
5389
+ if (value === void 0 || value === null) return "audit";
5390
+ if (value === "audit" || value === "review" || value === "explain") return value;
5391
+ throw new Error(
5392
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
5393
+ );
5394
+ }
5395
+ function readConfiguredBrief(cwd, value) {
5396
+ if (value === void 0 || value === null) return void 0;
5397
+ if (typeof value !== "string" || value.trim().length === 0) {
5398
+ throw new Error(
5399
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
5400
+ );
5401
+ }
5402
+ const filePath = path17__namespace.resolve(cwd, value);
5403
+ let text2;
5404
+ try {
5405
+ if (!fs16__namespace.statSync(filePath).isFile()) throw new Error("not a file");
5406
+ text2 = fs16__namespace.readFileSync(filePath, "utf8");
5407
+ } catch {
5408
+ throw new Error(
5409
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
5410
+ );
5411
+ }
5412
+ const parsed = parseOwnerBrief(value, text2);
5413
+ if (parsed.problems.length > 0) {
5414
+ throw new Error(
5415
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
5416
+ );
5417
+ }
5418
+ return parsed.brief;
5419
+ }
5301
5420
  function strictPositiveInteger(value, fallback, label) {
5302
5421
  if (value === void 0) return fallback;
5303
5422
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -5390,9 +5509,9 @@ function resolveKindRules(value) {
5390
5509
  function outputExcludePatterns(cwd, outDir, tmpDir) {
5391
5510
  const patterns = [];
5392
5511
  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)) {
5512
+ const absolute = path17__namespace.resolve(cwd, dir);
5513
+ const relative11 = path17__namespace.relative(cwd, absolute);
5514
+ if (!relative11 || relative11 === ".." || relative11.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative11)) {
5396
5515
  continue;
5397
5516
  }
5398
5517
  patterns.push(`${relative11.replace(/\\/g, "/")}/**`);
@@ -5525,11 +5644,11 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
5525
5644
  );
5526
5645
  }
5527
5646
  const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
5528
- const resolved = path16__namespace.resolve(candidate);
5529
- if (!fs15__namespace.existsSync(resolved)) {
5647
+ const resolved = path17__namespace.resolve(candidate);
5648
+ if (!fs16__namespace.existsSync(resolved)) {
5530
5649
  throw new Error(`Working directory does not exist: ${resolved}`);
5531
5650
  }
5532
- if (!fs15__namespace.statSync(resolved).isDirectory()) {
5651
+ if (!fs16__namespace.statSync(resolved).isDirectory()) {
5533
5652
  throw new Error(`Working directory is not a directory: ${resolved}`);
5534
5653
  }
5535
5654
  return resolved;
@@ -5657,6 +5776,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
5657
5776
  configuredSensitiveFiles,
5658
5777
  "`includeSensitiveFiles`"
5659
5778
  );
5779
+ const configuredBrief = readConfiguredBrief(
5780
+ cwd,
5781
+ cliOptions?.brief ?? userConfig?.brief
5782
+ );
5660
5783
  const presetExclude = [
5661
5784
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
5662
5785
  ];
@@ -5680,6 +5803,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
5680
5803
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
5681
5804
  ),
5682
5805
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
5806
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
5807
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
5683
5808
  ...changedSince === void 0 ? {} : { changedSince },
5684
5809
  ...staged ? { staged } : {},
5685
5810
  ...withDependents ? { withDependents } : {},
@@ -5765,6 +5890,12 @@ function configDigest(config) {
5765
5890
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
5766
5891
  // material would change the digest of every snapshot taken before the setting existed.
5767
5892
  ...config.maxParts === null ? {} : { maxParts: config.maxParts },
5893
+ // The default value is omitted for the same reason: a snapshot taken before the setting
5894
+ // existed kept the audit job, so it must keep the digest it was written with.
5895
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
5896
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
5897
+ // reader to do, so a changed brief is drift exactly like a changed budget.
5898
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
5768
5899
  artifacts: config.artifacts,
5769
5900
  include: config.include,
5770
5901
  excludePatterns: config.excludePatterns,
@@ -6736,9 +6867,15 @@ var UNLIMITED_SLOTS = 0;
6736
6867
  var ENTRY_POINT = /(^|\/)(index|cli|main|bin|server|app|mod)\.[cm]?[jt]sx?$/;
6737
6868
  var TEST_PATH = /(^|\/)(tests?|__tests__)\//;
6738
6869
  var TEST_FILE = /\.(test|spec)\.[^.]+$/;
6739
- function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMENT_SLOTS, history = []) {
6870
+ function generatePrompt(manifest, artifacts, context = {}) {
6871
+ const slots = context.slots ?? DEFAULT_ATTACHMENT_SLOTS;
6872
+ const task = context.task ?? "audit";
6873
+ const history = context.history ?? [];
6874
+ const overview = context.overview ?? { releases: [] };
6875
+ const brief = context.brief;
6740
6876
  const wrote = (name) => artifacts?.[name] !== false;
6741
6877
  const code = (value) => inlineCode(escapeControls(value));
6878
+ const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
6742
6879
  const lines = [
6743
6880
  "# PROMPT.md",
6744
6881
  "",
@@ -6754,30 +6891,22 @@ function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMEN
6754
6891
  "You are working on a codebase you cannot clone, run or grep. Everything you know about it comes",
6755
6892
  "from the snapshot that follows this instruction. Where these notes and the snapshot disagree,",
6756
6893
  "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
6894
  ""
6771
6895
  ];
6896
+ if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
6897
+ lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
6898
+ lines.push(...stakesSection(brief, code));
6772
6899
  lines.push(...haveSection(wrote), "");
6773
- lines.push(...systemSection(manifest, code), "");
6774
- lines.push(...historySection(history), "");
6775
- lines.push(...barSection(), "");
6900
+ lines.push(...whatThisIsSection(overview), "");
6901
+ lines.push(...systemSection(manifest, code, brief), "");
6902
+ lines.push(...historySection(history, brief, code), "");
6903
+ lines.push(...barSection(brief, code), "");
6776
6904
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
6777
6905
  lines.push(...answerSection(), "");
6778
- lines.push(...calibrationSection(), "");
6906
+ lines.push(...calibrationSection(brief, code), "");
6907
+ lines.push(...ownerNotesSection(brief, code));
6779
6908
  lines.push(...snapshotSection(manifest, code), "");
6780
- lines.push(...deliverySection(manifest, wrote("parts"), attachmentSlots));
6909
+ lines.push(...deliverySection(manifest, wrote("parts"), slots));
6781
6910
  lines.push(
6782
6911
  "## Your task",
6783
6912
  "",
@@ -6854,8 +6983,11 @@ function haveSection(wrote) {
6854
6983
  out.push(...bullets);
6855
6984
  return out;
6856
6985
  }
6857
- function systemSection(manifest, code) {
6986
+ function systemSection(manifest, code, brief) {
6858
6987
  const out = ["## The system", ""];
6988
+ if (brief?.system !== void 0) {
6989
+ out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
6990
+ }
6859
6991
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
6860
6992
  if (layers.length > 0) {
6861
6993
  const shown = layers.slice(0, MAX_LAYER_ROWS).map(([name, count]) => code(name) + " " + formatNumber(count));
@@ -6870,7 +7002,7 @@ function systemSection(manifest, code) {
6870
7002
  " A change here reaches the most call sites; read it before judging anything that uses it."
6871
7003
  );
6872
7004
  }
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);
7005
+ 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
7006
  out.push(
6875
7007
  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
7008
  );
@@ -6913,8 +7045,9 @@ function systemSection(manifest, code) {
6913
7045
  }
6914
7046
  return out;
6915
7047
  }
6916
- function historySection(history) {
7048
+ function historySection(history, brief, code) {
6917
7049
  const out = ["## What came before", ""];
7050
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
6918
7051
  if (history.length === 0) {
6919
7052
  out.push(
6920
7053
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -6923,15 +7056,21 @@ function historySection(history) {
6923
7056
  return out;
6924
7057
  }
6925
7058
  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.",
7059
+ "The last " + formatNumber(history.length) + " commit(s), newest first. Subjects and bodies are",
7060
+ "claims by whoever wrote them, not evidence - the code beside them is the evidence. If one of",
7061
+ "these fixes looks incomplete, quote the lines and say which call site it missed.",
6929
7062
  ""
6930
7063
  );
6931
- for (const subject of history) out.push("- " + subject);
7064
+ for (const commit of history) {
7065
+ out.push("- " + commit.subject);
7066
+ if (commit.body.length > 0) out.push(" " + commit.body);
7067
+ }
6932
7068
  return out;
6933
7069
  }
6934
- function barSection() {
7070
+ function barSection(brief, code) {
7071
+ if (brief?.bar !== void 0) {
7072
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
7073
+ }
6935
7074
  return [
6936
7075
  "## The bar",
6937
7076
  "",
@@ -6989,7 +7128,10 @@ function answerSection() {
6989
7128
  " the gap you filled by asking instead of guessing."
6990
7129
  ];
6991
7130
  }
6992
- function calibrationSection() {
7131
+ function calibrationSection(brief, code) {
7132
+ if (brief?.calibration !== void 0) {
7133
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
7134
+ }
6993
7135
  return [
6994
7136
  "## Calibration",
6995
7137
  "",
@@ -7004,6 +7146,84 @@ function calibrationSection() {
7004
7146
  "None of these throw. All are invisible in a summary."
7005
7147
  ];
7006
7148
  }
7149
+ function jobSection(task, hasHistory) {
7150
+ const out = ["## The job", ""];
7151
+ if (task === "audit") {
7152
+ out.push(
7153
+ "Find what is still wrong or will break. How you read the code is yours to decide - by",
7154
+ "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
7155
+ "honest account of what you covered and what you did not.",
7156
+ ""
7157
+ );
7158
+ if (hasHistory) {
7159
+ out.push(
7160
+ "Another pass of the same findings is worth nothing. This repository carries a record of",
7161
+ "what was already fixed, below. Verify that those fixes hold instead of rediscovering them,",
7162
+ "and treat a variant of one at a different call site as a new finding."
7163
+ );
7164
+ } else {
7165
+ out.push(
7166
+ "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
7167
+ "so you cannot tell what has already been tried. Do not assume this is the first attempt."
7168
+ );
7169
+ }
7170
+ out.push(
7171
+ "",
7172
+ "If the task at the end asks for something narrower - explain a file, review a change, answer",
7173
+ "a question - that task wins. The standard and the coverage duty below still apply to it."
7174
+ );
7175
+ } else if (task === "review") {
7176
+ out.push(
7177
+ "Review the change or the area named in the task against this snapshot. Report what breaks,",
7178
+ "what the change claims but does not do, and what a reader would believe that the code does",
7179
+ "not support. Restating the diff is not a review; the standard and the coverage duty below",
7180
+ "still apply."
7181
+ );
7182
+ } else {
7183
+ out.push(
7184
+ "Explain how the part of the system named in the task works: the data flow, the boundaries",
7185
+ "and the invariants it depends on. Cite the lines. If the snapshot does not contain what you",
7186
+ "need, say which file you need rather than reconstructing it from the shape of the names."
7187
+ );
7188
+ }
7189
+ return out;
7190
+ }
7191
+ function stakesSection(brief, code) {
7192
+ if (brief?.stakes === void 0) return [];
7193
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
7194
+ }
7195
+ function whatThisIsSection(overview) {
7196
+ const body = [];
7197
+ if (overview.description !== void 0) {
7198
+ body.push("- Declared in `package.json`: " + overview.description);
7199
+ }
7200
+ if (overview.summary !== void 0) {
7201
+ body.push("- From the `README.md` first paragraph: " + overview.summary);
7202
+ }
7203
+ if (overview.releases.length > 0) {
7204
+ body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
7205
+ }
7206
+ if (body.length === 0) return [];
7207
+ return [
7208
+ "## What this is",
7209
+ "",
7210
+ ...body,
7211
+ "",
7212
+ "Those are the project's own claims, not evidence about the code.",
7213
+ ""
7214
+ ];
7215
+ }
7216
+ function ownerNotesSection(brief, code) {
7217
+ if (brief === void 0 || brief.notes.length === 0) return [];
7218
+ const out = ["## Owner notes", ""];
7219
+ for (const note of brief.notes) {
7220
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
7221
+ }
7222
+ return out;
7223
+ }
7224
+ function ownerBlock(text2, path18, code) {
7225
+ return ["> Written by the project owner in " + code(path18) + ", not generated.", "", text2];
7226
+ }
7007
7227
  function snapshotSection(manifest, code) {
7008
7228
  const out = ["## This snapshot", ""];
7009
7229
  out.push("- Fingerprint: " + code(manifest.fingerprint) + " - quote it verbatim in your answer.");
@@ -7359,7 +7579,7 @@ function resolveChangedScope(cwd, request) {
7359
7579
  const descriptions = [];
7360
7580
  if (request.changedSince !== void 0) {
7361
7581
  assertUsableRef(request.changedSince);
7362
- for (const path17 of gitPaths(cwd, [
7582
+ for (const path18 of gitPaths(cwd, [
7363
7583
  "diff",
7364
7584
  "--name-only",
7365
7585
  "-z",
@@ -7367,9 +7587,9 @@ function resolveChangedScope(cwd, request) {
7367
7587
  `${request.changedSince}...HEAD`,
7368
7588
  "--"
7369
7589
  ])) {
7370
- paths.add(path17);
7590
+ paths.add(path18);
7371
7591
  }
7372
- for (const path17 of gitPaths(cwd, [
7592
+ for (const path18 of gitPaths(cwd, [
7373
7593
  "diff",
7374
7594
  "--name-only",
7375
7595
  "-z",
@@ -7377,15 +7597,15 @@ function resolveChangedScope(cwd, request) {
7377
7597
  "HEAD",
7378
7598
  "--"
7379
7599
  ])) {
7380
- paths.add(path17);
7600
+ paths.add(path18);
7381
7601
  }
7382
- for (const path17 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
7383
- paths.add(path17);
7602
+ for (const path18 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
7603
+ paths.add(path18);
7384
7604
  }
7385
7605
  descriptions.push(`changed since ${request.changedSince}`);
7386
7606
  }
7387
7607
  if (request.staged === true) {
7388
- for (const path17 of gitPaths(cwd, [
7608
+ for (const path18 of gitPaths(cwd, [
7389
7609
  "diff",
7390
7610
  "--cached",
7391
7611
  "--name-only",
@@ -7393,10 +7613,10 @@ function resolveChangedScope(cwd, request) {
7393
7613
  "--relative",
7394
7614
  "--"
7395
7615
  ])) {
7396
- paths.add(path17);
7397
- stagedPaths.add(path17);
7616
+ paths.add(path18);
7617
+ stagedPaths.add(path18);
7398
7618
  }
7399
- for (const path17 of gitPaths(cwd, [
7619
+ for (const path18 of gitPaths(cwd, [
7400
7620
  "diff",
7401
7621
  "--cached",
7402
7622
  "--name-only",
@@ -7405,7 +7625,7 @@ function resolveChangedScope(cwd, request) {
7405
7625
  "--diff-filter=D",
7406
7626
  "--"
7407
7627
  ])) {
7408
- deletedPaths.add(path17);
7628
+ deletedPaths.add(path18);
7409
7629
  }
7410
7630
  descriptions.push("staged");
7411
7631
  }
@@ -7443,10 +7663,10 @@ var PYTHON_SUFFIXES = [".py", ".pyi", "/__init__.py", "/__init__.pyi"];
7443
7663
  var CASE_INSENSITIVE_FILESYSTEM = process.platform === "win32" || process.platform === "darwin";
7444
7664
  var TSCONFIG_CACHE = /* @__PURE__ */ new Map();
7445
7665
  function tsconfigPathsFor(cwd) {
7446
- const configPath = path16__namespace.join(cwd, "tsconfig.json");
7666
+ const configPath = path17__namespace.join(cwd, "tsconfig.json");
7447
7667
  let stats;
7448
7668
  try {
7449
- stats = fs15__namespace.statSync(configPath);
7669
+ stats = fs16__namespace.statSync(configPath);
7450
7670
  } catch (err) {
7451
7671
  if (err.code === "ENOENT") return null;
7452
7672
  return null;
@@ -7480,8 +7700,8 @@ function tsconfigPathsFor(cwd) {
7480
7700
  return value;
7481
7701
  }
7482
7702
  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;
7703
+ const relative11 = path17__namespace.relative(cwd, target).replace(/\\/g, "/");
7704
+ return relative11.length === 0 || !relative11.startsWith("..") && !path17__namespace.isAbsolute(relative11) ? relative11 : null;
7485
7705
  }
7486
7706
  function rememberFirst(map, key, value) {
7487
7707
  if (!map.has(key)) map.set(key, value);
@@ -7496,15 +7716,15 @@ function buildImportResolver(files, options = {}) {
7496
7716
  if (CASE_INSENSITIVE_FILESYSTEM) {
7497
7717
  rememberFirst(byPathFolded, relativePath.toLowerCase(), relativePath);
7498
7718
  }
7499
- const extension = path16__namespace.posix.extname(relativePath);
7719
+ const extension = path17__namespace.posix.extname(relativePath);
7500
7720
  if (!SOURCE_EXTENSIONS.has(extension)) return;
7501
7721
  const stem = relativePath.slice(0, -extension.length);
7502
7722
  rememberFirst(byStem, stem, relativePath);
7503
7723
  if (CASE_INSENSITIVE_FILESYSTEM) {
7504
7724
  rememberFirst(byStemFolded, stem.toLowerCase(), relativePath);
7505
7725
  }
7506
- if (path16__namespace.posix.basename(stem) === "index") {
7507
- const directory = path16__namespace.posix.dirname(stem);
7726
+ if (path17__namespace.posix.basename(stem) === "index") {
7727
+ const directory = path17__namespace.posix.dirname(stem);
7508
7728
  rememberFirst(byStem, directory, relativePath);
7509
7729
  if (CASE_INSENSITIVE_FILESYSTEM) {
7510
7730
  rememberFirst(byStemFolded, directory.toLowerCase(), relativePath);
@@ -7520,7 +7740,7 @@ function buildImportResolver(files, options = {}) {
7520
7740
  return { byPath, byPathFolded, byStem, byStemFolded, tsconfig: options.tsconfig ?? null };
7521
7741
  }
7522
7742
  function resolveSpecifier(fromFile, specifier, resolver) {
7523
- const extension = path16__namespace.posix.extname(fromFile).toLowerCase();
7743
+ const extension = path17__namespace.posix.extname(fromFile).toLowerCase();
7524
7744
  const exact = (key) => resolver.byPath.get(key) ?? (CASE_INSENSITIVE_FILESYSTEM ? resolver.byPathFolded.get(key.toLowerCase()) : void 0) ?? null;
7525
7745
  const firstOf = (candidates) => {
7526
7746
  for (const candidate of candidates) {
@@ -7543,34 +7763,34 @@ function resolveSpecifier(fromFile, specifier, resolver) {
7543
7763
  if (PYTHON_EXTENSIONS.has(extension) && specifier.startsWith(".")) {
7544
7764
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
7545
7765
  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;
7766
+ let base = path17__namespace.posix.dirname(fromFile);
7767
+ for (let up = 1; up < dots; up += 1) base = path17__namespace.posix.dirname(base);
7768
+ const joined2 = rest ? path17__namespace.posix.normalize(path17__namespace.posix.join(base, rest)) : base;
7549
7769
  return firstOf([joined2, ...PYTHON_SUFFIXES.map((suffix) => `${joined2}${suffix}`)]);
7550
7770
  }
7551
7771
  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)
7772
+ const joined2 = path17__namespace.posix.normalize(
7773
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7554
7774
  );
7555
7775
  return firstOf([`${joined2}.rb`, joined2]);
7556
7776
  }
7557
7777
  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)
7778
+ const joined2 = path17__namespace.posix.normalize(
7779
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7560
7780
  );
7561
7781
  return exact(joined2);
7562
7782
  }
7563
7783
  if (extension === ".dart" && !specifier.includes(":")) {
7564
- const joined2 = path16__namespace.posix.normalize(
7565
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
7784
+ const joined2 = path17__namespace.posix.normalize(
7785
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7566
7786
  );
7567
7787
  return firstOf([joined2, `${joined2}.dart`]);
7568
7788
  }
7569
7789
  if (!RELATIVE_SPECIFIER.test(specifier)) {
7570
7790
  return resolveTsconfigSpecifier(specifier, resolver, lookupPath);
7571
7791
  }
7572
- const joined = path16__namespace.posix.normalize(
7573
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
7792
+ const joined = path17__namespace.posix.normalize(
7793
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
7574
7794
  );
7575
7795
  return lookupPath(joined);
7576
7796
  }
@@ -7594,13 +7814,13 @@ function resolveTsconfigSpecifier(specifier, resolver, lookupPath) {
7594
7814
  if (captured === null) continue;
7595
7815
  for (const target of rule.targets) {
7596
7816
  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));
7817
+ const base = config.baseUrl === null ? substituted : path17__namespace.posix.join(config.baseUrl, substituted);
7818
+ const hit = lookupPath(path17__namespace.posix.normalize(base));
7599
7819
  if (hit) return hit;
7600
7820
  }
7601
7821
  }
7602
7822
  if (config.baseUrl !== null) {
7603
- return lookupPath(path16__namespace.posix.normalize(path16__namespace.posix.join(config.baseUrl, specifier)));
7823
+ return lookupPath(path17__namespace.posix.normalize(path17__namespace.posix.join(config.baseUrl, specifier)));
7604
7824
  }
7605
7825
  return null;
7606
7826
  }
@@ -7611,6 +7831,58 @@ function importsChangedFile(importerPath, imports, changedPaths, resolver) {
7611
7831
  }
7612
7832
  return false;
7613
7833
  }
7834
+ var SUMMARY_LIMIT = 400;
7835
+ var MAX_RELEASES = 2;
7836
+ function readProjectOverview(cwd) {
7837
+ return {
7838
+ ...readDescription(cwd),
7839
+ ...readSummary(cwd),
7840
+ releases: readReleases(cwd)
7841
+ };
7842
+ }
7843
+ function readText(file) {
7844
+ try {
7845
+ return fs16__namespace.readFileSync(file, "utf8");
7846
+ } catch {
7847
+ return null;
7848
+ }
7849
+ }
7850
+ function readDescription(cwd) {
7851
+ const raw = readText(path17__namespace.join(cwd, "package.json"));
7852
+ if (raw === null) return {};
7853
+ try {
7854
+ const parsed = JSON.parse(stripJsonComments(raw));
7855
+ return typeof parsed.description === "string" && parsed.description.trim().length > 0 ? { description: parsed.description.trim() } : {};
7856
+ } catch {
7857
+ return {};
7858
+ }
7859
+ }
7860
+ function readSummary(cwd) {
7861
+ const raw = readText(path17__namespace.join(cwd, "README.md"));
7862
+ if (raw === null) return {};
7863
+ const lines = raw.split(/\r?\n/);
7864
+ const paragraph = [];
7865
+ for (const line of lines) {
7866
+ const trimmed = line.trim();
7867
+ if (paragraph.length === 0) {
7868
+ if (trimmed.length === 0) continue;
7869
+ if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^</.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
7870
+ if (/^\[[^\]]+\]:/.test(trimmed)) continue;
7871
+ } else if (trimmed.length === 0 || /^#/.test(trimmed)) {
7872
+ break;
7873
+ }
7874
+ paragraph.push(trimmed);
7875
+ }
7876
+ const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
7877
+ if (summary.length === 0) return {};
7878
+ return { summary: summary.length > SUMMARY_LIMIT ? summary.slice(0, SUMMARY_LIMIT - 1) + "\u2026" : summary };
7879
+ }
7880
+ function readReleases(cwd) {
7881
+ const raw = readText(path17__namespace.join(cwd, "CHANGELOG.md"));
7882
+ if (raw === null) return [];
7883
+ const headings = raw.split(/\r?\n/).filter((line) => /^##\s+\S/.test(line)).map((line) => line.replace(/^##\s+/, "").trim());
7884
+ return headings.slice(0, MAX_RELEASES);
7885
+ }
7614
7886
  var LANGUAGE_BY_EXTENSION = {
7615
7887
  ".ts": "typescript",
7616
7888
  ".mts": "typescript",
@@ -7668,10 +7940,10 @@ var LANGUAGE_BY_BASENAME = {
7668
7940
  };
7669
7941
  function detectLanguage(filePath) {
7670
7942
  const normalized = filePath.replace(/\\/g, "/");
7671
- const base = path16__namespace.posix.basename(normalized);
7943
+ const base = path17__namespace.posix.basename(normalized);
7672
7944
  if (LANGUAGE_BY_BASENAME[base]) return LANGUAGE_BY_BASENAME[base];
7673
7945
  if (base === ".env" || base.startsWith(".env.")) return "dotenv";
7674
- const ext = path16__namespace.posix.extname(base).toLowerCase();
7946
+ const ext = path17__namespace.posix.extname(base).toLowerCase();
7675
7947
  return LANGUAGE_BY_EXTENSION[ext] ?? "text";
7676
7948
  }
7677
7949
  function maskedPath(value, secretRules) {
@@ -7679,33 +7951,33 @@ function maskedPath(value, secretRules) {
7679
7951
  }
7680
7952
  function confineToDirectory(directory, filename) {
7681
7953
  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);
7954
+ if (path17__namespace.isAbsolute(filename)) return null;
7955
+ const base = path17__namespace.resolve(directory);
7956
+ const resolved = path17__namespace.resolve(base, filename);
7685
7957
  const caseInsensitive = process.platform === "win32" || process.platform === "darwin";
7686
- const prefix = caseInsensitive ? `${base}${path16__namespace.sep}`.toLowerCase() : `${base}${path16__namespace.sep}`;
7958
+ const prefix = caseInsensitive ? `${base}${path17__namespace.sep}`.toLowerCase() : `${base}${path17__namespace.sep}`;
7687
7959
  const candidate = caseInsensitive ? resolved.toLowerCase() : resolved;
7688
7960
  return candidate.startsWith(prefix) ? resolved : null;
7689
7961
  }
7690
7962
  function findStagingDirectory(config) {
7691
- const tmpDir = path16__namespace.resolve(config.cwd, config.tmpDir);
7963
+ const tmpDir = path17__namespace.resolve(config.cwd, config.tmpDir);
7692
7964
  let entries;
7693
7965
  try {
7694
- entries = fs15__namespace.readdirSync(tmpDir);
7966
+ entries = fs16__namespace.readdirSync(tmpDir);
7695
7967
  } catch {
7696
7968
  return null;
7697
7969
  }
7698
7970
  const runs = entries.filter((name) => name.startsWith("run-")).sort();
7699
7971
  const newest = runs[runs.length - 1];
7700
- return newest ? path16__namespace.join(tmpDir, newest) : null;
7972
+ return newest ? path17__namespace.join(tmpDir, newest) : null;
7701
7973
  }
7702
7974
  function describeMissingManifest(config, manifestPath) {
7703
- const outDir = path16__namespace.resolve(config.cwd, config.outDir);
7704
- const markerPath = path16__namespace.join(outDir, ".codebase-snapshot");
7975
+ const outDir = path17__namespace.resolve(config.cwd, config.outDir);
7976
+ const markerPath = path17__namespace.join(outDir, ".codebase-snapshot");
7705
7977
  let marker2 = null;
7706
7978
  try {
7707
- if (fs15__namespace.existsSync(markerPath)) {
7708
- const parsed = JSON.parse(fs15__namespace.readFileSync(markerPath, "utf8"));
7979
+ if (fs16__namespace.existsSync(markerPath)) {
7980
+ const parsed = JSON.parse(fs16__namespace.readFileSync(markerPath, "utf8"));
7709
7981
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
7710
7982
  marker2 = parsed;
7711
7983
  }
@@ -7740,13 +8012,13 @@ function sha256Hex(buffer) {
7740
8012
  return crypto2__namespace.createHash("sha256").update(buffer).digest("hex");
7741
8013
  }
7742
8014
  function wouldNowBeIncluded(cwd, relativePath) {
7743
- const absolutePath = path16__namespace.join(cwd, relativePath);
8015
+ const absolutePath = path17__namespace.join(cwd, relativePath);
7744
8016
  try {
7745
- const stats = fs15__namespace.statSync(absolutePath);
8017
+ const stats = fs16__namespace.statSync(absolutePath);
7746
8018
  if (!stats.isFile()) return false;
7747
8019
  if (isBinaryExtension(absolutePath)) return false;
7748
8020
  if (stats.size > BINARY_SCAN_BYTES && isBinaryFile(absolutePath)) return false;
7749
- return !decodeText(fs15__namespace.readFileSync(absolutePath)).binary;
8021
+ return !decodeText(fs16__namespace.readFileSync(absolutePath)).binary;
7750
8022
  } catch {
7751
8023
  return false;
7752
8024
  }
@@ -7758,7 +8030,7 @@ var TRUNCATION_REASONS = /* @__PURE__ */ new Set([
7758
8030
  ]);
7759
8031
  function isConfinedRelative(value) {
7760
8032
  if (value.length === 0 || value.includes("\0") || value.includes("\\")) return false;
7761
- if (path16__namespace.isAbsolute(value)) return false;
8033
+ if (path17__namespace.isAbsolute(value)) return false;
7762
8034
  return !value.split("/").includes("..");
7763
8035
  }
7764
8036
  function describeManifestShapeProblem(value) {
@@ -7926,7 +8198,7 @@ function describeManifestShapeProblem(value) {
7926
8198
  if (typeof filename !== "string" || filename.trim() === "") {
7927
8199
  return 'a "parts" entry has no "filename"';
7928
8200
  }
7929
- if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path16__namespace.isAbsolute(filename)) {
8201
+ if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path17__namespace.isAbsolute(filename)) {
7930
8202
  return 'a "parts" entry "filename" must be a bare filename inside parts/';
7931
8203
  }
7932
8204
  if (currentSchema) {
@@ -7952,8 +8224,8 @@ function describeManifestShapeProblem(value) {
7952
8224
  function validateSnapshot(configInput) {
7953
8225
  assertUsableConfigInput(configInput);
7954
8226
  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)) {
8227
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
8228
+ if (!fs16__namespace.existsSync(manifestPath)) {
7957
8229
  return {
7958
8230
  valid: false,
7959
8231
  manifestPresent: false,
@@ -7964,7 +8236,7 @@ function validateSnapshot(configInput) {
7964
8236
  }
7965
8237
  let manifest;
7966
8238
  try {
7967
- manifest = JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
8239
+ manifest = JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
7968
8240
  } catch (err) {
7969
8241
  return {
7970
8242
  valid: false,
@@ -7986,7 +8258,7 @@ function validateSnapshot(configInput) {
7986
8258
  }
7987
8259
  const drift = emptyDrift();
7988
8260
  const warnings = [];
7989
- const snapshotDir = path16__namespace.resolve(config.cwd, config.outDir);
8261
+ const snapshotDir = path17__namespace.resolve(config.cwd, config.outDir);
7990
8262
  const unreadableSkips = manifest.skipped.filter(
7991
8263
  (entry) => entry.reason === "missing" || entry.reason === "read-error"
7992
8264
  );
@@ -8089,7 +8361,7 @@ function validateSnapshot(configInput) {
8089
8361
  );
8090
8362
  return importsChangedFile(
8091
8363
  diskFile,
8092
- importsOfFile(diskFile, path16__namespace.join(config.cwd, diskFile)),
8364
+ importsOfFile(diskFile, path17__namespace.join(config.cwd, diskFile)),
8093
8365
  unchangedScope,
8094
8366
  dependentResolver
8095
8367
  );
@@ -8107,7 +8379,7 @@ function validateSnapshot(configInput) {
8107
8379
  // own output directory as a set of files missing from the snapshot, so a correct
8108
8380
  // snapshot was reported as drifting.
8109
8381
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
8110
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8382
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8111
8383
  ).filter((relative11) => relative11.length > 0 && !relative11.startsWith(".."))
8112
8384
  });
8113
8385
  for (const diskFile of collection.files) {
@@ -8133,7 +8405,7 @@ function validateSnapshot(configInput) {
8133
8405
  }
8134
8406
  let diskHash;
8135
8407
  try {
8136
- diskHash = sha256Hex(fs15__namespace.readFileSync(path16__namespace.join(config.cwd, diskFile)));
8408
+ diskHash = sha256Hex(fs16__namespace.readFileSync(path17__namespace.join(config.cwd, diskFile)));
8137
8409
  } catch (err) {
8138
8410
  if (err.code === "ENOENT") {
8139
8411
  drift.missingOnDisk.push(diskFile);
@@ -8157,7 +8429,7 @@ function validateSnapshot(configInput) {
8157
8429
  }
8158
8430
  let statFailure = null;
8159
8431
  try {
8160
- fs15__namespace.statSync(confined);
8432
+ fs16__namespace.statSync(confined);
8161
8433
  } catch (err) {
8162
8434
  statFailure = err;
8163
8435
  }
@@ -8177,7 +8449,7 @@ function validateSnapshot(configInput) {
8177
8449
  ...Object.values(config.budgets.byLayer)
8178
8450
  );
8179
8451
  const partNames = /* @__PURE__ */ new Set();
8180
- const partsDir = path16__namespace.join(snapshotDir, "parts");
8452
+ const partsDir = path17__namespace.join(snapshotDir, "parts");
8181
8453
  for (const part of manifest.parts) {
8182
8454
  if (!part || typeof part.filename !== "string") continue;
8183
8455
  partNames.add(part.filename);
@@ -8192,7 +8464,7 @@ function validateSnapshot(configInput) {
8192
8464
  }
8193
8465
  let buffer;
8194
8466
  try {
8195
- buffer = fs15__namespace.readFileSync(partPath);
8467
+ buffer = fs16__namespace.readFileSync(partPath);
8196
8468
  } catch {
8197
8469
  drift.partIssues.push({ part: part.filename, issue: "missing from snapshot/parts" });
8198
8470
  continue;
@@ -8548,11 +8820,11 @@ function validateSnapshot(configInput) {
8548
8820
  ];
8549
8821
  for (const [key, artifact] of declaredArtifacts) {
8550
8822
  if (!artifact) continue;
8551
- const artifactPath = path16__namespace.join(snapshotDir, ...key.split("/"));
8823
+ const artifactPath = path17__namespace.join(snapshotDir, ...key.split("/"));
8552
8824
  let buffer;
8553
8825
  try {
8554
- if (!fs15__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
8555
- buffer = fs15__namespace.readFileSync(artifactPath);
8826
+ if (!fs16__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
8827
+ buffer = fs16__namespace.readFileSync(artifactPath);
8556
8828
  } catch {
8557
8829
  drift.partIssues.push({ part: key, issue: "declared artifact is missing" });
8558
8830
  continue;
@@ -8565,9 +8837,9 @@ function validateSnapshot(configInput) {
8565
8837
  for (const match of buffer.toString("utf8").matchAll(/\]\(([^)\s]+)\)/g)) {
8566
8838
  const target = match[1].split("#")[0];
8567
8839
  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)) {
8840
+ const resolved = path17__namespace.resolve(snapshotDir, "reports", target);
8841
+ const relative11 = path17__namespace.relative(snapshotDir, resolved);
8842
+ if (relative11.startsWith("..") || path17__namespace.isAbsolute(relative11) || !fs16__namespace.existsSync(resolved)) {
8571
8843
  drift.partIssues.push({
8572
8844
  part: key,
8573
8845
  issue: `links to ${maskedPath(target, config.secretRules)}, which does not exist in the snapshot`
@@ -8580,7 +8852,7 @@ function validateSnapshot(configInput) {
8580
8852
  if (sarifArtifact) {
8581
8853
  const sarifKey = "reports/audit.sarif";
8582
8854
  try {
8583
- const buffer = fs15__namespace.readFileSync(path16__namespace.join(snapshotDir, "reports", "audit.sarif"));
8855
+ const buffer = fs16__namespace.readFileSync(path17__namespace.join(snapshotDir, "reports", "audit.sarif"));
8584
8856
  if (sha256Hex(buffer) !== sarifArtifact.sha256 || buffer.length !== sarifArtifact.byteSize) {
8585
8857
  drift.partIssues.push({ part: sarifKey, issue: "artifact does not match its recorded digest" });
8586
8858
  }
@@ -8698,17 +8970,17 @@ function isNewer(candidate, current) {
8698
8970
  }
8699
8971
  function cacheDirectory(env = process.env, platform = process.platform) {
8700
8972
  if (platform === "win32") {
8701
- const base2 = env.LOCALAPPDATA ?? path16__namespace.join(os__namespace.homedir(), "AppData", "Local");
8702
- return path16__namespace.join(base2, "codebase-snapshot");
8973
+ const base2 = env.LOCALAPPDATA ?? path17__namespace.join(os__namespace.homedir(), "AppData", "Local");
8974
+ return path17__namespace.join(base2, "codebase-snapshot");
8703
8975
  }
8704
8976
  if (platform === "darwin") {
8705
- return path16__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
8977
+ return path17__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
8706
8978
  }
8707
- const base = env.XDG_CACHE_HOME ?? path16__namespace.join(os__namespace.homedir(), ".cache");
8708
- return path16__namespace.join(base, "codebase-snapshot");
8979
+ const base = env.XDG_CACHE_HOME ?? path17__namespace.join(os__namespace.homedir(), ".cache");
8980
+ return path17__namespace.join(base, "codebase-snapshot");
8709
8981
  }
8710
8982
  function cacheFilePath(env = process.env) {
8711
- return path16__namespace.join(cacheDirectory(env), "update-check.json");
8983
+ return path17__namespace.join(cacheDirectory(env), "update-check.json");
8712
8984
  }
8713
8985
  function shouldCheck(argv, env) {
8714
8986
  const disabled = ["1", "true", "yes"].includes(
@@ -8738,7 +9010,7 @@ function shouldCheck(argv, env) {
8738
9010
  function readCache(file) {
8739
9011
  let raw;
8740
9012
  try {
8741
- raw = fs15__namespace.readFileSync(file, "utf8");
9013
+ raw = fs16__namespace.readFileSync(file, "utf8");
8742
9014
  } catch {
8743
9015
  return null;
8744
9016
  }
@@ -8755,8 +9027,8 @@ function readCache(file) {
8755
9027
  }
8756
9028
  function writeCache(file, entry) {
8757
9029
  try {
8758
- fs15__namespace.mkdirSync(path16__namespace.dirname(file), { recursive: true });
8759
- fs15__namespace.writeFileSync(file, `${JSON.stringify(entry)}
9030
+ fs16__namespace.mkdirSync(path17__namespace.dirname(file), { recursive: true });
9031
+ fs16__namespace.writeFileSync(file, `${JSON.stringify(entry)}
8760
9032
  `, "utf8");
8761
9033
  } catch {
8762
9034
  }
@@ -8855,13 +9127,13 @@ function describeMatcher(matcher) {
8855
9127
  return String(matcher);
8856
9128
  }
8857
9129
  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)) {
9130
+ const resolvedCwd = path17__namespace.resolve(cwd);
9131
+ const absolute = path17__namespace.resolve(resolvedCwd, target);
9132
+ const relative11 = path17__namespace.relative(resolvedCwd, absolute);
9133
+ if (relative11 === "" || relative11 === ".." || relative11.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative11)) {
8862
9134
  return { relative: target.replace(/\\/g, "/"), outsideRoot: true };
8863
9135
  }
8864
- return { relative: relative11.split(path16__namespace.sep).join("/"), outsideRoot: false };
9136
+ return { relative: relative11.split(path17__namespace.sep).join("/"), outsideRoot: false };
8865
9137
  }
8866
9138
  function findRuleMatch(rules, relativePath) {
8867
9139
  return rules.find(
@@ -8880,9 +9152,9 @@ function findRecordedAncestor(skipped, relative11, maskedPath2) {
8880
9152
  return nearest;
8881
9153
  }
8882
9154
  function readManifest2(config) {
8883
- const manifestPath = path16__namespace.resolve(config.cwd, config.outDir, "manifest.json");
9155
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
8884
9156
  try {
8885
- return JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
9157
+ return JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
8886
9158
  } catch {
8887
9159
  return null;
8888
9160
  }
@@ -8900,10 +9172,10 @@ function explainPath(config, target) {
8900
9172
  detail: "path resolves outside the configured repository root and was not inspected"
8901
9173
  };
8902
9174
  }
8903
- const absolute = path16__namespace.join(config.cwd, relative11);
9175
+ const absolute = path17__namespace.join(config.cwd, relative11);
8904
9176
  const result = {
8905
9177
  path: maskedPath2,
8906
- exists: fs15__namespace.existsSync(absolute),
9178
+ exists: fs16__namespace.existsSync(absolute),
8907
9179
  included: false
8908
9180
  };
8909
9181
  const collection = collectFiles(config.cwd, {
@@ -8917,7 +9189,7 @@ function explainPath(config, target) {
8917
9189
  // Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
8918
9190
  // that is only missing because the walker dropped the tool's own output directory.
8919
9191
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
8920
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
9192
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
8921
9193
  ).filter((relative12) => relative12.length > 0 && !relative12.startsWith(".."))
8922
9194
  });
8923
9195
  if (!collection.files.includes(relative11)) {
@@ -8982,7 +9254,7 @@ function explainPath(config, target) {
8982
9254
  }
8983
9255
  let sizeOnDisk = null;
8984
9256
  try {
8985
- sizeOnDisk = fs15__namespace.statSync(absolute).size;
9257
+ sizeOnDisk = fs16__namespace.statSync(absolute).size;
8986
9258
  } catch {
8987
9259
  sizeOnDisk = null;
8988
9260
  }
@@ -8992,10 +9264,10 @@ function explainPath(config, target) {
8992
9264
  result.detail = "binary content; generate skips it and records `binary` in manifest.skipped[]";
8993
9265
  return result;
8994
9266
  }
8995
- if (fs15__namespace.existsSync(absolute) && fs15__namespace.statSync(absolute).isFile()) {
9267
+ if (fs16__namespace.existsSync(absolute) && fs16__namespace.statSync(absolute).isFile()) {
8996
9268
  let buffer;
8997
9269
  try {
8998
- buffer = fs15__namespace.readFileSync(absolute);
9270
+ buffer = fs16__namespace.readFileSync(absolute);
8999
9271
  } catch (err) {
9000
9272
  result.included = false;
9001
9273
  result.reason = "read-error";
@@ -9285,14 +9557,14 @@ function compareManifests(before, after, secretRules) {
9285
9557
  function loadManifest(target) {
9286
9558
  let isDirectory;
9287
9559
  try {
9288
- isDirectory = fs15__namespace.statSync(target).isDirectory();
9560
+ isDirectory = fs16__namespace.statSync(target).isDirectory();
9289
9561
  } catch {
9290
9562
  throw new Error(`No snapshot found at ${target}: the path does not exist.`);
9291
9563
  }
9292
- const manifestPath = isDirectory ? path16__namespace.join(target, "manifest.json") : target;
9564
+ const manifestPath = isDirectory ? path17__namespace.join(target, "manifest.json") : target;
9293
9565
  let raw;
9294
9566
  try {
9295
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
9567
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
9296
9568
  } catch {
9297
9569
  throw new Error(`Could not read a manifest at ${manifestPath}.`);
9298
9570
  }
@@ -9394,15 +9666,15 @@ function canonicalIgnorePattern(line) {
9394
9666
  function appendGitignoreEntries(cwd, entries) {
9395
9667
  const wanted = [...new Set(entries)].filter((entry) => entry.trim().length > 0);
9396
9668
  if (wanted.length === 0) return { added: [], note: null };
9397
- const ignorePath = path16__namespace.join(cwd, ".gitignore");
9669
+ const ignorePath = path17__namespace.join(cwd, ".gitignore");
9398
9670
  const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
9399
9671
  let decoded = { text: "", bom: Buffer.alloc(0), encoding: "utf8" };
9400
9672
  try {
9401
- if (fs15__namespace.existsSync(ignorePath)) {
9402
- if (fs15__namespace.statSync(ignorePath).isDirectory()) {
9673
+ if (fs16__namespace.existsSync(ignorePath)) {
9674
+ if (fs16__namespace.statSync(ignorePath).isDirectory()) {
9403
9675
  return { added: [], note: `${ignorePath} is a directory, so it was not updated. ${manual}` };
9404
9676
  }
9405
- const read = decodeGitignore(fs15__namespace.readFileSync(ignorePath));
9677
+ const read = decodeGitignore(fs16__namespace.readFileSync(ignorePath));
9406
9678
  if (read === null) {
9407
9679
  return {
9408
9680
  added: [],
@@ -9424,7 +9696,7 @@ function appendGitignoreEntries(cwd, entries) {
9424
9696
  const newline = existing.includes("\r\n") ? "\r\n" : "\n";
9425
9697
  const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : newline;
9426
9698
  try {
9427
- fs15__namespace.writeFileSync(
9699
+ fs16__namespace.writeFileSync(
9428
9700
  ignorePath,
9429
9701
  encodeGitignore(decoded, `${existing}${prefix}${added.join(newline)}${newline}`)
9430
9702
  );
@@ -9434,7 +9706,7 @@ function appendGitignoreEntries(cwd, entries) {
9434
9706
  return { added, note: null };
9435
9707
  }
9436
9708
  function gitignorePath(cwd, filePath) {
9437
- return path16__namespace.relative(cwd, filePath).split(path16__namespace.sep).join("/");
9709
+ return path17__namespace.relative(cwd, filePath).split(path17__namespace.sep).join("/");
9438
9710
  }
9439
9711
 
9440
9712
  // src/wizard/config-template.ts
@@ -9590,6 +9862,10 @@ function renderConfig(answers) {
9590
9862
  // Experimental: grow the per-part budget until the snapshot fits this many parts, instead of
9591
9863
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
9592
9864
  // maxParts: 10,
9865
+ // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
9866
+ // brief: "docs/brief.md",
9867
+ // Which job the brief is written for: audit, review or explain.
9868
+ // promptTask: "audit",
9593
9869
  // afterGenerate: (manifest) => { /* write your own artifact */ }
9594
9870
  hooks: {},
9595
9871
  };
@@ -9984,7 +10260,7 @@ function parsePackageJson(raw) {
9984
10260
  }
9985
10261
  function readPackageJson(cwd) {
9986
10262
  try {
9987
- return parsePackageJson(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"));
10263
+ return parsePackageJson(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"));
9988
10264
  } catch {
9989
10265
  return null;
9990
10266
  }
@@ -10021,7 +10297,7 @@ function artifactAnswers(options) {
10021
10297
  }
10022
10298
  function topLevelDirs(cwd) {
10023
10299
  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();
10300
+ return fs16__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
10025
10301
  } catch {
10026
10302
  return [];
10027
10303
  }
@@ -10036,7 +10312,7 @@ function writeFileOrExplain(target, content) {
10036
10312
  try {
10037
10313
  let stats = null;
10038
10314
  try {
10039
- stats = fs15__namespace.lstatSync(target);
10315
+ stats = fs16__namespace.lstatSync(target);
10040
10316
  } catch {
10041
10317
  stats = null;
10042
10318
  }
@@ -10051,12 +10327,12 @@ function writeFileOrExplain(target, content) {
10051
10327
  );
10052
10328
  }
10053
10329
  const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
10054
- fs15__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
10330
+ fs16__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
10055
10331
  try {
10056
- fs15__namespace.renameSync(temporary, target);
10332
+ fs16__namespace.renameSync(temporary, target);
10057
10333
  } catch (err) {
10058
10334
  try {
10059
- fs15__namespace.unlinkSync(temporary);
10335
+ fs16__namespace.unlinkSync(temporary);
10060
10336
  } catch {
10061
10337
  }
10062
10338
  throw err;
@@ -10104,19 +10380,19 @@ function serializePackageJson(raw, value) {
10104
10380
  return `${bom}${text2}${raw.endsWith("\n") ? crlf ? "\r\n" : "\n" : ""}`;
10105
10381
  }
10106
10382
  function updatePackageJson(cwd, notes) {
10107
- const packagePath = path16__namespace.join(cwd, "package.json");
10383
+ const packagePath = path17__namespace.join(cwd, "package.json");
10108
10384
  const unchanged = {
10109
10385
  scripts: [],
10110
10386
  dependency: { name: GENERATOR_NAME, range: null, added: false }
10111
10387
  };
10112
- if (!fs15__namespace.existsSync(packagePath)) {
10388
+ if (!fs16__namespace.existsSync(packagePath)) {
10113
10389
  notes.push("No package.json found, so npm scripts and the devDependency were not added.");
10114
10390
  return unchanged;
10115
10391
  }
10116
10392
  let raw;
10117
10393
  let parsed;
10118
10394
  try {
10119
- raw = fs15__namespace.readFileSync(packagePath, "utf8");
10395
+ raw = fs16__namespace.readFileSync(packagePath, "utf8");
10120
10396
  parsed = parsePackageJson(raw);
10121
10397
  } catch {
10122
10398
  notes.push("Could not parse package.json; npm scripts and the devDependency were not added.");
@@ -10191,8 +10467,8 @@ function gitignoreEntriesFor(cwd, outDir, tmpDir) {
10191
10467
  const entries = [];
10192
10468
  for (const directory of [outDir, tmpDir]) {
10193
10469
  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)) {
10470
+ const relative11 = path17__namespace.relative(cwd, path17__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
10471
+ if (relative11 === "" || relative11 === "." || relative11.startsWith("..") || path17__namespace.isAbsolute(relative11)) {
10196
10472
  continue;
10197
10473
  }
10198
10474
  entries.push(`/${relative11}/`);
@@ -10444,7 +10720,7 @@ async function runInit(options) {
10444
10720
  const configText = renderConfig(answers);
10445
10721
  const preferredName = chooseConfigFileName(options.cwd);
10446
10722
  const presentConfigs = CONFIG_CANDIDATES.filter(
10447
- (name) => fs15__namespace.existsSync(path16__namespace.join(options.cwd, name))
10723
+ (name) => fs16__namespace.existsSync(path17__namespace.join(options.cwd, name))
10448
10724
  );
10449
10725
  const present = presentConfigs[0] ?? null;
10450
10726
  if (presentConfigs.length > 1) {
@@ -10453,7 +10729,7 @@ async function runInit(options) {
10453
10729
  );
10454
10730
  }
10455
10731
  const configName = present !== null && options.force ? present : preferredName;
10456
- const configPath = path16__namespace.join(options.cwd, configName);
10732
+ const configPath = path17__namespace.join(options.cwd, configName);
10457
10733
  const reused = present !== null && options.force !== true && options.reuseConfig === true;
10458
10734
  if (reused) notes.push(`Kept the existing ${present} instead of writing a new one.`);
10459
10735
  if (options.dryRun) {
@@ -10487,7 +10763,7 @@ async function runInit(options) {
10487
10763
  '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
10764
  );
10489
10765
  }
10490
- if (fs15__namespace.existsSync(configPath) && !options.force && !reused) {
10766
+ if (fs16__namespace.existsSync(configPath) && !options.force && !reused) {
10491
10767
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
10492
10768
  }
10493
10769
  if (!reused) writeFileOrExplain(configPath, configText);
@@ -10513,9 +10789,9 @@ async function runInit(options) {
10513
10789
  };
10514
10790
  }
10515
10791
  function describeTarget(cwd) {
10516
- const relative11 = path16__namespace.relative(process.cwd(), cwd);
10792
+ const relative11 = path17__namespace.relative(process.cwd(), cwd);
10517
10793
  if (relative11 === "") return "this directory";
10518
- if (relative11.startsWith("..") || path16__namespace.isAbsolute(relative11)) return cwd;
10794
+ if (relative11.startsWith("..") || path17__namespace.isAbsolute(relative11)) return cwd;
10519
10795
  return relative11;
10520
10796
  }
10521
10797
  function firstRunMessage(reason, cwd) {
@@ -10539,7 +10815,7 @@ function planFirstRun(facts) {
10539
10815
  var NOT_CONTENT = /* @__PURE__ */ new Set([".git", ".hg", ".svn", ".bzr", ".DS_Store", "Thumbs.db"]);
10540
10816
  function isEffectivelyEmpty(cwd) {
10541
10817
  try {
10542
- return fs15__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
10818
+ return fs16__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
10543
10819
  } catch {
10544
10820
  return false;
10545
10821
  }
@@ -10547,7 +10823,7 @@ function isEffectivelyEmpty(cwd) {
10547
10823
  function hasPriorSnapshot(cwd, outDir) {
10548
10824
  let parsed;
10549
10825
  try {
10550
- parsed = JSON.parse(fs15__namespace.readFileSync(path16__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
10826
+ parsed = JSON.parse(fs16__namespace.readFileSync(path17__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
10551
10827
  } catch {
10552
10828
  return false;
10553
10829
  }
@@ -10595,36 +10871,36 @@ fi
10595
10871
  `;
10596
10872
  }
10597
10873
  function gitDirectory(cwd) {
10598
- const dotGit = path16__namespace.join(cwd, ".git");
10874
+ const dotGit = path17__namespace.join(cwd, ".git");
10599
10875
  let stats;
10600
10876
  try {
10601
- stats = fs15__namespace.statSync(dotGit);
10877
+ stats = fs16__namespace.statSync(dotGit);
10602
10878
  } catch {
10603
10879
  return null;
10604
10880
  }
10605
10881
  if (stats.isDirectory()) return dotGit;
10606
10882
  if (!stats.isFile()) return null;
10607
10883
  try {
10608
- const contents = fs15__namespace.readFileSync(dotGit, "utf8");
10884
+ const contents = fs16__namespace.readFileSync(dotGit, "utf8");
10609
10885
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
10610
10886
  if (!match) return null;
10611
10887
  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;
10888
+ const resolved = path17__namespace.isAbsolute(target.trim()) ? target.trim() : path17__namespace.join(cwd, target.trim());
10889
+ if (!fs16__namespace.statSync(resolved).isDirectory()) return null;
10890
+ if (isInside2(path17__namespace.resolve(cwd), path17__namespace.resolve(resolved))) return resolved;
10891
+ return isRegisteredWorktree(path17__namespace.resolve(resolved), cwd) ? resolved : null;
10616
10892
  } catch {
10617
10893
  return null;
10618
10894
  }
10619
10895
  }
10620
10896
  function isInside2(parent, child) {
10621
- const relative11 = path16__namespace.relative(parent, child);
10622
- return relative11 === "" || !relative11.startsWith("..") && !path16__namespace.isAbsolute(relative11);
10897
+ const relative11 = path17__namespace.relative(parent, child);
10898
+ return relative11 === "" || !relative11.startsWith("..") && !path17__namespace.isAbsolute(relative11);
10623
10899
  }
10624
10900
  function isRegisteredWorktree(gitDir, cwd) {
10625
10901
  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");
10902
+ const back = fs16__namespace.readFileSync(path17__namespace.join(gitDir, "gitdir"), "utf8").trim();
10903
+ return path17__namespace.resolve(gitDir, back) === path17__namespace.join(path17__namespace.resolve(cwd), ".git");
10628
10904
  } catch {
10629
10905
  return false;
10630
10906
  }
@@ -10645,10 +10921,10 @@ function gitOutput(cwd, args) {
10645
10921
  function configuredHooksDirectory(cwd) {
10646
10922
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
10647
10923
  if (hooks === null) return null;
10648
- const resolved = path16__namespace.resolve(cwd, hooks);
10924
+ const resolved = path17__namespace.resolve(cwd, hooks);
10649
10925
  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 };
10926
+ const commonDir = common === null ? null : path17__namespace.resolve(cwd, common);
10927
+ if (isInside2(path17__namespace.resolve(cwd), resolved)) return { dir: resolved };
10652
10928
  if (commonDir !== null && isInside2(commonDir, resolved)) return { dir: resolved };
10653
10929
  return {
10654
10930
  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 +10945,10 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10669
10945
  ]
10670
10946
  };
10671
10947
  }
10672
- const hooksDir = configured === null ? path16__namespace.join(gitDir, "hooks") : configured.dir;
10673
- const hookPath = path16__namespace.join(hooksDir, "pre-commit");
10948
+ const hooksDir = configured === null ? path17__namespace.join(gitDir, "hooks") : configured.dir;
10949
+ const hookPath = path17__namespace.join(hooksDir, "pre-commit");
10674
10950
  try {
10675
- fs15__namespace.mkdirSync(hooksDir, { recursive: true });
10951
+ fs16__namespace.mkdirSync(hooksDir, { recursive: true });
10676
10952
  } catch (err) {
10677
10953
  return {
10678
10954
  path: hookPath,
@@ -10682,7 +10958,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10682
10958
  }
10683
10959
  let existing = null;
10684
10960
  try {
10685
- existing = fs15__namespace.readFileSync(hookPath, "utf8");
10961
+ existing = fs16__namespace.readFileSync(hookPath, "utf8");
10686
10962
  } catch {
10687
10963
  existing = null;
10688
10964
  }
@@ -10697,8 +10973,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10697
10973
  };
10698
10974
  }
10699
10975
  try {
10700
- fs15__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10701
- fs15__namespace.chmodSync(hookPath, 493);
10976
+ fs16__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10977
+ fs16__namespace.chmodSync(hookPath, 493);
10702
10978
  } catch (err) {
10703
10979
  return {
10704
10980
  path: hookPath,
@@ -10715,7 +10991,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10715
10991
  };
10716
10992
  }
10717
10993
  function workerEntry(directory, isCjs) {
10718
- const entry = path16__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10994
+ const entry = path17__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10719
10995
  return { path: entry, url: url.pathToFileURL(entry).href };
10720
10996
  }
10721
10997
 
@@ -10724,23 +11000,23 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
10724
11000
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
10725
11001
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
10726
11002
  var fileDerivationBytes = 0;
10727
- function takeDerivation(path17, hash, settings) {
10728
- const cached = FILE_DERIVATIONS.get(path17);
11003
+ function takeDerivation(path18, hash, settings) {
11004
+ const cached = FILE_DERIVATIONS.get(path18);
10729
11005
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
10730
- FILE_DERIVATIONS.delete(path17);
10731
- FILE_DERIVATIONS.set(path17, cached);
11006
+ FILE_DERIVATIONS.delete(path18);
11007
+ FILE_DERIVATIONS.set(path18, cached);
10732
11008
  return cached;
10733
11009
  }
10734
- function rememberDerivation(path17, hash, settings, derivation) {
11010
+ function rememberDerivation(path18, hash, settings, derivation) {
10735
11011
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
10736
11012
  const bytes = bodyBytes * 2 + 512;
10737
11013
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
10738
- const previous = FILE_DERIVATIONS.get(path17);
11014
+ const previous = FILE_DERIVATIONS.get(path18);
10739
11015
  if (previous !== void 0) {
10740
- FILE_DERIVATIONS.delete(path17);
11016
+ FILE_DERIVATIONS.delete(path18);
10741
11017
  fileDerivationBytes -= previous.bytes;
10742
11018
  } else {
10743
- FILE_DERIVATIONS.delete(path17);
11019
+ FILE_DERIVATIONS.delete(path18);
10744
11020
  }
10745
11021
  while (fileDerivationBytes + bytes > FILE_DERIVATION_LIMIT_BYTES) {
10746
11022
  const oldest = FILE_DERIVATIONS.keys().next();
@@ -10749,7 +11025,7 @@ function rememberDerivation(path17, hash, settings, derivation) {
10749
11025
  FILE_DERIVATIONS.delete(oldest.value);
10750
11026
  if (evicted !== void 0) fileDerivationBytes -= evicted.bytes;
10751
11027
  }
10752
- FILE_DERIVATIONS.set(path17, { ...derivation, hash, settings, bytes });
11028
+ FILE_DERIVATIONS.set(path18, { ...derivation, hash, settings, bytes });
10753
11029
  fileDerivationBytes += bytes;
10754
11030
  }
10755
11031
  function derivationSettings(config) {
@@ -11000,11 +11276,11 @@ function verifyInMemory(files, parts, unaccounted) {
11000
11276
  return errors;
11001
11277
  }
11002
11278
  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}`);
11279
+ const cwd = path17__namespace.resolve(config.cwd);
11280
+ const outDir = path17__namespace.resolve(cwd, config.outDir);
11281
+ const tmpDir = path17__namespace.resolve(cwd, config.tmpDir);
11282
+ const root = path17__namespace.parse(cwd).root;
11283
+ const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path17__namespace.sep}`);
11008
11284
  const reject = (reason) => {
11009
11285
  throw new Error(
11010
11286
  `Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
@@ -11044,6 +11320,28 @@ function maskSummaryStrings(value, secretRules) {
11044
11320
  function maskPathText(value, secretRules) {
11045
11321
  return findSecretInPath(value, secretRules)?.masked ?? value;
11046
11322
  }
11323
+ function maskOwnerBrief(brief, secretRules) {
11324
+ if (brief === void 0) return void 0;
11325
+ const mask = (value) => maskPathText(value, secretRules);
11326
+ return {
11327
+ ...brief,
11328
+ ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11329
+ ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11330
+ ...brief.history === void 0 ? {} : { history: mask(brief.history) },
11331
+ ...brief.bar === void 0 ? {} : { bar: mask(brief.bar) },
11332
+ ...brief.calibration === void 0 ? {} : { calibration: mask(brief.calibration) },
11333
+ ...brief.preamble === void 0 ? {} : { preamble: mask(brief.preamble) },
11334
+ notes: brief.notes.map((note) => ({ heading: note.heading, body: mask(note.body) }))
11335
+ };
11336
+ }
11337
+ function maskOverview(overview, secretRules) {
11338
+ const mask = (value) => maskPathText(value, secretRules);
11339
+ return {
11340
+ ...overview.description === void 0 ? {} : { description: mask(overview.description) },
11341
+ ...overview.summary === void 0 ? {} : { summary: mask(overview.summary) },
11342
+ releases: overview.releases.map(mask)
11343
+ };
11344
+ }
11047
11345
  function maskSkipRecords(records, secretRules) {
11048
11346
  return maskSkipPaths(records, secretRules);
11049
11347
  }
@@ -11064,14 +11362,14 @@ function listEntries(dir) {
11064
11362
  const walk = (absolute, prefix) => {
11065
11363
  let children;
11066
11364
  try {
11067
- children = fs15__namespace.readdirSync(absolute, { withFileTypes: true });
11365
+ children = fs16__namespace.readdirSync(absolute, { withFileTypes: true });
11068
11366
  } catch {
11069
11367
  return;
11070
11368
  }
11071
11369
  for (const child of children) {
11072
11370
  const relative11 = prefix === "" ? child.name : `${prefix}/${child.name}`;
11073
11371
  entries.push(relative11);
11074
- if (child.isDirectory()) walk(path16__namespace.join(absolute, child.name), relative11);
11372
+ if (child.isDirectory()) walk(path17__namespace.join(absolute, child.name), relative11);
11075
11373
  }
11076
11374
  };
11077
11375
  walk(dir, "");
@@ -11083,10 +11381,10 @@ function markerInventory(dir, written) {
11083
11381
  for (const entry of entries) {
11084
11382
  if (entry === OWNERSHIP_MARKER) continue;
11085
11383
  if (isIgnorableEntry(entry)) continue;
11086
- const full = path16__namespace.join(dir, ...entry.split("/"));
11384
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11087
11385
  let stats;
11088
11386
  try {
11089
- stats = fs15__namespace.lstatSync(full);
11387
+ stats = fs16__namespace.lstatSync(full);
11090
11388
  } catch {
11091
11389
  continue;
11092
11390
  }
@@ -11098,7 +11396,7 @@ function markerInventory(dir, written) {
11098
11396
  }
11099
11397
  let digest;
11100
11398
  try {
11101
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11399
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11102
11400
  } catch {
11103
11401
  continue;
11104
11402
  }
@@ -11119,15 +11417,15 @@ function markerPayload(dir, state, id, createdAt, written) {
11119
11417
  entries,
11120
11418
  files
11121
11419
  };
11122
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11123
- if (fs15__namespace.existsSync(manifestPath)) {
11124
- marker2.manifestSha256 = sha256Hex2(fs15__namespace.readFileSync(manifestPath));
11420
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11421
+ if (fs16__namespace.existsSync(manifestPath)) {
11422
+ marker2.manifestSha256 = sha256Hex2(fs16__namespace.readFileSync(manifestPath));
11125
11423
  }
11126
11424
  return marker2;
11127
11425
  }
11128
11426
  function writeOwnershipMarker(dir, marker2) {
11129
- fs15__namespace.writeFileSync(
11130
- path16__namespace.join(dir, OWNERSHIP_MARKER),
11427
+ fs16__namespace.writeFileSync(
11428
+ path17__namespace.join(dir, OWNERSHIP_MARKER),
11131
11429
  `${JSON.stringify(marker2, null, 2)}
11132
11430
  `,
11133
11431
  "utf8"
@@ -11139,13 +11437,13 @@ function markerBelongsTo(dir, id) {
11139
11437
  return evidence.marker.id === id;
11140
11438
  }
11141
11439
  function readOwnershipMarker(dir) {
11142
- const markerPath = path16__namespace.join(dir, OWNERSHIP_MARKER);
11143
- if (!fs15__namespace.existsSync(markerPath)) {
11440
+ const markerPath = path17__namespace.join(dir, OWNERSHIP_MARKER);
11441
+ if (!fs16__namespace.existsSync(markerPath)) {
11144
11442
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
11145
11443
  }
11146
11444
  let raw;
11147
11445
  try {
11148
- raw = fs15__namespace.readFileSync(markerPath, "utf8");
11446
+ raw = fs16__namespace.readFileSync(markerPath, "utf8");
11149
11447
  } catch {
11150
11448
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
11151
11449
  }
@@ -11245,10 +11543,10 @@ function verifyMarkerInventory(dir, entries, files) {
11245
11543
  for (const entry of entries) {
11246
11544
  if (entry === OWNERSHIP_MARKER) continue;
11247
11545
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
11248
- const full = path16__namespace.join(dir, ...entry.split("/"));
11546
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11249
11547
  let stats;
11250
11548
  try {
11251
- stats = fs15__namespace.lstatSync(full);
11549
+ stats = fs16__namespace.lstatSync(full);
11252
11550
  } catch {
11253
11551
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
11254
11552
  }
@@ -11273,7 +11571,7 @@ function verifyMarkerInventory(dir, entries, files) {
11273
11571
  }
11274
11572
  let digest;
11275
11573
  try {
11276
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11574
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11277
11575
  } catch {
11278
11576
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
11279
11577
  }
@@ -11294,12 +11592,12 @@ function assessSnapshotDirectory(dir) {
11294
11592
  marker: marker2
11295
11593
  };
11296
11594
  }
11297
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11298
- const hasManifest = fs15__namespace.existsSync(manifestPath);
11595
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11596
+ const hasManifest = fs16__namespace.existsSync(manifestPath);
11299
11597
  if (hasManifest) {
11300
11598
  let raw;
11301
11599
  try {
11302
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
11600
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
11303
11601
  } catch {
11304
11602
  return {
11305
11603
  owned: false,
@@ -11394,13 +11692,13 @@ function containsNoFiles(dir) {
11394
11692
  const current = pending.pop();
11395
11693
  let entries;
11396
11694
  try {
11397
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
11695
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
11398
11696
  } catch {
11399
11697
  return false;
11400
11698
  }
11401
11699
  for (const entry of entries) {
11402
11700
  if (entry.isDirectory()) {
11403
- pending.push(path16__namespace.join(current, entry.name));
11701
+ pending.push(path17__namespace.join(current, entry.name));
11404
11702
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
11405
11703
  return false;
11406
11704
  }
@@ -11409,13 +11707,13 @@ function containsNoFiles(dir) {
11409
11707
  return true;
11410
11708
  }
11411
11709
  function assertReplaceable(target, label, secretRules) {
11412
- if (!fs15__namespace.existsSync(target)) return;
11413
- if (!fs15__namespace.statSync(target).isDirectory()) {
11710
+ if (!fs16__namespace.existsSync(target)) return;
11711
+ if (!fs16__namespace.statSync(target).isDirectory()) {
11414
11712
  throw new Error(
11415
11713
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
11416
11714
  );
11417
11715
  }
11418
- const entries = fs15__namespace.readdirSync(target);
11716
+ const entries = fs16__namespace.readdirSync(target);
11419
11717
  if (entries.length === 0) return;
11420
11718
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
11421
11719
  if (containsNoFiles(target)) return;
@@ -11435,18 +11733,18 @@ function assertReplaceable(target, label, secretRules) {
11435
11733
  );
11436
11734
  }
11437
11735
  function assertStagingRootUsable(tmpDir, secretRules) {
11438
- if (!fs15__namespace.existsSync(tmpDir)) return;
11439
- if (!fs15__namespace.statSync(tmpDir).isDirectory()) {
11736
+ if (!fs16__namespace.existsSync(tmpDir)) return;
11737
+ if (!fs16__namespace.statSync(tmpDir).isDirectory()) {
11440
11738
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
11441
11739
  }
11442
- const entries = fs15__namespace.readdirSync(tmpDir);
11740
+ const entries = fs16__namespace.readdirSync(tmpDir);
11443
11741
  if (entries.length === 0) return;
11444
11742
  const foreign = entries.filter((name) => {
11445
- const full = path16__namespace.join(tmpDir, name);
11743
+ const full = path17__namespace.join(tmpDir, name);
11446
11744
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
11447
11745
  let stats;
11448
11746
  try {
11449
- stats = fs15__namespace.statSync(full);
11747
+ stats = fs16__namespace.statSync(full);
11450
11748
  } catch {
11451
11749
  return true;
11452
11750
  }
@@ -11454,7 +11752,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11454
11752
  const { marker: marker2 } = readOwnershipMarker(full);
11455
11753
  if (marker2) return false;
11456
11754
  try {
11457
- return fs15__namespace.readdirSync(full).length > 0;
11755
+ return fs16__namespace.readdirSync(full).length > 0;
11458
11756
  } catch {
11459
11757
  return true;
11460
11758
  }
@@ -11469,13 +11767,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11469
11767
  function cleanStaleRunDirs(tmpDir) {
11470
11768
  let entries;
11471
11769
  try {
11472
- entries = fs15__namespace.readdirSync(tmpDir);
11770
+ entries = fs16__namespace.readdirSync(tmpDir);
11473
11771
  } catch {
11474
11772
  return;
11475
11773
  }
11476
11774
  for (const name of entries) {
11477
11775
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
11478
- const full = path16__namespace.join(tmpDir, name);
11776
+ const full = path17__namespace.join(tmpDir, name);
11479
11777
  const { marker: marker2 } = readOwnershipMarker(full);
11480
11778
  if (marker2) {
11481
11779
  const created = Date.parse(marker2.createdAt);
@@ -11483,33 +11781,33 @@ function cleanStaleRunDirs(tmpDir) {
11483
11781
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
11484
11782
  if (aged || abandoned) {
11485
11783
  try {
11486
- fs15__namespace.rmSync(full, { recursive: true, force: true });
11784
+ fs16__namespace.rmSync(full, { recursive: true, force: true });
11487
11785
  } catch {
11488
11786
  }
11489
11787
  }
11490
11788
  continue;
11491
11789
  }
11492
11790
  try {
11493
- if (fs15__namespace.readdirSync(full).length === 0) fs15__namespace.rmSync(full, { recursive: true, force: true });
11791
+ if (fs16__namespace.readdirSync(full).length === 0) fs16__namespace.rmSync(full, { recursive: true, force: true });
11494
11792
  } catch {
11495
11793
  }
11496
11794
  }
11497
11795
  }
11498
11796
  function removeIfEmpty(dir) {
11499
11797
  try {
11500
- if (fs15__namespace.readdirSync(dir).length === 0) fs15__namespace.rmSync(dir, { recursive: true, force: true });
11798
+ if (fs16__namespace.readdirSync(dir).length === 0) fs16__namespace.rmSync(dir, { recursive: true, force: true });
11501
11799
  } catch {
11502
11800
  }
11503
11801
  }
11504
11802
  function ensureParentDirectory(target, label) {
11505
- const parent = path16__namespace.dirname(target);
11506
- if (fs15__namespace.existsSync(parent) && !fs15__namespace.statSync(parent).isDirectory()) {
11803
+ const parent = path17__namespace.dirname(target);
11804
+ if (fs16__namespace.existsSync(parent) && !fs16__namespace.statSync(parent).isDirectory()) {
11507
11805
  throw new Error(
11508
11806
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
11509
11807
  );
11510
11808
  }
11511
11809
  try {
11512
- fs15__namespace.mkdirSync(parent, { recursive: true });
11810
+ fs16__namespace.mkdirSync(parent, { recursive: true });
11513
11811
  } catch (err) {
11514
11812
  throw new Error(
11515
11813
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -11567,17 +11865,17 @@ function acquireRunLock(stagingRoot) {
11567
11865
  `;
11568
11866
  for (let attempt = 0; attempt < 2; attempt += 1) {
11569
11867
  try {
11570
- const handle = fs15__namespace.openSync(lockPath, "wx");
11868
+ const handle = fs16__namespace.openSync(lockPath, "wx");
11571
11869
  try {
11572
- fs15__namespace.writeSync(handle, payload);
11870
+ fs16__namespace.writeSync(handle, payload);
11573
11871
  } finally {
11574
- fs15__namespace.closeSync(handle);
11872
+ fs16__namespace.closeSync(handle);
11575
11873
  }
11576
11874
  const stopHeartbeat = startLockHeartbeat(lockPath);
11577
11875
  return () => {
11578
11876
  stopHeartbeat();
11579
11877
  try {
11580
- fs15__namespace.rmSync(lockPath, { force: true });
11878
+ fs16__namespace.rmSync(lockPath, { force: true });
11581
11879
  } catch {
11582
11880
  }
11583
11881
  };
@@ -11597,26 +11895,26 @@ function lockKeyFor(stagingRoot) {
11597
11895
  return sha256Hex2(key).slice(0, 16);
11598
11896
  }
11599
11897
  function canonicalLockTarget(targetPath) {
11600
- const resolved = path16__namespace.resolve(targetPath);
11898
+ const resolved = path17__namespace.resolve(targetPath);
11601
11899
  let existing = resolved;
11602
11900
  const tail = [];
11603
11901
  for (; ; ) {
11604
11902
  try {
11605
- return path16__namespace.join(fs15__namespace.realpathSync(existing), ...tail);
11903
+ return path17__namespace.join(fs16__namespace.realpathSync(existing), ...tail);
11606
11904
  } catch {
11607
- const parent = path16__namespace.dirname(existing);
11905
+ const parent = path17__namespace.dirname(existing);
11608
11906
  if (parent === existing) return resolved;
11609
- tail.unshift(path16__namespace.basename(existing));
11907
+ tail.unshift(path17__namespace.basename(existing));
11610
11908
  existing = parent;
11611
11909
  }
11612
11910
  }
11613
11911
  }
11614
11912
  function lockPathFor(stagingRoot) {
11615
- return path16__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11913
+ return path17__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11616
11914
  }
11617
11915
  function lockHeartbeatAgeMs(lockPath) {
11618
11916
  try {
11619
- return Date.now() - fs15__namespace.statSync(lockPath).mtimeMs;
11917
+ return Date.now() - fs16__namespace.statSync(lockPath).mtimeMs;
11620
11918
  } catch {
11621
11919
  return Number.POSITIVE_INFINITY;
11622
11920
  }
@@ -11624,7 +11922,7 @@ function lockHeartbeatAgeMs(lockPath) {
11624
11922
  function lockOwnerIsGone(lockPath) {
11625
11923
  let raw;
11626
11924
  try {
11627
- raw = fs15__namespace.readFileSync(lockPath, "utf8");
11925
+ raw = fs16__namespace.readFileSync(lockPath, "utf8");
11628
11926
  } catch {
11629
11927
  return false;
11630
11928
  }
@@ -11646,16 +11944,16 @@ function lockOwnerIsGone(lockPath) {
11646
11944
  function reclaimStaleLock(lockPath) {
11647
11945
  let before;
11648
11946
  try {
11649
- before = fs15__namespace.statSync(lockPath);
11947
+ before = fs16__namespace.statSync(lockPath);
11650
11948
  } catch {
11651
11949
  return true;
11652
11950
  }
11653
11951
  if (!lockOwnerIsGone(lockPath)) return false;
11654
11952
  try {
11655
- const current = fs15__namespace.statSync(lockPath);
11953
+ const current = fs16__namespace.statSync(lockPath);
11656
11954
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
11657
11955
  if (!sameFile) return false;
11658
- fs15__namespace.rmSync(lockPath, { force: true });
11956
+ fs16__namespace.rmSync(lockPath, { force: true });
11659
11957
  return true;
11660
11958
  } catch {
11661
11959
  return false;
@@ -11666,12 +11964,12 @@ function lockFileIsAncient(lockPath) {
11666
11964
  }
11667
11965
  function writeManifestAtomically(manifestPath, manifest) {
11668
11966
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
11669
- fs15__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11967
+ fs16__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11670
11968
  try {
11671
- fs15__namespace.renameSync(tempPath, manifestPath);
11969
+ fs16__namespace.renameSync(tempPath, manifestPath);
11672
11970
  } catch (err) {
11673
11971
  try {
11674
- fs15__namespace.rmSync(tempPath, { force: true });
11972
+ fs16__namespace.rmSync(tempPath, { force: true });
11675
11973
  } catch {
11676
11974
  }
11677
11975
  throw err;
@@ -11696,21 +11994,21 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap) {
11696
11994
  }
11697
11995
  }
11698
11996
  function recoverInterruptedPublish(outDir) {
11699
- if (fs15__namespace.existsSync(outDir)) return;
11700
- const parent = path16__namespace.dirname(outDir);
11701
- const base = path16__namespace.basename(outDir);
11997
+ if (fs16__namespace.existsSync(outDir)) return;
11998
+ const parent = path17__namespace.dirname(outDir);
11999
+ const base = path17__namespace.basename(outDir);
11702
12000
  let backups;
11703
12001
  try {
11704
- backups = fs15__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
12002
+ backups = fs16__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
11705
12003
  } catch {
11706
12004
  return;
11707
12005
  }
11708
12006
  if (backups.length !== 1) return;
11709
- const backupDir = path16__namespace.join(parent, backups[0]);
12007
+ const backupDir = path17__namespace.join(parent, backups[0]);
11710
12008
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
11711
12009
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
11712
12010
  try {
11713
- fs15__namespace.renameSync(backupDir, outDir);
12011
+ fs16__namespace.renameSync(backupDir, outDir);
11714
12012
  process.stderr.write(
11715
12013
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
11716
12014
  `
@@ -11720,16 +12018,16 @@ function recoverInterruptedPublish(outDir) {
11720
12018
  }
11721
12019
  function swapOnce(stagingDir, outDir, beforeSwap) {
11722
12020
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
11723
- const hadPrevious = fs15__namespace.existsSync(outDir);
12021
+ const hadPrevious = fs16__namespace.existsSync(outDir);
11724
12022
  if (hadPrevious) beforeSwap?.();
11725
12023
  let movedAside = false;
11726
12024
  if (hadPrevious) {
11727
12025
  try {
11728
- fs15__namespace.renameSync(outDir, backupDir);
12026
+ fs16__namespace.renameSync(outDir, backupDir);
11729
12027
  movedAside = true;
11730
12028
  } catch (err) {
11731
12029
  if (!isLockError(err)) throw err;
11732
- fs15__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
12030
+ fs16__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
11733
12031
  process.stderr.write(
11734
12032
  `\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
12033
  `
@@ -11738,26 +12036,26 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11738
12036
  }
11739
12037
  try {
11740
12038
  try {
11741
- fs15__namespace.renameSync(stagingDir, outDir);
12039
+ fs16__namespace.renameSync(stagingDir, outDir);
11742
12040
  } catch (err) {
11743
12041
  if (err.code !== "EXDEV") throw err;
11744
12042
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
11745
12043
  try {
11746
- fs15__namespace.cpSync(stagingDir, partialDir, { recursive: true });
11747
- fs15__namespace.renameSync(partialDir, outDir);
11748
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12044
+ fs16__namespace.cpSync(stagingDir, partialDir, { recursive: true });
12045
+ fs16__namespace.renameSync(partialDir, outDir);
12046
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
11749
12047
  } catch (copyErr) {
11750
12048
  try {
11751
- fs15__namespace.rmSync(partialDir, { recursive: true, force: true });
12049
+ fs16__namespace.rmSync(partialDir, { recursive: true, force: true });
11752
12050
  } catch {
11753
12051
  }
11754
12052
  throw copyErr;
11755
12053
  }
11756
12054
  }
11757
12055
  } 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);
12056
+ if (hadPrevious && movedAside && fs16__namespace.existsSync(backupDir)) {
12057
+ if (fs16__namespace.existsSync(outDir)) fs16__namespace.rmSync(outDir, { recursive: true, force: true });
12058
+ fs16__namespace.renameSync(backupDir, outDir);
11761
12059
  } else if (hadPrevious && !movedAside) {
11762
12060
  process.stderr.write(
11763
12061
  `\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 +12066,7 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11768
12066
  }
11769
12067
  if (hadPrevious) {
11770
12068
  try {
11771
- fs15__namespace.rmSync(backupDir, { recursive: true, force: true });
12069
+ fs16__namespace.rmSync(backupDir, { recursive: true, force: true });
11772
12070
  } catch (err) {
11773
12071
  process.stderr.write(
11774
12072
  `\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 +12224,7 @@ function generateSnapshot(configInput, options) {
11926
12224
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
11927
12225
  // output — but only at these exact paths, not at every directory that shares the name.
11928
12226
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
11929
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
12227
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
11930
12228
  ).filter((relative11) => relative11.length > 0 && !relative11.startsWith("..")),
11931
12229
  // A staged path can be absent from the working tree while its index blob exists. Discovery
11932
12230
  // lists the working tree, so those paths would never reach the scan at all.
@@ -11955,7 +12253,7 @@ function generateSnapshot(configInput, options) {
11955
12253
  let totalSizeBytes = 0;
11956
12254
  let largeFileCount = 0;
11957
12255
  for (const relativePath of candidateFiles) {
11958
- const absolutePath = path16__namespace.join(config.cwd, relativePath);
12256
+ const absolutePath = path17__namespace.join(config.cwd, relativePath);
11959
12257
  const fromIndex = stagedPaths.has(relativePath);
11960
12258
  let buffer;
11961
12259
  let sizeBytes;
@@ -11986,9 +12284,9 @@ function generateSnapshot(configInput, options) {
11986
12284
  } else {
11987
12285
  let stats;
11988
12286
  try {
11989
- stats = fs15__namespace.statSync(absolutePath);
12287
+ stats = fs16__namespace.statSync(absolutePath);
11990
12288
  if (!stats.isFile()) {
11991
- const nestedRepository = stats.isDirectory() && fs15__namespace.existsSync(path16__namespace.join(absolutePath, ".git"));
12289
+ const nestedRepository = stats.isDirectory() && fs16__namespace.existsSync(path17__namespace.join(absolutePath, ".git"));
11992
12290
  skipped.push(
11993
12291
  nestedRepository ? {
11994
12292
  path: relativePath,
@@ -12024,7 +12322,7 @@ function generateSnapshot(configInput, options) {
12024
12322
  continue;
12025
12323
  }
12026
12324
  try {
12027
- buffer = fs15__namespace.readFileSync(absolutePath);
12325
+ buffer = fs16__namespace.readFileSync(absolutePath);
12028
12326
  } catch (err) {
12029
12327
  const code = err.code;
12030
12328
  skipped.push({
@@ -12153,14 +12451,14 @@ function generateSnapshot(configInput, options) {
12153
12451
  (finding) => finding.path === void 0 || keep.has(finding.path)
12154
12452
  );
12155
12453
  retain(encodingNotes, (note) => keep.has(note.path));
12156
- retain(oversizeSummaryPaths, (path17) => keep.has(path17));
12157
- retain(previewSummaryPaths, (path17) => keep.has(path17));
12454
+ retain(oversizeSummaryPaths, (path18) => keep.has(path18));
12455
+ retain(previewSummaryPaths, (path18) => keep.has(path18));
12158
12456
  retain(fileWarnings, (warning) => keep.has(warning.path));
12159
- for (const path17 of [...monolithBodies.keys()]) {
12160
- if (!keep.has(path17)) monolithBodies.delete(path17);
12457
+ for (const path18 of [...monolithBodies.keys()]) {
12458
+ if (!keep.has(path18)) monolithBodies.delete(path18);
12161
12459
  }
12162
- for (const path17 of [...skippedSummaryImports.keys()]) {
12163
- if (!keep.has(path17)) skippedSummaryImports.delete(path17);
12460
+ for (const path18 of [...skippedSummaryImports.keys()]) {
12461
+ if (!keep.has(path18)) skippedSummaryImports.delete(path18);
12164
12462
  }
12165
12463
  }
12166
12464
  if (changedScope !== null) {
@@ -12299,6 +12597,8 @@ function generateSnapshot(configInput, options) {
12299
12597
  // omitted from `digest` when it is off so an existing snapshot does not start reporting
12300
12598
  // configuration drift.
12301
12599
  maxParts: config.maxParts ?? null,
12600
+ promptTask: config.promptTask,
12601
+ ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12302
12602
  discovery: config.discovery ?? "auto",
12303
12603
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12304
12604
  // describes the run has to name it.
@@ -12429,14 +12729,16 @@ function generateSnapshot(configInput, options) {
12429
12729
  if (auditText !== null) manifest.artifacts.audit = artifactRecord(auditText);
12430
12730
  const readmeText = artifacts.readme ? generateReadme(manifest, artifacts) : null;
12431
12731
  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;
12732
+ const promptText = artifacts.prompt ? generatePrompt(manifest, artifacts, {
12733
+ slots: config.attachmentSlots,
12734
+ task: config.promptTask,
12735
+ brief: maskOwnerBrief(config.brief, config.secretRules),
12736
+ history: recentCommits(config.cwd).map((commit) => ({
12737
+ subject: maskPathText(commit.subject, config.secretRules),
12738
+ body: maskPathText(commit.body, config.secretRules)
12739
+ })),
12740
+ overview: maskOverview(readProjectOverview(config.cwd), config.secretRules)
12741
+ }) : null;
12440
12742
  if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
12441
12743
  if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
12442
12744
  let monolithJson = null;
@@ -12512,12 +12814,12 @@ function generateSnapshot(configInput, options) {
12512
12814
  let releaseDeferred = false;
12513
12815
  try {
12514
12816
  ensureParentDirectory(outDir, "outDir");
12515
- fs15__namespace.mkdirSync(tmpDir, { recursive: true });
12817
+ fs16__namespace.mkdirSync(tmpDir, { recursive: true });
12516
12818
  cleanStaleRunDirs(tmpDir);
12517
12819
  const snapshotId = crypto2__namespace.randomUUID();
12518
12820
  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);
12821
+ stagingDir = path17__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12822
+ fs16__namespace.mkdirSync(stagingDir);
12521
12823
  writeOwnershipMarker(stagingDir, {
12522
12824
  generator: GENERATOR_NAME,
12523
12825
  version: GENERATOR_VERSION,
@@ -12527,30 +12829,30 @@ function generateSnapshot(configInput, options) {
12527
12829
  id: snapshotId,
12528
12830
  pid: process.pid
12529
12831
  });
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 });
12832
+ const partsDir = path17__namespace.join(stagingDir, "parts");
12833
+ const reportsDir = path17__namespace.join(stagingDir, "reports");
12834
+ if (artifacts.parts) fs16__namespace.mkdirSync(partsDir, { recursive: true });
12533
12835
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || config.sarif === true) {
12534
- fs15__namespace.mkdirSync(reportsDir, { recursive: true });
12836
+ fs16__namespace.mkdirSync(reportsDir, { recursive: true });
12535
12837
  }
12536
12838
  const writtenArtifacts = /* @__PURE__ */ new Map();
12537
12839
  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);
12840
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12841
+ fs16__namespace.writeFileSync(full, data, "utf8");
12842
+ const stats = fs16__namespace.statSync(full);
12541
12843
  writtenArtifacts.set(relativeEntry, {
12542
12844
  digest: { path: relativeEntry, bytes: stats.size, sha256: sha256Hex2(data) },
12543
12845
  mtimeMs: stats.mtimeMs
12544
12846
  });
12545
12847
  };
12546
12848
  const recordArtifact = (targetDir, relativeEntry) => {
12547
- const full = path16__namespace.join(targetDir, ...relativeEntry.split("/"));
12548
- const stats = fs15__namespace.statSync(full);
12849
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12850
+ const stats = fs16__namespace.statSync(full);
12549
12851
  writtenArtifacts.set(relativeEntry, {
12550
12852
  digest: {
12551
12853
  path: relativeEntry,
12552
12854
  bytes: stats.size,
12553
- sha256: sha256Hex2(fs15__namespace.readFileSync(full))
12855
+ sha256: sha256Hex2(fs16__namespace.readFileSync(full))
12554
12856
  },
12555
12857
  mtimeMs: stats.mtimeMs
12556
12858
  });
@@ -12598,7 +12900,7 @@ function generateSnapshot(configInput, options) {
12598
12900
  const shipHookState = () => {
12599
12901
  if (!markerBelongsTo(outDir, snapshotId)) return;
12600
12902
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
12601
- writeManifestAtomically(path16__namespace.join(outDir, "manifest.json"), manifest);
12903
+ writeManifestAtomically(path17__namespace.join(outDir, "manifest.json"), manifest);
12602
12904
  recordArtifact(outDir, "manifest.json");
12603
12905
  }
12604
12906
  writeOwnershipMarker(
@@ -12641,7 +12943,7 @@ function generateSnapshot(configInput, options) {
12641
12943
  } catch (err) {
12642
12944
  if (stagingDir !== null) {
12643
12945
  try {
12644
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12946
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
12645
12947
  } catch {
12646
12948
  }
12647
12949
  }