codebase-snapshot 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var childProcess = require('child_process');
4
- var fs15 = require('fs');
5
- var path16 = require('path');
4
+ var fs16 = require('fs');
5
+ var path17 = require('path');
6
6
  var util = require('util');
7
7
  var crypto3 = require('crypto');
8
8
  var module$1 = require('module');
@@ -37,8 +37,8 @@ function _interopNamespace(e) {
37
37
  }
38
38
 
39
39
  var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
40
- var fs15__namespace = /*#__PURE__*/_interopNamespace(fs15);
41
- var path16__namespace = /*#__PURE__*/_interopNamespace(path16);
40
+ var fs16__namespace = /*#__PURE__*/_interopNamespace(fs16);
41
+ var path17__namespace = /*#__PURE__*/_interopNamespace(path17);
42
42
  var crypto3__namespace = /*#__PURE__*/_interopNamespace(crypto3);
43
43
  var ts2__default = /*#__PURE__*/_interopDefault(ts2);
44
44
  var readline__namespace = /*#__PURE__*/_interopNamespace(readline);
@@ -93,15 +93,15 @@ var SKIPPED_WALK_DIRS = /* @__PURE__ */ new Set([
93
93
  ]);
94
94
  function readSmallFile(fullPath) {
95
95
  try {
96
- const stats = fs15__namespace.statSync(fullPath);
96
+ const stats = fs16__namespace.statSync(fullPath);
97
97
  if (!stats.isFile() || stats.size > MANIFEST_MAX_BYTES) return null;
98
- return fs15__namespace.readFileSync(fullPath, "utf8");
98
+ return fs16__namespace.readFileSync(fullPath, "utf8");
99
99
  } catch {
100
100
  return null;
101
101
  }
102
102
  }
103
103
  function readManifest(cwd, name) {
104
- return readSmallFile(path16__namespace.join(cwd, name));
104
+ return readSmallFile(path17__namespace.join(cwd, name));
105
105
  }
106
106
  function dependenciesFromPackageJson(raw) {
107
107
  const names = /* @__PURE__ */ new Set();
@@ -161,7 +161,7 @@ function pnpmWorkspacePatterns(raw) {
161
161
  function childDirectories(cwd, parent) {
162
162
  let entries;
163
163
  try {
164
- entries = fs15__namespace.readdirSync(path16__namespace.join(cwd, parent), { withFileTypes: true });
164
+ entries = fs16__namespace.readdirSync(path17__namespace.join(cwd, parent), { withFileTypes: true });
165
165
  } catch {
166
166
  return [];
167
167
  }
@@ -197,12 +197,12 @@ function scanWorkspacePackages(cwd, patterns) {
197
197
  const files = /* @__PURE__ */ new Set();
198
198
  const dependencies = /* @__PURE__ */ new Set();
199
199
  for (const relative15 of workspacePackageDirs(cwd, patterns)) {
200
- const full = path16__namespace.join(cwd, relative15);
200
+ const full = path17__namespace.join(cwd, relative15);
201
201
  try {
202
- for (const entry of fs15__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
202
+ for (const entry of fs16__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
203
203
  } catch {
204
204
  }
205
- const raw = readSmallFile(path16__namespace.join(full, "package.json"));
205
+ const raw = readSmallFile(path17__namespace.join(full, "package.json"));
206
206
  if (raw !== null) {
207
207
  for (const name of dependenciesFromPackageJson(raw)) dependencies.add(name);
208
208
  }
@@ -212,7 +212,7 @@ function scanWorkspacePackages(cwd, patterns) {
212
212
  var SNAPSHOT_MARKER = ".codebase-snapshot";
213
213
  function isToolOwnedDirectory(dir) {
214
214
  try {
215
- return fs15__namespace.statSync(dir).isDirectory() && fs15__namespace.existsSync(path16__namespace.join(dir, SNAPSHOT_MARKER));
215
+ return fs16__namespace.statSync(dir).isDirectory() && fs16__namespace.existsSync(path17__namespace.join(dir, SNAPSHOT_MARKER));
216
216
  } catch {
217
217
  return false;
218
218
  }
@@ -227,7 +227,7 @@ function countMarkdownFiles(cwd) {
227
227
  directoriesSeen += 1;
228
228
  let entries;
229
229
  try {
230
- entries = fs15__namespace.readdirSync(current.dir, { withFileTypes: true });
230
+ entries = fs16__namespace.readdirSync(current.dir, { withFileTypes: true });
231
231
  } catch {
232
232
  continue;
233
233
  }
@@ -238,7 +238,7 @@ function countMarkdownFiles(cwd) {
238
238
  }
239
239
  if (!entry.isDirectory() || current.depth >= 2) continue;
240
240
  if (entry.name.startsWith(".") || SKIPPED_WALK_DIRS.has(entry.name)) continue;
241
- const child = path16__namespace.join(current.dir, entry.name);
241
+ const child = path17__namespace.join(current.dir, entry.name);
242
242
  if (isToolOwnedDirectory(child)) continue;
243
243
  queue.push({ dir: child, depth: current.depth + 1 });
244
244
  }
@@ -249,7 +249,7 @@ function buildPresetContext(cwd) {
249
249
  const files = /* @__PURE__ */ new Set();
250
250
  const dirs = /* @__PURE__ */ new Set();
251
251
  try {
252
- for (const entry of fs15__namespace.readdirSync(cwd, { withFileTypes: true })) {
252
+ for (const entry of fs16__namespace.readdirSync(cwd, { withFileTypes: true })) {
253
253
  if (entry.isDirectory()) dirs.add(entry.name);
254
254
  else if (entry.isFile()) files.add(entry.name);
255
255
  }
@@ -266,7 +266,7 @@ function buildPresetContext(cwd) {
266
266
  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;
267
267
  let workspace = { files: /* @__PURE__ */ new Set(), dependencies: /* @__PURE__ */ new Set() };
268
268
  if (isWorkspace) {
269
- const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path16__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
269
+ const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path17__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
270
270
  const declared = pnpmRaw === null ? [] : pnpmWorkspacePatterns(pnpmRaw);
271
271
  const patterns = declared.length > 0 ? declared : declaredWorkspaces.length > 0 ? declaredWorkspaces : DEFAULT_WORKSPACE_PATTERNS;
272
272
  workspace = scanWorkspacePackages(cwd, patterns);
@@ -2220,7 +2220,7 @@ function applySpansKeepingQuotes(line, spans) {
2220
2220
 
2221
2221
  // src/version.ts
2222
2222
  var GENERATOR_NAME = "codebase-snapshot";
2223
- var GENERATOR_VERSION = "0.11.0";
2223
+ var GENERATOR_VERSION = "0.12.1";
2224
2224
  var SCHEMA_VERSION = "3.0.0";
2225
2225
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2226
2226
  function isOurGeneratorName(name) {
@@ -2237,14 +2237,14 @@ var PRESET_IGNORES = new Set(
2237
2237
  );
2238
2238
  function readLinkTarget(linkPath, fallback) {
2239
2239
  try {
2240
- return fs15__namespace.readlinkSync(linkPath);
2240
+ return fs16__namespace.readlinkSync(linkPath);
2241
2241
  } catch {
2242
2242
  return fallback;
2243
2243
  }
2244
2244
  }
2245
2245
  function brokenLinkRecord(linkPath, relativePath, rootReal) {
2246
2246
  const rawTarget = readLinkTarget(linkPath, linkPath);
2247
- const resolvedFallback = path16__namespace.resolve(path16__namespace.dirname(linkPath), rawTarget);
2247
+ const resolvedFallback = path17__namespace.resolve(path17__namespace.dirname(linkPath), rawTarget);
2248
2248
  return isInside(rootReal, resolvedFallback) ? { path: relativePath, reason: "read-error", detail: "broken symlink" } : {
2249
2249
  path: relativePath,
2250
2250
  reason: "outside-root",
@@ -2252,8 +2252,8 @@ function brokenLinkRecord(linkPath, relativePath, rootReal) {
2252
2252
  };
2253
2253
  }
2254
2254
  function isInside(root, candidate) {
2255
- const relative15 = path16__namespace.relative(root, candidate);
2256
- return relative15 === "" || !relative15.startsWith(`..${path16__namespace.sep}`) && relative15 !== ".." && !path16__namespace.isAbsolute(relative15);
2255
+ const relative15 = path17__namespace.relative(root, candidate);
2256
+ return relative15 === "" || !relative15.startsWith(`..${path17__namespace.sep}`) && relative15 !== ".." && !path17__namespace.isAbsolute(relative15);
2257
2257
  }
2258
2258
  var GIT_OUTPUT_LIMIT = 68157440;
2259
2259
  function getGitInfo(cwd, fallbackBranch = "main") {
@@ -2511,10 +2511,10 @@ function trimUnescapedTrailingSpaces(line) {
2511
2511
  return line.slice(0, end);
2512
2512
  }
2513
2513
  function readGitignoreRules(dir) {
2514
- const gitignorePath2 = path16__namespace.join(dir, ".gitignore");
2514
+ const gitignorePath2 = path17__namespace.join(dir, ".gitignore");
2515
2515
  let raw;
2516
2516
  try {
2517
- raw = fs15__namespace.readFileSync(gitignorePath2, "utf8");
2517
+ raw = fs16__namespace.readFileSync(gitignorePath2, "utf8");
2518
2518
  } catch {
2519
2519
  return [];
2520
2520
  }
@@ -2668,11 +2668,23 @@ function defaultIgnoreReason(relativePath, toolDirNames = DEFAULT_TOOL_DIR_NAMES
2668
2668
  }
2669
2669
  return null;
2670
2670
  }
2671
- function recentCommitSubjects(cwd, limit = 10) {
2671
+ var COMMIT_BODY_LIMIT = 400;
2672
+ function truncateAtSentence(text2, limit) {
2673
+ if (text2.length <= limit) return text2;
2674
+ const window = text2.slice(0, limit);
2675
+ const sentence = Math.max(window.lastIndexOf(". "), window.lastIndexOf("; "));
2676
+ if (sentence > limit / 3) return window.slice(0, sentence + 1).trim();
2677
+ const space = window.lastIndexOf(" ");
2678
+ if (space > limit / 3) return window.slice(0, space).trim() + "\u2026";
2679
+ return window.trim() + "\u2026";
2680
+ }
2681
+ function recentCommits(cwd, limit = 10) {
2672
2682
  try {
2673
2683
  const stdout = childProcess__namespace.execFileSync(
2674
2684
  "git",
2675
- ["log", "-n", String(limit), "--pretty=%s", "--no-color"],
2685
+ // \x1f between fields and \x1e between records: neither can appear in a commit message, so
2686
+ // the parse cannot be confused by a message that contains a newline or a dash.
2687
+ ["log", "-n", String(limit), "--pretty=format:%s%x1f%b%x1e", "--no-color"],
2676
2688
  {
2677
2689
  cwd,
2678
2690
  stdio: ["ignore", "pipe", "ignore"],
@@ -2680,7 +2692,16 @@ function recentCommitSubjects(cwd, limit = 10) {
2680
2692
  maxBuffer: GIT_OUTPUT_LIMIT
2681
2693
  }
2682
2694
  );
2683
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
2695
+ return stdout.split("").map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
2696
+ const separator = record.indexOf("");
2697
+ const subject = separator === -1 ? record : record.slice(0, separator);
2698
+ const rawBody = separator === -1 ? "" : record.slice(separator + 1);
2699
+ const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ").replace(/\s*\|\s*/g, " ").replace(/\s+/g, " ").trim();
2700
+ return {
2701
+ subject: subject.trim(),
2702
+ body: truncateAtSentence(body, COMMIT_BODY_LIMIT)
2703
+ };
2704
+ }).filter((commit) => commit.subject.length > 0);
2684
2705
  } catch {
2685
2706
  return [];
2686
2707
  }
@@ -2704,7 +2725,7 @@ function listIgnoredPaths(cwd) {
2704
2725
  }
2705
2726
  function hasSnapshotMarker(target) {
2706
2727
  try {
2707
- return fs15__namespace.statSync(target).isDirectory() && fs15__namespace.existsSync(path16__namespace.join(target, ".codebase-snapshot"));
2728
+ return fs16__namespace.statSync(target).isDirectory() && fs16__namespace.existsSync(path17__namespace.join(target, ".codebase-snapshot"));
2708
2729
  } catch {
2709
2730
  return false;
2710
2731
  }
@@ -2713,7 +2734,7 @@ var IGNORABLE_DIRECTORY_ENTRIES = /* @__PURE__ */ new Set([".DS_Store"]);
2713
2734
  function isToolOwnedDirectory2(dir) {
2714
2735
  let raw;
2715
2736
  try {
2716
- raw = fs15__namespace.readFileSync(path16__namespace.join(dir, ".codebase-snapshot"), "utf8");
2737
+ raw = fs16__namespace.readFileSync(path17__namespace.join(dir, ".codebase-snapshot"), "utf8");
2717
2738
  } catch {
2718
2739
  return false;
2719
2740
  }
@@ -2740,7 +2761,7 @@ function isToolOwnedDirectory2(dir) {
2740
2761
  }
2741
2762
  let entries;
2742
2763
  try {
2743
- entries = fs15__namespace.readdirSync(dir);
2764
+ entries = fs16__namespace.readdirSync(dir);
2744
2765
  } catch {
2745
2766
  return false;
2746
2767
  }
@@ -2757,7 +2778,7 @@ function makeToolOwnedDecider(cwd, toolOwnedPaths) {
2757
2778
  const prefix = parts.slice(0, depth).join("/");
2758
2779
  let hasMarker = markers.get(prefix);
2759
2780
  if (hasMarker === void 0) {
2760
- hasMarker = isToolOwnedDirectory2(path16__namespace.join(cwd, prefix));
2781
+ hasMarker = isToolOwnedDirectory2(path17__namespace.join(cwd, prefix));
2761
2782
  markers.set(prefix, hasMarker);
2762
2783
  }
2763
2784
  if (hasMarker) return true;
@@ -2772,7 +2793,7 @@ function makeLinkProbe() {
2772
2793
  let known = cache.get(absolutePath);
2773
2794
  if (known === void 0) {
2774
2795
  try {
2775
- known = fs15__namespace.lstatSync(absolutePath).isSymbolicLink();
2796
+ known = fs16__namespace.lstatSync(absolutePath).isSymbolicLink();
2776
2797
  } catch {
2777
2798
  known = false;
2778
2799
  }
@@ -2785,7 +2806,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2785
2806
  const isLink = makeLinkProbe();
2786
2807
  let rootReal = cwd;
2787
2808
  try {
2788
- rootReal = fs15__namespace.realpathSync(cwd);
2809
+ rootReal = fs16__namespace.realpathSync(cwd);
2789
2810
  } catch {
2790
2811
  }
2791
2812
  const reported = /* @__PURE__ */ new Set();
@@ -2800,7 +2821,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2800
2821
  let linkedPath = null;
2801
2822
  for (let depth = 1; depth <= parts.length; depth += 1) {
2802
2823
  const prefix = parts.slice(0, depth).join("/");
2803
- if (isLink(path16__namespace.join(cwd, prefix))) {
2824
+ if (isLink(path17__namespace.join(cwd, prefix))) {
2804
2825
  linkedPath = prefix;
2805
2826
  break;
2806
2827
  }
@@ -2809,11 +2830,11 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2809
2830
  kept.push(candidate);
2810
2831
  continue;
2811
2832
  }
2812
- const absolute = path16__namespace.join(cwd, linkedPath);
2833
+ const absolute = path17__namespace.join(cwd, linkedPath);
2813
2834
  const rawTarget = readLinkTarget(absolute, absolute);
2814
2835
  let targetReal = null;
2815
2836
  try {
2816
- targetReal = fs15__namespace.realpathSync(absolute);
2837
+ targetReal = fs16__namespace.realpathSync(absolute);
2817
2838
  } catch {
2818
2839
  targetReal = null;
2819
2840
  }
@@ -2831,7 +2852,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2831
2852
  }
2832
2853
  let stats = null;
2833
2854
  try {
2834
- stats = fs15__namespace.statSync(absolute);
2855
+ stats = fs16__namespace.statSync(absolute);
2835
2856
  } catch {
2836
2857
  stats = null;
2837
2858
  }
@@ -2919,7 +2940,7 @@ function collectFiles(cwd, options = {}) {
2919
2940
  "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."
2920
2941
  );
2921
2942
  }
2922
- if (fs15__namespace.existsSync(path16__namespace.join(cwd, ".git"))) {
2943
+ if (fs16__namespace.existsSync(path17__namespace.join(cwd, ".git"))) {
2923
2944
  throw new Error(
2924
2945
  "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."
2925
2946
  );
@@ -2987,7 +3008,7 @@ function collectFiles(cwd, options = {}) {
2987
3008
  }
2988
3009
  function rootRealFor(root) {
2989
3010
  try {
2990
- return fs15__namespace.realpathSync(root);
3011
+ return fs16__namespace.realpathSync(root);
2991
3012
  } catch {
2992
3013
  return root;
2993
3014
  }
@@ -2996,18 +3017,18 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
2996
3017
  const results = { files: [], skipped: [] };
2997
3018
  const stack = [];
2998
3019
  const toolDirNames = toolDirNamesFor(reservedPaths);
2999
- const relativeToBase = (target) => path16__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
3020
+ const relativeToBase = (target) => path17__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
3000
3021
  const enter = (current, layers) => {
3001
3022
  if (visited.has(current)) return false;
3002
3023
  visited.add(current);
3003
3024
  const localRules = readGitignoreRules(current);
3004
3025
  const gitignoreLayers = localRules.length === 0 ? layers : [
3005
3026
  ...layers,
3006
- { prefix: path16__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
3027
+ { prefix: path17__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
3007
3028
  ];
3008
3029
  let entries;
3009
3030
  try {
3010
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
3031
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
3011
3032
  } catch {
3012
3033
  results.skipped.push({
3013
3034
  path: relativeToBase(current),
@@ -3029,8 +3050,8 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3029
3050
  }
3030
3051
  const entry = frame.entries[frame.index];
3031
3052
  frame.index += 1;
3032
- const fullPath = path16__namespace.join(frame.dir, entry.name);
3033
- const relPath = path16__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
3053
+ const fullPath = path17__namespace.join(frame.dir, entry.name);
3054
+ const relPath = path17__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
3034
3055
  if (reservedPaths.has(relPath)) continue;
3035
3056
  if (entry.isDirectory() && DEFAULT_IGNORED_DIRS.includes(entry.name)) {
3036
3057
  results.skipped.push({
@@ -3063,14 +3084,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3063
3084
  if (entry.isSymbolicLink()) {
3064
3085
  let targetReal;
3065
3086
  try {
3066
- targetReal = fs15__namespace.realpathSync(fullPath);
3087
+ targetReal = fs16__namespace.realpathSync(fullPath);
3067
3088
  } catch {
3068
3089
  results.skipped.push(brokenLinkRecord(fullPath, relPath, rootReal));
3069
3090
  continue;
3070
3091
  }
3071
3092
  let stats;
3072
3093
  try {
3073
- stats = fs15__namespace.statSync(fullPath);
3094
+ stats = fs16__namespace.statSync(fullPath);
3074
3095
  } catch {
3075
3096
  results.skipped.push({ path: relPath, reason: "read-error", detail: "unreadable symlink" });
3076
3097
  continue;
@@ -3100,7 +3121,7 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3100
3121
  });
3101
3122
  continue;
3102
3123
  }
3103
- const targetRelative = path16__namespace.relative(rootReal, targetReal).split(path16__namespace.sep).join("/");
3124
+ const targetRelative = path17__namespace.relative(rootReal, targetReal).split(path17__namespace.sep).join("/");
3104
3125
  if (isSensitivePath(targetRelative)) {
3105
3126
  results.skipped.push({
3106
3127
  path: relPath,
@@ -3292,6 +3313,77 @@ function summarizeMarkdown(content) {
3292
3313
  frontmatterKeys: Array.from(new Set(frontmatterKeys)).sort()
3293
3314
  };
3294
3315
  }
3316
+ var OWNER_SECTIONS = ["Stakes", "The system", "What came before", "The bar", "Calibration"];
3317
+ var RESERVED_SECTIONS = [
3318
+ "The job",
3319
+ "What you have",
3320
+ "Coverage",
3321
+ "What a useful answer contains",
3322
+ "This snapshot",
3323
+ "Attaching this",
3324
+ "Your task"
3325
+ ];
3326
+ function parseOwnerBrief(filePath, text2) {
3327
+ const problems = [];
3328
+ const source = text2.replace(/^\uFEFF/, "");
3329
+ const preamble = [];
3330
+ const sections = [];
3331
+ let current = null;
3332
+ for (const line of source.split(/\r?\n/)) {
3333
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
3334
+ if (heading) {
3335
+ current = { heading: heading[1], body: [] };
3336
+ sections.push(current);
3337
+ continue;
3338
+ }
3339
+ if (current) current.body.push(line);
3340
+ else preamble.push(line);
3341
+ }
3342
+ const recognised = {};
3343
+ const notes = [];
3344
+ const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
3345
+ const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
3346
+ const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
3347
+ const seen = /* @__PURE__ */ new Set();
3348
+ for (const section of sections) {
3349
+ const body = section.body.join("\n").trim();
3350
+ const key = canonical(section.heading);
3351
+ if (seen.has(key)) {
3352
+ problems.push(
3353
+ `the brief defines "${section.heading}" twice; a section cannot say two things.`
3354
+ );
3355
+ continue;
3356
+ }
3357
+ seen.add(key);
3358
+ if (canonicalReserved.has(key)) {
3359
+ problems.push(
3360
+ `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.`
3361
+ );
3362
+ continue;
3363
+ }
3364
+ const ownerName = canonicalOwner.get(key);
3365
+ if (ownerName !== void 0) {
3366
+ recognised[ownerName] = body;
3367
+ continue;
3368
+ }
3369
+ notes.push({ heading: section.heading, body });
3370
+ }
3371
+ const preambleText = preamble.join("\n").trim();
3372
+ return {
3373
+ brief: {
3374
+ path: filePath,
3375
+ digest: crypto3.createHash("sha256").update(text2, "utf8").digest("hex"),
3376
+ ...recognised["Stakes"] ? { stakes: recognised["Stakes"] } : {},
3377
+ ...recognised["The system"] ? { system: recognised["The system"] } : {},
3378
+ ...recognised["What came before"] ? { history: recognised["What came before"] } : {},
3379
+ ...recognised["The bar"] ? { bar: recognised["The bar"] } : {},
3380
+ ...recognised["Calibration"] ? { calibration: recognised["Calibration"] } : {},
3381
+ notes,
3382
+ ...preambleText.length > 0 ? { preamble: preambleText } : {}
3383
+ },
3384
+ problems
3385
+ };
3386
+ }
3295
3387
 
3296
3388
  // src/tokenize.ts
3297
3389
  var WORD_RUN = /[A-Za-z0-9_]+/g;
@@ -3328,20 +3420,20 @@ var CONFIG_FILENAMES = [
3328
3420
  ];
3329
3421
  function findConfigFile(cwd) {
3330
3422
  for (const filename of CONFIG_FILENAMES) {
3331
- const fullPath = path16__namespace.join(cwd, filename);
3423
+ const fullPath = path17__namespace.join(cwd, filename);
3332
3424
  let stats = null;
3333
3425
  try {
3334
- stats = fs15__namespace.statSync(fullPath);
3426
+ stats = fs16__namespace.statSync(fullPath);
3335
3427
  } catch {
3336
- if (fs15__namespace.existsSync(fullPath)) return fullPath;
3428
+ if (fs16__namespace.existsSync(fullPath)) return fullPath;
3337
3429
  continue;
3338
3430
  }
3339
3431
  if (stats.isFile()) return fullPath;
3340
3432
  }
3341
- const pkgJsonPath = path16__namespace.join(cwd, "package.json");
3342
- if (!fs15__namespace.existsSync(pkgJsonPath)) return null;
3433
+ const pkgJsonPath = path17__namespace.join(cwd, "package.json");
3434
+ if (!fs16__namespace.existsSync(pkgJsonPath)) return null;
3343
3435
  try {
3344
- const parsed = JSON.parse(stripJsonComments(fs15__namespace.readFileSync(pkgJsonPath, "utf8")));
3436
+ const parsed = JSON.parse(stripJsonComments(fs16__namespace.readFileSync(pkgJsonPath, "utf8")));
3345
3437
  const snapshot = parsed?.snapshot;
3346
3438
  return typeof snapshot === "object" && snapshot !== null && !Array.isArray(snapshot) ? pkgJsonPath : null;
3347
3439
  } catch {
@@ -3407,6 +3499,8 @@ function normalizeResolvedConfig(config) {
3407
3499
  // is re-validated because the number reaches a rendered artifact.
3408
3500
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3409
3501
  maxParts: resolveMaxParts(config.maxParts),
3502
+ promptTask: resolvePromptTask(config.promptTask),
3503
+ ...config.brief === void 0 ? {} : { brief: config.brief },
3410
3504
  includeMonolith: artifacts.monolith,
3411
3505
  secretRules: compileSecretRules(config.secretRules),
3412
3506
  artifacts,
@@ -3477,6 +3571,7 @@ var CONFIG_KEY_NAMES = [
3477
3571
  "artifacts",
3478
3572
  "attachmentSlots",
3479
3573
  "branch",
3574
+ "brief",
3480
3575
  "budgets",
3481
3576
  "changedSince",
3482
3577
  "cwd",
@@ -3498,6 +3593,7 @@ var CONFIG_KEY_NAMES = [
3498
3593
  "outDir",
3499
3594
  "preset",
3500
3595
  "previewHeadLines",
3596
+ "promptTask",
3501
3597
  "staged",
3502
3598
  "previewTailLines",
3503
3599
  "secretRules",
@@ -3548,10 +3644,10 @@ function readConfigExport(exported, file) {
3548
3644
  var lastModuleConfig = null;
3549
3645
  function moduleConfigKey(fullPath) {
3550
3646
  try {
3551
- return crypto3.createHash("sha256").update(fs15__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
3647
+ return crypto3.createHash("sha256").update(fs16__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
3552
3648
  } catch {
3553
3649
  try {
3554
- const stats = fs15__namespace.statSync(fullPath);
3650
+ const stats = fs16__namespace.statSync(fullPath);
3555
3651
  return `stat-${stats.mtimeMs}-${stats.size}`;
3556
3652
  } catch {
3557
3653
  return "unreadable";
@@ -3577,7 +3673,7 @@ async function importConfigModule(fullPath) {
3577
3673
  function attachConfigDir(config, filePath) {
3578
3674
  if (typeof config === "object" && config !== null) {
3579
3675
  Object.defineProperty(config, CONFIG_DIR_SYMBOL, {
3580
- value: path16__namespace.dirname(filePath),
3676
+ value: path17__namespace.dirname(filePath),
3581
3677
  enumerable: false,
3582
3678
  configurable: true
3583
3679
  });
@@ -3589,12 +3685,12 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3589
3685
  const errors = [];
3590
3686
  const configDirectories = [];
3591
3687
  for (const filename of CONFIG_FILENAMES) {
3592
- const fullPath = path16__namespace.join(cwd, filename);
3688
+ const fullPath = path17__namespace.join(cwd, filename);
3593
3689
  let candidateStats = null;
3594
3690
  try {
3595
- candidateStats = fs15__namespace.statSync(fullPath);
3691
+ candidateStats = fs16__namespace.statSync(fullPath);
3596
3692
  } catch {
3597
- if (!fs15__namespace.existsSync(fullPath)) continue;
3693
+ if (!fs16__namespace.existsSync(fullPath)) continue;
3598
3694
  }
3599
3695
  if (candidateStats !== null && !candidateStats.isFile()) {
3600
3696
  configDirectories.push(fullPath);
@@ -3602,7 +3698,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3602
3698
  }
3603
3699
  if (filename.endsWith(".json") || filename === ".snapshotrc") {
3604
3700
  try {
3605
- const config = parseJsonish(fs15__namespace.readFileSync(fullPath, "utf8"), fullPath);
3701
+ const config = parseJsonish(fs16__namespace.readFileSync(fullPath, "utf8"), fullPath);
3606
3702
  if (config === null || typeof config !== "object" || Array.isArray(config)) {
3607
3703
  throw new Error(
3608
3704
  `${fullPath} does not hold a configuration object (received ${describeValue2(config)}).`
@@ -3642,10 +3738,10 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3642
3738
  continue;
3643
3739
  }
3644
3740
  }
3645
- const pkgJsonPath = path16__namespace.join(cwd, "package.json");
3646
- if (fs15__namespace.existsSync(pkgJsonPath)) {
3741
+ const pkgJsonPath = path17__namespace.join(cwd, "package.json");
3742
+ if (fs16__namespace.existsSync(pkgJsonPath)) {
3647
3743
  try {
3648
- const parsed = parseJsonish(fs15__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
3744
+ const parsed = parseJsonish(fs16__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
3649
3745
  const snapshotKey = parsed.snapshot;
3650
3746
  if (snapshotKey && typeof snapshotKey === "object" && !Array.isArray(snapshotKey)) {
3651
3747
  assertKnownConfigKeys(
@@ -3782,6 +3878,38 @@ function resolveMaxParts(value) {
3782
3878
  }
3783
3879
  return value;
3784
3880
  }
3881
+ function resolvePromptTask(value) {
3882
+ if (value === void 0 || value === null) return "audit";
3883
+ if (value === "audit" || value === "review" || value === "explain") return value;
3884
+ throw new Error(
3885
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
3886
+ );
3887
+ }
3888
+ function readConfiguredBrief(cwd, value) {
3889
+ if (value === void 0 || value === null) return void 0;
3890
+ if (typeof value !== "string" || value.trim().length === 0) {
3891
+ throw new Error(
3892
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
3893
+ );
3894
+ }
3895
+ const filePath = path17__namespace.resolve(cwd, value);
3896
+ let text2;
3897
+ try {
3898
+ if (!fs16__namespace.statSync(filePath).isFile()) throw new Error("not a file");
3899
+ text2 = fs16__namespace.readFileSync(filePath, "utf8");
3900
+ } catch {
3901
+ throw new Error(
3902
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
3903
+ );
3904
+ }
3905
+ const parsed = parseOwnerBrief(value, text2);
3906
+ if (parsed.problems.length > 0) {
3907
+ throw new Error(
3908
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
3909
+ );
3910
+ }
3911
+ return parsed.brief;
3912
+ }
3785
3913
  function strictPositiveInteger(value, fallback, label) {
3786
3914
  if (value === void 0) return fallback;
3787
3915
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -3874,9 +4002,9 @@ function resolveKindRules(value) {
3874
4002
  function outputExcludePatterns(cwd, outDir, tmpDir) {
3875
4003
  const patterns = [];
3876
4004
  for (const dir of [outDir, tmpDir]) {
3877
- const absolute = path16__namespace.resolve(cwd, dir);
3878
- const relative15 = path16__namespace.relative(cwd, absolute);
3879
- if (!relative15 || relative15 === ".." || relative15.startsWith(`..${path16__namespace.sep}`) || path16__namespace.isAbsolute(relative15)) {
4005
+ const absolute = path17__namespace.resolve(cwd, dir);
4006
+ const relative15 = path17__namespace.relative(cwd, absolute);
4007
+ if (!relative15 || relative15 === ".." || relative15.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative15)) {
3880
4008
  continue;
3881
4009
  }
3882
4010
  patterns.push(`${relative15.replace(/\\/g, "/")}/**`);
@@ -4009,11 +4137,11 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
4009
4137
  );
4010
4138
  }
4011
4139
  const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
4012
- const resolved = path16__namespace.resolve(candidate);
4013
- if (!fs15__namespace.existsSync(resolved)) {
4140
+ const resolved = path17__namespace.resolve(candidate);
4141
+ if (!fs16__namespace.existsSync(resolved)) {
4014
4142
  throw new Error(`Working directory does not exist: ${resolved}`);
4015
4143
  }
4016
- if (!fs15__namespace.statSync(resolved).isDirectory()) {
4144
+ if (!fs16__namespace.statSync(resolved).isDirectory()) {
4017
4145
  throw new Error(`Working directory is not a directory: ${resolved}`);
4018
4146
  }
4019
4147
  return resolved;
@@ -4141,6 +4269,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4141
4269
  configuredSensitiveFiles,
4142
4270
  "`includeSensitiveFiles`"
4143
4271
  );
4272
+ const configuredBrief = readConfiguredBrief(
4273
+ cwd,
4274
+ cliOptions?.brief ?? userConfig?.brief
4275
+ );
4144
4276
  const presetExclude = [
4145
4277
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
4146
4278
  ];
@@ -4164,6 +4296,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4164
4296
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4165
4297
  ),
4166
4298
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4299
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
4300
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
4167
4301
  ...changedSince === void 0 ? {} : { changedSince },
4168
4302
  ...staged ? { staged } : {},
4169
4303
  ...withDependents ? { withDependents } : {},
@@ -4249,6 +4383,12 @@ function configDigest(config) {
4249
4383
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4250
4384
  // material would change the digest of every snapshot taken before the setting existed.
4251
4385
  ...config.maxParts === null ? {} : { maxParts: config.maxParts },
4386
+ // The default value is omitted for the same reason: a snapshot taken before the setting
4387
+ // existed kept the audit job, so it must keep the digest it was written with.
4388
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
4389
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
4390
+ // reader to do, so a changed brief is drift exactly like a changed budget.
4391
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
4252
4392
  artifacts: config.artifacts,
4253
4393
  include: config.include,
4254
4394
  excludePatterns: config.excludePatterns,
@@ -4332,7 +4472,7 @@ function resolveChangedScope(cwd, request) {
4332
4472
  const descriptions = [];
4333
4473
  if (request.changedSince !== void 0) {
4334
4474
  assertUsableRef(request.changedSince);
4335
- for (const path22 of gitPaths(cwd, [
4475
+ for (const path23 of gitPaths(cwd, [
4336
4476
  "diff",
4337
4477
  "--name-only",
4338
4478
  "-z",
@@ -4340,9 +4480,9 @@ function resolveChangedScope(cwd, request) {
4340
4480
  `${request.changedSince}...HEAD`,
4341
4481
  "--"
4342
4482
  ])) {
4343
- paths.add(path22);
4483
+ paths.add(path23);
4344
4484
  }
4345
- for (const path22 of gitPaths(cwd, [
4485
+ for (const path23 of gitPaths(cwd, [
4346
4486
  "diff",
4347
4487
  "--name-only",
4348
4488
  "-z",
@@ -4350,15 +4490,15 @@ function resolveChangedScope(cwd, request) {
4350
4490
  "HEAD",
4351
4491
  "--"
4352
4492
  ])) {
4353
- paths.add(path22);
4493
+ paths.add(path23);
4354
4494
  }
4355
- for (const path22 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4356
- paths.add(path22);
4495
+ for (const path23 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4496
+ paths.add(path23);
4357
4497
  }
4358
4498
  descriptions.push(`changed since ${request.changedSince}`);
4359
4499
  }
4360
4500
  if (request.staged === true) {
4361
- for (const path22 of gitPaths(cwd, [
4501
+ for (const path23 of gitPaths(cwd, [
4362
4502
  "diff",
4363
4503
  "--cached",
4364
4504
  "--name-only",
@@ -4366,10 +4506,10 @@ function resolveChangedScope(cwd, request) {
4366
4506
  "--relative",
4367
4507
  "--"
4368
4508
  ])) {
4369
- paths.add(path22);
4370
- stagedPaths.add(path22);
4509
+ paths.add(path23);
4510
+ stagedPaths.add(path23);
4371
4511
  }
4372
- for (const path22 of gitPaths(cwd, [
4512
+ for (const path23 of gitPaths(cwd, [
4373
4513
  "diff",
4374
4514
  "--cached",
4375
4515
  "--name-only",
@@ -4378,7 +4518,7 @@ function resolveChangedScope(cwd, request) {
4378
4518
  "--diff-filter=D",
4379
4519
  "--"
4380
4520
  ])) {
4381
- deletedPaths.add(path22);
4521
+ deletedPaths.add(path23);
4382
4522
  }
4383
4523
  descriptions.push("staged");
4384
4524
  }
@@ -4416,10 +4556,10 @@ var PYTHON_SUFFIXES = [".py", ".pyi", "/__init__.py", "/__init__.pyi"];
4416
4556
  var CASE_INSENSITIVE_FILESYSTEM = process.platform === "win32" || process.platform === "darwin";
4417
4557
  var TSCONFIG_CACHE = /* @__PURE__ */ new Map();
4418
4558
  function tsconfigPathsFor(cwd) {
4419
- const configPath = path16__namespace.join(cwd, "tsconfig.json");
4559
+ const configPath = path17__namespace.join(cwd, "tsconfig.json");
4420
4560
  let stats;
4421
4561
  try {
4422
- stats = fs15__namespace.statSync(configPath);
4562
+ stats = fs16__namespace.statSync(configPath);
4423
4563
  } catch (err) {
4424
4564
  if (err.code === "ENOENT") return null;
4425
4565
  return null;
@@ -4453,8 +4593,8 @@ function tsconfigPathsFor(cwd) {
4453
4593
  return value;
4454
4594
  }
4455
4595
  function repositoryRelative(cwd, target) {
4456
- const relative15 = path16__namespace.relative(cwd, target).replace(/\\/g, "/");
4457
- return relative15.length === 0 || !relative15.startsWith("..") && !path16__namespace.isAbsolute(relative15) ? relative15 : null;
4596
+ const relative15 = path17__namespace.relative(cwd, target).replace(/\\/g, "/");
4597
+ return relative15.length === 0 || !relative15.startsWith("..") && !path17__namespace.isAbsolute(relative15) ? relative15 : null;
4458
4598
  }
4459
4599
  function rememberFirst(map, key, value) {
4460
4600
  if (!map.has(key)) map.set(key, value);
@@ -4469,15 +4609,15 @@ function buildImportResolver(files, options = {}) {
4469
4609
  if (CASE_INSENSITIVE_FILESYSTEM) {
4470
4610
  rememberFirst(byPathFolded, relativePath.toLowerCase(), relativePath);
4471
4611
  }
4472
- const extension = path16__namespace.posix.extname(relativePath);
4612
+ const extension = path17__namespace.posix.extname(relativePath);
4473
4613
  if (!SOURCE_EXTENSIONS.has(extension)) return;
4474
4614
  const stem = relativePath.slice(0, -extension.length);
4475
4615
  rememberFirst(byStem, stem, relativePath);
4476
4616
  if (CASE_INSENSITIVE_FILESYSTEM) {
4477
4617
  rememberFirst(byStemFolded, stem.toLowerCase(), relativePath);
4478
4618
  }
4479
- if (path16__namespace.posix.basename(stem) === "index") {
4480
- const directory = path16__namespace.posix.dirname(stem);
4619
+ if (path17__namespace.posix.basename(stem) === "index") {
4620
+ const directory = path17__namespace.posix.dirname(stem);
4481
4621
  rememberFirst(byStem, directory, relativePath);
4482
4622
  if (CASE_INSENSITIVE_FILESYSTEM) {
4483
4623
  rememberFirst(byStemFolded, directory.toLowerCase(), relativePath);
@@ -4493,7 +4633,7 @@ function buildImportResolver(files, options = {}) {
4493
4633
  return { byPath, byPathFolded, byStem, byStemFolded, tsconfig: options.tsconfig ?? null };
4494
4634
  }
4495
4635
  function resolveSpecifier(fromFile, specifier, resolver) {
4496
- const extension = path16__namespace.posix.extname(fromFile).toLowerCase();
4636
+ const extension = path17__namespace.posix.extname(fromFile).toLowerCase();
4497
4637
  const exact = (key) => resolver.byPath.get(key) ?? (CASE_INSENSITIVE_FILESYSTEM ? resolver.byPathFolded.get(key.toLowerCase()) : void 0) ?? null;
4498
4638
  const firstOf = (candidates) => {
4499
4639
  for (const candidate of candidates) {
@@ -4516,34 +4656,34 @@ function resolveSpecifier(fromFile, specifier, resolver) {
4516
4656
  if (PYTHON_EXTENSIONS.has(extension) && specifier.startsWith(".")) {
4517
4657
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
4518
4658
  const rest = specifier.slice(dots).replace(/\./g, "/");
4519
- let base = path16__namespace.posix.dirname(fromFile);
4520
- for (let up = 1; up < dots; up += 1) base = path16__namespace.posix.dirname(base);
4521
- const joined2 = rest ? path16__namespace.posix.normalize(path16__namespace.posix.join(base, rest)) : base;
4659
+ let base = path17__namespace.posix.dirname(fromFile);
4660
+ for (let up = 1; up < dots; up += 1) base = path17__namespace.posix.dirname(base);
4661
+ const joined2 = rest ? path17__namespace.posix.normalize(path17__namespace.posix.join(base, rest)) : base;
4522
4662
  return firstOf([joined2, ...PYTHON_SUFFIXES.map((suffix) => `${joined2}${suffix}`)]);
4523
4663
  }
4524
4664
  if (RUBY_EXTENSIONS.has(extension) && specifier.startsWith("./")) {
4525
- const joined2 = path16__namespace.posix.normalize(
4526
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
4665
+ const joined2 = path17__namespace.posix.normalize(
4666
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4527
4667
  );
4528
4668
  return firstOf([`${joined2}.rb`, joined2]);
4529
4669
  }
4530
4670
  if (C_EXTENSIONS.has(extension) && specifier.startsWith("./")) {
4531
- const joined2 = path16__namespace.posix.normalize(
4532
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
4671
+ const joined2 = path17__namespace.posix.normalize(
4672
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4533
4673
  );
4534
4674
  return exact(joined2);
4535
4675
  }
4536
4676
  if (extension === ".dart" && !specifier.includes(":")) {
4537
- const joined2 = path16__namespace.posix.normalize(
4538
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
4677
+ const joined2 = path17__namespace.posix.normalize(
4678
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4539
4679
  );
4540
4680
  return firstOf([joined2, `${joined2}.dart`]);
4541
4681
  }
4542
4682
  if (!RELATIVE_SPECIFIER.test(specifier)) {
4543
4683
  return resolveTsconfigSpecifier(specifier, resolver, lookupPath);
4544
4684
  }
4545
- const joined = path16__namespace.posix.normalize(
4546
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
4685
+ const joined = path17__namespace.posix.normalize(
4686
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4547
4687
  );
4548
4688
  return lookupPath(joined);
4549
4689
  }
@@ -4567,13 +4707,13 @@ function resolveTsconfigSpecifier(specifier, resolver, lookupPath) {
4567
4707
  if (captured === null) continue;
4568
4708
  for (const target of rule.targets) {
4569
4709
  const substituted = target.split("*").join(captured);
4570
- const base = config.baseUrl === null ? substituted : path16__namespace.posix.join(config.baseUrl, substituted);
4571
- const hit = lookupPath(path16__namespace.posix.normalize(base));
4710
+ const base = config.baseUrl === null ? substituted : path17__namespace.posix.join(config.baseUrl, substituted);
4711
+ const hit = lookupPath(path17__namespace.posix.normalize(base));
4572
4712
  if (hit) return hit;
4573
4713
  }
4574
4714
  }
4575
4715
  if (config.baseUrl !== null) {
4576
- return lookupPath(path16__namespace.posix.normalize(path16__namespace.posix.join(config.baseUrl, specifier)));
4716
+ return lookupPath(path17__namespace.posix.normalize(path17__namespace.posix.join(config.baseUrl, specifier)));
4577
4717
  }
4578
4718
  return null;
4579
4719
  }
@@ -5193,9 +5333,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
5193
5333
  var jvmProfile = {
5194
5334
  id: "jvm",
5195
5335
  extensions: [".java", ".kt", ".kts", ".scala"],
5196
- summarize(path22, content) {
5336
+ summarize(path23, content) {
5197
5337
  const summary = emptySummary();
5198
- const lower = path22.toLowerCase();
5338
+ const lower = path23.toLowerCase();
5199
5339
  const isJava = lower.endsWith(".java");
5200
5340
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
5201
5341
  eachLine(content, (line) => {
@@ -5516,17 +5656,17 @@ var rustProfile = {
5516
5656
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script>/gi;
5517
5657
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
5518
5658
  var ASTRO_FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?=\r?\n|$)/;
5519
- function componentName(path22) {
5520
- const base = path22.split("/").pop() ?? path22;
5659
+ function componentName(path23) {
5660
+ const base = path23.split("/").pop() ?? path23;
5521
5661
  return base.replace(/\.[^.]+$/, "");
5522
5662
  }
5523
5663
  var sfcProfile = {
5524
5664
  id: "sfc",
5525
5665
  extensions: [".vue", ".svelte", ".astro"],
5526
- summarize(path22, content) {
5666
+ summarize(path23, content) {
5527
5667
  let script = "";
5528
- let usesJsx = path22.toLowerCase().endsWith(".astro");
5529
- if (path22.toLowerCase().endsWith(".astro")) {
5668
+ let usesJsx = path23.toLowerCase().endsWith(".astro");
5669
+ if (path23.toLowerCase().endsWith(".astro")) {
5530
5670
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
5531
5671
  if (frontmatter) script += `${frontmatter[1]}
5532
5672
  `;
@@ -5536,7 +5676,7 @@ var sfcProfile = {
5536
5676
  script += `${match[2]}
5537
5677
  `;
5538
5678
  }
5539
- const name = componentName(path22);
5679
+ const name = componentName(path23);
5540
5680
  if (!script.trim()) {
5541
5681
  const summary2 = emptySummary();
5542
5682
  if (name) {
@@ -5727,15 +5867,15 @@ for (const profile of LANGUAGE_PROFILES) {
5727
5867
  BY_EXTENSION.set(extension.toLowerCase(), profile);
5728
5868
  }
5729
5869
  }
5730
- function profileForPath(path22) {
5731
- const lower = path22.toLowerCase();
5870
+ function profileForPath(path23) {
5871
+ const lower = path23.toLowerCase();
5732
5872
  const dot = lower.lastIndexOf(".");
5733
5873
  if (dot === -1) return null;
5734
5874
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
5735
5875
  }
5736
- function summarizeWithProfile(path22, content) {
5737
- const profile = profileForPath(path22);
5738
- return profile ? profile.summarize(path22, content) : null;
5876
+ function summarizeWithProfile(path23, content) {
5877
+ const profile = profileForPath(path23);
5878
+ return profile ? profile.summarize(path23, content) : null;
5739
5879
  }
5740
5880
  var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
5741
5881
  ".png",
@@ -5780,7 +5920,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
5780
5920
  ".so"
5781
5921
  ]);
5782
5922
  function isBinaryExtension(filePath) {
5783
- const ext = path16__namespace.extname(filePath).toLowerCase();
5923
+ const ext = path17__namespace.extname(filePath).toLowerCase();
5784
5924
  return BINARY_EXTENSIONS.has(ext);
5785
5925
  }
5786
5926
  function countControlBytes(buffer) {
@@ -5947,13 +6087,13 @@ function isBinaryFile(absolutePath) {
5947
6087
  if (isBinaryExtension(absolutePath)) return true;
5948
6088
  let fd;
5949
6089
  try {
5950
- fd = fs15__namespace.openSync(absolutePath, "r");
6090
+ fd = fs16__namespace.openSync(absolutePath, "r");
5951
6091
  const buffer = Buffer.alloc(CHUNK);
5952
6092
  let sample;
5953
6093
  let position = 0;
5954
6094
  while (position < BINARY_SCAN_BYTES) {
5955
6095
  const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
5956
- const bytesRead = fs15__namespace.readSync(fd, buffer, 0, wanted, position);
6096
+ const bytesRead = fs16__namespace.readSync(fd, buffer, 0, wanted, position);
5957
6097
  if (bytesRead === 0) return false;
5958
6098
  const chunk = buffer.subarray(0, bytesRead);
5959
6099
  if (sample === void 0) {
@@ -5971,7 +6111,7 @@ function isBinaryFile(absolutePath) {
5971
6111
  } finally {
5972
6112
  if (fd !== void 0) {
5973
6113
  try {
5974
- fs15__namespace.closeSync(fd);
6114
+ fs16__namespace.closeSync(fd);
5975
6115
  } catch {
5976
6116
  }
5977
6117
  }
@@ -5993,9 +6133,9 @@ function importsOfText(relativePath, text2) {
5993
6133
  function importsOfFile(relativePath, absolutePath) {
5994
6134
  let buffer;
5995
6135
  try {
5996
- const stats = fs15__namespace.statSync(absolutePath);
6136
+ const stats = fs16__namespace.statSync(absolutePath);
5997
6137
  if (!stats.isFile() || stats.size > SUMMARY_MAX_SOURCE_BYTES) return [];
5998
- buffer = fs15__namespace.readFileSync(absolutePath);
6138
+ buffer = fs16__namespace.readFileSync(absolutePath);
5999
6139
  } catch {
6000
6140
  return [];
6001
6141
  }
@@ -6010,33 +6150,33 @@ function maskedPath(value, secretRules) {
6010
6150
  }
6011
6151
  function confineToDirectory(directory, filename) {
6012
6152
  if (filename.includes("\0")) return null;
6013
- if (path16__namespace.isAbsolute(filename)) return null;
6014
- const base = path16__namespace.resolve(directory);
6015
- const resolved = path16__namespace.resolve(base, filename);
6153
+ if (path17__namespace.isAbsolute(filename)) return null;
6154
+ const base = path17__namespace.resolve(directory);
6155
+ const resolved = path17__namespace.resolve(base, filename);
6016
6156
  const caseInsensitive = process.platform === "win32" || process.platform === "darwin";
6017
- const prefix = caseInsensitive ? `${base}${path16__namespace.sep}`.toLowerCase() : `${base}${path16__namespace.sep}`;
6157
+ const prefix = caseInsensitive ? `${base}${path17__namespace.sep}`.toLowerCase() : `${base}${path17__namespace.sep}`;
6018
6158
  const candidate = caseInsensitive ? resolved.toLowerCase() : resolved;
6019
6159
  return candidate.startsWith(prefix) ? resolved : null;
6020
6160
  }
6021
6161
  function findStagingDirectory(config) {
6022
- const tmpDir = path16__namespace.resolve(config.cwd, config.tmpDir);
6162
+ const tmpDir = path17__namespace.resolve(config.cwd, config.tmpDir);
6023
6163
  let entries;
6024
6164
  try {
6025
- entries = fs15__namespace.readdirSync(tmpDir);
6165
+ entries = fs16__namespace.readdirSync(tmpDir);
6026
6166
  } catch {
6027
6167
  return null;
6028
6168
  }
6029
6169
  const runs = entries.filter((name) => name.startsWith("run-")).sort();
6030
6170
  const newest = runs[runs.length - 1];
6031
- return newest ? path16__namespace.join(tmpDir, newest) : null;
6171
+ return newest ? path17__namespace.join(tmpDir, newest) : null;
6032
6172
  }
6033
6173
  function describeMissingManifest(config, manifestPath) {
6034
- const outDir = path16__namespace.resolve(config.cwd, config.outDir);
6035
- const markerPath = path16__namespace.join(outDir, ".codebase-snapshot");
6174
+ const outDir = path17__namespace.resolve(config.cwd, config.outDir);
6175
+ const markerPath = path17__namespace.join(outDir, ".codebase-snapshot");
6036
6176
  let marker2 = null;
6037
6177
  try {
6038
- if (fs15__namespace.existsSync(markerPath)) {
6039
- const parsed = JSON.parse(fs15__namespace.readFileSync(markerPath, "utf8"));
6178
+ if (fs16__namespace.existsSync(markerPath)) {
6179
+ const parsed = JSON.parse(fs16__namespace.readFileSync(markerPath, "utf8"));
6040
6180
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
6041
6181
  marker2 = parsed;
6042
6182
  }
@@ -6071,13 +6211,13 @@ function sha256Hex(buffer) {
6071
6211
  return crypto3__namespace.createHash("sha256").update(buffer).digest("hex");
6072
6212
  }
6073
6213
  function wouldNowBeIncluded(cwd, relativePath) {
6074
- const absolutePath = path16__namespace.join(cwd, relativePath);
6214
+ const absolutePath = path17__namespace.join(cwd, relativePath);
6075
6215
  try {
6076
- const stats = fs15__namespace.statSync(absolutePath);
6216
+ const stats = fs16__namespace.statSync(absolutePath);
6077
6217
  if (!stats.isFile()) return false;
6078
6218
  if (isBinaryExtension(absolutePath)) return false;
6079
6219
  if (stats.size > BINARY_SCAN_BYTES && isBinaryFile(absolutePath)) return false;
6080
- return !decodeText(fs15__namespace.readFileSync(absolutePath)).binary;
6220
+ return !decodeText(fs16__namespace.readFileSync(absolutePath)).binary;
6081
6221
  } catch {
6082
6222
  return false;
6083
6223
  }
@@ -6089,7 +6229,7 @@ var TRUNCATION_REASONS = /* @__PURE__ */ new Set([
6089
6229
  ]);
6090
6230
  function isConfinedRelative(value) {
6091
6231
  if (value.length === 0 || value.includes("\0") || value.includes("\\")) return false;
6092
- if (path16__namespace.isAbsolute(value)) return false;
6232
+ if (path17__namespace.isAbsolute(value)) return false;
6093
6233
  return !value.split("/").includes("..");
6094
6234
  }
6095
6235
  function describeManifestShapeProblem(value) {
@@ -6257,7 +6397,7 @@ function describeManifestShapeProblem(value) {
6257
6397
  if (typeof filename !== "string" || filename.trim() === "") {
6258
6398
  return 'a "parts" entry has no "filename"';
6259
6399
  }
6260
- if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path16__namespace.isAbsolute(filename)) {
6400
+ if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path17__namespace.isAbsolute(filename)) {
6261
6401
  return 'a "parts" entry "filename" must be a bare filename inside parts/';
6262
6402
  }
6263
6403
  if (currentSchema) {
@@ -6283,8 +6423,8 @@ function describeManifestShapeProblem(value) {
6283
6423
  function validateSnapshot(configInput) {
6284
6424
  assertUsableConfigInput(configInput);
6285
6425
  const config = isResolvedConfig(configInput) ? normalizeResolvedConfig(configInput) : resolveConfig(configInput);
6286
- const manifestPath = path16__namespace.resolve(config.cwd, config.outDir, "manifest.json");
6287
- if (!fs15__namespace.existsSync(manifestPath)) {
6426
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
6427
+ if (!fs16__namespace.existsSync(manifestPath)) {
6288
6428
  return {
6289
6429
  valid: false,
6290
6430
  manifestPresent: false,
@@ -6295,7 +6435,7 @@ function validateSnapshot(configInput) {
6295
6435
  }
6296
6436
  let manifest;
6297
6437
  try {
6298
- manifest = JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
6438
+ manifest = JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
6299
6439
  } catch (err) {
6300
6440
  return {
6301
6441
  valid: false,
@@ -6317,7 +6457,7 @@ function validateSnapshot(configInput) {
6317
6457
  }
6318
6458
  const drift = emptyDrift();
6319
6459
  const warnings = [];
6320
- const snapshotDir = path16__namespace.resolve(config.cwd, config.outDir);
6460
+ const snapshotDir = path17__namespace.resolve(config.cwd, config.outDir);
6321
6461
  const unreadableSkips = manifest.skipped.filter(
6322
6462
  (entry) => entry.reason === "missing" || entry.reason === "read-error"
6323
6463
  );
@@ -6420,7 +6560,7 @@ function validateSnapshot(configInput) {
6420
6560
  );
6421
6561
  return importsChangedFile(
6422
6562
  diskFile,
6423
- importsOfFile(diskFile, path16__namespace.join(config.cwd, diskFile)),
6563
+ importsOfFile(diskFile, path17__namespace.join(config.cwd, diskFile)),
6424
6564
  unchangedScope,
6425
6565
  dependentResolver
6426
6566
  );
@@ -6438,7 +6578,7 @@ function validateSnapshot(configInput) {
6438
6578
  // own output directory as a set of files missing from the snapshot, so a correct
6439
6579
  // snapshot was reported as drifting.
6440
6580
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
6441
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
6581
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
6442
6582
  ).filter((relative15) => relative15.length > 0 && !relative15.startsWith(".."))
6443
6583
  });
6444
6584
  for (const diskFile of collection.files) {
@@ -6464,7 +6604,7 @@ function validateSnapshot(configInput) {
6464
6604
  }
6465
6605
  let diskHash;
6466
6606
  try {
6467
- diskHash = sha256Hex(fs15__namespace.readFileSync(path16__namespace.join(config.cwd, diskFile)));
6607
+ diskHash = sha256Hex(fs16__namespace.readFileSync(path17__namespace.join(config.cwd, diskFile)));
6468
6608
  } catch (err) {
6469
6609
  if (err.code === "ENOENT") {
6470
6610
  drift.missingOnDisk.push(diskFile);
@@ -6488,7 +6628,7 @@ function validateSnapshot(configInput) {
6488
6628
  }
6489
6629
  let statFailure = null;
6490
6630
  try {
6491
- fs15__namespace.statSync(confined);
6631
+ fs16__namespace.statSync(confined);
6492
6632
  } catch (err) {
6493
6633
  statFailure = err;
6494
6634
  }
@@ -6508,7 +6648,7 @@ function validateSnapshot(configInput) {
6508
6648
  ...Object.values(config.budgets.byLayer)
6509
6649
  );
6510
6650
  const partNames = /* @__PURE__ */ new Set();
6511
- const partsDir = path16__namespace.join(snapshotDir, "parts");
6651
+ const partsDir = path17__namespace.join(snapshotDir, "parts");
6512
6652
  for (const part of manifest.parts) {
6513
6653
  if (!part || typeof part.filename !== "string") continue;
6514
6654
  partNames.add(part.filename);
@@ -6523,7 +6663,7 @@ function validateSnapshot(configInput) {
6523
6663
  }
6524
6664
  let buffer;
6525
6665
  try {
6526
- buffer = fs15__namespace.readFileSync(partPath);
6666
+ buffer = fs16__namespace.readFileSync(partPath);
6527
6667
  } catch {
6528
6668
  drift.partIssues.push({ part: part.filename, issue: "missing from snapshot/parts" });
6529
6669
  continue;
@@ -6879,11 +7019,11 @@ function validateSnapshot(configInput) {
6879
7019
  ];
6880
7020
  for (const [key, artifact] of declaredArtifacts) {
6881
7021
  if (!artifact) continue;
6882
- const artifactPath = path16__namespace.join(snapshotDir, ...key.split("/"));
7022
+ const artifactPath = path17__namespace.join(snapshotDir, ...key.split("/"));
6883
7023
  let buffer;
6884
7024
  try {
6885
- if (!fs15__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
6886
- buffer = fs15__namespace.readFileSync(artifactPath);
7025
+ if (!fs16__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
7026
+ buffer = fs16__namespace.readFileSync(artifactPath);
6887
7027
  } catch {
6888
7028
  drift.partIssues.push({ part: key, issue: "declared artifact is missing" });
6889
7029
  continue;
@@ -6896,9 +7036,9 @@ function validateSnapshot(configInput) {
6896
7036
  for (const match of buffer.toString("utf8").matchAll(/\]\(([^)\s]+)\)/g)) {
6897
7037
  const target = match[1].split("#")[0];
6898
7038
  if (target.length === 0 || /^[a-z][a-z0-9+.-]*:/i.test(target)) continue;
6899
- const resolved = path16__namespace.resolve(snapshotDir, "reports", target);
6900
- const relative15 = path16__namespace.relative(snapshotDir, resolved);
6901
- if (relative15.startsWith("..") || path16__namespace.isAbsolute(relative15) || !fs15__namespace.existsSync(resolved)) {
7039
+ const resolved = path17__namespace.resolve(snapshotDir, "reports", target);
7040
+ const relative15 = path17__namespace.relative(snapshotDir, resolved);
7041
+ if (relative15.startsWith("..") || path17__namespace.isAbsolute(relative15) || !fs16__namespace.existsSync(resolved)) {
6902
7042
  drift.partIssues.push({
6903
7043
  part: key,
6904
7044
  issue: `links to ${maskedPath(target, config.secretRules)}, which does not exist in the snapshot`
@@ -6911,7 +7051,7 @@ function validateSnapshot(configInput) {
6911
7051
  if (sarifArtifact) {
6912
7052
  const sarifKey = "reports/audit.sarif";
6913
7053
  try {
6914
- const buffer = fs15__namespace.readFileSync(path16__namespace.join(snapshotDir, "reports", "audit.sarif"));
7054
+ const buffer = fs16__namespace.readFileSync(path17__namespace.join(snapshotDir, "reports", "audit.sarif"));
6915
7055
  if (sha256Hex(buffer) !== sarifArtifact.sha256 || buffer.length !== sarifArtifact.byteSize) {
6916
7056
  drift.partIssues.push({ part: sarifKey, issue: "artifact does not match its recorded digest" });
6917
7057
  }
@@ -7195,14 +7335,14 @@ function compareManifests(before, after, secretRules) {
7195
7335
  function loadManifest(target) {
7196
7336
  let isDirectory;
7197
7337
  try {
7198
- isDirectory = fs15__namespace.statSync(target).isDirectory();
7338
+ isDirectory = fs16__namespace.statSync(target).isDirectory();
7199
7339
  } catch {
7200
7340
  throw new Error(`No snapshot found at ${target}: the path does not exist.`);
7201
7341
  }
7202
- const manifestPath = isDirectory ? path16__namespace.join(target, "manifest.json") : target;
7342
+ const manifestPath = isDirectory ? path17__namespace.join(target, "manifest.json") : target;
7203
7343
  let raw;
7204
7344
  try {
7205
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
7345
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
7206
7346
  } catch {
7207
7347
  throw new Error(`Could not read a manifest at ${manifestPath}.`);
7208
7348
  }
@@ -7435,10 +7575,10 @@ var LANGUAGE_BY_BASENAME = {
7435
7575
  };
7436
7576
  function detectLanguage(filePath) {
7437
7577
  const normalized = filePath.replace(/\\/g, "/");
7438
- const base = path16__namespace.posix.basename(normalized);
7578
+ const base = path17__namespace.posix.basename(normalized);
7439
7579
  if (LANGUAGE_BY_BASENAME[base]) return LANGUAGE_BY_BASENAME[base];
7440
7580
  if (base === ".env" || base.startsWith(".env.")) return "dotenv";
7441
- const ext = path16__namespace.posix.extname(base).toLowerCase();
7581
+ const ext = path17__namespace.posix.extname(base).toLowerCase();
7442
7582
  return LANGUAGE_BY_EXTENSION[ext] ?? "text";
7443
7583
  }
7444
7584
 
@@ -7480,13 +7620,13 @@ function describeMatcher(matcher) {
7480
7620
  return String(matcher);
7481
7621
  }
7482
7622
  function normalizeTarget(cwd, target) {
7483
- const resolvedCwd = path16__namespace.resolve(cwd);
7484
- const absolute = path16__namespace.resolve(resolvedCwd, target);
7485
- const relative15 = path16__namespace.relative(resolvedCwd, absolute);
7486
- if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path16__namespace.sep}`) || path16__namespace.isAbsolute(relative15)) {
7623
+ const resolvedCwd = path17__namespace.resolve(cwd);
7624
+ const absolute = path17__namespace.resolve(resolvedCwd, target);
7625
+ const relative15 = path17__namespace.relative(resolvedCwd, absolute);
7626
+ if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative15)) {
7487
7627
  return { relative: target.replace(/\\/g, "/"), outsideRoot: true };
7488
7628
  }
7489
- return { relative: relative15.split(path16__namespace.sep).join("/"), outsideRoot: false };
7629
+ return { relative: relative15.split(path17__namespace.sep).join("/"), outsideRoot: false };
7490
7630
  }
7491
7631
  function findRuleMatch(rules, relativePath) {
7492
7632
  return rules.find(
@@ -7505,9 +7645,9 @@ function findRecordedAncestor(skipped, relative15, maskedPath2) {
7505
7645
  return nearest;
7506
7646
  }
7507
7647
  function readManifest2(config) {
7508
- const manifestPath = path16__namespace.resolve(config.cwd, config.outDir, "manifest.json");
7648
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
7509
7649
  try {
7510
- return JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
7650
+ return JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
7511
7651
  } catch {
7512
7652
  return null;
7513
7653
  }
@@ -7525,10 +7665,10 @@ function explainPath(config, target) {
7525
7665
  detail: "path resolves outside the configured repository root and was not inspected"
7526
7666
  };
7527
7667
  }
7528
- const absolute = path16__namespace.join(config.cwd, relative15);
7668
+ const absolute = path17__namespace.join(config.cwd, relative15);
7529
7669
  const result = {
7530
7670
  path: maskedPath2,
7531
- exists: fs15__namespace.existsSync(absolute),
7671
+ exists: fs16__namespace.existsSync(absolute),
7532
7672
  included: false
7533
7673
  };
7534
7674
  const collection = collectFiles(config.cwd, {
@@ -7542,7 +7682,7 @@ function explainPath(config, target) {
7542
7682
  // Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
7543
7683
  // that is only missing because the walker dropped the tool's own output directory.
7544
7684
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
7545
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
7685
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
7546
7686
  ).filter((relative16) => relative16.length > 0 && !relative16.startsWith(".."))
7547
7687
  });
7548
7688
  if (!collection.files.includes(relative15)) {
@@ -7607,7 +7747,7 @@ function explainPath(config, target) {
7607
7747
  }
7608
7748
  let sizeOnDisk = null;
7609
7749
  try {
7610
- sizeOnDisk = fs15__namespace.statSync(absolute).size;
7750
+ sizeOnDisk = fs16__namespace.statSync(absolute).size;
7611
7751
  } catch {
7612
7752
  sizeOnDisk = null;
7613
7753
  }
@@ -7617,10 +7757,10 @@ function explainPath(config, target) {
7617
7757
  result.detail = "binary content; generate skips it and records `binary` in manifest.skipped[]";
7618
7758
  return result;
7619
7759
  }
7620
- if (fs15__namespace.existsSync(absolute) && fs15__namespace.statSync(absolute).isFile()) {
7760
+ if (fs16__namespace.existsSync(absolute) && fs16__namespace.statSync(absolute).isFile()) {
7621
7761
  let buffer;
7622
7762
  try {
7623
- buffer = fs15__namespace.readFileSync(absolute);
7763
+ buffer = fs16__namespace.readFileSync(absolute);
7624
7764
  } catch (err) {
7625
7765
  result.included = false;
7626
7766
  result.reason = "read-error";
@@ -7746,15 +7886,15 @@ function canonicalIgnorePattern(line) {
7746
7886
  function appendGitignoreEntries(cwd, entries) {
7747
7887
  const wanted = [...new Set(entries)].filter((entry) => entry.trim().length > 0);
7748
7888
  if (wanted.length === 0) return { added: [], note: null };
7749
- const ignorePath = path16__namespace.join(cwd, ".gitignore");
7889
+ const ignorePath = path17__namespace.join(cwd, ".gitignore");
7750
7890
  const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
7751
7891
  let decoded = { text: "", bom: Buffer.alloc(0), encoding: "utf8" };
7752
7892
  try {
7753
- if (fs15__namespace.existsSync(ignorePath)) {
7754
- if (fs15__namespace.statSync(ignorePath).isDirectory()) {
7893
+ if (fs16__namespace.existsSync(ignorePath)) {
7894
+ if (fs16__namespace.statSync(ignorePath).isDirectory()) {
7755
7895
  return { added: [], note: `${ignorePath} is a directory, so it was not updated. ${manual}` };
7756
7896
  }
7757
- const read = decodeGitignore(fs15__namespace.readFileSync(ignorePath));
7897
+ const read = decodeGitignore(fs16__namespace.readFileSync(ignorePath));
7758
7898
  if (read === null) {
7759
7899
  return {
7760
7900
  added: [],
@@ -7776,7 +7916,7 @@ function appendGitignoreEntries(cwd, entries) {
7776
7916
  const newline = existing.includes("\r\n") ? "\r\n" : "\n";
7777
7917
  const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : newline;
7778
7918
  try {
7779
- fs15__namespace.writeFileSync(
7919
+ fs16__namespace.writeFileSync(
7780
7920
  ignorePath,
7781
7921
  encodeGitignore(decoded, `${existing}${prefix}${added.join(newline)}${newline}`)
7782
7922
  );
@@ -7786,7 +7926,7 @@ function appendGitignoreEntries(cwd, entries) {
7786
7926
  return { added, note: null };
7787
7927
  }
7788
7928
  function gitignorePath(cwd, filePath) {
7789
- return path16__namespace.relative(cwd, filePath).split(path16__namespace.sep).join("/");
7929
+ return path17__namespace.relative(cwd, filePath).split(path17__namespace.sep).join("/");
7790
7930
  }
7791
7931
 
7792
7932
  // src/wizard/config-template.ts
@@ -7937,6 +8077,10 @@ function renderConfig(answers) {
7937
8077
  // Experimental: grow the per-part budget until the snapshot fits this many parts, instead of
7938
8078
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
7939
8079
  // maxParts: 10,
8080
+ // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
8081
+ // brief: "docs/brief.md",
8082
+ // Which job the brief is written for: audit, review or explain.
8083
+ // promptTask: "audit",
7940
8084
  // afterGenerate: (manifest) => { /* write your own artifact */ }
7941
8085
  hooks: {},
7942
8086
  };
@@ -8331,7 +8475,7 @@ function parsePackageJson(raw) {
8331
8475
  }
8332
8476
  function readPackageJson(cwd) {
8333
8477
  try {
8334
- return parsePackageJson(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"));
8478
+ return parsePackageJson(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"));
8335
8479
  } catch {
8336
8480
  return null;
8337
8481
  }
@@ -8368,7 +8512,7 @@ function artifactAnswers(options) {
8368
8512
  }
8369
8513
  function topLevelDirs(cwd) {
8370
8514
  try {
8371
- return fs15__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
8515
+ return fs16__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
8372
8516
  } catch {
8373
8517
  return [];
8374
8518
  }
@@ -8383,7 +8527,7 @@ function writeFileOrExplain(target, content) {
8383
8527
  try {
8384
8528
  let stats = null;
8385
8529
  try {
8386
- stats = fs15__namespace.lstatSync(target);
8530
+ stats = fs16__namespace.lstatSync(target);
8387
8531
  } catch {
8388
8532
  stats = null;
8389
8533
  }
@@ -8398,12 +8542,12 @@ function writeFileOrExplain(target, content) {
8398
8542
  );
8399
8543
  }
8400
8544
  const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
8401
- fs15__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
8545
+ fs16__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
8402
8546
  try {
8403
- fs15__namespace.renameSync(temporary, target);
8547
+ fs16__namespace.renameSync(temporary, target);
8404
8548
  } catch (err) {
8405
8549
  try {
8406
- fs15__namespace.unlinkSync(temporary);
8550
+ fs16__namespace.unlinkSync(temporary);
8407
8551
  } catch {
8408
8552
  }
8409
8553
  throw err;
@@ -8451,19 +8595,19 @@ function serializePackageJson(raw, value) {
8451
8595
  return `${bom}${text2}${raw.endsWith("\n") ? crlf ? "\r\n" : "\n" : ""}`;
8452
8596
  }
8453
8597
  function updatePackageJson(cwd, notes) {
8454
- const packagePath = path16__namespace.join(cwd, "package.json");
8598
+ const packagePath = path17__namespace.join(cwd, "package.json");
8455
8599
  const unchanged = {
8456
8600
  scripts: [],
8457
8601
  dependency: { name: GENERATOR_NAME, range: null, added: false }
8458
8602
  };
8459
- if (!fs15__namespace.existsSync(packagePath)) {
8603
+ if (!fs16__namespace.existsSync(packagePath)) {
8460
8604
  notes.push("No package.json found, so npm scripts and the devDependency were not added.");
8461
8605
  return unchanged;
8462
8606
  }
8463
8607
  let raw;
8464
8608
  let parsed;
8465
8609
  try {
8466
- raw = fs15__namespace.readFileSync(packagePath, "utf8");
8610
+ raw = fs16__namespace.readFileSync(packagePath, "utf8");
8467
8611
  parsed = parsePackageJson(raw);
8468
8612
  } catch {
8469
8613
  notes.push("Could not parse package.json; npm scripts and the devDependency were not added.");
@@ -8538,8 +8682,8 @@ function gitignoreEntriesFor(cwd, outDir, tmpDir) {
8538
8682
  const entries = [];
8539
8683
  for (const directory of [outDir, tmpDir]) {
8540
8684
  if (directory === null) continue;
8541
- const relative15 = path16__namespace.relative(cwd, path16__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
8542
- if (relative15 === "" || relative15 === "." || relative15.startsWith("..") || path16__namespace.isAbsolute(relative15)) {
8685
+ const relative15 = path17__namespace.relative(cwd, path17__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
8686
+ if (relative15 === "" || relative15 === "." || relative15.startsWith("..") || path17__namespace.isAbsolute(relative15)) {
8543
8687
  continue;
8544
8688
  }
8545
8689
  entries.push(`/${relative15}/`);
@@ -8791,7 +8935,7 @@ async function runInit(options) {
8791
8935
  const configText = renderConfig(answers);
8792
8936
  const preferredName = chooseConfigFileName(options.cwd);
8793
8937
  const presentConfigs = CONFIG_CANDIDATES.filter(
8794
- (name) => fs15__namespace.existsSync(path16__namespace.join(options.cwd, name))
8938
+ (name) => fs16__namespace.existsSync(path17__namespace.join(options.cwd, name))
8795
8939
  );
8796
8940
  const present = presentConfigs[0] ?? null;
8797
8941
  if (presentConfigs.length > 1) {
@@ -8800,7 +8944,7 @@ async function runInit(options) {
8800
8944
  );
8801
8945
  }
8802
8946
  const configName = present !== null && options.force ? present : preferredName;
8803
- const configPath = path16__namespace.join(options.cwd, configName);
8947
+ const configPath = path17__namespace.join(options.cwd, configName);
8804
8948
  const reused = present !== null && options.force !== true && options.reuseConfig === true;
8805
8949
  if (reused) notes.push(`Kept the existing ${present} instead of writing a new one.`);
8806
8950
  if (options.dryRun) {
@@ -8834,7 +8978,7 @@ async function runInit(options) {
8834
8978
  '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.'
8835
8979
  );
8836
8980
  }
8837
- if (fs15__namespace.existsSync(configPath) && !options.force && !reused) {
8981
+ if (fs16__namespace.existsSync(configPath) && !options.force && !reused) {
8838
8982
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
8839
8983
  }
8840
8984
  if (!reused) writeFileOrExplain(configPath, configText);
@@ -8860,9 +9004,9 @@ async function runInit(options) {
8860
9004
  };
8861
9005
  }
8862
9006
  function describeTarget(cwd) {
8863
- const relative15 = path16__namespace.relative(process.cwd(), cwd);
9007
+ const relative15 = path17__namespace.relative(process.cwd(), cwd);
8864
9008
  if (relative15 === "") return "this directory";
8865
- if (relative15.startsWith("..") || path16__namespace.isAbsolute(relative15)) return cwd;
9009
+ if (relative15.startsWith("..") || path17__namespace.isAbsolute(relative15)) return cwd;
8866
9010
  return relative15;
8867
9011
  }
8868
9012
  function firstRunMessage(reason, cwd) {
@@ -8886,7 +9030,7 @@ function planFirstRun(facts) {
8886
9030
  var NOT_CONTENT = /* @__PURE__ */ new Set([".git", ".hg", ".svn", ".bzr", ".DS_Store", "Thumbs.db"]);
8887
9031
  function isEffectivelyEmpty(cwd) {
8888
9032
  try {
8889
- return fs15__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
9033
+ return fs16__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
8890
9034
  } catch {
8891
9035
  return false;
8892
9036
  }
@@ -8894,7 +9038,7 @@ function isEffectivelyEmpty(cwd) {
8894
9038
  function hasPriorSnapshot(cwd, outDir) {
8895
9039
  let parsed;
8896
9040
  try {
8897
- parsed = JSON.parse(fs15__namespace.readFileSync(path16__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
9041
+ parsed = JSON.parse(fs16__namespace.readFileSync(path17__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
8898
9042
  } catch {
8899
9043
  return false;
8900
9044
  }
@@ -9733,9 +9877,15 @@ var UNLIMITED_SLOTS = 0;
9733
9877
  var ENTRY_POINT = /(^|\/)(index|cli|main|bin|server|app|mod)\.[cm]?[jt]sx?$/;
9734
9878
  var TEST_PATH = /(^|\/)(tests?|__tests__)\//;
9735
9879
  var TEST_FILE = /\.(test|spec)\.[^.]+$/;
9736
- function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMENT_SLOTS, history = []) {
9880
+ function generatePrompt(manifest, artifacts, context = {}) {
9881
+ const slots = context.slots ?? DEFAULT_ATTACHMENT_SLOTS;
9882
+ const task = context.task ?? "audit";
9883
+ const history = context.history ?? [];
9884
+ const overview = context.overview ?? { releases: [] };
9885
+ const brief = context.brief;
9737
9886
  const wrote = (name) => artifacts?.[name] !== false;
9738
9887
  const code = (value) => inlineCode(escapeControls(value));
9888
+ const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
9739
9889
  const lines = [
9740
9890
  "# PROMPT.md",
9741
9891
  "",
@@ -9751,30 +9901,22 @@ function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMEN
9751
9901
  "You are working on a codebase you cannot clone, run or grep. Everything you know about it comes",
9752
9902
  "from the snapshot that follows this instruction. Where these notes and the snapshot disagree,",
9753
9903
  "the snapshot is what exists.",
9754
- "",
9755
- "## The job",
9756
- "",
9757
- "Find what is still wrong or will break. How you read the code is yours to decide - by",
9758
- "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
9759
- "honest account of what you covered and what you did not.",
9760
- "",
9761
- 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,",
9762
- 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.",
9763
- 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.",
9764
- "",
9765
- "If the task at the end asks for something narrower - explain a file, review a change, answer a",
9766
- "question - that task wins. The standard and the coverage duty below still apply to it.",
9767
9904
  ""
9768
9905
  ];
9906
+ if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
9907
+ lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
9908
+ lines.push(...stakesSection(brief, code));
9769
9909
  lines.push(...haveSection(wrote), "");
9770
- lines.push(...systemSection(manifest, code), "");
9771
- lines.push(...historySection(history), "");
9772
- lines.push(...barSection(), "");
9910
+ lines.push(...whatThisIsSection(overview), "");
9911
+ lines.push(...systemSection(manifest, code, brief), "");
9912
+ lines.push(...historySection(history, brief, code), "");
9913
+ lines.push(...barSection(brief, code), "");
9773
9914
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
9774
9915
  lines.push(...answerSection(), "");
9775
- lines.push(...calibrationSection(), "");
9916
+ lines.push(...calibrationSection(brief, code), "");
9917
+ lines.push(...ownerNotesSection(brief, code));
9776
9918
  lines.push(...snapshotSection(manifest, code), "");
9777
- lines.push(...deliverySection(manifest, wrote("parts"), attachmentSlots));
9919
+ lines.push(...deliverySection(manifest, wrote("parts"), slots));
9778
9920
  lines.push(
9779
9921
  "## Your task",
9780
9922
  "",
@@ -9851,8 +9993,11 @@ function haveSection(wrote) {
9851
9993
  out.push(...bullets);
9852
9994
  return out;
9853
9995
  }
9854
- function systemSection(manifest, code) {
9996
+ function systemSection(manifest, code, brief) {
9855
9997
  const out = ["## The system", ""];
9998
+ if (brief?.system !== void 0) {
9999
+ out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
10000
+ }
9856
10001
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
9857
10002
  if (layers.length > 0) {
9858
10003
  const shown = layers.slice(0, MAX_LAYER_ROWS).map(([name, count]) => code(name) + " " + formatNumber(count));
@@ -9867,7 +10012,7 @@ function systemSection(manifest, code) {
9867
10012
  " A change here reaches the most call sites; read it before judging anything that uses it."
9868
10013
  );
9869
10014
  }
9870
- const entryPoints = manifest.files.map((file) => file.relativePath).filter((path22) => ENTRY_POINT.test(path22)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
10015
+ const entryPoints = manifest.files.map((file) => file.relativePath).filter((path23) => ENTRY_POINT.test(path23)).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length).slice(0, MAX_ENTRY_POINTS);
9871
10016
  out.push(
9872
10017
  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"
9873
10018
  );
@@ -9910,8 +10055,9 @@ function systemSection(manifest, code) {
9910
10055
  }
9911
10056
  return out;
9912
10057
  }
9913
- function historySection(history) {
10058
+ function historySection(history, brief, code) {
9914
10059
  const out = ["## What came before", ""];
10060
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
9915
10061
  if (history.length === 0) {
9916
10062
  out.push(
9917
10063
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -9920,15 +10066,21 @@ function historySection(history) {
9920
10066
  return out;
9921
10067
  }
9922
10068
  out.push(
9923
- "Commit subjects, newest first. They are claims by whoever wrote them, not evidence - the code",
9924
- "beside them is the evidence. If one of these fixes looks incomplete, quote the lines and say",
9925
- "which call site it missed.",
10069
+ "The last " + formatNumber(history.length) + " " + (history.length === 1 ? "commit" : "commits") + ", newest first. Subjects and bodies are claims",
10070
+ "by whoever wrote them, not evidence - the code beside them is the evidence. If one of these",
10071
+ "fixes looks incomplete, quote the lines and say which call site it missed.",
9926
10072
  ""
9927
10073
  );
9928
- for (const subject of history) out.push("- " + subject);
10074
+ for (const commit of history) {
10075
+ out.push("- " + commit.subject);
10076
+ if (commit.body.length > 0) out.push(" " + commit.body);
10077
+ }
9929
10078
  return out;
9930
10079
  }
9931
- function barSection() {
10080
+ function barSection(brief, code) {
10081
+ if (brief?.bar !== void 0) {
10082
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
10083
+ }
9932
10084
  return [
9933
10085
  "## The bar",
9934
10086
  "",
@@ -9986,7 +10138,10 @@ function answerSection() {
9986
10138
  " the gap you filled by asking instead of guessing."
9987
10139
  ];
9988
10140
  }
9989
- function calibrationSection() {
10141
+ function calibrationSection(brief, code) {
10142
+ if (brief?.calibration !== void 0) {
10143
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
10144
+ }
9990
10145
  return [
9991
10146
  "## Calibration",
9992
10147
  "",
@@ -10001,6 +10156,84 @@ function calibrationSection() {
10001
10156
  "None of these throw. All are invisible in a summary."
10002
10157
  ];
10003
10158
  }
10159
+ function jobSection(task, hasHistory) {
10160
+ const out = ["## The job", ""];
10161
+ if (task === "audit") {
10162
+ out.push(
10163
+ "Find what is still wrong or will break. How you read the code is yours to decide - by",
10164
+ "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
10165
+ "honest account of what you covered and what you did not.",
10166
+ ""
10167
+ );
10168
+ if (hasHistory) {
10169
+ out.push(
10170
+ "Another pass of the same findings is worth nothing. This repository carries a record of",
10171
+ "what was already fixed, below. Verify that those fixes hold instead of rediscovering them,",
10172
+ "and treat a variant of one at a different call site as a new finding."
10173
+ );
10174
+ } else {
10175
+ out.push(
10176
+ "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
10177
+ "so you cannot tell what has already been tried. Do not assume this is the first attempt."
10178
+ );
10179
+ }
10180
+ out.push(
10181
+ "",
10182
+ "If the task at the end asks for something narrower - explain a file, review a change, answer",
10183
+ "a question - that task wins. The standard and the coverage duty below still apply to it."
10184
+ );
10185
+ } else if (task === "review") {
10186
+ out.push(
10187
+ "Review the change or the area named in the task against this snapshot. Report what breaks,",
10188
+ "what the change claims but does not do, and what a reader would believe that the code does",
10189
+ "not support. Restating the diff is not a review; the standard and the coverage duty below",
10190
+ "still apply."
10191
+ );
10192
+ } else {
10193
+ out.push(
10194
+ "Explain how the part of the system named in the task works: the data flow, the boundaries",
10195
+ "and the invariants it depends on. Cite the lines. If the snapshot does not contain what you",
10196
+ "need, say which file you need rather than reconstructing it from the shape of the names."
10197
+ );
10198
+ }
10199
+ return out;
10200
+ }
10201
+ function stakesSection(brief, code) {
10202
+ if (brief?.stakes === void 0) return [];
10203
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
10204
+ }
10205
+ function whatThisIsSection(overview) {
10206
+ const body = [];
10207
+ if (overview.description !== void 0) {
10208
+ body.push("- Declared in `package.json`: " + overview.description);
10209
+ }
10210
+ if (overview.summary !== void 0) {
10211
+ body.push("- From the `README.md` first paragraph: " + overview.summary);
10212
+ }
10213
+ if (overview.releases.length > 0) {
10214
+ body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
10215
+ }
10216
+ if (body.length === 0) return [];
10217
+ return [
10218
+ "## What this is",
10219
+ "",
10220
+ ...body,
10221
+ "",
10222
+ "Those are the project's own claims, not evidence about the code.",
10223
+ ""
10224
+ ];
10225
+ }
10226
+ function ownerNotesSection(brief, code) {
10227
+ if (brief === void 0 || brief.notes.length === 0) return [];
10228
+ const out = ["## Owner notes", ""];
10229
+ for (const note of brief.notes) {
10230
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
10231
+ }
10232
+ return out;
10233
+ }
10234
+ function ownerBlock(text2, path23, code) {
10235
+ return ["> Written by the project owner in " + code(path23) + ", not generated.", "", text2];
10236
+ }
10004
10237
  function snapshotSection(manifest, code) {
10005
10238
  const out = ["## This snapshot", ""];
10006
10239
  out.push("- Fingerprint: " + code(manifest.fingerprint) + " - quote it verbatim in your answer.");
@@ -10099,7 +10332,8 @@ function deliverySection(manifest, partsWritten, slots) {
10099
10332
  );
10100
10333
  if (parts > 1) {
10101
10334
  out.push(
10102
- " Either raise `--max-part-bytes` to merge the parts, or set `--max-parts " + slots + "` and let the parts grow to the count instead."
10335
+ " Either raise `--max-part-bytes` to merge the parts, or set",
10336
+ " `--max-parts " + slots + "` and let the parts grow to the count instead."
10103
10337
  );
10104
10338
  }
10105
10339
  } else {
@@ -10313,6 +10547,64 @@ function treeTruncationWarnings(treeText) {
10313
10547
  }
10314
10548
  return warnings;
10315
10549
  }
10550
+ var SUMMARY_LIMIT = 400;
10551
+ var MAX_RELEASES = 2;
10552
+ function readProjectOverview(cwd) {
10553
+ return {
10554
+ ...readDescription(cwd),
10555
+ ...readSummary(cwd),
10556
+ releases: readReleases(cwd)
10557
+ };
10558
+ }
10559
+ function readText(file) {
10560
+ try {
10561
+ return fs16__namespace.readFileSync(file, "utf8");
10562
+ } catch {
10563
+ return null;
10564
+ }
10565
+ }
10566
+ function readDescription(cwd) {
10567
+ const raw = readText(path17__namespace.join(cwd, "package.json"));
10568
+ if (raw === null) return {};
10569
+ try {
10570
+ const parsed = JSON.parse(stripJsonComments(raw));
10571
+ return typeof parsed.description === "string" && parsed.description.trim().length > 0 ? { description: parsed.description.trim() } : {};
10572
+ } catch {
10573
+ return {};
10574
+ }
10575
+ }
10576
+ function readSummary(cwd) {
10577
+ const raw = readText(path17__namespace.join(cwd, "README.md"));
10578
+ if (raw === null) return {};
10579
+ const text2 = raw.replace(/<h[1-6][^>]*>[\s\S]*?<\/h[1-6]>/gi, "\n").replace(/<\/(p|div|section|header|footer|li)>/gi, "\n").replace(/<br\s*\/?>/gi, " ").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
10580
+ const paragraph = [];
10581
+ for (const line of text2.split(/\r?\n/)) {
10582
+ const trimmed = line.trim();
10583
+ if (paragraph.length === 0) {
10584
+ if (trimmed.length === 0) continue;
10585
+ if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
10586
+ if (/^\[[^\]]+\]:/.test(trimmed)) continue;
10587
+ } else if (trimmed.length === 0 || /^#/.test(trimmed)) {
10588
+ break;
10589
+ }
10590
+ paragraph.push(trimmed);
10591
+ }
10592
+ const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
10593
+ if (summary.length === 0) return {};
10594
+ return { summary: truncate(summary, SUMMARY_LIMIT) };
10595
+ }
10596
+ function truncate(text2, limit) {
10597
+ if (text2.length <= limit) return text2;
10598
+ const window = text2.slice(0, limit);
10599
+ const space = window.lastIndexOf(" ");
10600
+ return (space > limit / 2 ? window.slice(0, space) : window).trim() + "\u2026";
10601
+ }
10602
+ function readReleases(cwd) {
10603
+ const raw = readText(path17__namespace.join(cwd, "CHANGELOG.md"));
10604
+ if (raw === null) return [];
10605
+ const headings = raw.split(/\r?\n/).map((line) => /^##\s+(.+?)\s*$/.exec(line)?.[1]?.trim()).filter((heading) => heading !== void 0 && /^v?\d+\.\d+/.test(heading));
10606
+ return headings.slice(0, MAX_RELEASES);
10607
+ }
10316
10608
  var PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
10317
10609
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
10318
10610
  var UP_TO_DATE_INTERVAL_MS = 60 * 60 * 1e3;
@@ -10361,17 +10653,17 @@ function isNewer(candidate, current) {
10361
10653
  }
10362
10654
  function cacheDirectory(env = process.env, platform = process.platform) {
10363
10655
  if (platform === "win32") {
10364
- const base2 = env.LOCALAPPDATA ?? path16__namespace.join(os__namespace.homedir(), "AppData", "Local");
10365
- return path16__namespace.join(base2, "codebase-snapshot");
10656
+ const base2 = env.LOCALAPPDATA ?? path17__namespace.join(os__namespace.homedir(), "AppData", "Local");
10657
+ return path17__namespace.join(base2, "codebase-snapshot");
10366
10658
  }
10367
10659
  if (platform === "darwin") {
10368
- return path16__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
10660
+ return path17__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
10369
10661
  }
10370
- const base = env.XDG_CACHE_HOME ?? path16__namespace.join(os__namespace.homedir(), ".cache");
10371
- return path16__namespace.join(base, "codebase-snapshot");
10662
+ const base = env.XDG_CACHE_HOME ?? path17__namespace.join(os__namespace.homedir(), ".cache");
10663
+ return path17__namespace.join(base, "codebase-snapshot");
10372
10664
  }
10373
10665
  function cacheFilePath(env = process.env) {
10374
- return path16__namespace.join(cacheDirectory(env), "update-check.json");
10666
+ return path17__namespace.join(cacheDirectory(env), "update-check.json");
10375
10667
  }
10376
10668
  function shouldCheck(argv, env) {
10377
10669
  const disabled = ["1", "true", "yes"].includes(
@@ -10401,7 +10693,7 @@ function shouldCheck(argv, env) {
10401
10693
  function readCache(file) {
10402
10694
  let raw;
10403
10695
  try {
10404
- raw = fs15__namespace.readFileSync(file, "utf8");
10696
+ raw = fs16__namespace.readFileSync(file, "utf8");
10405
10697
  } catch {
10406
10698
  return null;
10407
10699
  }
@@ -10418,8 +10710,8 @@ function readCache(file) {
10418
10710
  }
10419
10711
  function writeCache(file, entry) {
10420
10712
  try {
10421
- fs15__namespace.mkdirSync(path16__namespace.dirname(file), { recursive: true });
10422
- fs15__namespace.writeFileSync(file, `${JSON.stringify(entry)}
10713
+ fs16__namespace.mkdirSync(path17__namespace.dirname(file), { recursive: true });
10714
+ fs16__namespace.writeFileSync(file, `${JSON.stringify(entry)}
10423
10715
  `, "utf8");
10424
10716
  } catch {
10425
10717
  }
@@ -10550,36 +10842,36 @@ fi
10550
10842
  `;
10551
10843
  }
10552
10844
  function gitDirectory(cwd) {
10553
- const dotGit = path16__namespace.join(cwd, ".git");
10845
+ const dotGit = path17__namespace.join(cwd, ".git");
10554
10846
  let stats;
10555
10847
  try {
10556
- stats = fs15__namespace.statSync(dotGit);
10848
+ stats = fs16__namespace.statSync(dotGit);
10557
10849
  } catch {
10558
10850
  return null;
10559
10851
  }
10560
10852
  if (stats.isDirectory()) return dotGit;
10561
10853
  if (!stats.isFile()) return null;
10562
10854
  try {
10563
- const contents = fs15__namespace.readFileSync(dotGit, "utf8");
10855
+ const contents = fs16__namespace.readFileSync(dotGit, "utf8");
10564
10856
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
10565
10857
  if (!match) return null;
10566
10858
  const target = match[1];
10567
- const resolved = path16__namespace.isAbsolute(target.trim()) ? target.trim() : path16__namespace.join(cwd, target.trim());
10568
- if (!fs15__namespace.statSync(resolved).isDirectory()) return null;
10569
- if (isInside2(path16__namespace.resolve(cwd), path16__namespace.resolve(resolved))) return resolved;
10570
- return isRegisteredWorktree(path16__namespace.resolve(resolved), cwd) ? resolved : null;
10859
+ const resolved = path17__namespace.isAbsolute(target.trim()) ? target.trim() : path17__namespace.join(cwd, target.trim());
10860
+ if (!fs16__namespace.statSync(resolved).isDirectory()) return null;
10861
+ if (isInside2(path17__namespace.resolve(cwd), path17__namespace.resolve(resolved))) return resolved;
10862
+ return isRegisteredWorktree(path17__namespace.resolve(resolved), cwd) ? resolved : null;
10571
10863
  } catch {
10572
10864
  return null;
10573
10865
  }
10574
10866
  }
10575
10867
  function isInside2(parent, child) {
10576
- const relative15 = path16__namespace.relative(parent, child);
10577
- return relative15 === "" || !relative15.startsWith("..") && !path16__namespace.isAbsolute(relative15);
10868
+ const relative15 = path17__namespace.relative(parent, child);
10869
+ return relative15 === "" || !relative15.startsWith("..") && !path17__namespace.isAbsolute(relative15);
10578
10870
  }
10579
10871
  function isRegisteredWorktree(gitDir, cwd) {
10580
10872
  try {
10581
- const back = fs15__namespace.readFileSync(path16__namespace.join(gitDir, "gitdir"), "utf8").trim();
10582
- return path16__namespace.resolve(gitDir, back) === path16__namespace.join(path16__namespace.resolve(cwd), ".git");
10873
+ const back = fs16__namespace.readFileSync(path17__namespace.join(gitDir, "gitdir"), "utf8").trim();
10874
+ return path17__namespace.resolve(gitDir, back) === path17__namespace.join(path17__namespace.resolve(cwd), ".git");
10583
10875
  } catch {
10584
10876
  return false;
10585
10877
  }
@@ -10600,10 +10892,10 @@ function gitOutput(cwd, args) {
10600
10892
  function configuredHooksDirectory(cwd) {
10601
10893
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
10602
10894
  if (hooks === null) return null;
10603
- const resolved = path16__namespace.resolve(cwd, hooks);
10895
+ const resolved = path17__namespace.resolve(cwd, hooks);
10604
10896
  const common = gitOutput(cwd, ["rev-parse", "--git-common-dir"]);
10605
- const commonDir = common === null ? null : path16__namespace.resolve(cwd, common);
10606
- if (isInside2(path16__namespace.resolve(cwd), resolved)) return { dir: resolved };
10897
+ const commonDir = common === null ? null : path17__namespace.resolve(cwd, common);
10898
+ if (isInside2(path17__namespace.resolve(cwd), resolved)) return { dir: resolved };
10607
10899
  if (commonDir !== null && isInside2(commonDir, resolved)) return { dir: resolved };
10608
10900
  return {
10609
10901
  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.`
@@ -10624,10 +10916,10 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10624
10916
  ]
10625
10917
  };
10626
10918
  }
10627
- const hooksDir = configured === null ? path16__namespace.join(gitDir, "hooks") : configured.dir;
10628
- const hookPath = path16__namespace.join(hooksDir, "pre-commit");
10919
+ const hooksDir = configured === null ? path17__namespace.join(gitDir, "hooks") : configured.dir;
10920
+ const hookPath = path17__namespace.join(hooksDir, "pre-commit");
10629
10921
  try {
10630
- fs15__namespace.mkdirSync(hooksDir, { recursive: true });
10922
+ fs16__namespace.mkdirSync(hooksDir, { recursive: true });
10631
10923
  } catch (err) {
10632
10924
  return {
10633
10925
  path: hookPath,
@@ -10637,7 +10929,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10637
10929
  }
10638
10930
  let existing = null;
10639
10931
  try {
10640
- existing = fs15__namespace.readFileSync(hookPath, "utf8");
10932
+ existing = fs16__namespace.readFileSync(hookPath, "utf8");
10641
10933
  } catch {
10642
10934
  existing = null;
10643
10935
  }
@@ -10652,8 +10944,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10652
10944
  };
10653
10945
  }
10654
10946
  try {
10655
- fs15__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10656
- fs15__namespace.chmodSync(hookPath, 493);
10947
+ fs16__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10948
+ fs16__namespace.chmodSync(hookPath, 493);
10657
10949
  } catch (err) {
10658
10950
  return {
10659
10951
  path: hookPath,
@@ -10670,7 +10962,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10670
10962
  };
10671
10963
  }
10672
10964
  function workerEntry(directory, isCjs) {
10673
- const entry = path16__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10965
+ const entry = path17__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10674
10966
  return { path: entry, url: url.pathToFileURL(entry).href };
10675
10967
  }
10676
10968
  var WORKER_SOURCE = `
@@ -10737,7 +11029,7 @@ function generateInWorker(cwd, cliOptions, options = {}) {
10737
11029
  resolve12(result);
10738
11030
  };
10739
11031
  const isCjs = typeof __dirname !== "undefined";
10740
- const directory = isCjs ? __dirname : path16__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
11032
+ const directory = isCjs ? __dirname : path17__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
10741
11033
  try {
10742
11034
  worker = new worker_threads.Worker(WORKER_SOURCE, {
10743
11035
  eval: true,
@@ -10772,23 +11064,23 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
10772
11064
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
10773
11065
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
10774
11066
  var fileDerivationBytes = 0;
10775
- function takeDerivation(path22, hash, settings) {
10776
- const cached = FILE_DERIVATIONS.get(path22);
11067
+ function takeDerivation(path23, hash, settings) {
11068
+ const cached = FILE_DERIVATIONS.get(path23);
10777
11069
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
10778
- FILE_DERIVATIONS.delete(path22);
10779
- FILE_DERIVATIONS.set(path22, cached);
11070
+ FILE_DERIVATIONS.delete(path23);
11071
+ FILE_DERIVATIONS.set(path23, cached);
10780
11072
  return cached;
10781
11073
  }
10782
- function rememberDerivation(path22, hash, settings, derivation) {
11074
+ function rememberDerivation(path23, hash, settings, derivation) {
10783
11075
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
10784
11076
  const bytes = bodyBytes * 2 + 512;
10785
11077
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
10786
- const previous = FILE_DERIVATIONS.get(path22);
11078
+ const previous = FILE_DERIVATIONS.get(path23);
10787
11079
  if (previous !== void 0) {
10788
- FILE_DERIVATIONS.delete(path22);
11080
+ FILE_DERIVATIONS.delete(path23);
10789
11081
  fileDerivationBytes -= previous.bytes;
10790
11082
  } else {
10791
- FILE_DERIVATIONS.delete(path22);
11083
+ FILE_DERIVATIONS.delete(path23);
10792
11084
  }
10793
11085
  while (fileDerivationBytes + bytes > FILE_DERIVATION_LIMIT_BYTES) {
10794
11086
  const oldest = FILE_DERIVATIONS.keys().next();
@@ -10797,7 +11089,7 @@ function rememberDerivation(path22, hash, settings, derivation) {
10797
11089
  FILE_DERIVATIONS.delete(oldest.value);
10798
11090
  if (evicted !== void 0) fileDerivationBytes -= evicted.bytes;
10799
11091
  }
10800
- FILE_DERIVATIONS.set(path22, { ...derivation, hash, settings, bytes });
11092
+ FILE_DERIVATIONS.set(path23, { ...derivation, hash, settings, bytes });
10801
11093
  fileDerivationBytes += bytes;
10802
11094
  }
10803
11095
  function derivationSettings(config) {
@@ -11048,11 +11340,11 @@ function verifyInMemory(files, parts, unaccounted) {
11048
11340
  return errors;
11049
11341
  }
11050
11342
  function resolveSafeOutputDirs(config) {
11051
- const cwd = path16__namespace.resolve(config.cwd);
11052
- const outDir = path16__namespace.resolve(cwd, config.outDir);
11053
- const tmpDir = path16__namespace.resolve(cwd, config.tmpDir);
11054
- const root = path16__namespace.parse(cwd).root;
11055
- const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path16__namespace.sep}`);
11343
+ const cwd = path17__namespace.resolve(config.cwd);
11344
+ const outDir = path17__namespace.resolve(cwd, config.outDir);
11345
+ const tmpDir = path17__namespace.resolve(cwd, config.tmpDir);
11346
+ const root = path17__namespace.parse(cwd).root;
11347
+ const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path17__namespace.sep}`);
11056
11348
  const reject = (reason) => {
11057
11349
  throw new Error(
11058
11350
  `Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
@@ -11092,6 +11384,28 @@ function maskSummaryStrings(value, secretRules) {
11092
11384
  function maskPathText(value, secretRules) {
11093
11385
  return findSecretInPath(value, secretRules)?.masked ?? value;
11094
11386
  }
11387
+ function maskOwnerBrief(brief, secretRules) {
11388
+ if (brief === void 0) return void 0;
11389
+ const mask = (value) => maskPathText(value, secretRules);
11390
+ return {
11391
+ ...brief,
11392
+ ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11393
+ ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11394
+ ...brief.history === void 0 ? {} : { history: mask(brief.history) },
11395
+ ...brief.bar === void 0 ? {} : { bar: mask(brief.bar) },
11396
+ ...brief.calibration === void 0 ? {} : { calibration: mask(brief.calibration) },
11397
+ ...brief.preamble === void 0 ? {} : { preamble: mask(brief.preamble) },
11398
+ notes: brief.notes.map((note) => ({ heading: note.heading, body: mask(note.body) }))
11399
+ };
11400
+ }
11401
+ function maskOverview(overview, secretRules) {
11402
+ const mask = (value) => maskPathText(value, secretRules);
11403
+ return {
11404
+ ...overview.description === void 0 ? {} : { description: mask(overview.description) },
11405
+ ...overview.summary === void 0 ? {} : { summary: mask(overview.summary) },
11406
+ releases: overview.releases.map(mask)
11407
+ };
11408
+ }
11095
11409
  function maskSkipRecords(records, secretRules) {
11096
11410
  return maskSkipPaths(records, secretRules);
11097
11411
  }
@@ -11112,14 +11426,14 @@ function listEntries(dir) {
11112
11426
  const walk = (absolute, prefix) => {
11113
11427
  let children;
11114
11428
  try {
11115
- children = fs15__namespace.readdirSync(absolute, { withFileTypes: true });
11429
+ children = fs16__namespace.readdirSync(absolute, { withFileTypes: true });
11116
11430
  } catch {
11117
11431
  return;
11118
11432
  }
11119
11433
  for (const child of children) {
11120
11434
  const relative15 = prefix === "" ? child.name : `${prefix}/${child.name}`;
11121
11435
  entries.push(relative15);
11122
- if (child.isDirectory()) walk(path16__namespace.join(absolute, child.name), relative15);
11436
+ if (child.isDirectory()) walk(path17__namespace.join(absolute, child.name), relative15);
11123
11437
  }
11124
11438
  };
11125
11439
  walk(dir, "");
@@ -11131,10 +11445,10 @@ function markerInventory(dir, written) {
11131
11445
  for (const entry of entries) {
11132
11446
  if (entry === OWNERSHIP_MARKER) continue;
11133
11447
  if (isIgnorableEntry(entry)) continue;
11134
- const full = path16__namespace.join(dir, ...entry.split("/"));
11448
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11135
11449
  let stats;
11136
11450
  try {
11137
- stats = fs15__namespace.lstatSync(full);
11451
+ stats = fs16__namespace.lstatSync(full);
11138
11452
  } catch {
11139
11453
  continue;
11140
11454
  }
@@ -11146,7 +11460,7 @@ function markerInventory(dir, written) {
11146
11460
  }
11147
11461
  let digest;
11148
11462
  try {
11149
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11463
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11150
11464
  } catch {
11151
11465
  continue;
11152
11466
  }
@@ -11167,15 +11481,15 @@ function markerPayload(dir, state, id, createdAt, written) {
11167
11481
  entries,
11168
11482
  files
11169
11483
  };
11170
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11171
- if (fs15__namespace.existsSync(manifestPath)) {
11172
- marker2.manifestSha256 = sha256Hex2(fs15__namespace.readFileSync(manifestPath));
11484
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11485
+ if (fs16__namespace.existsSync(manifestPath)) {
11486
+ marker2.manifestSha256 = sha256Hex2(fs16__namespace.readFileSync(manifestPath));
11173
11487
  }
11174
11488
  return marker2;
11175
11489
  }
11176
11490
  function writeOwnershipMarker(dir, marker2) {
11177
- fs15__namespace.writeFileSync(
11178
- path16__namespace.join(dir, OWNERSHIP_MARKER),
11491
+ fs16__namespace.writeFileSync(
11492
+ path17__namespace.join(dir, OWNERSHIP_MARKER),
11179
11493
  `${JSON.stringify(marker2, null, 2)}
11180
11494
  `,
11181
11495
  "utf8"
@@ -11187,13 +11501,13 @@ function markerBelongsTo(dir, id) {
11187
11501
  return evidence.marker.id === id;
11188
11502
  }
11189
11503
  function readOwnershipMarker(dir) {
11190
- const markerPath = path16__namespace.join(dir, OWNERSHIP_MARKER);
11191
- if (!fs15__namespace.existsSync(markerPath)) {
11504
+ const markerPath = path17__namespace.join(dir, OWNERSHIP_MARKER);
11505
+ if (!fs16__namespace.existsSync(markerPath)) {
11192
11506
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
11193
11507
  }
11194
11508
  let raw;
11195
11509
  try {
11196
- raw = fs15__namespace.readFileSync(markerPath, "utf8");
11510
+ raw = fs16__namespace.readFileSync(markerPath, "utf8");
11197
11511
  } catch {
11198
11512
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
11199
11513
  }
@@ -11293,10 +11607,10 @@ function verifyMarkerInventory(dir, entries, files) {
11293
11607
  for (const entry of entries) {
11294
11608
  if (entry === OWNERSHIP_MARKER) continue;
11295
11609
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
11296
- const full = path16__namespace.join(dir, ...entry.split("/"));
11610
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11297
11611
  let stats;
11298
11612
  try {
11299
- stats = fs15__namespace.lstatSync(full);
11613
+ stats = fs16__namespace.lstatSync(full);
11300
11614
  } catch {
11301
11615
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
11302
11616
  }
@@ -11321,7 +11635,7 @@ function verifyMarkerInventory(dir, entries, files) {
11321
11635
  }
11322
11636
  let digest;
11323
11637
  try {
11324
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11638
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11325
11639
  } catch {
11326
11640
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
11327
11641
  }
@@ -11342,12 +11656,12 @@ function assessSnapshotDirectory(dir) {
11342
11656
  marker: marker2
11343
11657
  };
11344
11658
  }
11345
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11346
- const hasManifest = fs15__namespace.existsSync(manifestPath);
11659
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11660
+ const hasManifest = fs16__namespace.existsSync(manifestPath);
11347
11661
  if (hasManifest) {
11348
11662
  let raw;
11349
11663
  try {
11350
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
11664
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
11351
11665
  } catch {
11352
11666
  return {
11353
11667
  owned: false,
@@ -11442,13 +11756,13 @@ function containsNoFiles(dir) {
11442
11756
  const current = pending.pop();
11443
11757
  let entries;
11444
11758
  try {
11445
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
11759
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
11446
11760
  } catch {
11447
11761
  return false;
11448
11762
  }
11449
11763
  for (const entry of entries) {
11450
11764
  if (entry.isDirectory()) {
11451
- pending.push(path16__namespace.join(current, entry.name));
11765
+ pending.push(path17__namespace.join(current, entry.name));
11452
11766
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
11453
11767
  return false;
11454
11768
  }
@@ -11457,13 +11771,13 @@ function containsNoFiles(dir) {
11457
11771
  return true;
11458
11772
  }
11459
11773
  function assertReplaceable(target, label, secretRules) {
11460
- if (!fs15__namespace.existsSync(target)) return;
11461
- if (!fs15__namespace.statSync(target).isDirectory()) {
11774
+ if (!fs16__namespace.existsSync(target)) return;
11775
+ if (!fs16__namespace.statSync(target).isDirectory()) {
11462
11776
  throw new Error(
11463
11777
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
11464
11778
  );
11465
11779
  }
11466
- const entries = fs15__namespace.readdirSync(target);
11780
+ const entries = fs16__namespace.readdirSync(target);
11467
11781
  if (entries.length === 0) return;
11468
11782
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
11469
11783
  if (containsNoFiles(target)) return;
@@ -11483,18 +11797,18 @@ function assertReplaceable(target, label, secretRules) {
11483
11797
  );
11484
11798
  }
11485
11799
  function assertStagingRootUsable(tmpDir, secretRules) {
11486
- if (!fs15__namespace.existsSync(tmpDir)) return;
11487
- if (!fs15__namespace.statSync(tmpDir).isDirectory()) {
11800
+ if (!fs16__namespace.existsSync(tmpDir)) return;
11801
+ if (!fs16__namespace.statSync(tmpDir).isDirectory()) {
11488
11802
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
11489
11803
  }
11490
- const entries = fs15__namespace.readdirSync(tmpDir);
11804
+ const entries = fs16__namespace.readdirSync(tmpDir);
11491
11805
  if (entries.length === 0) return;
11492
11806
  const foreign = entries.filter((name) => {
11493
- const full = path16__namespace.join(tmpDir, name);
11807
+ const full = path17__namespace.join(tmpDir, name);
11494
11808
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
11495
11809
  let stats;
11496
11810
  try {
11497
- stats = fs15__namespace.statSync(full);
11811
+ stats = fs16__namespace.statSync(full);
11498
11812
  } catch {
11499
11813
  return true;
11500
11814
  }
@@ -11502,7 +11816,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11502
11816
  const { marker: marker2 } = readOwnershipMarker(full);
11503
11817
  if (marker2) return false;
11504
11818
  try {
11505
- return fs15__namespace.readdirSync(full).length > 0;
11819
+ return fs16__namespace.readdirSync(full).length > 0;
11506
11820
  } catch {
11507
11821
  return true;
11508
11822
  }
@@ -11517,13 +11831,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11517
11831
  function cleanStaleRunDirs(tmpDir) {
11518
11832
  let entries;
11519
11833
  try {
11520
- entries = fs15__namespace.readdirSync(tmpDir);
11834
+ entries = fs16__namespace.readdirSync(tmpDir);
11521
11835
  } catch {
11522
11836
  return;
11523
11837
  }
11524
11838
  for (const name of entries) {
11525
11839
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
11526
- const full = path16__namespace.join(tmpDir, name);
11840
+ const full = path17__namespace.join(tmpDir, name);
11527
11841
  const { marker: marker2 } = readOwnershipMarker(full);
11528
11842
  if (marker2) {
11529
11843
  const created = Date.parse(marker2.createdAt);
@@ -11531,33 +11845,33 @@ function cleanStaleRunDirs(tmpDir) {
11531
11845
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
11532
11846
  if (aged || abandoned) {
11533
11847
  try {
11534
- fs15__namespace.rmSync(full, { recursive: true, force: true });
11848
+ fs16__namespace.rmSync(full, { recursive: true, force: true });
11535
11849
  } catch {
11536
11850
  }
11537
11851
  }
11538
11852
  continue;
11539
11853
  }
11540
11854
  try {
11541
- if (fs15__namespace.readdirSync(full).length === 0) fs15__namespace.rmSync(full, { recursive: true, force: true });
11855
+ if (fs16__namespace.readdirSync(full).length === 0) fs16__namespace.rmSync(full, { recursive: true, force: true });
11542
11856
  } catch {
11543
11857
  }
11544
11858
  }
11545
11859
  }
11546
11860
  function removeIfEmpty(dir) {
11547
11861
  try {
11548
- if (fs15__namespace.readdirSync(dir).length === 0) fs15__namespace.rmSync(dir, { recursive: true, force: true });
11862
+ if (fs16__namespace.readdirSync(dir).length === 0) fs16__namespace.rmSync(dir, { recursive: true, force: true });
11549
11863
  } catch {
11550
11864
  }
11551
11865
  }
11552
11866
  function ensureParentDirectory(target, label) {
11553
- const parent = path16__namespace.dirname(target);
11554
- if (fs15__namespace.existsSync(parent) && !fs15__namespace.statSync(parent).isDirectory()) {
11867
+ const parent = path17__namespace.dirname(target);
11868
+ if (fs16__namespace.existsSync(parent) && !fs16__namespace.statSync(parent).isDirectory()) {
11555
11869
  throw new Error(
11556
11870
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
11557
11871
  );
11558
11872
  }
11559
11873
  try {
11560
- fs15__namespace.mkdirSync(parent, { recursive: true });
11874
+ fs16__namespace.mkdirSync(parent, { recursive: true });
11561
11875
  } catch (err) {
11562
11876
  throw new Error(
11563
11877
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -11615,17 +11929,17 @@ function acquireRunLock(stagingRoot) {
11615
11929
  `;
11616
11930
  for (let attempt = 0; attempt < 2; attempt += 1) {
11617
11931
  try {
11618
- const handle = fs15__namespace.openSync(lockPath, "wx");
11932
+ const handle = fs16__namespace.openSync(lockPath, "wx");
11619
11933
  try {
11620
- fs15__namespace.writeSync(handle, payload);
11934
+ fs16__namespace.writeSync(handle, payload);
11621
11935
  } finally {
11622
- fs15__namespace.closeSync(handle);
11936
+ fs16__namespace.closeSync(handle);
11623
11937
  }
11624
11938
  const stopHeartbeat = startLockHeartbeat(lockPath);
11625
11939
  return () => {
11626
11940
  stopHeartbeat();
11627
11941
  try {
11628
- fs15__namespace.rmSync(lockPath, { force: true });
11942
+ fs16__namespace.rmSync(lockPath, { force: true });
11629
11943
  } catch {
11630
11944
  }
11631
11945
  };
@@ -11645,26 +11959,26 @@ function lockKeyFor(stagingRoot) {
11645
11959
  return sha256Hex2(key).slice(0, 16);
11646
11960
  }
11647
11961
  function canonicalLockTarget(targetPath2) {
11648
- const resolved = path16__namespace.resolve(targetPath2);
11962
+ const resolved = path17__namespace.resolve(targetPath2);
11649
11963
  let existing = resolved;
11650
11964
  const tail = [];
11651
11965
  for (; ; ) {
11652
11966
  try {
11653
- return path16__namespace.join(fs15__namespace.realpathSync(existing), ...tail);
11967
+ return path17__namespace.join(fs16__namespace.realpathSync(existing), ...tail);
11654
11968
  } catch {
11655
- const parent = path16__namespace.dirname(existing);
11969
+ const parent = path17__namespace.dirname(existing);
11656
11970
  if (parent === existing) return resolved;
11657
- tail.unshift(path16__namespace.basename(existing));
11971
+ tail.unshift(path17__namespace.basename(existing));
11658
11972
  existing = parent;
11659
11973
  }
11660
11974
  }
11661
11975
  }
11662
11976
  function lockPathFor(stagingRoot) {
11663
- return path16__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11977
+ return path17__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11664
11978
  }
11665
11979
  function lockHeartbeatAgeMs(lockPath) {
11666
11980
  try {
11667
- return Date.now() - fs15__namespace.statSync(lockPath).mtimeMs;
11981
+ return Date.now() - fs16__namespace.statSync(lockPath).mtimeMs;
11668
11982
  } catch {
11669
11983
  return Number.POSITIVE_INFINITY;
11670
11984
  }
@@ -11672,7 +11986,7 @@ function lockHeartbeatAgeMs(lockPath) {
11672
11986
  function lockOwnerIsGone(lockPath) {
11673
11987
  let raw;
11674
11988
  try {
11675
- raw = fs15__namespace.readFileSync(lockPath, "utf8");
11989
+ raw = fs16__namespace.readFileSync(lockPath, "utf8");
11676
11990
  } catch {
11677
11991
  return false;
11678
11992
  }
@@ -11694,16 +12008,16 @@ function lockOwnerIsGone(lockPath) {
11694
12008
  function reclaimStaleLock(lockPath) {
11695
12009
  let before;
11696
12010
  try {
11697
- before = fs15__namespace.statSync(lockPath);
12011
+ before = fs16__namespace.statSync(lockPath);
11698
12012
  } catch {
11699
12013
  return true;
11700
12014
  }
11701
12015
  if (!lockOwnerIsGone(lockPath)) return false;
11702
12016
  try {
11703
- const current = fs15__namespace.statSync(lockPath);
12017
+ const current = fs16__namespace.statSync(lockPath);
11704
12018
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
11705
12019
  if (!sameFile) return false;
11706
- fs15__namespace.rmSync(lockPath, { force: true });
12020
+ fs16__namespace.rmSync(lockPath, { force: true });
11707
12021
  return true;
11708
12022
  } catch {
11709
12023
  return false;
@@ -11714,12 +12028,12 @@ function lockFileIsAncient(lockPath) {
11714
12028
  }
11715
12029
  function writeManifestAtomically(manifestPath, manifest) {
11716
12030
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
11717
- fs15__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
12031
+ fs16__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11718
12032
  try {
11719
- fs15__namespace.renameSync(tempPath, manifestPath);
12033
+ fs16__namespace.renameSync(tempPath, manifestPath);
11720
12034
  } catch (err) {
11721
12035
  try {
11722
- fs15__namespace.rmSync(tempPath, { force: true });
12036
+ fs16__namespace.rmSync(tempPath, { force: true });
11723
12037
  } catch {
11724
12038
  }
11725
12039
  throw err;
@@ -11744,21 +12058,21 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap) {
11744
12058
  }
11745
12059
  }
11746
12060
  function recoverInterruptedPublish(outDir) {
11747
- if (fs15__namespace.existsSync(outDir)) return;
11748
- const parent = path16__namespace.dirname(outDir);
11749
- const base = path16__namespace.basename(outDir);
12061
+ if (fs16__namespace.existsSync(outDir)) return;
12062
+ const parent = path17__namespace.dirname(outDir);
12063
+ const base = path17__namespace.basename(outDir);
11750
12064
  let backups;
11751
12065
  try {
11752
- backups = fs15__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
12066
+ backups = fs16__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
11753
12067
  } catch {
11754
12068
  return;
11755
12069
  }
11756
12070
  if (backups.length !== 1) return;
11757
- const backupDir = path16__namespace.join(parent, backups[0]);
12071
+ const backupDir = path17__namespace.join(parent, backups[0]);
11758
12072
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
11759
12073
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
11760
12074
  try {
11761
- fs15__namespace.renameSync(backupDir, outDir);
12075
+ fs16__namespace.renameSync(backupDir, outDir);
11762
12076
  process.stderr.write(
11763
12077
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
11764
12078
  `
@@ -11768,16 +12082,16 @@ function recoverInterruptedPublish(outDir) {
11768
12082
  }
11769
12083
  function swapOnce(stagingDir, outDir, beforeSwap) {
11770
12084
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
11771
- const hadPrevious = fs15__namespace.existsSync(outDir);
12085
+ const hadPrevious = fs16__namespace.existsSync(outDir);
11772
12086
  if (hadPrevious) beforeSwap?.();
11773
12087
  let movedAside = false;
11774
12088
  if (hadPrevious) {
11775
12089
  try {
11776
- fs15__namespace.renameSync(outDir, backupDir);
12090
+ fs16__namespace.renameSync(outDir, backupDir);
11777
12091
  movedAside = true;
11778
12092
  } catch (err) {
11779
12093
  if (!isLockError(err)) throw err;
11780
- fs15__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
12094
+ fs16__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
11781
12095
  process.stderr.write(
11782
12096
  `\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.
11783
12097
  `
@@ -11786,26 +12100,26 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11786
12100
  }
11787
12101
  try {
11788
12102
  try {
11789
- fs15__namespace.renameSync(stagingDir, outDir);
12103
+ fs16__namespace.renameSync(stagingDir, outDir);
11790
12104
  } catch (err) {
11791
12105
  if (err.code !== "EXDEV") throw err;
11792
12106
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
11793
12107
  try {
11794
- fs15__namespace.cpSync(stagingDir, partialDir, { recursive: true });
11795
- fs15__namespace.renameSync(partialDir, outDir);
11796
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12108
+ fs16__namespace.cpSync(stagingDir, partialDir, { recursive: true });
12109
+ fs16__namespace.renameSync(partialDir, outDir);
12110
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
11797
12111
  } catch (copyErr) {
11798
12112
  try {
11799
- fs15__namespace.rmSync(partialDir, { recursive: true, force: true });
12113
+ fs16__namespace.rmSync(partialDir, { recursive: true, force: true });
11800
12114
  } catch {
11801
12115
  }
11802
12116
  throw copyErr;
11803
12117
  }
11804
12118
  }
11805
12119
  } catch (err) {
11806
- if (hadPrevious && movedAside && fs15__namespace.existsSync(backupDir)) {
11807
- if (fs15__namespace.existsSync(outDir)) fs15__namespace.rmSync(outDir, { recursive: true, force: true });
11808
- fs15__namespace.renameSync(backupDir, outDir);
12120
+ if (hadPrevious && movedAside && fs16__namespace.existsSync(backupDir)) {
12121
+ if (fs16__namespace.existsSync(outDir)) fs16__namespace.rmSync(outDir, { recursive: true, force: true });
12122
+ fs16__namespace.renameSync(backupDir, outDir);
11809
12123
  } else if (hadPrevious && !movedAside) {
11810
12124
  process.stderr.write(
11811
12125
  `\u26A0 The previous snapshot at ${outDir} was removed and the new one could not be moved into place. It is complete at ${stagingDir}.
@@ -11816,7 +12130,7 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11816
12130
  }
11817
12131
  if (hadPrevious) {
11818
12132
  try {
11819
- fs15__namespace.rmSync(backupDir, { recursive: true, force: true });
12133
+ fs16__namespace.rmSync(backupDir, { recursive: true, force: true });
11820
12134
  } catch (err) {
11821
12135
  process.stderr.write(
11822
12136
  `\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.
@@ -11974,7 +12288,7 @@ function generateSnapshot(configInput, options) {
11974
12288
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
11975
12289
  // output — but only at these exact paths, not at every directory that shares the name.
11976
12290
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
11977
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
12291
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
11978
12292
  ).filter((relative15) => relative15.length > 0 && !relative15.startsWith("..")),
11979
12293
  // A staged path can be absent from the working tree while its index blob exists. Discovery
11980
12294
  // lists the working tree, so those paths would never reach the scan at all.
@@ -12003,7 +12317,7 @@ function generateSnapshot(configInput, options) {
12003
12317
  let totalSizeBytes = 0;
12004
12318
  let largeFileCount = 0;
12005
12319
  for (const relativePath of candidateFiles) {
12006
- const absolutePath = path16__namespace.join(config.cwd, relativePath);
12320
+ const absolutePath = path17__namespace.join(config.cwd, relativePath);
12007
12321
  const fromIndex = stagedPaths.has(relativePath);
12008
12322
  let buffer;
12009
12323
  let sizeBytes;
@@ -12034,9 +12348,9 @@ function generateSnapshot(configInput, options) {
12034
12348
  } else {
12035
12349
  let stats;
12036
12350
  try {
12037
- stats = fs15__namespace.statSync(absolutePath);
12351
+ stats = fs16__namespace.statSync(absolutePath);
12038
12352
  if (!stats.isFile()) {
12039
- const nestedRepository = stats.isDirectory() && fs15__namespace.existsSync(path16__namespace.join(absolutePath, ".git"));
12353
+ const nestedRepository = stats.isDirectory() && fs16__namespace.existsSync(path17__namespace.join(absolutePath, ".git"));
12040
12354
  skipped.push(
12041
12355
  nestedRepository ? {
12042
12356
  path: relativePath,
@@ -12072,7 +12386,7 @@ function generateSnapshot(configInput, options) {
12072
12386
  continue;
12073
12387
  }
12074
12388
  try {
12075
- buffer = fs15__namespace.readFileSync(absolutePath);
12389
+ buffer = fs16__namespace.readFileSync(absolutePath);
12076
12390
  } catch (err) {
12077
12391
  const code = err.code;
12078
12392
  skipped.push({
@@ -12201,14 +12515,14 @@ function generateSnapshot(configInput, options) {
12201
12515
  (finding) => finding.path === void 0 || keep.has(finding.path)
12202
12516
  );
12203
12517
  retain(encodingNotes, (note) => keep.has(note.path));
12204
- retain(oversizeSummaryPaths, (path22) => keep.has(path22));
12205
- retain(previewSummaryPaths, (path22) => keep.has(path22));
12518
+ retain(oversizeSummaryPaths, (path23) => keep.has(path23));
12519
+ retain(previewSummaryPaths, (path23) => keep.has(path23));
12206
12520
  retain(fileWarnings, (warning) => keep.has(warning.path));
12207
- for (const path22 of [...monolithBodies.keys()]) {
12208
- if (!keep.has(path22)) monolithBodies.delete(path22);
12521
+ for (const path23 of [...monolithBodies.keys()]) {
12522
+ if (!keep.has(path23)) monolithBodies.delete(path23);
12209
12523
  }
12210
- for (const path22 of [...skippedSummaryImports.keys()]) {
12211
- if (!keep.has(path22)) skippedSummaryImports.delete(path22);
12524
+ for (const path23 of [...skippedSummaryImports.keys()]) {
12525
+ if (!keep.has(path23)) skippedSummaryImports.delete(path23);
12212
12526
  }
12213
12527
  }
12214
12528
  if (changedScope !== null) {
@@ -12347,6 +12661,8 @@ function generateSnapshot(configInput, options) {
12347
12661
  // omitted from `digest` when it is off so an existing snapshot does not start reporting
12348
12662
  // configuration drift.
12349
12663
  maxParts: config.maxParts ?? null,
12664
+ promptTask: config.promptTask,
12665
+ ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12350
12666
  discovery: config.discovery ?? "auto",
12351
12667
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12352
12668
  // describes the run has to name it.
@@ -12477,14 +12793,16 @@ function generateSnapshot(configInput, options) {
12477
12793
  if (auditText !== null) manifest.artifacts.audit = artifactRecord(auditText);
12478
12794
  const readmeText = artifacts.readme ? generateReadme(manifest, artifacts) : null;
12479
12795
  if (readmeText !== null) manifest.artifacts.readme = artifactRecord(readmeText);
12480
- const promptText = artifacts.prompt ? generatePrompt(
12481
- manifest,
12482
- artifacts,
12483
- config.attachmentSlots,
12484
- // Commit subjects are user input and reach an artifact, so they go through the same
12485
- // masking as every other name the run reproduces.
12486
- recentCommitSubjects(config.cwd).map((subject) => maskPathText(subject, config.secretRules))
12487
- ) : null;
12796
+ const promptText = artifacts.prompt ? generatePrompt(manifest, artifacts, {
12797
+ slots: config.attachmentSlots,
12798
+ task: config.promptTask,
12799
+ brief: maskOwnerBrief(config.brief, config.secretRules),
12800
+ history: recentCommits(config.cwd).map((commit) => ({
12801
+ subject: maskPathText(commit.subject, config.secretRules),
12802
+ body: maskPathText(commit.body, config.secretRules)
12803
+ })),
12804
+ overview: maskOverview(readProjectOverview(config.cwd), config.secretRules)
12805
+ }) : null;
12488
12806
  if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
12489
12807
  if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
12490
12808
  let monolithJson = null;
@@ -12560,12 +12878,12 @@ function generateSnapshot(configInput, options) {
12560
12878
  let releaseDeferred = false;
12561
12879
  try {
12562
12880
  ensureParentDirectory(outDir, "outDir");
12563
- fs15__namespace.mkdirSync(tmpDir, { recursive: true });
12881
+ fs16__namespace.mkdirSync(tmpDir, { recursive: true });
12564
12882
  cleanStaleRunDirs(tmpDir);
12565
12883
  const snapshotId = crypto3__namespace.randomUUID();
12566
12884
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
12567
- stagingDir = path16__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12568
- fs15__namespace.mkdirSync(stagingDir);
12885
+ stagingDir = path17__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12886
+ fs16__namespace.mkdirSync(stagingDir);
12569
12887
  writeOwnershipMarker(stagingDir, {
12570
12888
  generator: GENERATOR_NAME,
12571
12889
  version: GENERATOR_VERSION,
@@ -12575,30 +12893,30 @@ function generateSnapshot(configInput, options) {
12575
12893
  id: snapshotId,
12576
12894
  pid: process.pid
12577
12895
  });
12578
- const partsDir = path16__namespace.join(stagingDir, "parts");
12579
- const reportsDir = path16__namespace.join(stagingDir, "reports");
12580
- if (artifacts.parts) fs15__namespace.mkdirSync(partsDir, { recursive: true });
12896
+ const partsDir = path17__namespace.join(stagingDir, "parts");
12897
+ const reportsDir = path17__namespace.join(stagingDir, "reports");
12898
+ if (artifacts.parts) fs16__namespace.mkdirSync(partsDir, { recursive: true });
12581
12899
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || config.sarif === true) {
12582
- fs15__namespace.mkdirSync(reportsDir, { recursive: true });
12900
+ fs16__namespace.mkdirSync(reportsDir, { recursive: true });
12583
12901
  }
12584
12902
  const writtenArtifacts = /* @__PURE__ */ new Map();
12585
12903
  const writeArtifact = (targetDir, relativeEntry, data) => {
12586
- const full = path16__namespace.join(targetDir, ...relativeEntry.split("/"));
12587
- fs15__namespace.writeFileSync(full, data, "utf8");
12588
- const stats = fs15__namespace.statSync(full);
12904
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12905
+ fs16__namespace.writeFileSync(full, data, "utf8");
12906
+ const stats = fs16__namespace.statSync(full);
12589
12907
  writtenArtifacts.set(relativeEntry, {
12590
12908
  digest: { path: relativeEntry, bytes: stats.size, sha256: sha256Hex2(data) },
12591
12909
  mtimeMs: stats.mtimeMs
12592
12910
  });
12593
12911
  };
12594
12912
  const recordArtifact = (targetDir, relativeEntry) => {
12595
- const full = path16__namespace.join(targetDir, ...relativeEntry.split("/"));
12596
- const stats = fs15__namespace.statSync(full);
12913
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12914
+ const stats = fs16__namespace.statSync(full);
12597
12915
  writtenArtifacts.set(relativeEntry, {
12598
12916
  digest: {
12599
12917
  path: relativeEntry,
12600
12918
  bytes: stats.size,
12601
- sha256: sha256Hex2(fs15__namespace.readFileSync(full))
12919
+ sha256: sha256Hex2(fs16__namespace.readFileSync(full))
12602
12920
  },
12603
12921
  mtimeMs: stats.mtimeMs
12604
12922
  });
@@ -12646,7 +12964,7 @@ function generateSnapshot(configInput, options) {
12646
12964
  const shipHookState = () => {
12647
12965
  if (!markerBelongsTo(outDir, snapshotId)) return;
12648
12966
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
12649
- writeManifestAtomically(path16__namespace.join(outDir, "manifest.json"), manifest);
12967
+ writeManifestAtomically(path17__namespace.join(outDir, "manifest.json"), manifest);
12650
12968
  recordArtifact(outDir, "manifest.json");
12651
12969
  }
12652
12970
  writeOwnershipMarker(
@@ -12689,7 +13007,7 @@ function generateSnapshot(configInput, options) {
12689
13007
  } catch (err) {
12690
13008
  if (stagingDir !== null) {
12691
13009
  try {
12692
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
13010
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
12693
13011
  } catch {
12694
13012
  }
12695
13013
  }
@@ -12783,8 +13101,8 @@ function findSection(sections, relativePath) {
12783
13101
  if (exact) return exact;
12784
13102
  const foldedPath = rendered.toLowerCase();
12785
13103
  const folded = sections.filter((section) => {
12786
- const path22 = section.path.toLowerCase();
12787
- return path22 === relativePath.toLowerCase() || path22 === foldedPath;
13104
+ const path23 = section.path.toLowerCase();
13105
+ return path23 === relativePath.toLowerCase() || path23 === foldedPath;
12788
13106
  });
12789
13107
  return folded.length === 1 ? folded[0] : null;
12790
13108
  }
@@ -12810,9 +13128,9 @@ function foldForComparison(value) {
12810
13128
  return process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
12811
13129
  }
12812
13130
  function canonicalPath(value) {
12813
- const absolute = path16__namespace.resolve(value);
13131
+ const absolute = path17__namespace.resolve(value);
12814
13132
  try {
12815
- return fs15__namespace.realpathSync(absolute);
13133
+ return fs16__namespace.realpathSync(absolute);
12816
13134
  } catch {
12817
13135
  return absolute;
12818
13136
  }
@@ -12820,29 +13138,29 @@ function canonicalPath(value) {
12820
13138
  function isInside3(parent, child) {
12821
13139
  const foldedParent = foldForComparison(parent);
12822
13140
  const foldedChild = foldForComparison(child);
12823
- return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path16__namespace.sep}`);
13141
+ return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path17__namespace.sep}`);
12824
13142
  }
12825
13143
  function resolveThroughExistingAncestor(target) {
12826
13144
  let existing = target;
12827
13145
  const missing = [];
12828
- while (!fs15__namespace.existsSync(existing)) {
12829
- missing.unshift(path16__namespace.basename(existing));
12830
- const parent = path16__namespace.dirname(existing);
13146
+ while (!fs16__namespace.existsSync(existing)) {
13147
+ missing.unshift(path17__namespace.basename(existing));
13148
+ const parent = path17__namespace.dirname(existing);
12831
13149
  if (parent === existing) break;
12832
13150
  existing = parent;
12833
13151
  }
12834
13152
  const resolved = canonicalPath(existing);
12835
- return missing.length === 0 ? resolved : path16__namespace.join(resolved, ...missing);
13153
+ return missing.length === 0 ? resolved : path17__namespace.join(resolved, ...missing);
12836
13154
  }
12837
13155
  function resolveRoot(requested, context) {
12838
13156
  if (requested !== void 0 && (typeof requested !== "string" || requested.trim().length === 0)) {
12839
13157
  return { ok: false, message: '"root" must be a non-empty string when provided.' };
12840
13158
  }
12841
13159
  const wanted = typeof requested === "string" ? requested.trim() : context.cwd;
12842
- const absolute = path16__namespace.resolve(context.cwd, wanted);
13160
+ const absolute = path17__namespace.resolve(context.cwd, wanted);
12843
13161
  let stats;
12844
13162
  try {
12845
- stats = fs15__namespace.statSync(absolute);
13163
+ stats = fs16__namespace.statSync(absolute);
12846
13164
  } catch {
12847
13165
  return { ok: false, message: `"${wanted}" does not exist, so it cannot be a repository root.` };
12848
13166
  }
@@ -12894,7 +13212,7 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
12894
13212
  }
12895
13213
  const requested = overrides.outDir.trim();
12896
13214
  const permitted = allowedRoots !== void 0 && allowedRoots.length > 0 ? allowedRoots : [root];
12897
- const resolved = resolveThroughExistingAncestor(path16__namespace.resolve(root, requested));
13215
+ const resolved = resolveThroughExistingAncestor(path17__namespace.resolve(root, requested));
12898
13216
  if (!permitted.some((allowed) => isInside3(canonicalPath(allowed), resolved))) {
12899
13217
  const shown = permitted.map((allowed) => canonicalPath(allowed)).join(", ");
12900
13218
  return {
@@ -12927,25 +13245,25 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
12927
13245
  var MANIFEST_CACHE_LIMIT = 8;
12928
13246
  var manifestCache = /* @__PURE__ */ new Map();
12929
13247
  function manifestPathFor(workspace) {
12930
- return path16__namespace.resolve(workspace.root, workspace.config.outDir, "manifest.json");
13248
+ return path17__namespace.resolve(workspace.root, workspace.config.outDir, "manifest.json");
12931
13249
  }
12932
13250
  function partPathFor(workspace, filename) {
12933
13251
  if (filename.length === 0 || filename.includes("\0")) return null;
12934
- const partsDir = path16__namespace.resolve(workspace.root, workspace.config.outDir, "parts");
12935
- const resolved = path16__namespace.resolve(partsDir, filename);
12936
- const relative15 = path16__namespace.relative(partsDir, resolved);
12937
- if (relative15.length === 0 || relative15.includes(path16__namespace.sep) || relative15.includes("/") || relative15.includes("\\") || path16__namespace.isAbsolute(relative15)) {
13252
+ const partsDir = path17__namespace.resolve(workspace.root, workspace.config.outDir, "parts");
13253
+ const resolved = path17__namespace.resolve(partsDir, filename);
13254
+ const relative15 = path17__namespace.relative(partsDir, resolved);
13255
+ if (relative15.length === 0 || relative15.includes(path17__namespace.sep) || relative15.includes("/") || relative15.includes("\\") || path17__namespace.isAbsolute(relative15)) {
12938
13256
  return null;
12939
13257
  }
12940
13258
  let stats;
12941
13259
  try {
12942
- stats = fs15__namespace.lstatSync(resolved);
13260
+ stats = fs16__namespace.lstatSync(resolved);
12943
13261
  } catch {
12944
13262
  return null;
12945
13263
  }
12946
13264
  if (!stats.isFile()) return null;
12947
13265
  try {
12948
- if (path16__namespace.dirname(fs15__namespace.realpathSync(resolved)) !== fs15__namespace.realpathSync(partsDir)) return null;
13266
+ if (path17__namespace.dirname(fs16__namespace.realpathSync(resolved)) !== fs16__namespace.realpathSync(partsDir)) return null;
12949
13267
  } catch {
12950
13268
  return null;
12951
13269
  }
@@ -12953,10 +13271,10 @@ function partPathFor(workspace, filename) {
12953
13271
  }
12954
13272
  function readManifest3(workspace) {
12955
13273
  const file = manifestPathFor(workspace);
12956
- const shown = path16__namespace.relative(workspace.root, file).split(path16__namespace.sep).join("/") || file;
13274
+ const shown = path17__namespace.relative(workspace.root, file).split(path17__namespace.sep).join("/") || file;
12957
13275
  let stats;
12958
13276
  try {
12959
- stats = fs15__namespace.statSync(file);
13277
+ stats = fs16__namespace.statSync(file);
12960
13278
  } catch {
12961
13279
  return {
12962
13280
  ok: false,
@@ -12970,7 +13288,7 @@ function readManifest3(workspace) {
12970
13288
  }
12971
13289
  let raw;
12972
13290
  try {
12973
- raw = fs15__namespace.readFileSync(file, "utf8");
13291
+ raw = fs16__namespace.readFileSync(file, "utf8");
12974
13292
  } catch (error) {
12975
13293
  return {
12976
13294
  ok: false,
@@ -13082,7 +13400,7 @@ function formatBytes(bytes) {
13082
13400
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
13083
13401
  }
13084
13402
  function relativeFor(workspace, absolute) {
13085
- return path16__namespace.relative(workspace.root, absolute).split(path16__namespace.sep).join("/");
13403
+ return path17__namespace.relative(workspace.root, absolute).split(path17__namespace.sep).join("/");
13086
13404
  }
13087
13405
  function capped(values, limit = 20) {
13088
13406
  return { count: values.length, sample: values.slice(0, limit) };
@@ -13101,13 +13419,13 @@ function summarizeDrift(drift) {
13101
13419
  function toRelativePath(root, value) {
13102
13420
  const cleaned = value.trim();
13103
13421
  if (cleaned.length === 0 || cleaned.includes("\0")) return null;
13104
- const resolvedRoot = path16__namespace.resolve(root);
13105
- const absolute = path16__namespace.resolve(resolvedRoot, cleaned);
13106
- const relative15 = path16__namespace.relative(resolvedRoot, absolute);
13107
- if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path16__namespace.sep}`) || path16__namespace.isAbsolute(relative15)) {
13422
+ const resolvedRoot = path17__namespace.resolve(root);
13423
+ const absolute = path17__namespace.resolve(resolvedRoot, cleaned);
13424
+ const relative15 = path17__namespace.relative(resolvedRoot, absolute);
13425
+ if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative15)) {
13108
13426
  return null;
13109
13427
  }
13110
- return relative15.split(path16__namespace.sep).join("/");
13428
+ return relative15.split(path17__namespace.sep).join("/");
13111
13429
  }
13112
13430
  function symbolsOf(entry) {
13113
13431
  const summary = entry.summary;
@@ -13337,7 +13655,7 @@ var generateTool = {
13337
13655
  if (!result.ok) return failure(result.message);
13338
13656
  const summary = result.summary;
13339
13657
  forgetManifest(manifestPathFor(workspace));
13340
- const written = relativeFor(workspace, path16__namespace.resolve(workspace.root, workspace.config.outDir));
13658
+ const written = relativeFor(workspace, path17__namespace.resolve(workspace.root, workspace.config.outDir));
13341
13659
  const lines = [
13342
13660
  `Wrote ${written}/`,
13343
13661
  `Files: ${summary.totalFiles} included, ${summary.skippedCount} skipped, ${plural(summary.partsCount, "part")}`,
@@ -13738,7 +14056,7 @@ var readTool = {
13738
14056
  }
13739
14057
  let partText;
13740
14058
  try {
13741
- partText = fs15__namespace.readFileSync(partPath, "utf8");
14059
+ partText = fs16__namespace.readFileSync(partPath, "utf8");
13742
14060
  } catch {
13743
14061
  return failure(
13744
14062
  `${entry.part} could not be read, so the snapshot is damaged. Run snapshot_generate to rebuild it.`
@@ -14043,6 +14361,8 @@ var VALIDATE_OPTIONS = [
14043
14361
  "large-file-bytes",
14044
14362
  "max-monolith-bytes",
14045
14363
  "max-parts",
14364
+ "brief",
14365
+ "prompt-task",
14046
14366
  "include-monolith",
14047
14367
  "include-sensitive-files",
14048
14368
  "skip-artifacts",
@@ -14070,6 +14390,8 @@ var COMMAND_OPTION_SCOPE = {
14070
14390
  "max-monolith-bytes",
14071
14391
  "attachment-slots",
14072
14392
  "max-parts",
14393
+ "brief",
14394
+ "prompt-task",
14073
14395
  "include-monolith",
14074
14396
  "include-sensitive-files",
14075
14397
  "skip-artifacts",
@@ -14512,6 +14834,20 @@ function buildAgentContract() {
14512
14834
  appliesTo: optionAppliesTo("attachment-slots"),
14513
14835
  summary: "Files the destination accepts in one message (0 = no limit). PROMPT.md plans the delivery against it: which parts to attach, what to leave behind, and the part budget that would merge them. It does not change the payload."
14514
14836
  },
14837
+ {
14838
+ flag: "--brief",
14839
+ type: "string",
14840
+ default: "unset",
14841
+ appliesTo: optionAppliesTo("brief"),
14842
+ summary: "Path to the owner-written half of PROMPT.md: Stakes, The system, What came before, The bar and Calibration replace or extend the generated prose; any other heading is kept as Owner notes. The measured headings cannot be redefined. A missing file is an error and an edited file is config drift."
14843
+ },
14844
+ {
14845
+ flag: "--prompt-task",
14846
+ type: "string",
14847
+ default: "audit",
14848
+ appliesTo: optionAppliesTo("prompt-task"),
14849
+ summary: "Which job the brief is written for: audit (default), review or explain. It changes the opening section, not the standard."
14850
+ },
14515
14851
  {
14516
14852
  flag: "--max-parts",
14517
14853
  type: "number",
@@ -14732,6 +15068,8 @@ function buildAgentContract() {
14732
15068
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
14733
15069
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
14734
15070
  { key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
15071
+ { key: "brief", type: "string", default: "unset", summary: "Path to the owner-written half of PROMPT.md. Recognised headings: Stakes, The system, What came before, The bar, Calibration; unknown headings are kept as Owner notes; measured headings are refused. The file is digested, so editing it is drift." },
15072
+ { key: "promptTask", type: "string", default: "audit", summary: "Which job the brief is written for: audit, review or explain. The standard and the coverage duty are the same in all three." },
14735
15073
  { key: "maxParts", type: "number | null", default: null, summary: "Experimental: the most parts a snapshot may have. The per-part budget grows to fit, up to the run's own needs; the effective ceiling is recorded in manifest.budgets.maxPartBytes and may exceed maxPartBytes." },
14736
15074
  { key: "attachmentSlots", type: "number", default: 10, summary: "Files the destination accepts in one message (0 = no limit); PROMPT.md plans the delivery to fit. It does not change the payload, and it is not part of the config digest." },
14737
15075
  { key: "discovery", type: '"auto" | "git" | "walk"', default: "auto", summary: "How files are discovered; `walk` scans the tree and reads .gitignore directly when a .git directory cannot be listed." },
@@ -14999,17 +15337,17 @@ var LEGACY_AGENTS_MARKER = "<!-- codebase-snapshot:skill:start -->";
14999
15337
  function targetPath(cwd, target) {
15000
15338
  switch (target) {
15001
15339
  case "claude":
15002
- return path16__namespace.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15340
+ return path17__namespace.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15003
15341
  case "cursor":
15004
- return path16__namespace.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15342
+ return path17__namespace.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15005
15343
  }
15006
15344
  }
15007
15345
  function assertWritableInsideRepository(cwd, filePath) {
15008
- const root = fs15__namespace.realpathSync(cwd);
15009
- const shown = path16__namespace.relative(root, filePath) || filePath;
15346
+ const root = fs16__namespace.realpathSync(cwd);
15347
+ const shown = path17__namespace.relative(root, filePath) || filePath;
15010
15348
  let stat = null;
15011
15349
  try {
15012
- stat = fs15__namespace.lstatSync(filePath);
15350
+ stat = fs16__namespace.lstatSync(filePath);
15013
15351
  } catch {
15014
15352
  stat = null;
15015
15353
  }
@@ -15025,32 +15363,32 @@ function assertWritableInsideRepository(cwd, filePath) {
15025
15363
  }
15026
15364
  let existing = filePath;
15027
15365
  const missing = [];
15028
- while (!fs15__namespace.existsSync(existing)) {
15029
- missing.unshift(path16__namespace.basename(existing));
15030
- const parent = path16__namespace.dirname(existing);
15366
+ while (!fs16__namespace.existsSync(existing)) {
15367
+ missing.unshift(path17__namespace.basename(existing));
15368
+ const parent = path17__namespace.dirname(existing);
15031
15369
  if (parent === existing) break;
15032
15370
  existing = parent;
15033
15371
  }
15034
- const realAncestor = fs15__namespace.realpathSync(existing);
15035
- const resolved = missing.length === 0 ? realAncestor : path16__namespace.join(realAncestor, ...missing);
15036
- if (resolved !== root && !resolved.startsWith(`${root}${path16__namespace.sep}`)) {
15372
+ const realAncestor = fs16__namespace.realpathSync(existing);
15373
+ const resolved = missing.length === 0 ? realAncestor : path17__namespace.join(realAncestor, ...missing);
15374
+ if (resolved !== root && !resolved.startsWith(`${root}${path17__namespace.sep}`)) {
15037
15375
  throw new Error(
15038
15376
  `${REFUSED}: ${shown} resolves outside the repository (${resolved}). Move it back inside ${root}, or remove the link, and run again.`
15039
15377
  );
15040
15378
  }
15041
15379
  }
15042
15380
  function writeIfChanged(target, filePath, content) {
15043
- const existing = fs15__namespace.existsSync(filePath) ? fs15__namespace.readFileSync(filePath, "utf8") : null;
15381
+ const existing = fs16__namespace.existsSync(filePath) ? fs16__namespace.readFileSync(filePath, "utf8") : null;
15044
15382
  if (existing === content) return { target, path: filePath, action: "unchanged" };
15045
- fs15__namespace.mkdirSync(path16__namespace.dirname(filePath), { recursive: true });
15046
- fs15__namespace.writeFileSync(filePath, content, "utf8");
15383
+ fs16__namespace.mkdirSync(path17__namespace.dirname(filePath), { recursive: true });
15384
+ fs16__namespace.writeFileSync(filePath, content, "utf8");
15047
15385
  return { target, path: filePath, action: existing === null ? "created" : "updated" };
15048
15386
  }
15049
15387
  function legacyAgentsNote(cwd) {
15050
- const filePath = path16__namespace.join(cwd, "AGENTS.md");
15388
+ const filePath = path17__namespace.join(cwd, "AGENTS.md");
15051
15389
  try {
15052
- if (!fs15__namespace.existsSync(filePath)) return null;
15053
- if (!fs15__namespace.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15390
+ if (!fs16__namespace.existsSync(filePath)) return null;
15391
+ if (!fs16__namespace.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15054
15392
  } catch {
15055
15393
  return null;
15056
15394
  }
@@ -15062,9 +15400,9 @@ function installSkill(cwd, target = "all") {
15062
15400
  const notes = [];
15063
15401
  const wanted = target === "all" ? ["claude", "cursor"] : [target];
15064
15402
  for (const item of wanted) assertWritableInsideRepository(cwd, targetPath(cwd, item));
15065
- const createsSomething = wanted.some((item) => !fs15__namespace.existsSync(targetPath(cwd, item)));
15403
+ const createsSomething = wanted.some((item) => !fs16__namespace.existsSync(targetPath(cwd, item)));
15066
15404
  if (createsSomething) {
15067
- assertWritableInsideRepository(cwd, path16__namespace.join(cwd, ".gitignore"));
15405
+ assertWritableInsideRepository(cwd, path17__namespace.join(cwd, ".gitignore"));
15068
15406
  }
15069
15407
  for (const item of wanted) {
15070
15408
  written.push(writeIfChanged(item, targetPath(cwd, item), skill));
@@ -15225,7 +15563,7 @@ async function workspaceFor(context) {
15225
15563
  }
15226
15564
  function readFileIfPresent(file) {
15227
15565
  try {
15228
- return fs15__namespace.readFileSync(file, "utf8");
15566
+ return fs16__namespace.readFileSync(file, "utf8");
15229
15567
  } catch {
15230
15568
  return null;
15231
15569
  }
@@ -15321,7 +15659,7 @@ function buildResourceProvider() {
15321
15659
  const report = REPORT_URIS.get(uri);
15322
15660
  if (report) {
15323
15661
  const text2 = readFileIfPresent(
15324
- path16__namespace.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15662
+ path17__namespace.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15325
15663
  );
15326
15664
  if (text2 === null) return null;
15327
15665
  return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, REPORT_ADVICE) };
@@ -15343,7 +15681,7 @@ function buildResourceProvider() {
15343
15681
  if (partPath === null) return null;
15344
15682
  let partBytes;
15345
15683
  try {
15346
- partBytes = fs15__namespace.statSync(partPath).size;
15684
+ partBytes = fs16__namespace.statSync(partPath).size;
15347
15685
  } catch {
15348
15686
  return null;
15349
15687
  }
@@ -15379,52 +15717,52 @@ function validateArguments(schema, value) {
15379
15717
  }
15380
15718
  return problems;
15381
15719
  }
15382
- function checkValue(path22, schema, value) {
15720
+ function checkValue(path23, schema, value) {
15383
15721
  if (schema.enum && !schema.enum.includes(value)) {
15384
- return [`"${path22}" must be one of: ${schema.enum.join(", ")}`];
15722
+ return [`"${path23}" must be one of: ${schema.enum.join(", ")}`];
15385
15723
  }
15386
15724
  switch (schema.type) {
15387
15725
  case "string": {
15388
- if (typeof value !== "string") return [`"${path22}" must be a string`];
15726
+ if (typeof value !== "string") return [`"${path23}" must be a string`];
15389
15727
  const problems = [];
15390
15728
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
15391
- problems.push(`"${path22}" must be at least ${schema.minLength} character(s)`);
15729
+ problems.push(`"${path23}" must be at least ${schema.minLength} character(s)`);
15392
15730
  }
15393
15731
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
15394
- problems.push(`"${path22}" must be at most ${schema.maxLength} character(s)`);
15732
+ problems.push(`"${path23}" must be at most ${schema.maxLength} character(s)`);
15395
15733
  }
15396
15734
  return problems;
15397
15735
  }
15398
15736
  case "number":
15399
15737
  case "integer": {
15400
15738
  if (typeof value !== "number" || Number.isNaN(value)) {
15401
- return [`"${path22}" must be a number`];
15739
+ return [`"${path23}" must be a number`];
15402
15740
  }
15403
15741
  if (schema.type === "integer" && !Number.isInteger(value)) {
15404
- return [`"${path22}" must be an integer`];
15742
+ return [`"${path23}" must be an integer`];
15405
15743
  }
15406
15744
  const problems = [];
15407
15745
  if (schema.minimum !== void 0 && value < schema.minimum) {
15408
- problems.push(`"${path22}" must be >= ${schema.minimum}`);
15746
+ problems.push(`"${path23}" must be >= ${schema.minimum}`);
15409
15747
  }
15410
15748
  if (schema.maximum !== void 0 && value > schema.maximum) {
15411
- problems.push(`"${path22}" must be <= ${schema.maximum}`);
15749
+ problems.push(`"${path23}" must be <= ${schema.maximum}`);
15412
15750
  }
15413
15751
  return problems;
15414
15752
  }
15415
15753
  case "boolean":
15416
- return typeof value === "boolean" ? [] : [`"${path22}" must be a boolean`];
15754
+ return typeof value === "boolean" ? [] : [`"${path23}" must be a boolean`];
15417
15755
  case "array": {
15418
- if (!Array.isArray(value)) return [`"${path22}" must be an array`];
15756
+ if (!Array.isArray(value)) return [`"${path23}" must be an array`];
15419
15757
  if (!schema.items) return [];
15420
15758
  const problems = [];
15421
15759
  value.forEach((item, index) => {
15422
- problems.push(...checkValue(`${path22}[${index}]`, schema.items, item));
15760
+ problems.push(...checkValue(`${path23}[${index}]`, schema.items, item));
15423
15761
  });
15424
15762
  return problems;
15425
15763
  }
15426
15764
  case "object":
15427
- return isJsonObject(value) ? [] : [`"${path22}" must be an object`];
15765
+ return isJsonObject(value) ? [] : [`"${path23}" must be an object`];
15428
15766
  default:
15429
15767
  return [];
15430
15768
  }
@@ -16000,6 +16338,8 @@ var CLI_OPTIONS = {
16000
16338
  "max-monolith-bytes": { type: "string" },
16001
16339
  "attachment-slots": { type: "string" },
16002
16340
  "max-parts": { type: "string" },
16341
+ brief: { type: "string" },
16342
+ "prompt-task": { type: "string" },
16003
16343
  "include-monolith": { type: "boolean" },
16004
16344
  "include-sensitive-files": { type: "boolean" },
16005
16345
  "skip-artifacts": { type: "string" },
@@ -16078,6 +16418,9 @@ Options:
16078
16418
  0 = no limit); PROMPT.md plans the delivery to fit
16079
16419
  --max-parts <n> Experimental: grow the part budget until the snapshot has at
16080
16420
  most n parts, instead of adding parts as the code grows
16421
+ --brief <path> Owner-written half of PROMPT.md (stakes, system, history,
16422
+ bar, calibration); merged at fixed slots
16423
+ --prompt-task <task> audit | review | explain - which job the brief is for
16081
16424
  --skip-artifacts <names> Comma-separated artifacts to omit
16082
16425
  (readme, manifest, parts, navigation,
16083
16426
  projectTree, audit, monolith)
@@ -16162,6 +16505,13 @@ function parseCountOption(raw, optionName, minimum = 0) {
16162
16505
  }
16163
16506
  return value;
16164
16507
  }
16508
+ function parsePromptTask(value) {
16509
+ if (value === void 0) return void 0;
16510
+ if (value === "audit" || value === "review" || value === "explain") return value;
16511
+ throw new UsageError(
16512
+ '--prompt-task expects audit, review or explain, received "' + value + '".'
16513
+ );
16514
+ }
16165
16515
  function parseArtifactList(raw, flag) {
16166
16516
  const names = raw.split(",").map((name) => name.trim()).filter(Boolean);
16167
16517
  if (names.length === 0) {
@@ -16226,10 +16576,10 @@ function parseCliArgs(argv) {
16226
16576
  }
16227
16577
  if (values.cwd !== void 0) {
16228
16578
  const target = String(values.cwd);
16229
- if (!fs15__namespace.existsSync(target)) {
16579
+ if (!fs16__namespace.existsSync(target)) {
16230
16580
  throw new UsageError(`--cwd directory does not exist: ${target}`);
16231
16581
  }
16232
- if (!fs15__namespace.statSync(target).isDirectory()) {
16582
+ if (!fs16__namespace.statSync(target).isDirectory()) {
16233
16583
  throw new UsageError(`--cwd is not a directory: ${target}`);
16234
16584
  }
16235
16585
  }
@@ -16375,7 +16725,7 @@ function parseCliArgs(argv) {
16375
16725
  install: values.install === true,
16376
16726
  noInstall: values["no-install"] === true,
16377
16727
  target: values.target === void 0 ? void 0 : String(values.target),
16378
- cwd: values.cwd === void 0 ? process.cwd() : path16__namespace.resolve(String(values.cwd)),
16728
+ cwd: values.cwd === void 0 ? process.cwd() : path17__namespace.resolve(String(values.cwd)),
16379
16729
  outDir: values["out-dir"] === void 0 ? void 0 : String(values["out-dir"]),
16380
16730
  includeMonolith: values["include-monolith"] === true || onlyNamesMonolith === true ? true : void 0,
16381
16731
  includeSensitiveFiles: values["include-sensitive-files"] === true ? true : void 0,
@@ -16408,6 +16758,8 @@ function parseCliArgs(argv) {
16408
16758
  "attachment-slots"
16409
16759
  ),
16410
16760
  maxParts: parseCountOption(values["max-parts"], "max-parts", 1),
16761
+ brief: values.brief === void 0 ? void 0 : String(values.brief),
16762
+ promptTask: parsePromptTask(values["prompt-task"]),
16411
16763
  skipArtifacts,
16412
16764
  onlyArtifacts,
16413
16765
  discovery: isDiscoveryMode(rawDiscovery) ? rawDiscovery : void 0,
@@ -16461,9 +16813,9 @@ function splitList(value) {
16461
16813
  return value.split(",").map((entry) => entry.trim()).filter(Boolean);
16462
16814
  }
16463
16815
  function displayOutPath(cwd, outDir, ...segments) {
16464
- const absolute = path16__namespace.resolve(cwd, outDir, ...segments);
16465
- const relative15 = path16__namespace.relative(cwd, absolute);
16466
- if (relative15 && !relative15.startsWith("..") && !path16__namespace.isAbsolute(relative15)) return relative15;
16816
+ const absolute = path17__namespace.resolve(cwd, outDir, ...segments);
16817
+ const relative15 = path17__namespace.relative(cwd, absolute);
16818
+ if (relative15 && !relative15.startsWith("..") && !path17__namespace.isAbsolute(relative15)) return relative15;
16467
16819
  return absolute;
16468
16820
  }
16469
16821
  function nextStepHint(cwd, scriptsAddedNow) {
@@ -16471,7 +16823,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
16471
16823
  if (!hasScript) {
16472
16824
  try {
16473
16825
  const parsed = JSON.parse(
16474
- stripJsonComments(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"))
16826
+ stripJsonComments(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"))
16475
16827
  );
16476
16828
  hasScript = typeof parsed.scripts?.snapshot === "string";
16477
16829
  } catch {
@@ -16479,8 +16831,8 @@ function nextStepHint(cwd, scriptsAddedNow) {
16479
16831
  }
16480
16832
  }
16481
16833
  if (!hasScript) return `npx ${GENERATOR_NAME} generate`;
16482
- const bin = path16__namespace.join(cwd, "node_modules", ".bin", "codebase-snapshot");
16483
- const installed = fs15__namespace.existsSync(bin) || fs15__namespace.existsSync(`${bin}.cmd`);
16834
+ const bin = path17__namespace.join(cwd, "node_modules", ".bin", "codebase-snapshot");
16835
+ const installed = fs16__namespace.existsSync(bin) || fs16__namespace.existsSync(`${bin}.cmd`);
16484
16836
  return installed ? "npm run snapshot" : "npm install && npm run snapshot";
16485
16837
  }
16486
16838
  function presetSummary(init) {
@@ -16516,7 +16868,7 @@ async function runInitCommand(invocation) {
16516
16868
  if (hook) for (const note of hook.notes) info(` ${note}`);
16517
16869
  return 0;
16518
16870
  }
16519
- info(`\u2705 Created ${path16__namespace.basename(result.configPath)} (${presetSummary(result)})`);
16871
+ info(`\u2705 Created ${path17__namespace.basename(result.configPath)} (${presetSummary(result)})`);
16520
16872
  if (result.scripts.length > 0) info(` Added npm scripts: ${result.scripts.join(", ")}`);
16521
16873
  if (result.dependency.added && result.dependency.range !== null) {
16522
16874
  info(` Added devDependency: ${result.dependency.name} ${result.dependency.range}`);
@@ -16539,18 +16891,18 @@ async function runInitCommand(invocation) {
16539
16891
  function generatorOrigin(cwd) {
16540
16892
  try {
16541
16893
  const pkg = JSON.parse(
16542
- stripJsonComments(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"))
16894
+ stripJsonComments(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"))
16543
16895
  );
16544
16896
  const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
16545
16897
  if (typeof spec === "string") return `project dependency ${spec}`;
16546
16898
  } catch {
16547
16899
  }
16548
16900
  const entry = process.argv[1] ?? "";
16549
- if (entry.includes("_npx") || entry.includes(`${path16__namespace.sep}npx${path16__namespace.sep}`)) return "via npx";
16901
+ if (entry.includes("_npx") || entry.includes(`${path17__namespace.sep}npx${path17__namespace.sep}`)) return "via npx";
16550
16902
  return "global or direct install";
16551
16903
  }
16552
16904
  function detectPackageManager(cwd) {
16553
- const has = (name) => fs15__namespace.existsSync(path16__namespace.join(cwd, name));
16905
+ const has = (name) => fs16__namespace.existsSync(path17__namespace.join(cwd, name));
16554
16906
  if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
16555
16907
  if (has("pnpm-lock.yaml")) return { name: "pnpm", command: "pnpm", args: ["install"] };
16556
16908
  if (has("yarn.lock")) return { name: "yarn", command: "yarn", args: ["install"] };
@@ -16667,7 +17019,7 @@ async function runSetupCommand(invocation, options = {}) {
16667
17019
  }
16668
17020
  info("\n\u{1F9EA} Dry run \u2014 setup would:");
16669
17021
  info(
16670
- ` 1. ${init.reused ? `keep ${path16__namespace.basename(keptConfigPath)}` : `write ${path16__namespace.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
17022
+ ` 1. ${init.reused ? `keep ${path17__namespace.basename(keptConfigPath)}` : `write ${path17__namespace.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
16671
17023
  );
16672
17024
  info(" 2. add the npm scripts, the devDependency and the .gitignore entries");
16673
17025
  if (manager !== null) info(` 3. install with ${manager}`);
@@ -16680,9 +17032,9 @@ async function runSetupCommand(invocation, options = {}) {
16680
17032
  if (invocation.format !== "json") {
16681
17033
  if (!interactive) info(`\u{1F680} Setup for: ${invocation.cwd}`);
16682
17034
  if (init.reused) {
16683
- info(`\u267B Keeping ${path16__namespace.basename(keptConfigPath)}`);
17035
+ info(`\u267B Keeping ${path17__namespace.basename(keptConfigPath)}`);
16684
17036
  } else {
16685
- info(`\u2705 Created ${path16__namespace.basename(keptConfigPath)} (${presetSummary(init)})`);
17037
+ info(`\u2705 Created ${path17__namespace.basename(keptConfigPath)} (${presetSummary(init)})`);
16686
17038
  }
16687
17039
  if (init.scripts.length > 0) info(` Added npm scripts: ${init.scripts.join(", ")}`);
16688
17040
  if (init.dependency.added && init.dependency.range !== null) {
@@ -16696,7 +17048,7 @@ async function runSetupCommand(invocation, options = {}) {
16696
17048
  info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
16697
17049
  }
16698
17050
  }
16699
- const hasManifest = fs15__namespace.existsSync(path16__namespace.join(invocation.cwd, "package.json"));
17051
+ const hasManifest = fs16__namespace.existsSync(path17__namespace.join(invocation.cwd, "package.json"));
16700
17052
  let install = null;
16701
17053
  if (invocation.noInstall) {
16702
17054
  if (invocation.format !== "json") info(" Skipped the install (--no-install)");
@@ -16739,6 +17091,10 @@ async function runSetupCommand(invocation, options = {}) {
16739
17091
  if (invocation.maxParts !== void 0) {
16740
17092
  generateArgs.push("--max-parts", String(invocation.maxParts));
16741
17093
  }
17094
+ if (invocation.brief !== void 0) generateArgs.push("--brief", invocation.brief);
17095
+ if (invocation.promptTask !== void 0) {
17096
+ generateArgs.push("--prompt-task", invocation.promptTask);
17097
+ }
16742
17098
  if (invocation.skeleton === true) generateArgs.push("--skeleton");
16743
17099
  if (invocation.sarif === true) generateArgs.push("--sarif");
16744
17100
  if (invocation.noUpdateCheck) generateArgs.push("--no-update-check");
@@ -16824,7 +17180,7 @@ function runSkillCommand(invocation) {
16824
17180
  }
16825
17181
  info(`\u2705 Agent skill installed (${SKILL_NAME}):`);
16826
17182
  for (const item of result.written) {
16827
- const shown = path16__namespace.relative(invocation.cwd, item.path) || item.path;
17183
+ const shown = path17__namespace.relative(invocation.cwd, item.path) || item.path;
16828
17184
  info(` - ${item.action.padEnd(9)} ${shown}`);
16829
17185
  }
16830
17186
  if (result.gitignored.length > 0) {
@@ -16945,7 +17301,7 @@ ${USAGE}
16945
17301
  return runSkillCommand(invocation);
16946
17302
  }
16947
17303
  if (invocation.command === "mcp") {
16948
- return await runStdioServer({ cwd: path16__namespace.resolve(invocation.cwd) });
17304
+ return await runStdioServer({ cwd: path17__namespace.resolve(invocation.cwd) });
16949
17305
  }
16950
17306
  if (invocation.command === "setup") {
16951
17307
  return runSetupCommand(invocation);
@@ -16964,7 +17320,7 @@ ${USAGE}
16964
17320
  );
16965
17321
  }
16966
17322
  for (const warning of loaded.warnings) warn(`\u26A0 Config: ${warning}`);
16967
- if (loaded.file) info(`\u2699 Using config ${path16__namespace.relative(process.cwd(), loaded.file) || loaded.file}`);
17323
+ if (loaded.file) info(`\u2699 Using config ${path17__namespace.relative(process.cwd(), loaded.file) || loaded.file}`);
16968
17324
  let resolved;
16969
17325
  try {
16970
17326
  resolved = resolveConfig(
@@ -16983,6 +17339,8 @@ ${USAGE}
16983
17339
  maxMonolithBytes: invocation.maxMonolithBytes,
16984
17340
  attachmentSlots: invocation.attachmentSlots,
16985
17341
  maxParts: invocation.maxParts,
17342
+ brief: invocation.brief,
17343
+ promptTask: invocation.promptTask,
16986
17344
  skipArtifacts: invocation.skipArtifacts,
16987
17345
  // `--only-artifacts` is forwarded as itself, not only as the derived suppression list:
16988
17346
  // suppression cannot switch an artifact *on*, so a config that had turned one of the
@@ -17006,13 +17364,13 @@ ${USAGE}
17006
17364
  return result.valid ? 0 : 1;
17007
17365
  }
17008
17366
  if (invocation.command === "report") {
17009
- const manifestPath = path16__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17010
- if (!fs15__namespace.existsSync(manifestPath)) {
17367
+ const manifestPath = path17__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17368
+ if (!fs16__namespace.existsSync(manifestPath)) {
17011
17369
  return fail(invocation.format, `Manifest not found at ${manifestPath}. Run generate first.`);
17012
17370
  }
17013
17371
  let manifest;
17014
17372
  try {
17015
- manifest = JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
17373
+ manifest = JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
17016
17374
  } catch (err) {
17017
17375
  return fail(invocation.format, `Could not read ${manifestPath}: ${err.message}`);
17018
17376
  }
@@ -17216,19 +17574,19 @@ function finishWatchRun(state, now) {
17216
17574
  };
17217
17575
  }
17218
17576
  function comparablePath(value) {
17219
- const absolute = path16__namespace.resolve(value);
17577
+ const absolute = path17__namespace.resolve(value);
17220
17578
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
17221
17579
  }
17222
17580
  function isSameOrInside(parent, candidate) {
17223
- const relative15 = path16__namespace.relative(parent, candidate);
17224
- return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path16__namespace.sep}`) && !path16__namespace.isAbsolute(relative15);
17581
+ const relative15 = path17__namespace.relative(parent, candidate);
17582
+ return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path17__namespace.sep}`) && !path17__namespace.isAbsolute(relative15);
17225
17583
  }
17226
17584
  function isGeneratedWatchPath(candidate, paths) {
17227
- const absolute = comparablePath(path16__namespace.resolve(paths.cwd, candidate));
17228
- const outDir = comparablePath(path16__namespace.resolve(paths.cwd, paths.outDir));
17229
- const tmpDir = comparablePath(path16__namespace.resolve(paths.cwd, paths.tmpDir));
17585
+ const absolute = comparablePath(path17__namespace.resolve(paths.cwd, candidate));
17586
+ const outDir = comparablePath(path17__namespace.resolve(paths.cwd, paths.outDir));
17587
+ const tmpDir = comparablePath(path17__namespace.resolve(paths.cwd, paths.tmpDir));
17230
17588
  if (isSameOrInside(outDir, absolute) || isSameOrInside(tmpDir, absolute)) return true;
17231
- const offsets = [path16__namespace.basename(outDir), path16__namespace.basename(tmpDir)].filter((name) => name.length > 0);
17589
+ const offsets = [path17__namespace.basename(outDir), path17__namespace.basename(tmpDir)].filter((name) => name.length > 0);
17232
17590
  const leftover = absolute.split(/[\\/]+/).some(
17233
17591
  (segment) => offsets.some(
17234
17592
  (name) => segment.startsWith(`${name}.backup-`) || segment.startsWith(`${name}.partial-`)
@@ -17251,8 +17609,8 @@ function decideWatchEvent(state, event, paths) {
17251
17609
  function watchPathsFor(config) {
17252
17610
  return {
17253
17611
  cwd: config.cwd,
17254
- outDir: path16__namespace.resolve(config.cwd, config.outDir),
17255
- tmpDir: path16__namespace.resolve(config.cwd, config.tmpDir)
17612
+ outDir: path17__namespace.resolve(config.cwd, config.outDir),
17613
+ tmpDir: path17__namespace.resolve(config.cwd, config.tmpDir)
17256
17614
  };
17257
17615
  }
17258
17616
  function watchSupportProblem(platform = process.platform, version = process.versions.node) {
@@ -17310,6 +17668,8 @@ async function runWatchLoop(invocation, resolved, options) {
17310
17668
  maxMonolithBytes: invocation.maxMonolithBytes,
17311
17669
  attachmentSlots: invocation.attachmentSlots,
17312
17670
  maxParts: invocation.maxParts,
17671
+ brief: invocation.brief,
17672
+ promptTask: invocation.promptTask,
17313
17673
  skipArtifacts: invocation.skipArtifacts,
17314
17674
  onlyArtifacts: invocation.onlyArtifacts,
17315
17675
  discovery: invocation.discovery,
@@ -17338,11 +17698,11 @@ async function runWatchLoop(invocation, resolved, options) {
17338
17698
  info("\u{1F440} Watching for changes. Press Ctrl+C to stop.");
17339
17699
  let watcher;
17340
17700
  try {
17341
- watcher = fs15__namespace.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17701
+ watcher = fs16__namespace.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17342
17702
  const decision = decideWatchEvent(
17343
17703
  state,
17344
17704
  {
17345
- path: filename ? path16__namespace.resolve(resolved.cwd, filename.toString()) : null,
17705
+ path: filename ? path17__namespace.resolve(resolved.cwd, filename.toString()) : null,
17346
17706
  now: performance.now()
17347
17707
  },
17348
17708
  paths
@@ -17381,7 +17741,7 @@ async function runWatchLoop(invocation, resolved, options) {
17381
17741
  return 0;
17382
17742
  }
17383
17743
  var entryFile = process.argv[1] ?? "";
17384
- var entryName = path16__namespace.basename(entryFile).toLowerCase();
17744
+ var entryName = path17__namespace.basename(entryFile).toLowerCase();
17385
17745
  var invokedDirectly = entryName === "cli.js" || entryName === "cli.cjs";
17386
17746
  if (invokedDirectly) {
17387
17747
  void main().then(