codebase-snapshot 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.0";
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,14 @@ 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 recentCommits(cwd, limit = 10) {
2672
2673
  try {
2673
2674
  const stdout = childProcess__namespace.execFileSync(
2674
2675
  "git",
2675
- ["log", "-n", String(limit), "--pretty=%s", "--no-color"],
2676
+ // \x1f between fields and \x1e between records: neither can appear in a commit message, so
2677
+ // the parse cannot be confused by a message that contains a newline or a dash.
2678
+ ["log", "-n", String(limit), "--pretty=format:%s%x1f%b%x1e", "--no-color"],
2676
2679
  {
2677
2680
  cwd,
2678
2681
  stdio: ["ignore", "pipe", "ignore"],
@@ -2680,7 +2683,16 @@ function recentCommitSubjects(cwd, limit = 10) {
2680
2683
  maxBuffer: GIT_OUTPUT_LIMIT
2681
2684
  }
2682
2685
  );
2683
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
2686
+ return stdout.split("").map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
2687
+ const separator = record.indexOf("");
2688
+ const subject = separator === -1 ? record : record.slice(0, separator);
2689
+ const rawBody = separator === -1 ? "" : record.slice(separator + 1);
2690
+ const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ");
2691
+ return {
2692
+ subject: subject.trim(),
2693
+ body: body.length > COMMIT_BODY_LIMIT ? body.slice(0, COMMIT_BODY_LIMIT - 1) + "\u2026" : body
2694
+ };
2695
+ }).filter((commit) => commit.subject.length > 0);
2684
2696
  } catch {
2685
2697
  return [];
2686
2698
  }
@@ -2704,7 +2716,7 @@ function listIgnoredPaths(cwd) {
2704
2716
  }
2705
2717
  function hasSnapshotMarker(target) {
2706
2718
  try {
2707
- return fs15__namespace.statSync(target).isDirectory() && fs15__namespace.existsSync(path16__namespace.join(target, ".codebase-snapshot"));
2719
+ return fs16__namespace.statSync(target).isDirectory() && fs16__namespace.existsSync(path17__namespace.join(target, ".codebase-snapshot"));
2708
2720
  } catch {
2709
2721
  return false;
2710
2722
  }
@@ -2713,7 +2725,7 @@ var IGNORABLE_DIRECTORY_ENTRIES = /* @__PURE__ */ new Set([".DS_Store"]);
2713
2725
  function isToolOwnedDirectory2(dir) {
2714
2726
  let raw;
2715
2727
  try {
2716
- raw = fs15__namespace.readFileSync(path16__namespace.join(dir, ".codebase-snapshot"), "utf8");
2728
+ raw = fs16__namespace.readFileSync(path17__namespace.join(dir, ".codebase-snapshot"), "utf8");
2717
2729
  } catch {
2718
2730
  return false;
2719
2731
  }
@@ -2740,7 +2752,7 @@ function isToolOwnedDirectory2(dir) {
2740
2752
  }
2741
2753
  let entries;
2742
2754
  try {
2743
- entries = fs15__namespace.readdirSync(dir);
2755
+ entries = fs16__namespace.readdirSync(dir);
2744
2756
  } catch {
2745
2757
  return false;
2746
2758
  }
@@ -2757,7 +2769,7 @@ function makeToolOwnedDecider(cwd, toolOwnedPaths) {
2757
2769
  const prefix = parts.slice(0, depth).join("/");
2758
2770
  let hasMarker = markers.get(prefix);
2759
2771
  if (hasMarker === void 0) {
2760
- hasMarker = isToolOwnedDirectory2(path16__namespace.join(cwd, prefix));
2772
+ hasMarker = isToolOwnedDirectory2(path17__namespace.join(cwd, prefix));
2761
2773
  markers.set(prefix, hasMarker);
2762
2774
  }
2763
2775
  if (hasMarker) return true;
@@ -2772,7 +2784,7 @@ function makeLinkProbe() {
2772
2784
  let known = cache.get(absolutePath);
2773
2785
  if (known === void 0) {
2774
2786
  try {
2775
- known = fs15__namespace.lstatSync(absolutePath).isSymbolicLink();
2787
+ known = fs16__namespace.lstatSync(absolutePath).isSymbolicLink();
2776
2788
  } catch {
2777
2789
  known = false;
2778
2790
  }
@@ -2785,7 +2797,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2785
2797
  const isLink = makeLinkProbe();
2786
2798
  let rootReal = cwd;
2787
2799
  try {
2788
- rootReal = fs15__namespace.realpathSync(cwd);
2800
+ rootReal = fs16__namespace.realpathSync(cwd);
2789
2801
  } catch {
2790
2802
  }
2791
2803
  const reported = /* @__PURE__ */ new Set();
@@ -2800,7 +2812,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2800
2812
  let linkedPath = null;
2801
2813
  for (let depth = 1; depth <= parts.length; depth += 1) {
2802
2814
  const prefix = parts.slice(0, depth).join("/");
2803
- if (isLink(path16__namespace.join(cwd, prefix))) {
2815
+ if (isLink(path17__namespace.join(cwd, prefix))) {
2804
2816
  linkedPath = prefix;
2805
2817
  break;
2806
2818
  }
@@ -2809,11 +2821,11 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2809
2821
  kept.push(candidate);
2810
2822
  continue;
2811
2823
  }
2812
- const absolute = path16__namespace.join(cwd, linkedPath);
2824
+ const absolute = path17__namespace.join(cwd, linkedPath);
2813
2825
  const rawTarget = readLinkTarget(absolute, absolute);
2814
2826
  let targetReal = null;
2815
2827
  try {
2816
- targetReal = fs15__namespace.realpathSync(absolute);
2828
+ targetReal = fs16__namespace.realpathSync(absolute);
2817
2829
  } catch {
2818
2830
  targetReal = null;
2819
2831
  }
@@ -2831,7 +2843,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
2831
2843
  }
2832
2844
  let stats = null;
2833
2845
  try {
2834
- stats = fs15__namespace.statSync(absolute);
2846
+ stats = fs16__namespace.statSync(absolute);
2835
2847
  } catch {
2836
2848
  stats = null;
2837
2849
  }
@@ -2919,7 +2931,7 @@ function collectFiles(cwd, options = {}) {
2919
2931
  "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
2932
  );
2921
2933
  }
2922
- if (fs15__namespace.existsSync(path16__namespace.join(cwd, ".git"))) {
2934
+ if (fs16__namespace.existsSync(path17__namespace.join(cwd, ".git"))) {
2923
2935
  throw new Error(
2924
2936
  "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
2937
  );
@@ -2987,7 +2999,7 @@ function collectFiles(cwd, options = {}) {
2987
2999
  }
2988
3000
  function rootRealFor(root) {
2989
3001
  try {
2990
- return fs15__namespace.realpathSync(root);
3002
+ return fs16__namespace.realpathSync(root);
2991
3003
  } catch {
2992
3004
  return root;
2993
3005
  }
@@ -2996,18 +3008,18 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
2996
3008
  const results = { files: [], skipped: [] };
2997
3009
  const stack = [];
2998
3010
  const toolDirNames = toolDirNamesFor(reservedPaths);
2999
- const relativeToBase = (target) => path16__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
3011
+ const relativeToBase = (target) => path17__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
3000
3012
  const enter = (current, layers) => {
3001
3013
  if (visited.has(current)) return false;
3002
3014
  visited.add(current);
3003
3015
  const localRules = readGitignoreRules(current);
3004
3016
  const gitignoreLayers = localRules.length === 0 ? layers : [
3005
3017
  ...layers,
3006
- { prefix: path16__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
3018
+ { prefix: path17__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
3007
3019
  ];
3008
3020
  let entries;
3009
3021
  try {
3010
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
3022
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
3011
3023
  } catch {
3012
3024
  results.skipped.push({
3013
3025
  path: relativeToBase(current),
@@ -3029,8 +3041,8 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3029
3041
  }
3030
3042
  const entry = frame.entries[frame.index];
3031
3043
  frame.index += 1;
3032
- const fullPath = path16__namespace.join(frame.dir, entry.name);
3033
- const relPath = path16__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
3044
+ const fullPath = path17__namespace.join(frame.dir, entry.name);
3045
+ const relPath = path17__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
3034
3046
  if (reservedPaths.has(relPath)) continue;
3035
3047
  if (entry.isDirectory() && DEFAULT_IGNORED_DIRS.includes(entry.name)) {
3036
3048
  results.skipped.push({
@@ -3063,14 +3075,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3063
3075
  if (entry.isSymbolicLink()) {
3064
3076
  let targetReal;
3065
3077
  try {
3066
- targetReal = fs15__namespace.realpathSync(fullPath);
3078
+ targetReal = fs16__namespace.realpathSync(fullPath);
3067
3079
  } catch {
3068
3080
  results.skipped.push(brokenLinkRecord(fullPath, relPath, rootReal));
3069
3081
  continue;
3070
3082
  }
3071
3083
  let stats;
3072
3084
  try {
3073
- stats = fs15__namespace.statSync(fullPath);
3085
+ stats = fs16__namespace.statSync(fullPath);
3074
3086
  } catch {
3075
3087
  results.skipped.push({ path: relPath, reason: "read-error", detail: "unreadable symlink" });
3076
3088
  continue;
@@ -3100,7 +3112,7 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
3100
3112
  });
3101
3113
  continue;
3102
3114
  }
3103
- const targetRelative = path16__namespace.relative(rootReal, targetReal).split(path16__namespace.sep).join("/");
3115
+ const targetRelative = path17__namespace.relative(rootReal, targetReal).split(path17__namespace.sep).join("/");
3104
3116
  if (isSensitivePath(targetRelative)) {
3105
3117
  results.skipped.push({
3106
3118
  path: relPath,
@@ -3292,6 +3304,77 @@ function summarizeMarkdown(content) {
3292
3304
  frontmatterKeys: Array.from(new Set(frontmatterKeys)).sort()
3293
3305
  };
3294
3306
  }
3307
+ var OWNER_SECTIONS = ["Stakes", "The system", "What came before", "The bar", "Calibration"];
3308
+ var RESERVED_SECTIONS = [
3309
+ "The job",
3310
+ "What you have",
3311
+ "Coverage",
3312
+ "What a useful answer contains",
3313
+ "This snapshot",
3314
+ "Attaching this",
3315
+ "Your task"
3316
+ ];
3317
+ function parseOwnerBrief(filePath, text2) {
3318
+ const problems = [];
3319
+ const source = text2.replace(/^\uFEFF/, "");
3320
+ const preamble = [];
3321
+ const sections = [];
3322
+ let current = null;
3323
+ for (const line of source.split(/\r?\n/)) {
3324
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
3325
+ if (heading) {
3326
+ current = { heading: heading[1], body: [] };
3327
+ sections.push(current);
3328
+ continue;
3329
+ }
3330
+ if (current) current.body.push(line);
3331
+ else preamble.push(line);
3332
+ }
3333
+ const recognised = {};
3334
+ const notes = [];
3335
+ const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
3336
+ const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
3337
+ const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
3338
+ const seen = /* @__PURE__ */ new Set();
3339
+ for (const section of sections) {
3340
+ const body = section.body.join("\n").trim();
3341
+ const key = canonical(section.heading);
3342
+ if (seen.has(key)) {
3343
+ problems.push(
3344
+ `the brief defines "${section.heading}" twice; a section cannot say two things.`
3345
+ );
3346
+ continue;
3347
+ }
3348
+ seen.add(key);
3349
+ if (canonicalReserved.has(key)) {
3350
+ problems.push(
3351
+ `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.`
3352
+ );
3353
+ continue;
3354
+ }
3355
+ const ownerName = canonicalOwner.get(key);
3356
+ if (ownerName !== void 0) {
3357
+ recognised[ownerName] = body;
3358
+ continue;
3359
+ }
3360
+ notes.push({ heading: section.heading, body });
3361
+ }
3362
+ const preambleText = preamble.join("\n").trim();
3363
+ return {
3364
+ brief: {
3365
+ path: filePath,
3366
+ digest: crypto3.createHash("sha256").update(text2, "utf8").digest("hex"),
3367
+ ...recognised["Stakes"] ? { stakes: recognised["Stakes"] } : {},
3368
+ ...recognised["The system"] ? { system: recognised["The system"] } : {},
3369
+ ...recognised["What came before"] ? { history: recognised["What came before"] } : {},
3370
+ ...recognised["The bar"] ? { bar: recognised["The bar"] } : {},
3371
+ ...recognised["Calibration"] ? { calibration: recognised["Calibration"] } : {},
3372
+ notes,
3373
+ ...preambleText.length > 0 ? { preamble: preambleText } : {}
3374
+ },
3375
+ problems
3376
+ };
3377
+ }
3295
3378
 
3296
3379
  // src/tokenize.ts
3297
3380
  var WORD_RUN = /[A-Za-z0-9_]+/g;
@@ -3328,20 +3411,20 @@ var CONFIG_FILENAMES = [
3328
3411
  ];
3329
3412
  function findConfigFile(cwd) {
3330
3413
  for (const filename of CONFIG_FILENAMES) {
3331
- const fullPath = path16__namespace.join(cwd, filename);
3414
+ const fullPath = path17__namespace.join(cwd, filename);
3332
3415
  let stats = null;
3333
3416
  try {
3334
- stats = fs15__namespace.statSync(fullPath);
3417
+ stats = fs16__namespace.statSync(fullPath);
3335
3418
  } catch {
3336
- if (fs15__namespace.existsSync(fullPath)) return fullPath;
3419
+ if (fs16__namespace.existsSync(fullPath)) return fullPath;
3337
3420
  continue;
3338
3421
  }
3339
3422
  if (stats.isFile()) return fullPath;
3340
3423
  }
3341
- const pkgJsonPath = path16__namespace.join(cwd, "package.json");
3342
- if (!fs15__namespace.existsSync(pkgJsonPath)) return null;
3424
+ const pkgJsonPath = path17__namespace.join(cwd, "package.json");
3425
+ if (!fs16__namespace.existsSync(pkgJsonPath)) return null;
3343
3426
  try {
3344
- const parsed = JSON.parse(stripJsonComments(fs15__namespace.readFileSync(pkgJsonPath, "utf8")));
3427
+ const parsed = JSON.parse(stripJsonComments(fs16__namespace.readFileSync(pkgJsonPath, "utf8")));
3345
3428
  const snapshot = parsed?.snapshot;
3346
3429
  return typeof snapshot === "object" && snapshot !== null && !Array.isArray(snapshot) ? pkgJsonPath : null;
3347
3430
  } catch {
@@ -3407,6 +3490,8 @@ function normalizeResolvedConfig(config) {
3407
3490
  // is re-validated because the number reaches a rendered artifact.
3408
3491
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3409
3492
  maxParts: resolveMaxParts(config.maxParts),
3493
+ promptTask: resolvePromptTask(config.promptTask),
3494
+ ...config.brief === void 0 ? {} : { brief: config.brief },
3410
3495
  includeMonolith: artifacts.monolith,
3411
3496
  secretRules: compileSecretRules(config.secretRules),
3412
3497
  artifacts,
@@ -3477,6 +3562,7 @@ var CONFIG_KEY_NAMES = [
3477
3562
  "artifacts",
3478
3563
  "attachmentSlots",
3479
3564
  "branch",
3565
+ "brief",
3480
3566
  "budgets",
3481
3567
  "changedSince",
3482
3568
  "cwd",
@@ -3498,6 +3584,7 @@ var CONFIG_KEY_NAMES = [
3498
3584
  "outDir",
3499
3585
  "preset",
3500
3586
  "previewHeadLines",
3587
+ "promptTask",
3501
3588
  "staged",
3502
3589
  "previewTailLines",
3503
3590
  "secretRules",
@@ -3548,10 +3635,10 @@ function readConfigExport(exported, file) {
3548
3635
  var lastModuleConfig = null;
3549
3636
  function moduleConfigKey(fullPath) {
3550
3637
  try {
3551
- return crypto3.createHash("sha256").update(fs15__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
3638
+ return crypto3.createHash("sha256").update(fs16__namespace.readFileSync(fullPath)).digest("hex").slice(0, 24);
3552
3639
  } catch {
3553
3640
  try {
3554
- const stats = fs15__namespace.statSync(fullPath);
3641
+ const stats = fs16__namespace.statSync(fullPath);
3555
3642
  return `stat-${stats.mtimeMs}-${stats.size}`;
3556
3643
  } catch {
3557
3644
  return "unreadable";
@@ -3577,7 +3664,7 @@ async function importConfigModule(fullPath) {
3577
3664
  function attachConfigDir(config, filePath) {
3578
3665
  if (typeof config === "object" && config !== null) {
3579
3666
  Object.defineProperty(config, CONFIG_DIR_SYMBOL, {
3580
- value: path16__namespace.dirname(filePath),
3667
+ value: path17__namespace.dirname(filePath),
3581
3668
  enumerable: false,
3582
3669
  configurable: true
3583
3670
  });
@@ -3589,12 +3676,12 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3589
3676
  const errors = [];
3590
3677
  const configDirectories = [];
3591
3678
  for (const filename of CONFIG_FILENAMES) {
3592
- const fullPath = path16__namespace.join(cwd, filename);
3679
+ const fullPath = path17__namespace.join(cwd, filename);
3593
3680
  let candidateStats = null;
3594
3681
  try {
3595
- candidateStats = fs15__namespace.statSync(fullPath);
3682
+ candidateStats = fs16__namespace.statSync(fullPath);
3596
3683
  } catch {
3597
- if (!fs15__namespace.existsSync(fullPath)) continue;
3684
+ if (!fs16__namespace.existsSync(fullPath)) continue;
3598
3685
  }
3599
3686
  if (candidateStats !== null && !candidateStats.isFile()) {
3600
3687
  configDirectories.push(fullPath);
@@ -3602,7 +3689,7 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3602
3689
  }
3603
3690
  if (filename.endsWith(".json") || filename === ".snapshotrc") {
3604
3691
  try {
3605
- const config = parseJsonish(fs15__namespace.readFileSync(fullPath, "utf8"), fullPath);
3692
+ const config = parseJsonish(fs16__namespace.readFileSync(fullPath, "utf8"), fullPath);
3606
3693
  if (config === null || typeof config !== "object" || Array.isArray(config)) {
3607
3694
  throw new Error(
3608
3695
  `${fullPath} does not hold a configuration object (received ${describeValue2(config)}).`
@@ -3642,10 +3729,10 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3642
3729
  continue;
3643
3730
  }
3644
3731
  }
3645
- const pkgJsonPath = path16__namespace.join(cwd, "package.json");
3646
- if (fs15__namespace.existsSync(pkgJsonPath)) {
3732
+ const pkgJsonPath = path17__namespace.join(cwd, "package.json");
3733
+ if (fs16__namespace.existsSync(pkgJsonPath)) {
3647
3734
  try {
3648
- const parsed = parseJsonish(fs15__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
3735
+ const parsed = parseJsonish(fs16__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
3649
3736
  const snapshotKey = parsed.snapshot;
3650
3737
  if (snapshotKey && typeof snapshotKey === "object" && !Array.isArray(snapshotKey)) {
3651
3738
  assertKnownConfigKeys(
@@ -3782,6 +3869,38 @@ function resolveMaxParts(value) {
3782
3869
  }
3783
3870
  return value;
3784
3871
  }
3872
+ function resolvePromptTask(value) {
3873
+ if (value === void 0 || value === null) return "audit";
3874
+ if (value === "audit" || value === "review" || value === "explain") return value;
3875
+ throw new Error(
3876
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
3877
+ );
3878
+ }
3879
+ function readConfiguredBrief(cwd, value) {
3880
+ if (value === void 0 || value === null) return void 0;
3881
+ if (typeof value !== "string" || value.trim().length === 0) {
3882
+ throw new Error(
3883
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
3884
+ );
3885
+ }
3886
+ const filePath = path17__namespace.resolve(cwd, value);
3887
+ let text2;
3888
+ try {
3889
+ if (!fs16__namespace.statSync(filePath).isFile()) throw new Error("not a file");
3890
+ text2 = fs16__namespace.readFileSync(filePath, "utf8");
3891
+ } catch {
3892
+ throw new Error(
3893
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
3894
+ );
3895
+ }
3896
+ const parsed = parseOwnerBrief(value, text2);
3897
+ if (parsed.problems.length > 0) {
3898
+ throw new Error(
3899
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
3900
+ );
3901
+ }
3902
+ return parsed.brief;
3903
+ }
3785
3904
  function strictPositiveInteger(value, fallback, label) {
3786
3905
  if (value === void 0) return fallback;
3787
3906
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -3874,9 +3993,9 @@ function resolveKindRules(value) {
3874
3993
  function outputExcludePatterns(cwd, outDir, tmpDir) {
3875
3994
  const patterns = [];
3876
3995
  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)) {
3996
+ const absolute = path17__namespace.resolve(cwd, dir);
3997
+ const relative15 = path17__namespace.relative(cwd, absolute);
3998
+ if (!relative15 || relative15 === ".." || relative15.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative15)) {
3880
3999
  continue;
3881
4000
  }
3882
4001
  patterns.push(`${relative15.replace(/\\/g, "/")}/**`);
@@ -4009,11 +4128,11 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
4009
4128
  );
4010
4129
  }
4011
4130
  const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
4012
- const resolved = path16__namespace.resolve(candidate);
4013
- if (!fs15__namespace.existsSync(resolved)) {
4131
+ const resolved = path17__namespace.resolve(candidate);
4132
+ if (!fs16__namespace.existsSync(resolved)) {
4014
4133
  throw new Error(`Working directory does not exist: ${resolved}`);
4015
4134
  }
4016
- if (!fs15__namespace.statSync(resolved).isDirectory()) {
4135
+ if (!fs16__namespace.statSync(resolved).isDirectory()) {
4017
4136
  throw new Error(`Working directory is not a directory: ${resolved}`);
4018
4137
  }
4019
4138
  return resolved;
@@ -4141,6 +4260,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4141
4260
  configuredSensitiveFiles,
4142
4261
  "`includeSensitiveFiles`"
4143
4262
  );
4263
+ const configuredBrief = readConfiguredBrief(
4264
+ cwd,
4265
+ cliOptions?.brief ?? userConfig?.brief
4266
+ );
4144
4267
  const presetExclude = [
4145
4268
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
4146
4269
  ];
@@ -4164,6 +4287,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4164
4287
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4165
4288
  ),
4166
4289
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4290
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
4291
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
4167
4292
  ...changedSince === void 0 ? {} : { changedSince },
4168
4293
  ...staged ? { staged } : {},
4169
4294
  ...withDependents ? { withDependents } : {},
@@ -4249,6 +4374,12 @@ function configDigest(config) {
4249
4374
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4250
4375
  // material would change the digest of every snapshot taken before the setting existed.
4251
4376
  ...config.maxParts === null ? {} : { maxParts: config.maxParts },
4377
+ // The default value is omitted for the same reason: a snapshot taken before the setting
4378
+ // existed kept the audit job, so it must keep the digest it was written with.
4379
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
4380
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
4381
+ // reader to do, so a changed brief is drift exactly like a changed budget.
4382
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
4252
4383
  artifacts: config.artifacts,
4253
4384
  include: config.include,
4254
4385
  excludePatterns: config.excludePatterns,
@@ -4332,7 +4463,7 @@ function resolveChangedScope(cwd, request) {
4332
4463
  const descriptions = [];
4333
4464
  if (request.changedSince !== void 0) {
4334
4465
  assertUsableRef(request.changedSince);
4335
- for (const path22 of gitPaths(cwd, [
4466
+ for (const path23 of gitPaths(cwd, [
4336
4467
  "diff",
4337
4468
  "--name-only",
4338
4469
  "-z",
@@ -4340,9 +4471,9 @@ function resolveChangedScope(cwd, request) {
4340
4471
  `${request.changedSince}...HEAD`,
4341
4472
  "--"
4342
4473
  ])) {
4343
- paths.add(path22);
4474
+ paths.add(path23);
4344
4475
  }
4345
- for (const path22 of gitPaths(cwd, [
4476
+ for (const path23 of gitPaths(cwd, [
4346
4477
  "diff",
4347
4478
  "--name-only",
4348
4479
  "-z",
@@ -4350,15 +4481,15 @@ function resolveChangedScope(cwd, request) {
4350
4481
  "HEAD",
4351
4482
  "--"
4352
4483
  ])) {
4353
- paths.add(path22);
4484
+ paths.add(path23);
4354
4485
  }
4355
- for (const path22 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4356
- paths.add(path22);
4486
+ for (const path23 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4487
+ paths.add(path23);
4357
4488
  }
4358
4489
  descriptions.push(`changed since ${request.changedSince}`);
4359
4490
  }
4360
4491
  if (request.staged === true) {
4361
- for (const path22 of gitPaths(cwd, [
4492
+ for (const path23 of gitPaths(cwd, [
4362
4493
  "diff",
4363
4494
  "--cached",
4364
4495
  "--name-only",
@@ -4366,10 +4497,10 @@ function resolveChangedScope(cwd, request) {
4366
4497
  "--relative",
4367
4498
  "--"
4368
4499
  ])) {
4369
- paths.add(path22);
4370
- stagedPaths.add(path22);
4500
+ paths.add(path23);
4501
+ stagedPaths.add(path23);
4371
4502
  }
4372
- for (const path22 of gitPaths(cwd, [
4503
+ for (const path23 of gitPaths(cwd, [
4373
4504
  "diff",
4374
4505
  "--cached",
4375
4506
  "--name-only",
@@ -4378,7 +4509,7 @@ function resolveChangedScope(cwd, request) {
4378
4509
  "--diff-filter=D",
4379
4510
  "--"
4380
4511
  ])) {
4381
- deletedPaths.add(path22);
4512
+ deletedPaths.add(path23);
4382
4513
  }
4383
4514
  descriptions.push("staged");
4384
4515
  }
@@ -4416,10 +4547,10 @@ var PYTHON_SUFFIXES = [".py", ".pyi", "/__init__.py", "/__init__.pyi"];
4416
4547
  var CASE_INSENSITIVE_FILESYSTEM = process.platform === "win32" || process.platform === "darwin";
4417
4548
  var TSCONFIG_CACHE = /* @__PURE__ */ new Map();
4418
4549
  function tsconfigPathsFor(cwd) {
4419
- const configPath = path16__namespace.join(cwd, "tsconfig.json");
4550
+ const configPath = path17__namespace.join(cwd, "tsconfig.json");
4420
4551
  let stats;
4421
4552
  try {
4422
- stats = fs15__namespace.statSync(configPath);
4553
+ stats = fs16__namespace.statSync(configPath);
4423
4554
  } catch (err) {
4424
4555
  if (err.code === "ENOENT") return null;
4425
4556
  return null;
@@ -4453,8 +4584,8 @@ function tsconfigPathsFor(cwd) {
4453
4584
  return value;
4454
4585
  }
4455
4586
  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;
4587
+ const relative15 = path17__namespace.relative(cwd, target).replace(/\\/g, "/");
4588
+ return relative15.length === 0 || !relative15.startsWith("..") && !path17__namespace.isAbsolute(relative15) ? relative15 : null;
4458
4589
  }
4459
4590
  function rememberFirst(map, key, value) {
4460
4591
  if (!map.has(key)) map.set(key, value);
@@ -4469,15 +4600,15 @@ function buildImportResolver(files, options = {}) {
4469
4600
  if (CASE_INSENSITIVE_FILESYSTEM) {
4470
4601
  rememberFirst(byPathFolded, relativePath.toLowerCase(), relativePath);
4471
4602
  }
4472
- const extension = path16__namespace.posix.extname(relativePath);
4603
+ const extension = path17__namespace.posix.extname(relativePath);
4473
4604
  if (!SOURCE_EXTENSIONS.has(extension)) return;
4474
4605
  const stem = relativePath.slice(0, -extension.length);
4475
4606
  rememberFirst(byStem, stem, relativePath);
4476
4607
  if (CASE_INSENSITIVE_FILESYSTEM) {
4477
4608
  rememberFirst(byStemFolded, stem.toLowerCase(), relativePath);
4478
4609
  }
4479
- if (path16__namespace.posix.basename(stem) === "index") {
4480
- const directory = path16__namespace.posix.dirname(stem);
4610
+ if (path17__namespace.posix.basename(stem) === "index") {
4611
+ const directory = path17__namespace.posix.dirname(stem);
4481
4612
  rememberFirst(byStem, directory, relativePath);
4482
4613
  if (CASE_INSENSITIVE_FILESYSTEM) {
4483
4614
  rememberFirst(byStemFolded, directory.toLowerCase(), relativePath);
@@ -4493,7 +4624,7 @@ function buildImportResolver(files, options = {}) {
4493
4624
  return { byPath, byPathFolded, byStem, byStemFolded, tsconfig: options.tsconfig ?? null };
4494
4625
  }
4495
4626
  function resolveSpecifier(fromFile, specifier, resolver) {
4496
- const extension = path16__namespace.posix.extname(fromFile).toLowerCase();
4627
+ const extension = path17__namespace.posix.extname(fromFile).toLowerCase();
4497
4628
  const exact = (key) => resolver.byPath.get(key) ?? (CASE_INSENSITIVE_FILESYSTEM ? resolver.byPathFolded.get(key.toLowerCase()) : void 0) ?? null;
4498
4629
  const firstOf = (candidates) => {
4499
4630
  for (const candidate of candidates) {
@@ -4516,34 +4647,34 @@ function resolveSpecifier(fromFile, specifier, resolver) {
4516
4647
  if (PYTHON_EXTENSIONS.has(extension) && specifier.startsWith(".")) {
4517
4648
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
4518
4649
  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;
4650
+ let base = path17__namespace.posix.dirname(fromFile);
4651
+ for (let up = 1; up < dots; up += 1) base = path17__namespace.posix.dirname(base);
4652
+ const joined2 = rest ? path17__namespace.posix.normalize(path17__namespace.posix.join(base, rest)) : base;
4522
4653
  return firstOf([joined2, ...PYTHON_SUFFIXES.map((suffix) => `${joined2}${suffix}`)]);
4523
4654
  }
4524
4655
  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)
4656
+ const joined2 = path17__namespace.posix.normalize(
4657
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4527
4658
  );
4528
4659
  return firstOf([`${joined2}.rb`, joined2]);
4529
4660
  }
4530
4661
  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)
4662
+ const joined2 = path17__namespace.posix.normalize(
4663
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4533
4664
  );
4534
4665
  return exact(joined2);
4535
4666
  }
4536
4667
  if (extension === ".dart" && !specifier.includes(":")) {
4537
- const joined2 = path16__namespace.posix.normalize(
4538
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
4668
+ const joined2 = path17__namespace.posix.normalize(
4669
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4539
4670
  );
4540
4671
  return firstOf([joined2, `${joined2}.dart`]);
4541
4672
  }
4542
4673
  if (!RELATIVE_SPECIFIER.test(specifier)) {
4543
4674
  return resolveTsconfigSpecifier(specifier, resolver, lookupPath);
4544
4675
  }
4545
- const joined = path16__namespace.posix.normalize(
4546
- path16__namespace.posix.join(path16__namespace.posix.dirname(fromFile), specifier)
4676
+ const joined = path17__namespace.posix.normalize(
4677
+ path17__namespace.posix.join(path17__namespace.posix.dirname(fromFile), specifier)
4547
4678
  );
4548
4679
  return lookupPath(joined);
4549
4680
  }
@@ -4567,13 +4698,13 @@ function resolveTsconfigSpecifier(specifier, resolver, lookupPath) {
4567
4698
  if (captured === null) continue;
4568
4699
  for (const target of rule.targets) {
4569
4700
  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));
4701
+ const base = config.baseUrl === null ? substituted : path17__namespace.posix.join(config.baseUrl, substituted);
4702
+ const hit = lookupPath(path17__namespace.posix.normalize(base));
4572
4703
  if (hit) return hit;
4573
4704
  }
4574
4705
  }
4575
4706
  if (config.baseUrl !== null) {
4576
- return lookupPath(path16__namespace.posix.normalize(path16__namespace.posix.join(config.baseUrl, specifier)));
4707
+ return lookupPath(path17__namespace.posix.normalize(path17__namespace.posix.join(config.baseUrl, specifier)));
4577
4708
  }
4578
4709
  return null;
4579
4710
  }
@@ -5193,9 +5324,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
5193
5324
  var jvmProfile = {
5194
5325
  id: "jvm",
5195
5326
  extensions: [".java", ".kt", ".kts", ".scala"],
5196
- summarize(path22, content) {
5327
+ summarize(path23, content) {
5197
5328
  const summary = emptySummary();
5198
- const lower = path22.toLowerCase();
5329
+ const lower = path23.toLowerCase();
5199
5330
  const isJava = lower.endsWith(".java");
5200
5331
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
5201
5332
  eachLine(content, (line) => {
@@ -5516,17 +5647,17 @@ var rustProfile = {
5516
5647
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script>/gi;
5517
5648
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
5518
5649
  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;
5650
+ function componentName(path23) {
5651
+ const base = path23.split("/").pop() ?? path23;
5521
5652
  return base.replace(/\.[^.]+$/, "");
5522
5653
  }
5523
5654
  var sfcProfile = {
5524
5655
  id: "sfc",
5525
5656
  extensions: [".vue", ".svelte", ".astro"],
5526
- summarize(path22, content) {
5657
+ summarize(path23, content) {
5527
5658
  let script = "";
5528
- let usesJsx = path22.toLowerCase().endsWith(".astro");
5529
- if (path22.toLowerCase().endsWith(".astro")) {
5659
+ let usesJsx = path23.toLowerCase().endsWith(".astro");
5660
+ if (path23.toLowerCase().endsWith(".astro")) {
5530
5661
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
5531
5662
  if (frontmatter) script += `${frontmatter[1]}
5532
5663
  `;
@@ -5536,7 +5667,7 @@ var sfcProfile = {
5536
5667
  script += `${match[2]}
5537
5668
  `;
5538
5669
  }
5539
- const name = componentName(path22);
5670
+ const name = componentName(path23);
5540
5671
  if (!script.trim()) {
5541
5672
  const summary2 = emptySummary();
5542
5673
  if (name) {
@@ -5727,15 +5858,15 @@ for (const profile of LANGUAGE_PROFILES) {
5727
5858
  BY_EXTENSION.set(extension.toLowerCase(), profile);
5728
5859
  }
5729
5860
  }
5730
- function profileForPath(path22) {
5731
- const lower = path22.toLowerCase();
5861
+ function profileForPath(path23) {
5862
+ const lower = path23.toLowerCase();
5732
5863
  const dot = lower.lastIndexOf(".");
5733
5864
  if (dot === -1) return null;
5734
5865
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
5735
5866
  }
5736
- function summarizeWithProfile(path22, content) {
5737
- const profile = profileForPath(path22);
5738
- return profile ? profile.summarize(path22, content) : null;
5867
+ function summarizeWithProfile(path23, content) {
5868
+ const profile = profileForPath(path23);
5869
+ return profile ? profile.summarize(path23, content) : null;
5739
5870
  }
5740
5871
  var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
5741
5872
  ".png",
@@ -5780,7 +5911,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
5780
5911
  ".so"
5781
5912
  ]);
5782
5913
  function isBinaryExtension(filePath) {
5783
- const ext = path16__namespace.extname(filePath).toLowerCase();
5914
+ const ext = path17__namespace.extname(filePath).toLowerCase();
5784
5915
  return BINARY_EXTENSIONS.has(ext);
5785
5916
  }
5786
5917
  function countControlBytes(buffer) {
@@ -5947,13 +6078,13 @@ function isBinaryFile(absolutePath) {
5947
6078
  if (isBinaryExtension(absolutePath)) return true;
5948
6079
  let fd;
5949
6080
  try {
5950
- fd = fs15__namespace.openSync(absolutePath, "r");
6081
+ fd = fs16__namespace.openSync(absolutePath, "r");
5951
6082
  const buffer = Buffer.alloc(CHUNK);
5952
6083
  let sample;
5953
6084
  let position = 0;
5954
6085
  while (position < BINARY_SCAN_BYTES) {
5955
6086
  const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
5956
- const bytesRead = fs15__namespace.readSync(fd, buffer, 0, wanted, position);
6087
+ const bytesRead = fs16__namespace.readSync(fd, buffer, 0, wanted, position);
5957
6088
  if (bytesRead === 0) return false;
5958
6089
  const chunk = buffer.subarray(0, bytesRead);
5959
6090
  if (sample === void 0) {
@@ -5971,7 +6102,7 @@ function isBinaryFile(absolutePath) {
5971
6102
  } finally {
5972
6103
  if (fd !== void 0) {
5973
6104
  try {
5974
- fs15__namespace.closeSync(fd);
6105
+ fs16__namespace.closeSync(fd);
5975
6106
  } catch {
5976
6107
  }
5977
6108
  }
@@ -5993,9 +6124,9 @@ function importsOfText(relativePath, text2) {
5993
6124
  function importsOfFile(relativePath, absolutePath) {
5994
6125
  let buffer;
5995
6126
  try {
5996
- const stats = fs15__namespace.statSync(absolutePath);
6127
+ const stats = fs16__namespace.statSync(absolutePath);
5997
6128
  if (!stats.isFile() || stats.size > SUMMARY_MAX_SOURCE_BYTES) return [];
5998
- buffer = fs15__namespace.readFileSync(absolutePath);
6129
+ buffer = fs16__namespace.readFileSync(absolutePath);
5999
6130
  } catch {
6000
6131
  return [];
6001
6132
  }
@@ -6010,33 +6141,33 @@ function maskedPath(value, secretRules) {
6010
6141
  }
6011
6142
  function confineToDirectory(directory, filename) {
6012
6143
  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);
6144
+ if (path17__namespace.isAbsolute(filename)) return null;
6145
+ const base = path17__namespace.resolve(directory);
6146
+ const resolved = path17__namespace.resolve(base, filename);
6016
6147
  const caseInsensitive = process.platform === "win32" || process.platform === "darwin";
6017
- const prefix = caseInsensitive ? `${base}${path16__namespace.sep}`.toLowerCase() : `${base}${path16__namespace.sep}`;
6148
+ const prefix = caseInsensitive ? `${base}${path17__namespace.sep}`.toLowerCase() : `${base}${path17__namespace.sep}`;
6018
6149
  const candidate = caseInsensitive ? resolved.toLowerCase() : resolved;
6019
6150
  return candidate.startsWith(prefix) ? resolved : null;
6020
6151
  }
6021
6152
  function findStagingDirectory(config) {
6022
- const tmpDir = path16__namespace.resolve(config.cwd, config.tmpDir);
6153
+ const tmpDir = path17__namespace.resolve(config.cwd, config.tmpDir);
6023
6154
  let entries;
6024
6155
  try {
6025
- entries = fs15__namespace.readdirSync(tmpDir);
6156
+ entries = fs16__namespace.readdirSync(tmpDir);
6026
6157
  } catch {
6027
6158
  return null;
6028
6159
  }
6029
6160
  const runs = entries.filter((name) => name.startsWith("run-")).sort();
6030
6161
  const newest = runs[runs.length - 1];
6031
- return newest ? path16__namespace.join(tmpDir, newest) : null;
6162
+ return newest ? path17__namespace.join(tmpDir, newest) : null;
6032
6163
  }
6033
6164
  function describeMissingManifest(config, manifestPath) {
6034
- const outDir = path16__namespace.resolve(config.cwd, config.outDir);
6035
- const markerPath = path16__namespace.join(outDir, ".codebase-snapshot");
6165
+ const outDir = path17__namespace.resolve(config.cwd, config.outDir);
6166
+ const markerPath = path17__namespace.join(outDir, ".codebase-snapshot");
6036
6167
  let marker2 = null;
6037
6168
  try {
6038
- if (fs15__namespace.existsSync(markerPath)) {
6039
- const parsed = JSON.parse(fs15__namespace.readFileSync(markerPath, "utf8"));
6169
+ if (fs16__namespace.existsSync(markerPath)) {
6170
+ const parsed = JSON.parse(fs16__namespace.readFileSync(markerPath, "utf8"));
6040
6171
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
6041
6172
  marker2 = parsed;
6042
6173
  }
@@ -6071,13 +6202,13 @@ function sha256Hex(buffer) {
6071
6202
  return crypto3__namespace.createHash("sha256").update(buffer).digest("hex");
6072
6203
  }
6073
6204
  function wouldNowBeIncluded(cwd, relativePath) {
6074
- const absolutePath = path16__namespace.join(cwd, relativePath);
6205
+ const absolutePath = path17__namespace.join(cwd, relativePath);
6075
6206
  try {
6076
- const stats = fs15__namespace.statSync(absolutePath);
6207
+ const stats = fs16__namespace.statSync(absolutePath);
6077
6208
  if (!stats.isFile()) return false;
6078
6209
  if (isBinaryExtension(absolutePath)) return false;
6079
6210
  if (stats.size > BINARY_SCAN_BYTES && isBinaryFile(absolutePath)) return false;
6080
- return !decodeText(fs15__namespace.readFileSync(absolutePath)).binary;
6211
+ return !decodeText(fs16__namespace.readFileSync(absolutePath)).binary;
6081
6212
  } catch {
6082
6213
  return false;
6083
6214
  }
@@ -6089,7 +6220,7 @@ var TRUNCATION_REASONS = /* @__PURE__ */ new Set([
6089
6220
  ]);
6090
6221
  function isConfinedRelative(value) {
6091
6222
  if (value.length === 0 || value.includes("\0") || value.includes("\\")) return false;
6092
- if (path16__namespace.isAbsolute(value)) return false;
6223
+ if (path17__namespace.isAbsolute(value)) return false;
6093
6224
  return !value.split("/").includes("..");
6094
6225
  }
6095
6226
  function describeManifestShapeProblem(value) {
@@ -6257,7 +6388,7 @@ function describeManifestShapeProblem(value) {
6257
6388
  if (typeof filename !== "string" || filename.trim() === "") {
6258
6389
  return 'a "parts" entry has no "filename"';
6259
6390
  }
6260
- if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path16__namespace.isAbsolute(filename)) {
6391
+ if (filename.includes("/") || filename.includes("\\") || filename.includes("\0") || filename === "." || filename === ".." || path17__namespace.isAbsolute(filename)) {
6261
6392
  return 'a "parts" entry "filename" must be a bare filename inside parts/';
6262
6393
  }
6263
6394
  if (currentSchema) {
@@ -6283,8 +6414,8 @@ function describeManifestShapeProblem(value) {
6283
6414
  function validateSnapshot(configInput) {
6284
6415
  assertUsableConfigInput(configInput);
6285
6416
  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)) {
6417
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
6418
+ if (!fs16__namespace.existsSync(manifestPath)) {
6288
6419
  return {
6289
6420
  valid: false,
6290
6421
  manifestPresent: false,
@@ -6295,7 +6426,7 @@ function validateSnapshot(configInput) {
6295
6426
  }
6296
6427
  let manifest;
6297
6428
  try {
6298
- manifest = JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
6429
+ manifest = JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
6299
6430
  } catch (err) {
6300
6431
  return {
6301
6432
  valid: false,
@@ -6317,7 +6448,7 @@ function validateSnapshot(configInput) {
6317
6448
  }
6318
6449
  const drift = emptyDrift();
6319
6450
  const warnings = [];
6320
- const snapshotDir = path16__namespace.resolve(config.cwd, config.outDir);
6451
+ const snapshotDir = path17__namespace.resolve(config.cwd, config.outDir);
6321
6452
  const unreadableSkips = manifest.skipped.filter(
6322
6453
  (entry) => entry.reason === "missing" || entry.reason === "read-error"
6323
6454
  );
@@ -6420,7 +6551,7 @@ function validateSnapshot(configInput) {
6420
6551
  );
6421
6552
  return importsChangedFile(
6422
6553
  diskFile,
6423
- importsOfFile(diskFile, path16__namespace.join(config.cwd, diskFile)),
6554
+ importsOfFile(diskFile, path17__namespace.join(config.cwd, diskFile)),
6424
6555
  unchangedScope,
6425
6556
  dependentResolver
6426
6557
  );
@@ -6438,7 +6569,7 @@ function validateSnapshot(configInput) {
6438
6569
  // own output directory as a set of files missing from the snapshot, so a correct
6439
6570
  // snapshot was reported as drifting.
6440
6571
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
6441
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
6572
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
6442
6573
  ).filter((relative15) => relative15.length > 0 && !relative15.startsWith(".."))
6443
6574
  });
6444
6575
  for (const diskFile of collection.files) {
@@ -6464,7 +6595,7 @@ function validateSnapshot(configInput) {
6464
6595
  }
6465
6596
  let diskHash;
6466
6597
  try {
6467
- diskHash = sha256Hex(fs15__namespace.readFileSync(path16__namespace.join(config.cwd, diskFile)));
6598
+ diskHash = sha256Hex(fs16__namespace.readFileSync(path17__namespace.join(config.cwd, diskFile)));
6468
6599
  } catch (err) {
6469
6600
  if (err.code === "ENOENT") {
6470
6601
  drift.missingOnDisk.push(diskFile);
@@ -6488,7 +6619,7 @@ function validateSnapshot(configInput) {
6488
6619
  }
6489
6620
  let statFailure = null;
6490
6621
  try {
6491
- fs15__namespace.statSync(confined);
6622
+ fs16__namespace.statSync(confined);
6492
6623
  } catch (err) {
6493
6624
  statFailure = err;
6494
6625
  }
@@ -6508,7 +6639,7 @@ function validateSnapshot(configInput) {
6508
6639
  ...Object.values(config.budgets.byLayer)
6509
6640
  );
6510
6641
  const partNames = /* @__PURE__ */ new Set();
6511
- const partsDir = path16__namespace.join(snapshotDir, "parts");
6642
+ const partsDir = path17__namespace.join(snapshotDir, "parts");
6512
6643
  for (const part of manifest.parts) {
6513
6644
  if (!part || typeof part.filename !== "string") continue;
6514
6645
  partNames.add(part.filename);
@@ -6523,7 +6654,7 @@ function validateSnapshot(configInput) {
6523
6654
  }
6524
6655
  let buffer;
6525
6656
  try {
6526
- buffer = fs15__namespace.readFileSync(partPath);
6657
+ buffer = fs16__namespace.readFileSync(partPath);
6527
6658
  } catch {
6528
6659
  drift.partIssues.push({ part: part.filename, issue: "missing from snapshot/parts" });
6529
6660
  continue;
@@ -6879,11 +7010,11 @@ function validateSnapshot(configInput) {
6879
7010
  ];
6880
7011
  for (const [key, artifact] of declaredArtifacts) {
6881
7012
  if (!artifact) continue;
6882
- const artifactPath = path16__namespace.join(snapshotDir, ...key.split("/"));
7013
+ const artifactPath = path17__namespace.join(snapshotDir, ...key.split("/"));
6883
7014
  let buffer;
6884
7015
  try {
6885
- if (!fs15__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
6886
- buffer = fs15__namespace.readFileSync(artifactPath);
7016
+ if (!fs16__namespace.statSync(artifactPath).isFile()) throw new Error("not a regular file");
7017
+ buffer = fs16__namespace.readFileSync(artifactPath);
6887
7018
  } catch {
6888
7019
  drift.partIssues.push({ part: key, issue: "declared artifact is missing" });
6889
7020
  continue;
@@ -6896,9 +7027,9 @@ function validateSnapshot(configInput) {
6896
7027
  for (const match of buffer.toString("utf8").matchAll(/\]\(([^)\s]+)\)/g)) {
6897
7028
  const target = match[1].split("#")[0];
6898
7029
  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)) {
7030
+ const resolved = path17__namespace.resolve(snapshotDir, "reports", target);
7031
+ const relative15 = path17__namespace.relative(snapshotDir, resolved);
7032
+ if (relative15.startsWith("..") || path17__namespace.isAbsolute(relative15) || !fs16__namespace.existsSync(resolved)) {
6902
7033
  drift.partIssues.push({
6903
7034
  part: key,
6904
7035
  issue: `links to ${maskedPath(target, config.secretRules)}, which does not exist in the snapshot`
@@ -6911,7 +7042,7 @@ function validateSnapshot(configInput) {
6911
7042
  if (sarifArtifact) {
6912
7043
  const sarifKey = "reports/audit.sarif";
6913
7044
  try {
6914
- const buffer = fs15__namespace.readFileSync(path16__namespace.join(snapshotDir, "reports", "audit.sarif"));
7045
+ const buffer = fs16__namespace.readFileSync(path17__namespace.join(snapshotDir, "reports", "audit.sarif"));
6915
7046
  if (sha256Hex(buffer) !== sarifArtifact.sha256 || buffer.length !== sarifArtifact.byteSize) {
6916
7047
  drift.partIssues.push({ part: sarifKey, issue: "artifact does not match its recorded digest" });
6917
7048
  }
@@ -7195,14 +7326,14 @@ function compareManifests(before, after, secretRules) {
7195
7326
  function loadManifest(target) {
7196
7327
  let isDirectory;
7197
7328
  try {
7198
- isDirectory = fs15__namespace.statSync(target).isDirectory();
7329
+ isDirectory = fs16__namespace.statSync(target).isDirectory();
7199
7330
  } catch {
7200
7331
  throw new Error(`No snapshot found at ${target}: the path does not exist.`);
7201
7332
  }
7202
- const manifestPath = isDirectory ? path16__namespace.join(target, "manifest.json") : target;
7333
+ const manifestPath = isDirectory ? path17__namespace.join(target, "manifest.json") : target;
7203
7334
  let raw;
7204
7335
  try {
7205
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
7336
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
7206
7337
  } catch {
7207
7338
  throw new Error(`Could not read a manifest at ${manifestPath}.`);
7208
7339
  }
@@ -7435,10 +7566,10 @@ var LANGUAGE_BY_BASENAME = {
7435
7566
  };
7436
7567
  function detectLanguage(filePath) {
7437
7568
  const normalized = filePath.replace(/\\/g, "/");
7438
- const base = path16__namespace.posix.basename(normalized);
7569
+ const base = path17__namespace.posix.basename(normalized);
7439
7570
  if (LANGUAGE_BY_BASENAME[base]) return LANGUAGE_BY_BASENAME[base];
7440
7571
  if (base === ".env" || base.startsWith(".env.")) return "dotenv";
7441
- const ext = path16__namespace.posix.extname(base).toLowerCase();
7572
+ const ext = path17__namespace.posix.extname(base).toLowerCase();
7442
7573
  return LANGUAGE_BY_EXTENSION[ext] ?? "text";
7443
7574
  }
7444
7575
 
@@ -7480,13 +7611,13 @@ function describeMatcher(matcher) {
7480
7611
  return String(matcher);
7481
7612
  }
7482
7613
  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)) {
7614
+ const resolvedCwd = path17__namespace.resolve(cwd);
7615
+ const absolute = path17__namespace.resolve(resolvedCwd, target);
7616
+ const relative15 = path17__namespace.relative(resolvedCwd, absolute);
7617
+ if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative15)) {
7487
7618
  return { relative: target.replace(/\\/g, "/"), outsideRoot: true };
7488
7619
  }
7489
- return { relative: relative15.split(path16__namespace.sep).join("/"), outsideRoot: false };
7620
+ return { relative: relative15.split(path17__namespace.sep).join("/"), outsideRoot: false };
7490
7621
  }
7491
7622
  function findRuleMatch(rules, relativePath) {
7492
7623
  return rules.find(
@@ -7505,9 +7636,9 @@ function findRecordedAncestor(skipped, relative15, maskedPath2) {
7505
7636
  return nearest;
7506
7637
  }
7507
7638
  function readManifest2(config) {
7508
- const manifestPath = path16__namespace.resolve(config.cwd, config.outDir, "manifest.json");
7639
+ const manifestPath = path17__namespace.resolve(config.cwd, config.outDir, "manifest.json");
7509
7640
  try {
7510
- return JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
7641
+ return JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
7511
7642
  } catch {
7512
7643
  return null;
7513
7644
  }
@@ -7525,10 +7656,10 @@ function explainPath(config, target) {
7525
7656
  detail: "path resolves outside the configured repository root and was not inspected"
7526
7657
  };
7527
7658
  }
7528
- const absolute = path16__namespace.join(config.cwd, relative15);
7659
+ const absolute = path17__namespace.join(config.cwd, relative15);
7529
7660
  const result = {
7530
7661
  path: maskedPath2,
7531
- exists: fs15__namespace.existsSync(absolute),
7662
+ exists: fs16__namespace.existsSync(absolute),
7532
7663
  included: false
7533
7664
  };
7534
7665
  const collection = collectFiles(config.cwd, {
@@ -7542,7 +7673,7 @@ function explainPath(config, target) {
7542
7673
  // Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
7543
7674
  // that is only missing because the walker dropped the tool's own output directory.
7544
7675
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
7545
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
7676
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
7546
7677
  ).filter((relative16) => relative16.length > 0 && !relative16.startsWith(".."))
7547
7678
  });
7548
7679
  if (!collection.files.includes(relative15)) {
@@ -7607,7 +7738,7 @@ function explainPath(config, target) {
7607
7738
  }
7608
7739
  let sizeOnDisk = null;
7609
7740
  try {
7610
- sizeOnDisk = fs15__namespace.statSync(absolute).size;
7741
+ sizeOnDisk = fs16__namespace.statSync(absolute).size;
7611
7742
  } catch {
7612
7743
  sizeOnDisk = null;
7613
7744
  }
@@ -7617,10 +7748,10 @@ function explainPath(config, target) {
7617
7748
  result.detail = "binary content; generate skips it and records `binary` in manifest.skipped[]";
7618
7749
  return result;
7619
7750
  }
7620
- if (fs15__namespace.existsSync(absolute) && fs15__namespace.statSync(absolute).isFile()) {
7751
+ if (fs16__namespace.existsSync(absolute) && fs16__namespace.statSync(absolute).isFile()) {
7621
7752
  let buffer;
7622
7753
  try {
7623
- buffer = fs15__namespace.readFileSync(absolute);
7754
+ buffer = fs16__namespace.readFileSync(absolute);
7624
7755
  } catch (err) {
7625
7756
  result.included = false;
7626
7757
  result.reason = "read-error";
@@ -7746,15 +7877,15 @@ function canonicalIgnorePattern(line) {
7746
7877
  function appendGitignoreEntries(cwd, entries) {
7747
7878
  const wanted = [...new Set(entries)].filter((entry) => entry.trim().length > 0);
7748
7879
  if (wanted.length === 0) return { added: [], note: null };
7749
- const ignorePath = path16__namespace.join(cwd, ".gitignore");
7880
+ const ignorePath = path17__namespace.join(cwd, ".gitignore");
7750
7881
  const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
7751
7882
  let decoded = { text: "", bom: Buffer.alloc(0), encoding: "utf8" };
7752
7883
  try {
7753
- if (fs15__namespace.existsSync(ignorePath)) {
7754
- if (fs15__namespace.statSync(ignorePath).isDirectory()) {
7884
+ if (fs16__namespace.existsSync(ignorePath)) {
7885
+ if (fs16__namespace.statSync(ignorePath).isDirectory()) {
7755
7886
  return { added: [], note: `${ignorePath} is a directory, so it was not updated. ${manual}` };
7756
7887
  }
7757
- const read = decodeGitignore(fs15__namespace.readFileSync(ignorePath));
7888
+ const read = decodeGitignore(fs16__namespace.readFileSync(ignorePath));
7758
7889
  if (read === null) {
7759
7890
  return {
7760
7891
  added: [],
@@ -7776,7 +7907,7 @@ function appendGitignoreEntries(cwd, entries) {
7776
7907
  const newline = existing.includes("\r\n") ? "\r\n" : "\n";
7777
7908
  const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : newline;
7778
7909
  try {
7779
- fs15__namespace.writeFileSync(
7910
+ fs16__namespace.writeFileSync(
7780
7911
  ignorePath,
7781
7912
  encodeGitignore(decoded, `${existing}${prefix}${added.join(newline)}${newline}`)
7782
7913
  );
@@ -7786,7 +7917,7 @@ function appendGitignoreEntries(cwd, entries) {
7786
7917
  return { added, note: null };
7787
7918
  }
7788
7919
  function gitignorePath(cwd, filePath) {
7789
- return path16__namespace.relative(cwd, filePath).split(path16__namespace.sep).join("/");
7920
+ return path17__namespace.relative(cwd, filePath).split(path17__namespace.sep).join("/");
7790
7921
  }
7791
7922
 
7792
7923
  // src/wizard/config-template.ts
@@ -7937,6 +8068,10 @@ function renderConfig(answers) {
7937
8068
  // Experimental: grow the per-part budget until the snapshot fits this many parts, instead of
7938
8069
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
7939
8070
  // maxParts: 10,
8071
+ // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
8072
+ // brief: "docs/brief.md",
8073
+ // Which job the brief is written for: audit, review or explain.
8074
+ // promptTask: "audit",
7940
8075
  // afterGenerate: (manifest) => { /* write your own artifact */ }
7941
8076
  hooks: {},
7942
8077
  };
@@ -8331,7 +8466,7 @@ function parsePackageJson(raw) {
8331
8466
  }
8332
8467
  function readPackageJson(cwd) {
8333
8468
  try {
8334
- return parsePackageJson(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"));
8469
+ return parsePackageJson(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"));
8335
8470
  } catch {
8336
8471
  return null;
8337
8472
  }
@@ -8368,7 +8503,7 @@ function artifactAnswers(options) {
8368
8503
  }
8369
8504
  function topLevelDirs(cwd) {
8370
8505
  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();
8506
+ return fs16__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
8372
8507
  } catch {
8373
8508
  return [];
8374
8509
  }
@@ -8383,7 +8518,7 @@ function writeFileOrExplain(target, content) {
8383
8518
  try {
8384
8519
  let stats = null;
8385
8520
  try {
8386
- stats = fs15__namespace.lstatSync(target);
8521
+ stats = fs16__namespace.lstatSync(target);
8387
8522
  } catch {
8388
8523
  stats = null;
8389
8524
  }
@@ -8398,12 +8533,12 @@ function writeFileOrExplain(target, content) {
8398
8533
  );
8399
8534
  }
8400
8535
  const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
8401
- fs15__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
8536
+ fs16__namespace.writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
8402
8537
  try {
8403
- fs15__namespace.renameSync(temporary, target);
8538
+ fs16__namespace.renameSync(temporary, target);
8404
8539
  } catch (err) {
8405
8540
  try {
8406
- fs15__namespace.unlinkSync(temporary);
8541
+ fs16__namespace.unlinkSync(temporary);
8407
8542
  } catch {
8408
8543
  }
8409
8544
  throw err;
@@ -8451,19 +8586,19 @@ function serializePackageJson(raw, value) {
8451
8586
  return `${bom}${text2}${raw.endsWith("\n") ? crlf ? "\r\n" : "\n" : ""}`;
8452
8587
  }
8453
8588
  function updatePackageJson(cwd, notes) {
8454
- const packagePath = path16__namespace.join(cwd, "package.json");
8589
+ const packagePath = path17__namespace.join(cwd, "package.json");
8455
8590
  const unchanged = {
8456
8591
  scripts: [],
8457
8592
  dependency: { name: GENERATOR_NAME, range: null, added: false }
8458
8593
  };
8459
- if (!fs15__namespace.existsSync(packagePath)) {
8594
+ if (!fs16__namespace.existsSync(packagePath)) {
8460
8595
  notes.push("No package.json found, so npm scripts and the devDependency were not added.");
8461
8596
  return unchanged;
8462
8597
  }
8463
8598
  let raw;
8464
8599
  let parsed;
8465
8600
  try {
8466
- raw = fs15__namespace.readFileSync(packagePath, "utf8");
8601
+ raw = fs16__namespace.readFileSync(packagePath, "utf8");
8467
8602
  parsed = parsePackageJson(raw);
8468
8603
  } catch {
8469
8604
  notes.push("Could not parse package.json; npm scripts and the devDependency were not added.");
@@ -8538,8 +8673,8 @@ function gitignoreEntriesFor(cwd, outDir, tmpDir) {
8538
8673
  const entries = [];
8539
8674
  for (const directory of [outDir, tmpDir]) {
8540
8675
  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)) {
8676
+ const relative15 = path17__namespace.relative(cwd, path17__namespace.resolve(cwd, directory)).replace(/\\/g, "/");
8677
+ if (relative15 === "" || relative15 === "." || relative15.startsWith("..") || path17__namespace.isAbsolute(relative15)) {
8543
8678
  continue;
8544
8679
  }
8545
8680
  entries.push(`/${relative15}/`);
@@ -8791,7 +8926,7 @@ async function runInit(options) {
8791
8926
  const configText = renderConfig(answers);
8792
8927
  const preferredName = chooseConfigFileName(options.cwd);
8793
8928
  const presentConfigs = CONFIG_CANDIDATES.filter(
8794
- (name) => fs15__namespace.existsSync(path16__namespace.join(options.cwd, name))
8929
+ (name) => fs16__namespace.existsSync(path17__namespace.join(options.cwd, name))
8795
8930
  );
8796
8931
  const present = presentConfigs[0] ?? null;
8797
8932
  if (presentConfigs.length > 1) {
@@ -8800,7 +8935,7 @@ async function runInit(options) {
8800
8935
  );
8801
8936
  }
8802
8937
  const configName = present !== null && options.force ? present : preferredName;
8803
- const configPath = path16__namespace.join(options.cwd, configName);
8938
+ const configPath = path17__namespace.join(options.cwd, configName);
8804
8939
  const reused = present !== null && options.force !== true && options.reuseConfig === true;
8805
8940
  if (reused) notes.push(`Kept the existing ${present} instead of writing a new one.`);
8806
8941
  if (options.dryRun) {
@@ -8834,7 +8969,7 @@ async function runInit(options) {
8834
8969
  '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
8970
  );
8836
8971
  }
8837
- if (fs15__namespace.existsSync(configPath) && !options.force && !reused) {
8972
+ if (fs16__namespace.existsSync(configPath) && !options.force && !reused) {
8838
8973
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
8839
8974
  }
8840
8975
  if (!reused) writeFileOrExplain(configPath, configText);
@@ -8860,9 +8995,9 @@ async function runInit(options) {
8860
8995
  };
8861
8996
  }
8862
8997
  function describeTarget(cwd) {
8863
- const relative15 = path16__namespace.relative(process.cwd(), cwd);
8998
+ const relative15 = path17__namespace.relative(process.cwd(), cwd);
8864
8999
  if (relative15 === "") return "this directory";
8865
- if (relative15.startsWith("..") || path16__namespace.isAbsolute(relative15)) return cwd;
9000
+ if (relative15.startsWith("..") || path17__namespace.isAbsolute(relative15)) return cwd;
8866
9001
  return relative15;
8867
9002
  }
8868
9003
  function firstRunMessage(reason, cwd) {
@@ -8886,7 +9021,7 @@ function planFirstRun(facts) {
8886
9021
  var NOT_CONTENT = /* @__PURE__ */ new Set([".git", ".hg", ".svn", ".bzr", ".DS_Store", "Thumbs.db"]);
8887
9022
  function isEffectivelyEmpty(cwd) {
8888
9023
  try {
8889
- return fs15__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
9024
+ return fs16__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
8890
9025
  } catch {
8891
9026
  return false;
8892
9027
  }
@@ -8894,7 +9029,7 @@ function isEffectivelyEmpty(cwd) {
8894
9029
  function hasPriorSnapshot(cwd, outDir) {
8895
9030
  let parsed;
8896
9031
  try {
8897
- parsed = JSON.parse(fs15__namespace.readFileSync(path16__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
9032
+ parsed = JSON.parse(fs16__namespace.readFileSync(path17__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
8898
9033
  } catch {
8899
9034
  return false;
8900
9035
  }
@@ -9733,9 +9868,15 @@ var UNLIMITED_SLOTS = 0;
9733
9868
  var ENTRY_POINT = /(^|\/)(index|cli|main|bin|server|app|mod)\.[cm]?[jt]sx?$/;
9734
9869
  var TEST_PATH = /(^|\/)(tests?|__tests__)\//;
9735
9870
  var TEST_FILE = /\.(test|spec)\.[^.]+$/;
9736
- function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMENT_SLOTS, history = []) {
9871
+ function generatePrompt(manifest, artifacts, context = {}) {
9872
+ const slots = context.slots ?? DEFAULT_ATTACHMENT_SLOTS;
9873
+ const task = context.task ?? "audit";
9874
+ const history = context.history ?? [];
9875
+ const overview = context.overview ?? { releases: [] };
9876
+ const brief = context.brief;
9737
9877
  const wrote = (name) => artifacts?.[name] !== false;
9738
9878
  const code = (value) => inlineCode(escapeControls(value));
9879
+ const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
9739
9880
  const lines = [
9740
9881
  "# PROMPT.md",
9741
9882
  "",
@@ -9751,30 +9892,22 @@ function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMEN
9751
9892
  "You are working on a codebase you cannot clone, run or grep. Everything you know about it comes",
9752
9893
  "from the snapshot that follows this instruction. Where these notes and the snapshot disagree,",
9753
9894
  "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
9895
  ""
9768
9896
  ];
9897
+ if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
9898
+ lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
9899
+ lines.push(...stakesSection(brief, code));
9769
9900
  lines.push(...haveSection(wrote), "");
9770
- lines.push(...systemSection(manifest, code), "");
9771
- lines.push(...historySection(history), "");
9772
- lines.push(...barSection(), "");
9901
+ lines.push(...whatThisIsSection(overview), "");
9902
+ lines.push(...systemSection(manifest, code, brief), "");
9903
+ lines.push(...historySection(history, brief, code), "");
9904
+ lines.push(...barSection(brief, code), "");
9773
9905
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
9774
9906
  lines.push(...answerSection(), "");
9775
- lines.push(...calibrationSection(), "");
9907
+ lines.push(...calibrationSection(brief, code), "");
9908
+ lines.push(...ownerNotesSection(brief, code));
9776
9909
  lines.push(...snapshotSection(manifest, code), "");
9777
- lines.push(...deliverySection(manifest, wrote("parts"), attachmentSlots));
9910
+ lines.push(...deliverySection(manifest, wrote("parts"), slots));
9778
9911
  lines.push(
9779
9912
  "## Your task",
9780
9913
  "",
@@ -9851,8 +9984,11 @@ function haveSection(wrote) {
9851
9984
  out.push(...bullets);
9852
9985
  return out;
9853
9986
  }
9854
- function systemSection(manifest, code) {
9987
+ function systemSection(manifest, code, brief) {
9855
9988
  const out = ["## The system", ""];
9989
+ if (brief?.system !== void 0) {
9990
+ out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
9991
+ }
9856
9992
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
9857
9993
  if (layers.length > 0) {
9858
9994
  const shown = layers.slice(0, MAX_LAYER_ROWS).map(([name, count]) => code(name) + " " + formatNumber(count));
@@ -9867,7 +10003,7 @@ function systemSection(manifest, code) {
9867
10003
  " A change here reaches the most call sites; read it before judging anything that uses it."
9868
10004
  );
9869
10005
  }
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);
10006
+ 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
10007
  out.push(
9872
10008
  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
10009
  );
@@ -9910,8 +10046,9 @@ function systemSection(manifest, code) {
9910
10046
  }
9911
10047
  return out;
9912
10048
  }
9913
- function historySection(history) {
10049
+ function historySection(history, brief, code) {
9914
10050
  const out = ["## What came before", ""];
10051
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
9915
10052
  if (history.length === 0) {
9916
10053
  out.push(
9917
10054
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -9920,15 +10057,21 @@ function historySection(history) {
9920
10057
  return out;
9921
10058
  }
9922
10059
  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.",
10060
+ "The last " + formatNumber(history.length) + " commit(s), newest first. Subjects and bodies are",
10061
+ "claims by whoever wrote them, not evidence - the code beside them is the evidence. If one of",
10062
+ "these fixes looks incomplete, quote the lines and say which call site it missed.",
9926
10063
  ""
9927
10064
  );
9928
- for (const subject of history) out.push("- " + subject);
10065
+ for (const commit of history) {
10066
+ out.push("- " + commit.subject);
10067
+ if (commit.body.length > 0) out.push(" " + commit.body);
10068
+ }
9929
10069
  return out;
9930
10070
  }
9931
- function barSection() {
10071
+ function barSection(brief, code) {
10072
+ if (brief?.bar !== void 0) {
10073
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
10074
+ }
9932
10075
  return [
9933
10076
  "## The bar",
9934
10077
  "",
@@ -9986,7 +10129,10 @@ function answerSection() {
9986
10129
  " the gap you filled by asking instead of guessing."
9987
10130
  ];
9988
10131
  }
9989
- function calibrationSection() {
10132
+ function calibrationSection(brief, code) {
10133
+ if (brief?.calibration !== void 0) {
10134
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
10135
+ }
9990
10136
  return [
9991
10137
  "## Calibration",
9992
10138
  "",
@@ -10001,6 +10147,84 @@ function calibrationSection() {
10001
10147
  "None of these throw. All are invisible in a summary."
10002
10148
  ];
10003
10149
  }
10150
+ function jobSection(task, hasHistory) {
10151
+ const out = ["## The job", ""];
10152
+ if (task === "audit") {
10153
+ out.push(
10154
+ "Find what is still wrong or will break. How you read the code is yours to decide - by",
10155
+ "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
10156
+ "honest account of what you covered and what you did not.",
10157
+ ""
10158
+ );
10159
+ if (hasHistory) {
10160
+ out.push(
10161
+ "Another pass of the same findings is worth nothing. This repository carries a record of",
10162
+ "what was already fixed, below. Verify that those fixes hold instead of rediscovering them,",
10163
+ "and treat a variant of one at a different call site as a new finding."
10164
+ );
10165
+ } else {
10166
+ out.push(
10167
+ "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
10168
+ "so you cannot tell what has already been tried. Do not assume this is the first attempt."
10169
+ );
10170
+ }
10171
+ out.push(
10172
+ "",
10173
+ "If the task at the end asks for something narrower - explain a file, review a change, answer",
10174
+ "a question - that task wins. The standard and the coverage duty below still apply to it."
10175
+ );
10176
+ } else if (task === "review") {
10177
+ out.push(
10178
+ "Review the change or the area named in the task against this snapshot. Report what breaks,",
10179
+ "what the change claims but does not do, and what a reader would believe that the code does",
10180
+ "not support. Restating the diff is not a review; the standard and the coverage duty below",
10181
+ "still apply."
10182
+ );
10183
+ } else {
10184
+ out.push(
10185
+ "Explain how the part of the system named in the task works: the data flow, the boundaries",
10186
+ "and the invariants it depends on. Cite the lines. If the snapshot does not contain what you",
10187
+ "need, say which file you need rather than reconstructing it from the shape of the names."
10188
+ );
10189
+ }
10190
+ return out;
10191
+ }
10192
+ function stakesSection(brief, code) {
10193
+ if (brief?.stakes === void 0) return [];
10194
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
10195
+ }
10196
+ function whatThisIsSection(overview) {
10197
+ const body = [];
10198
+ if (overview.description !== void 0) {
10199
+ body.push("- Declared in `package.json`: " + overview.description);
10200
+ }
10201
+ if (overview.summary !== void 0) {
10202
+ body.push("- From the `README.md` first paragraph: " + overview.summary);
10203
+ }
10204
+ if (overview.releases.length > 0) {
10205
+ body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
10206
+ }
10207
+ if (body.length === 0) return [];
10208
+ return [
10209
+ "## What this is",
10210
+ "",
10211
+ ...body,
10212
+ "",
10213
+ "Those are the project's own claims, not evidence about the code.",
10214
+ ""
10215
+ ];
10216
+ }
10217
+ function ownerNotesSection(brief, code) {
10218
+ if (brief === void 0 || brief.notes.length === 0) return [];
10219
+ const out = ["## Owner notes", ""];
10220
+ for (const note of brief.notes) {
10221
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
10222
+ }
10223
+ return out;
10224
+ }
10225
+ function ownerBlock(text2, path23, code) {
10226
+ return ["> Written by the project owner in " + code(path23) + ", not generated.", "", text2];
10227
+ }
10004
10228
  function snapshotSection(manifest, code) {
10005
10229
  const out = ["## This snapshot", ""];
10006
10230
  out.push("- Fingerprint: " + code(manifest.fingerprint) + " - quote it verbatim in your answer.");
@@ -10313,6 +10537,58 @@ function treeTruncationWarnings(treeText) {
10313
10537
  }
10314
10538
  return warnings;
10315
10539
  }
10540
+ var SUMMARY_LIMIT = 400;
10541
+ var MAX_RELEASES = 2;
10542
+ function readProjectOverview(cwd) {
10543
+ return {
10544
+ ...readDescription(cwd),
10545
+ ...readSummary(cwd),
10546
+ releases: readReleases(cwd)
10547
+ };
10548
+ }
10549
+ function readText(file) {
10550
+ try {
10551
+ return fs16__namespace.readFileSync(file, "utf8");
10552
+ } catch {
10553
+ return null;
10554
+ }
10555
+ }
10556
+ function readDescription(cwd) {
10557
+ const raw = readText(path17__namespace.join(cwd, "package.json"));
10558
+ if (raw === null) return {};
10559
+ try {
10560
+ const parsed = JSON.parse(stripJsonComments(raw));
10561
+ return typeof parsed.description === "string" && parsed.description.trim().length > 0 ? { description: parsed.description.trim() } : {};
10562
+ } catch {
10563
+ return {};
10564
+ }
10565
+ }
10566
+ function readSummary(cwd) {
10567
+ const raw = readText(path17__namespace.join(cwd, "README.md"));
10568
+ if (raw === null) return {};
10569
+ const lines = raw.split(/\r?\n/);
10570
+ const paragraph = [];
10571
+ for (const line of lines) {
10572
+ const trimmed = line.trim();
10573
+ if (paragraph.length === 0) {
10574
+ if (trimmed.length === 0) continue;
10575
+ if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^</.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
10576
+ if (/^\[[^\]]+\]:/.test(trimmed)) continue;
10577
+ } else if (trimmed.length === 0 || /^#/.test(trimmed)) {
10578
+ break;
10579
+ }
10580
+ paragraph.push(trimmed);
10581
+ }
10582
+ const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
10583
+ if (summary.length === 0) return {};
10584
+ return { summary: summary.length > SUMMARY_LIMIT ? summary.slice(0, SUMMARY_LIMIT - 1) + "\u2026" : summary };
10585
+ }
10586
+ function readReleases(cwd) {
10587
+ const raw = readText(path17__namespace.join(cwd, "CHANGELOG.md"));
10588
+ if (raw === null) return [];
10589
+ const headings = raw.split(/\r?\n/).filter((line) => /^##\s+\S/.test(line)).map((line) => line.replace(/^##\s+/, "").trim());
10590
+ return headings.slice(0, MAX_RELEASES);
10591
+ }
10316
10592
  var PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
10317
10593
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
10318
10594
  var UP_TO_DATE_INTERVAL_MS = 60 * 60 * 1e3;
@@ -10361,17 +10637,17 @@ function isNewer(candidate, current) {
10361
10637
  }
10362
10638
  function cacheDirectory(env = process.env, platform = process.platform) {
10363
10639
  if (platform === "win32") {
10364
- const base2 = env.LOCALAPPDATA ?? path16__namespace.join(os__namespace.homedir(), "AppData", "Local");
10365
- return path16__namespace.join(base2, "codebase-snapshot");
10640
+ const base2 = env.LOCALAPPDATA ?? path17__namespace.join(os__namespace.homedir(), "AppData", "Local");
10641
+ return path17__namespace.join(base2, "codebase-snapshot");
10366
10642
  }
10367
10643
  if (platform === "darwin") {
10368
- return path16__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
10644
+ return path17__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
10369
10645
  }
10370
- const base = env.XDG_CACHE_HOME ?? path16__namespace.join(os__namespace.homedir(), ".cache");
10371
- return path16__namespace.join(base, "codebase-snapshot");
10646
+ const base = env.XDG_CACHE_HOME ?? path17__namespace.join(os__namespace.homedir(), ".cache");
10647
+ return path17__namespace.join(base, "codebase-snapshot");
10372
10648
  }
10373
10649
  function cacheFilePath(env = process.env) {
10374
- return path16__namespace.join(cacheDirectory(env), "update-check.json");
10650
+ return path17__namespace.join(cacheDirectory(env), "update-check.json");
10375
10651
  }
10376
10652
  function shouldCheck(argv, env) {
10377
10653
  const disabled = ["1", "true", "yes"].includes(
@@ -10401,7 +10677,7 @@ function shouldCheck(argv, env) {
10401
10677
  function readCache(file) {
10402
10678
  let raw;
10403
10679
  try {
10404
- raw = fs15__namespace.readFileSync(file, "utf8");
10680
+ raw = fs16__namespace.readFileSync(file, "utf8");
10405
10681
  } catch {
10406
10682
  return null;
10407
10683
  }
@@ -10418,8 +10694,8 @@ function readCache(file) {
10418
10694
  }
10419
10695
  function writeCache(file, entry) {
10420
10696
  try {
10421
- fs15__namespace.mkdirSync(path16__namespace.dirname(file), { recursive: true });
10422
- fs15__namespace.writeFileSync(file, `${JSON.stringify(entry)}
10697
+ fs16__namespace.mkdirSync(path17__namespace.dirname(file), { recursive: true });
10698
+ fs16__namespace.writeFileSync(file, `${JSON.stringify(entry)}
10423
10699
  `, "utf8");
10424
10700
  } catch {
10425
10701
  }
@@ -10550,36 +10826,36 @@ fi
10550
10826
  `;
10551
10827
  }
10552
10828
  function gitDirectory(cwd) {
10553
- const dotGit = path16__namespace.join(cwd, ".git");
10829
+ const dotGit = path17__namespace.join(cwd, ".git");
10554
10830
  let stats;
10555
10831
  try {
10556
- stats = fs15__namespace.statSync(dotGit);
10832
+ stats = fs16__namespace.statSync(dotGit);
10557
10833
  } catch {
10558
10834
  return null;
10559
10835
  }
10560
10836
  if (stats.isDirectory()) return dotGit;
10561
10837
  if (!stats.isFile()) return null;
10562
10838
  try {
10563
- const contents = fs15__namespace.readFileSync(dotGit, "utf8");
10839
+ const contents = fs16__namespace.readFileSync(dotGit, "utf8");
10564
10840
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
10565
10841
  if (!match) return null;
10566
10842
  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;
10843
+ const resolved = path17__namespace.isAbsolute(target.trim()) ? target.trim() : path17__namespace.join(cwd, target.trim());
10844
+ if (!fs16__namespace.statSync(resolved).isDirectory()) return null;
10845
+ if (isInside2(path17__namespace.resolve(cwd), path17__namespace.resolve(resolved))) return resolved;
10846
+ return isRegisteredWorktree(path17__namespace.resolve(resolved), cwd) ? resolved : null;
10571
10847
  } catch {
10572
10848
  return null;
10573
10849
  }
10574
10850
  }
10575
10851
  function isInside2(parent, child) {
10576
- const relative15 = path16__namespace.relative(parent, child);
10577
- return relative15 === "" || !relative15.startsWith("..") && !path16__namespace.isAbsolute(relative15);
10852
+ const relative15 = path17__namespace.relative(parent, child);
10853
+ return relative15 === "" || !relative15.startsWith("..") && !path17__namespace.isAbsolute(relative15);
10578
10854
  }
10579
10855
  function isRegisteredWorktree(gitDir, cwd) {
10580
10856
  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");
10857
+ const back = fs16__namespace.readFileSync(path17__namespace.join(gitDir, "gitdir"), "utf8").trim();
10858
+ return path17__namespace.resolve(gitDir, back) === path17__namespace.join(path17__namespace.resolve(cwd), ".git");
10583
10859
  } catch {
10584
10860
  return false;
10585
10861
  }
@@ -10600,10 +10876,10 @@ function gitOutput(cwd, args) {
10600
10876
  function configuredHooksDirectory(cwd) {
10601
10877
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
10602
10878
  if (hooks === null) return null;
10603
- const resolved = path16__namespace.resolve(cwd, hooks);
10879
+ const resolved = path17__namespace.resolve(cwd, hooks);
10604
10880
  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 };
10881
+ const commonDir = common === null ? null : path17__namespace.resolve(cwd, common);
10882
+ if (isInside2(path17__namespace.resolve(cwd), resolved)) return { dir: resolved };
10607
10883
  if (commonDir !== null && isInside2(commonDir, resolved)) return { dir: resolved };
10608
10884
  return {
10609
10885
  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 +10900,10 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10624
10900
  ]
10625
10901
  };
10626
10902
  }
10627
- const hooksDir = configured === null ? path16__namespace.join(gitDir, "hooks") : configured.dir;
10628
- const hookPath = path16__namespace.join(hooksDir, "pre-commit");
10903
+ const hooksDir = configured === null ? path17__namespace.join(gitDir, "hooks") : configured.dir;
10904
+ const hookPath = path17__namespace.join(hooksDir, "pre-commit");
10629
10905
  try {
10630
- fs15__namespace.mkdirSync(hooksDir, { recursive: true });
10906
+ fs16__namespace.mkdirSync(hooksDir, { recursive: true });
10631
10907
  } catch (err) {
10632
10908
  return {
10633
10909
  path: hookPath,
@@ -10637,7 +10913,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10637
10913
  }
10638
10914
  let existing = null;
10639
10915
  try {
10640
- existing = fs15__namespace.readFileSync(hookPath, "utf8");
10916
+ existing = fs16__namespace.readFileSync(hookPath, "utf8");
10641
10917
  } catch {
10642
10918
  existing = null;
10643
10919
  }
@@ -10652,8 +10928,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10652
10928
  };
10653
10929
  }
10654
10930
  try {
10655
- fs15__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10656
- fs15__namespace.chmodSync(hookPath, 493);
10931
+ fs16__namespace.writeFileSync(hookPath, hookScript(outDir), "utf8");
10932
+ fs16__namespace.chmodSync(hookPath, 493);
10657
10933
  } catch (err) {
10658
10934
  return {
10659
10935
  path: hookPath,
@@ -10670,7 +10946,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10670
10946
  };
10671
10947
  }
10672
10948
  function workerEntry(directory, isCjs) {
10673
- const entry = path16__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10949
+ const entry = path17__namespace.join(directory, isCjs ? "index.cjs" : "index.js");
10674
10950
  return { path: entry, url: url.pathToFileURL(entry).href };
10675
10951
  }
10676
10952
  var WORKER_SOURCE = `
@@ -10737,7 +11013,7 @@ function generateInWorker(cwd, cliOptions, options = {}) {
10737
11013
  resolve12(result);
10738
11014
  };
10739
11015
  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))));
11016
+ 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
11017
  try {
10742
11018
  worker = new worker_threads.Worker(WORKER_SOURCE, {
10743
11019
  eval: true,
@@ -10772,23 +11048,23 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
10772
11048
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
10773
11049
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
10774
11050
  var fileDerivationBytes = 0;
10775
- function takeDerivation(path22, hash, settings) {
10776
- const cached = FILE_DERIVATIONS.get(path22);
11051
+ function takeDerivation(path23, hash, settings) {
11052
+ const cached = FILE_DERIVATIONS.get(path23);
10777
11053
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
10778
- FILE_DERIVATIONS.delete(path22);
10779
- FILE_DERIVATIONS.set(path22, cached);
11054
+ FILE_DERIVATIONS.delete(path23);
11055
+ FILE_DERIVATIONS.set(path23, cached);
10780
11056
  return cached;
10781
11057
  }
10782
- function rememberDerivation(path22, hash, settings, derivation) {
11058
+ function rememberDerivation(path23, hash, settings, derivation) {
10783
11059
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
10784
11060
  const bytes = bodyBytes * 2 + 512;
10785
11061
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
10786
- const previous = FILE_DERIVATIONS.get(path22);
11062
+ const previous = FILE_DERIVATIONS.get(path23);
10787
11063
  if (previous !== void 0) {
10788
- FILE_DERIVATIONS.delete(path22);
11064
+ FILE_DERIVATIONS.delete(path23);
10789
11065
  fileDerivationBytes -= previous.bytes;
10790
11066
  } else {
10791
- FILE_DERIVATIONS.delete(path22);
11067
+ FILE_DERIVATIONS.delete(path23);
10792
11068
  }
10793
11069
  while (fileDerivationBytes + bytes > FILE_DERIVATION_LIMIT_BYTES) {
10794
11070
  const oldest = FILE_DERIVATIONS.keys().next();
@@ -10797,7 +11073,7 @@ function rememberDerivation(path22, hash, settings, derivation) {
10797
11073
  FILE_DERIVATIONS.delete(oldest.value);
10798
11074
  if (evicted !== void 0) fileDerivationBytes -= evicted.bytes;
10799
11075
  }
10800
- FILE_DERIVATIONS.set(path22, { ...derivation, hash, settings, bytes });
11076
+ FILE_DERIVATIONS.set(path23, { ...derivation, hash, settings, bytes });
10801
11077
  fileDerivationBytes += bytes;
10802
11078
  }
10803
11079
  function derivationSettings(config) {
@@ -11048,11 +11324,11 @@ function verifyInMemory(files, parts, unaccounted) {
11048
11324
  return errors;
11049
11325
  }
11050
11326
  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}`);
11327
+ const cwd = path17__namespace.resolve(config.cwd);
11328
+ const outDir = path17__namespace.resolve(cwd, config.outDir);
11329
+ const tmpDir = path17__namespace.resolve(cwd, config.tmpDir);
11330
+ const root = path17__namespace.parse(cwd).root;
11331
+ const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path17__namespace.sep}`);
11056
11332
  const reject = (reason) => {
11057
11333
  throw new Error(
11058
11334
  `Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
@@ -11092,6 +11368,28 @@ function maskSummaryStrings(value, secretRules) {
11092
11368
  function maskPathText(value, secretRules) {
11093
11369
  return findSecretInPath(value, secretRules)?.masked ?? value;
11094
11370
  }
11371
+ function maskOwnerBrief(brief, secretRules) {
11372
+ if (brief === void 0) return void 0;
11373
+ const mask = (value) => maskPathText(value, secretRules);
11374
+ return {
11375
+ ...brief,
11376
+ ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11377
+ ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11378
+ ...brief.history === void 0 ? {} : { history: mask(brief.history) },
11379
+ ...brief.bar === void 0 ? {} : { bar: mask(brief.bar) },
11380
+ ...brief.calibration === void 0 ? {} : { calibration: mask(brief.calibration) },
11381
+ ...brief.preamble === void 0 ? {} : { preamble: mask(brief.preamble) },
11382
+ notes: brief.notes.map((note) => ({ heading: note.heading, body: mask(note.body) }))
11383
+ };
11384
+ }
11385
+ function maskOverview(overview, secretRules) {
11386
+ const mask = (value) => maskPathText(value, secretRules);
11387
+ return {
11388
+ ...overview.description === void 0 ? {} : { description: mask(overview.description) },
11389
+ ...overview.summary === void 0 ? {} : { summary: mask(overview.summary) },
11390
+ releases: overview.releases.map(mask)
11391
+ };
11392
+ }
11095
11393
  function maskSkipRecords(records, secretRules) {
11096
11394
  return maskSkipPaths(records, secretRules);
11097
11395
  }
@@ -11112,14 +11410,14 @@ function listEntries(dir) {
11112
11410
  const walk = (absolute, prefix) => {
11113
11411
  let children;
11114
11412
  try {
11115
- children = fs15__namespace.readdirSync(absolute, { withFileTypes: true });
11413
+ children = fs16__namespace.readdirSync(absolute, { withFileTypes: true });
11116
11414
  } catch {
11117
11415
  return;
11118
11416
  }
11119
11417
  for (const child of children) {
11120
11418
  const relative15 = prefix === "" ? child.name : `${prefix}/${child.name}`;
11121
11419
  entries.push(relative15);
11122
- if (child.isDirectory()) walk(path16__namespace.join(absolute, child.name), relative15);
11420
+ if (child.isDirectory()) walk(path17__namespace.join(absolute, child.name), relative15);
11123
11421
  }
11124
11422
  };
11125
11423
  walk(dir, "");
@@ -11131,10 +11429,10 @@ function markerInventory(dir, written) {
11131
11429
  for (const entry of entries) {
11132
11430
  if (entry === OWNERSHIP_MARKER) continue;
11133
11431
  if (isIgnorableEntry(entry)) continue;
11134
- const full = path16__namespace.join(dir, ...entry.split("/"));
11432
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11135
11433
  let stats;
11136
11434
  try {
11137
- stats = fs15__namespace.lstatSync(full);
11435
+ stats = fs16__namespace.lstatSync(full);
11138
11436
  } catch {
11139
11437
  continue;
11140
11438
  }
@@ -11146,7 +11444,7 @@ function markerInventory(dir, written) {
11146
11444
  }
11147
11445
  let digest;
11148
11446
  try {
11149
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11447
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11150
11448
  } catch {
11151
11449
  continue;
11152
11450
  }
@@ -11167,15 +11465,15 @@ function markerPayload(dir, state, id, createdAt, written) {
11167
11465
  entries,
11168
11466
  files
11169
11467
  };
11170
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11171
- if (fs15__namespace.existsSync(manifestPath)) {
11172
- marker2.manifestSha256 = sha256Hex2(fs15__namespace.readFileSync(manifestPath));
11468
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11469
+ if (fs16__namespace.existsSync(manifestPath)) {
11470
+ marker2.manifestSha256 = sha256Hex2(fs16__namespace.readFileSync(manifestPath));
11173
11471
  }
11174
11472
  return marker2;
11175
11473
  }
11176
11474
  function writeOwnershipMarker(dir, marker2) {
11177
- fs15__namespace.writeFileSync(
11178
- path16__namespace.join(dir, OWNERSHIP_MARKER),
11475
+ fs16__namespace.writeFileSync(
11476
+ path17__namespace.join(dir, OWNERSHIP_MARKER),
11179
11477
  `${JSON.stringify(marker2, null, 2)}
11180
11478
  `,
11181
11479
  "utf8"
@@ -11187,13 +11485,13 @@ function markerBelongsTo(dir, id) {
11187
11485
  return evidence.marker.id === id;
11188
11486
  }
11189
11487
  function readOwnershipMarker(dir) {
11190
- const markerPath = path16__namespace.join(dir, OWNERSHIP_MARKER);
11191
- if (!fs15__namespace.existsSync(markerPath)) {
11488
+ const markerPath = path17__namespace.join(dir, OWNERSHIP_MARKER);
11489
+ if (!fs16__namespace.existsSync(markerPath)) {
11192
11490
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
11193
11491
  }
11194
11492
  let raw;
11195
11493
  try {
11196
- raw = fs15__namespace.readFileSync(markerPath, "utf8");
11494
+ raw = fs16__namespace.readFileSync(markerPath, "utf8");
11197
11495
  } catch {
11198
11496
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
11199
11497
  }
@@ -11293,10 +11591,10 @@ function verifyMarkerInventory(dir, entries, files) {
11293
11591
  for (const entry of entries) {
11294
11592
  if (entry === OWNERSHIP_MARKER) continue;
11295
11593
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
11296
- const full = path16__namespace.join(dir, ...entry.split("/"));
11594
+ const full = path17__namespace.join(dir, ...entry.split("/"));
11297
11595
  let stats;
11298
11596
  try {
11299
- stats = fs15__namespace.lstatSync(full);
11597
+ stats = fs16__namespace.lstatSync(full);
11300
11598
  } catch {
11301
11599
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
11302
11600
  }
@@ -11321,7 +11619,7 @@ function verifyMarkerInventory(dir, entries, files) {
11321
11619
  }
11322
11620
  let digest;
11323
11621
  try {
11324
- digest = sha256Hex2(fs15__namespace.readFileSync(full));
11622
+ digest = sha256Hex2(fs16__namespace.readFileSync(full));
11325
11623
  } catch {
11326
11624
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
11327
11625
  }
@@ -11342,12 +11640,12 @@ function assessSnapshotDirectory(dir) {
11342
11640
  marker: marker2
11343
11641
  };
11344
11642
  }
11345
- const manifestPath = path16__namespace.join(dir, "manifest.json");
11346
- const hasManifest = fs15__namespace.existsSync(manifestPath);
11643
+ const manifestPath = path17__namespace.join(dir, "manifest.json");
11644
+ const hasManifest = fs16__namespace.existsSync(manifestPath);
11347
11645
  if (hasManifest) {
11348
11646
  let raw;
11349
11647
  try {
11350
- raw = fs15__namespace.readFileSync(manifestPath, "utf8");
11648
+ raw = fs16__namespace.readFileSync(manifestPath, "utf8");
11351
11649
  } catch {
11352
11650
  return {
11353
11651
  owned: false,
@@ -11442,13 +11740,13 @@ function containsNoFiles(dir) {
11442
11740
  const current = pending.pop();
11443
11741
  let entries;
11444
11742
  try {
11445
- entries = fs15__namespace.readdirSync(current, { withFileTypes: true });
11743
+ entries = fs16__namespace.readdirSync(current, { withFileTypes: true });
11446
11744
  } catch {
11447
11745
  return false;
11448
11746
  }
11449
11747
  for (const entry of entries) {
11450
11748
  if (entry.isDirectory()) {
11451
- pending.push(path16__namespace.join(current, entry.name));
11749
+ pending.push(path17__namespace.join(current, entry.name));
11452
11750
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
11453
11751
  return false;
11454
11752
  }
@@ -11457,13 +11755,13 @@ function containsNoFiles(dir) {
11457
11755
  return true;
11458
11756
  }
11459
11757
  function assertReplaceable(target, label, secretRules) {
11460
- if (!fs15__namespace.existsSync(target)) return;
11461
- if (!fs15__namespace.statSync(target).isDirectory()) {
11758
+ if (!fs16__namespace.existsSync(target)) return;
11759
+ if (!fs16__namespace.statSync(target).isDirectory()) {
11462
11760
  throw new Error(
11463
11761
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
11464
11762
  );
11465
11763
  }
11466
- const entries = fs15__namespace.readdirSync(target);
11764
+ const entries = fs16__namespace.readdirSync(target);
11467
11765
  if (entries.length === 0) return;
11468
11766
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
11469
11767
  if (containsNoFiles(target)) return;
@@ -11483,18 +11781,18 @@ function assertReplaceable(target, label, secretRules) {
11483
11781
  );
11484
11782
  }
11485
11783
  function assertStagingRootUsable(tmpDir, secretRules) {
11486
- if (!fs15__namespace.existsSync(tmpDir)) return;
11487
- if (!fs15__namespace.statSync(tmpDir).isDirectory()) {
11784
+ if (!fs16__namespace.existsSync(tmpDir)) return;
11785
+ if (!fs16__namespace.statSync(tmpDir).isDirectory()) {
11488
11786
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
11489
11787
  }
11490
- const entries = fs15__namespace.readdirSync(tmpDir);
11788
+ const entries = fs16__namespace.readdirSync(tmpDir);
11491
11789
  if (entries.length === 0) return;
11492
11790
  const foreign = entries.filter((name) => {
11493
- const full = path16__namespace.join(tmpDir, name);
11791
+ const full = path17__namespace.join(tmpDir, name);
11494
11792
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
11495
11793
  let stats;
11496
11794
  try {
11497
- stats = fs15__namespace.statSync(full);
11795
+ stats = fs16__namespace.statSync(full);
11498
11796
  } catch {
11499
11797
  return true;
11500
11798
  }
@@ -11502,7 +11800,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11502
11800
  const { marker: marker2 } = readOwnershipMarker(full);
11503
11801
  if (marker2) return false;
11504
11802
  try {
11505
- return fs15__namespace.readdirSync(full).length > 0;
11803
+ return fs16__namespace.readdirSync(full).length > 0;
11506
11804
  } catch {
11507
11805
  return true;
11508
11806
  }
@@ -11517,13 +11815,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11517
11815
  function cleanStaleRunDirs(tmpDir) {
11518
11816
  let entries;
11519
11817
  try {
11520
- entries = fs15__namespace.readdirSync(tmpDir);
11818
+ entries = fs16__namespace.readdirSync(tmpDir);
11521
11819
  } catch {
11522
11820
  return;
11523
11821
  }
11524
11822
  for (const name of entries) {
11525
11823
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
11526
- const full = path16__namespace.join(tmpDir, name);
11824
+ const full = path17__namespace.join(tmpDir, name);
11527
11825
  const { marker: marker2 } = readOwnershipMarker(full);
11528
11826
  if (marker2) {
11529
11827
  const created = Date.parse(marker2.createdAt);
@@ -11531,33 +11829,33 @@ function cleanStaleRunDirs(tmpDir) {
11531
11829
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
11532
11830
  if (aged || abandoned) {
11533
11831
  try {
11534
- fs15__namespace.rmSync(full, { recursive: true, force: true });
11832
+ fs16__namespace.rmSync(full, { recursive: true, force: true });
11535
11833
  } catch {
11536
11834
  }
11537
11835
  }
11538
11836
  continue;
11539
11837
  }
11540
11838
  try {
11541
- if (fs15__namespace.readdirSync(full).length === 0) fs15__namespace.rmSync(full, { recursive: true, force: true });
11839
+ if (fs16__namespace.readdirSync(full).length === 0) fs16__namespace.rmSync(full, { recursive: true, force: true });
11542
11840
  } catch {
11543
11841
  }
11544
11842
  }
11545
11843
  }
11546
11844
  function removeIfEmpty(dir) {
11547
11845
  try {
11548
- if (fs15__namespace.readdirSync(dir).length === 0) fs15__namespace.rmSync(dir, { recursive: true, force: true });
11846
+ if (fs16__namespace.readdirSync(dir).length === 0) fs16__namespace.rmSync(dir, { recursive: true, force: true });
11549
11847
  } catch {
11550
11848
  }
11551
11849
  }
11552
11850
  function ensureParentDirectory(target, label) {
11553
- const parent = path16__namespace.dirname(target);
11554
- if (fs15__namespace.existsSync(parent) && !fs15__namespace.statSync(parent).isDirectory()) {
11851
+ const parent = path17__namespace.dirname(target);
11852
+ if (fs16__namespace.existsSync(parent) && !fs16__namespace.statSync(parent).isDirectory()) {
11555
11853
  throw new Error(
11556
11854
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
11557
11855
  );
11558
11856
  }
11559
11857
  try {
11560
- fs15__namespace.mkdirSync(parent, { recursive: true });
11858
+ fs16__namespace.mkdirSync(parent, { recursive: true });
11561
11859
  } catch (err) {
11562
11860
  throw new Error(
11563
11861
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -11615,17 +11913,17 @@ function acquireRunLock(stagingRoot) {
11615
11913
  `;
11616
11914
  for (let attempt = 0; attempt < 2; attempt += 1) {
11617
11915
  try {
11618
- const handle = fs15__namespace.openSync(lockPath, "wx");
11916
+ const handle = fs16__namespace.openSync(lockPath, "wx");
11619
11917
  try {
11620
- fs15__namespace.writeSync(handle, payload);
11918
+ fs16__namespace.writeSync(handle, payload);
11621
11919
  } finally {
11622
- fs15__namespace.closeSync(handle);
11920
+ fs16__namespace.closeSync(handle);
11623
11921
  }
11624
11922
  const stopHeartbeat = startLockHeartbeat(lockPath);
11625
11923
  return () => {
11626
11924
  stopHeartbeat();
11627
11925
  try {
11628
- fs15__namespace.rmSync(lockPath, { force: true });
11926
+ fs16__namespace.rmSync(lockPath, { force: true });
11629
11927
  } catch {
11630
11928
  }
11631
11929
  };
@@ -11645,26 +11943,26 @@ function lockKeyFor(stagingRoot) {
11645
11943
  return sha256Hex2(key).slice(0, 16);
11646
11944
  }
11647
11945
  function canonicalLockTarget(targetPath2) {
11648
- const resolved = path16__namespace.resolve(targetPath2);
11946
+ const resolved = path17__namespace.resolve(targetPath2);
11649
11947
  let existing = resolved;
11650
11948
  const tail = [];
11651
11949
  for (; ; ) {
11652
11950
  try {
11653
- return path16__namespace.join(fs15__namespace.realpathSync(existing), ...tail);
11951
+ return path17__namespace.join(fs16__namespace.realpathSync(existing), ...tail);
11654
11952
  } catch {
11655
- const parent = path16__namespace.dirname(existing);
11953
+ const parent = path17__namespace.dirname(existing);
11656
11954
  if (parent === existing) return resolved;
11657
- tail.unshift(path16__namespace.basename(existing));
11955
+ tail.unshift(path17__namespace.basename(existing));
11658
11956
  existing = parent;
11659
11957
  }
11660
11958
  }
11661
11959
  }
11662
11960
  function lockPathFor(stagingRoot) {
11663
- return path16__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11961
+ return path17__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11664
11962
  }
11665
11963
  function lockHeartbeatAgeMs(lockPath) {
11666
11964
  try {
11667
- return Date.now() - fs15__namespace.statSync(lockPath).mtimeMs;
11965
+ return Date.now() - fs16__namespace.statSync(lockPath).mtimeMs;
11668
11966
  } catch {
11669
11967
  return Number.POSITIVE_INFINITY;
11670
11968
  }
@@ -11672,7 +11970,7 @@ function lockHeartbeatAgeMs(lockPath) {
11672
11970
  function lockOwnerIsGone(lockPath) {
11673
11971
  let raw;
11674
11972
  try {
11675
- raw = fs15__namespace.readFileSync(lockPath, "utf8");
11973
+ raw = fs16__namespace.readFileSync(lockPath, "utf8");
11676
11974
  } catch {
11677
11975
  return false;
11678
11976
  }
@@ -11694,16 +11992,16 @@ function lockOwnerIsGone(lockPath) {
11694
11992
  function reclaimStaleLock(lockPath) {
11695
11993
  let before;
11696
11994
  try {
11697
- before = fs15__namespace.statSync(lockPath);
11995
+ before = fs16__namespace.statSync(lockPath);
11698
11996
  } catch {
11699
11997
  return true;
11700
11998
  }
11701
11999
  if (!lockOwnerIsGone(lockPath)) return false;
11702
12000
  try {
11703
- const current = fs15__namespace.statSync(lockPath);
12001
+ const current = fs16__namespace.statSync(lockPath);
11704
12002
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
11705
12003
  if (!sameFile) return false;
11706
- fs15__namespace.rmSync(lockPath, { force: true });
12004
+ fs16__namespace.rmSync(lockPath, { force: true });
11707
12005
  return true;
11708
12006
  } catch {
11709
12007
  return false;
@@ -11714,12 +12012,12 @@ function lockFileIsAncient(lockPath) {
11714
12012
  }
11715
12013
  function writeManifestAtomically(manifestPath, manifest) {
11716
12014
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
11717
- fs15__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
12015
+ fs16__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11718
12016
  try {
11719
- fs15__namespace.renameSync(tempPath, manifestPath);
12017
+ fs16__namespace.renameSync(tempPath, manifestPath);
11720
12018
  } catch (err) {
11721
12019
  try {
11722
- fs15__namespace.rmSync(tempPath, { force: true });
12020
+ fs16__namespace.rmSync(tempPath, { force: true });
11723
12021
  } catch {
11724
12022
  }
11725
12023
  throw err;
@@ -11744,21 +12042,21 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap) {
11744
12042
  }
11745
12043
  }
11746
12044
  function recoverInterruptedPublish(outDir) {
11747
- if (fs15__namespace.existsSync(outDir)) return;
11748
- const parent = path16__namespace.dirname(outDir);
11749
- const base = path16__namespace.basename(outDir);
12045
+ if (fs16__namespace.existsSync(outDir)) return;
12046
+ const parent = path17__namespace.dirname(outDir);
12047
+ const base = path17__namespace.basename(outDir);
11750
12048
  let backups;
11751
12049
  try {
11752
- backups = fs15__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
12050
+ backups = fs16__namespace.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
11753
12051
  } catch {
11754
12052
  return;
11755
12053
  }
11756
12054
  if (backups.length !== 1) return;
11757
- const backupDir = path16__namespace.join(parent, backups[0]);
12055
+ const backupDir = path17__namespace.join(parent, backups[0]);
11758
12056
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
11759
12057
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
11760
12058
  try {
11761
- fs15__namespace.renameSync(backupDir, outDir);
12059
+ fs16__namespace.renameSync(backupDir, outDir);
11762
12060
  process.stderr.write(
11763
12061
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
11764
12062
  `
@@ -11768,16 +12066,16 @@ function recoverInterruptedPublish(outDir) {
11768
12066
  }
11769
12067
  function swapOnce(stagingDir, outDir, beforeSwap) {
11770
12068
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
11771
- const hadPrevious = fs15__namespace.existsSync(outDir);
12069
+ const hadPrevious = fs16__namespace.existsSync(outDir);
11772
12070
  if (hadPrevious) beforeSwap?.();
11773
12071
  let movedAside = false;
11774
12072
  if (hadPrevious) {
11775
12073
  try {
11776
- fs15__namespace.renameSync(outDir, backupDir);
12074
+ fs16__namespace.renameSync(outDir, backupDir);
11777
12075
  movedAside = true;
11778
12076
  } catch (err) {
11779
12077
  if (!isLockError(err)) throw err;
11780
- fs15__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
12078
+ fs16__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
11781
12079
  process.stderr.write(
11782
12080
  `\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
12081
  `
@@ -11786,26 +12084,26 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11786
12084
  }
11787
12085
  try {
11788
12086
  try {
11789
- fs15__namespace.renameSync(stagingDir, outDir);
12087
+ fs16__namespace.renameSync(stagingDir, outDir);
11790
12088
  } catch (err) {
11791
12089
  if (err.code !== "EXDEV") throw err;
11792
12090
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
11793
12091
  try {
11794
- fs15__namespace.cpSync(stagingDir, partialDir, { recursive: true });
11795
- fs15__namespace.renameSync(partialDir, outDir);
11796
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12092
+ fs16__namespace.cpSync(stagingDir, partialDir, { recursive: true });
12093
+ fs16__namespace.renameSync(partialDir, outDir);
12094
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
11797
12095
  } catch (copyErr) {
11798
12096
  try {
11799
- fs15__namespace.rmSync(partialDir, { recursive: true, force: true });
12097
+ fs16__namespace.rmSync(partialDir, { recursive: true, force: true });
11800
12098
  } catch {
11801
12099
  }
11802
12100
  throw copyErr;
11803
12101
  }
11804
12102
  }
11805
12103
  } 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);
12104
+ if (hadPrevious && movedAside && fs16__namespace.existsSync(backupDir)) {
12105
+ if (fs16__namespace.existsSync(outDir)) fs16__namespace.rmSync(outDir, { recursive: true, force: true });
12106
+ fs16__namespace.renameSync(backupDir, outDir);
11809
12107
  } else if (hadPrevious && !movedAside) {
11810
12108
  process.stderr.write(
11811
12109
  `\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 +12114,7 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11816
12114
  }
11817
12115
  if (hadPrevious) {
11818
12116
  try {
11819
- fs15__namespace.rmSync(backupDir, { recursive: true, force: true });
12117
+ fs16__namespace.rmSync(backupDir, { recursive: true, force: true });
11820
12118
  } catch (err) {
11821
12119
  process.stderr.write(
11822
12120
  `\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 +12272,7 @@ function generateSnapshot(configInput, options) {
11974
12272
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
11975
12273
  // output — but only at these exact paths, not at every directory that shares the name.
11976
12274
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
11977
- (directory) => path16__namespace.relative(config.cwd, path16__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
12275
+ (directory) => path17__namespace.relative(config.cwd, path17__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
11978
12276
  ).filter((relative15) => relative15.length > 0 && !relative15.startsWith("..")),
11979
12277
  // A staged path can be absent from the working tree while its index blob exists. Discovery
11980
12278
  // lists the working tree, so those paths would never reach the scan at all.
@@ -12003,7 +12301,7 @@ function generateSnapshot(configInput, options) {
12003
12301
  let totalSizeBytes = 0;
12004
12302
  let largeFileCount = 0;
12005
12303
  for (const relativePath of candidateFiles) {
12006
- const absolutePath = path16__namespace.join(config.cwd, relativePath);
12304
+ const absolutePath = path17__namespace.join(config.cwd, relativePath);
12007
12305
  const fromIndex = stagedPaths.has(relativePath);
12008
12306
  let buffer;
12009
12307
  let sizeBytes;
@@ -12034,9 +12332,9 @@ function generateSnapshot(configInput, options) {
12034
12332
  } else {
12035
12333
  let stats;
12036
12334
  try {
12037
- stats = fs15__namespace.statSync(absolutePath);
12335
+ stats = fs16__namespace.statSync(absolutePath);
12038
12336
  if (!stats.isFile()) {
12039
- const nestedRepository = stats.isDirectory() && fs15__namespace.existsSync(path16__namespace.join(absolutePath, ".git"));
12337
+ const nestedRepository = stats.isDirectory() && fs16__namespace.existsSync(path17__namespace.join(absolutePath, ".git"));
12040
12338
  skipped.push(
12041
12339
  nestedRepository ? {
12042
12340
  path: relativePath,
@@ -12072,7 +12370,7 @@ function generateSnapshot(configInput, options) {
12072
12370
  continue;
12073
12371
  }
12074
12372
  try {
12075
- buffer = fs15__namespace.readFileSync(absolutePath);
12373
+ buffer = fs16__namespace.readFileSync(absolutePath);
12076
12374
  } catch (err) {
12077
12375
  const code = err.code;
12078
12376
  skipped.push({
@@ -12201,14 +12499,14 @@ function generateSnapshot(configInput, options) {
12201
12499
  (finding) => finding.path === void 0 || keep.has(finding.path)
12202
12500
  );
12203
12501
  retain(encodingNotes, (note) => keep.has(note.path));
12204
- retain(oversizeSummaryPaths, (path22) => keep.has(path22));
12205
- retain(previewSummaryPaths, (path22) => keep.has(path22));
12502
+ retain(oversizeSummaryPaths, (path23) => keep.has(path23));
12503
+ retain(previewSummaryPaths, (path23) => keep.has(path23));
12206
12504
  retain(fileWarnings, (warning) => keep.has(warning.path));
12207
- for (const path22 of [...monolithBodies.keys()]) {
12208
- if (!keep.has(path22)) monolithBodies.delete(path22);
12505
+ for (const path23 of [...monolithBodies.keys()]) {
12506
+ if (!keep.has(path23)) monolithBodies.delete(path23);
12209
12507
  }
12210
- for (const path22 of [...skippedSummaryImports.keys()]) {
12211
- if (!keep.has(path22)) skippedSummaryImports.delete(path22);
12508
+ for (const path23 of [...skippedSummaryImports.keys()]) {
12509
+ if (!keep.has(path23)) skippedSummaryImports.delete(path23);
12212
12510
  }
12213
12511
  }
12214
12512
  if (changedScope !== null) {
@@ -12347,6 +12645,8 @@ function generateSnapshot(configInput, options) {
12347
12645
  // omitted from `digest` when it is off so an existing snapshot does not start reporting
12348
12646
  // configuration drift.
12349
12647
  maxParts: config.maxParts ?? null,
12648
+ promptTask: config.promptTask,
12649
+ ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12350
12650
  discovery: config.discovery ?? "auto",
12351
12651
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12352
12652
  // describes the run has to name it.
@@ -12477,14 +12777,16 @@ function generateSnapshot(configInput, options) {
12477
12777
  if (auditText !== null) manifest.artifacts.audit = artifactRecord(auditText);
12478
12778
  const readmeText = artifacts.readme ? generateReadme(manifest, artifacts) : null;
12479
12779
  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;
12780
+ const promptText = artifacts.prompt ? generatePrompt(manifest, artifacts, {
12781
+ slots: config.attachmentSlots,
12782
+ task: config.promptTask,
12783
+ brief: maskOwnerBrief(config.brief, config.secretRules),
12784
+ history: recentCommits(config.cwd).map((commit) => ({
12785
+ subject: maskPathText(commit.subject, config.secretRules),
12786
+ body: maskPathText(commit.body, config.secretRules)
12787
+ })),
12788
+ overview: maskOverview(readProjectOverview(config.cwd), config.secretRules)
12789
+ }) : null;
12488
12790
  if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
12489
12791
  if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
12490
12792
  let monolithJson = null;
@@ -12560,12 +12862,12 @@ function generateSnapshot(configInput, options) {
12560
12862
  let releaseDeferred = false;
12561
12863
  try {
12562
12864
  ensureParentDirectory(outDir, "outDir");
12563
- fs15__namespace.mkdirSync(tmpDir, { recursive: true });
12865
+ fs16__namespace.mkdirSync(tmpDir, { recursive: true });
12564
12866
  cleanStaleRunDirs(tmpDir);
12565
12867
  const snapshotId = crypto3__namespace.randomUUID();
12566
12868
  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);
12869
+ stagingDir = path17__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12870
+ fs16__namespace.mkdirSync(stagingDir);
12569
12871
  writeOwnershipMarker(stagingDir, {
12570
12872
  generator: GENERATOR_NAME,
12571
12873
  version: GENERATOR_VERSION,
@@ -12575,30 +12877,30 @@ function generateSnapshot(configInput, options) {
12575
12877
  id: snapshotId,
12576
12878
  pid: process.pid
12577
12879
  });
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 });
12880
+ const partsDir = path17__namespace.join(stagingDir, "parts");
12881
+ const reportsDir = path17__namespace.join(stagingDir, "reports");
12882
+ if (artifacts.parts) fs16__namespace.mkdirSync(partsDir, { recursive: true });
12581
12883
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || config.sarif === true) {
12582
- fs15__namespace.mkdirSync(reportsDir, { recursive: true });
12884
+ fs16__namespace.mkdirSync(reportsDir, { recursive: true });
12583
12885
  }
12584
12886
  const writtenArtifacts = /* @__PURE__ */ new Map();
12585
12887
  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);
12888
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12889
+ fs16__namespace.writeFileSync(full, data, "utf8");
12890
+ const stats = fs16__namespace.statSync(full);
12589
12891
  writtenArtifacts.set(relativeEntry, {
12590
12892
  digest: { path: relativeEntry, bytes: stats.size, sha256: sha256Hex2(data) },
12591
12893
  mtimeMs: stats.mtimeMs
12592
12894
  });
12593
12895
  };
12594
12896
  const recordArtifact = (targetDir, relativeEntry) => {
12595
- const full = path16__namespace.join(targetDir, ...relativeEntry.split("/"));
12596
- const stats = fs15__namespace.statSync(full);
12897
+ const full = path17__namespace.join(targetDir, ...relativeEntry.split("/"));
12898
+ const stats = fs16__namespace.statSync(full);
12597
12899
  writtenArtifacts.set(relativeEntry, {
12598
12900
  digest: {
12599
12901
  path: relativeEntry,
12600
12902
  bytes: stats.size,
12601
- sha256: sha256Hex2(fs15__namespace.readFileSync(full))
12903
+ sha256: sha256Hex2(fs16__namespace.readFileSync(full))
12602
12904
  },
12603
12905
  mtimeMs: stats.mtimeMs
12604
12906
  });
@@ -12646,7 +12948,7 @@ function generateSnapshot(configInput, options) {
12646
12948
  const shipHookState = () => {
12647
12949
  if (!markerBelongsTo(outDir, snapshotId)) return;
12648
12950
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
12649
- writeManifestAtomically(path16__namespace.join(outDir, "manifest.json"), manifest);
12951
+ writeManifestAtomically(path17__namespace.join(outDir, "manifest.json"), manifest);
12650
12952
  recordArtifact(outDir, "manifest.json");
12651
12953
  }
12652
12954
  writeOwnershipMarker(
@@ -12689,7 +12991,7 @@ function generateSnapshot(configInput, options) {
12689
12991
  } catch (err) {
12690
12992
  if (stagingDir !== null) {
12691
12993
  try {
12692
- fs15__namespace.rmSync(stagingDir, { recursive: true, force: true });
12994
+ fs16__namespace.rmSync(stagingDir, { recursive: true, force: true });
12693
12995
  } catch {
12694
12996
  }
12695
12997
  }
@@ -12783,8 +13085,8 @@ function findSection(sections, relativePath) {
12783
13085
  if (exact) return exact;
12784
13086
  const foldedPath = rendered.toLowerCase();
12785
13087
  const folded = sections.filter((section) => {
12786
- const path22 = section.path.toLowerCase();
12787
- return path22 === relativePath.toLowerCase() || path22 === foldedPath;
13088
+ const path23 = section.path.toLowerCase();
13089
+ return path23 === relativePath.toLowerCase() || path23 === foldedPath;
12788
13090
  });
12789
13091
  return folded.length === 1 ? folded[0] : null;
12790
13092
  }
@@ -12810,9 +13112,9 @@ function foldForComparison(value) {
12810
13112
  return process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
12811
13113
  }
12812
13114
  function canonicalPath(value) {
12813
- const absolute = path16__namespace.resolve(value);
13115
+ const absolute = path17__namespace.resolve(value);
12814
13116
  try {
12815
- return fs15__namespace.realpathSync(absolute);
13117
+ return fs16__namespace.realpathSync(absolute);
12816
13118
  } catch {
12817
13119
  return absolute;
12818
13120
  }
@@ -12820,29 +13122,29 @@ function canonicalPath(value) {
12820
13122
  function isInside3(parent, child) {
12821
13123
  const foldedParent = foldForComparison(parent);
12822
13124
  const foldedChild = foldForComparison(child);
12823
- return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path16__namespace.sep}`);
13125
+ return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path17__namespace.sep}`);
12824
13126
  }
12825
13127
  function resolveThroughExistingAncestor(target) {
12826
13128
  let existing = target;
12827
13129
  const missing = [];
12828
- while (!fs15__namespace.existsSync(existing)) {
12829
- missing.unshift(path16__namespace.basename(existing));
12830
- const parent = path16__namespace.dirname(existing);
13130
+ while (!fs16__namespace.existsSync(existing)) {
13131
+ missing.unshift(path17__namespace.basename(existing));
13132
+ const parent = path17__namespace.dirname(existing);
12831
13133
  if (parent === existing) break;
12832
13134
  existing = parent;
12833
13135
  }
12834
13136
  const resolved = canonicalPath(existing);
12835
- return missing.length === 0 ? resolved : path16__namespace.join(resolved, ...missing);
13137
+ return missing.length === 0 ? resolved : path17__namespace.join(resolved, ...missing);
12836
13138
  }
12837
13139
  function resolveRoot(requested, context) {
12838
13140
  if (requested !== void 0 && (typeof requested !== "string" || requested.trim().length === 0)) {
12839
13141
  return { ok: false, message: '"root" must be a non-empty string when provided.' };
12840
13142
  }
12841
13143
  const wanted = typeof requested === "string" ? requested.trim() : context.cwd;
12842
- const absolute = path16__namespace.resolve(context.cwd, wanted);
13144
+ const absolute = path17__namespace.resolve(context.cwd, wanted);
12843
13145
  let stats;
12844
13146
  try {
12845
- stats = fs15__namespace.statSync(absolute);
13147
+ stats = fs16__namespace.statSync(absolute);
12846
13148
  } catch {
12847
13149
  return { ok: false, message: `"${wanted}" does not exist, so it cannot be a repository root.` };
12848
13150
  }
@@ -12894,7 +13196,7 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
12894
13196
  }
12895
13197
  const requested = overrides.outDir.trim();
12896
13198
  const permitted = allowedRoots !== void 0 && allowedRoots.length > 0 ? allowedRoots : [root];
12897
- const resolved = resolveThroughExistingAncestor(path16__namespace.resolve(root, requested));
13199
+ const resolved = resolveThroughExistingAncestor(path17__namespace.resolve(root, requested));
12898
13200
  if (!permitted.some((allowed) => isInside3(canonicalPath(allowed), resolved))) {
12899
13201
  const shown = permitted.map((allowed) => canonicalPath(allowed)).join(", ");
12900
13202
  return {
@@ -12927,25 +13229,25 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
12927
13229
  var MANIFEST_CACHE_LIMIT = 8;
12928
13230
  var manifestCache = /* @__PURE__ */ new Map();
12929
13231
  function manifestPathFor(workspace) {
12930
- return path16__namespace.resolve(workspace.root, workspace.config.outDir, "manifest.json");
13232
+ return path17__namespace.resolve(workspace.root, workspace.config.outDir, "manifest.json");
12931
13233
  }
12932
13234
  function partPathFor(workspace, filename) {
12933
13235
  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)) {
13236
+ const partsDir = path17__namespace.resolve(workspace.root, workspace.config.outDir, "parts");
13237
+ const resolved = path17__namespace.resolve(partsDir, filename);
13238
+ const relative15 = path17__namespace.relative(partsDir, resolved);
13239
+ if (relative15.length === 0 || relative15.includes(path17__namespace.sep) || relative15.includes("/") || relative15.includes("\\") || path17__namespace.isAbsolute(relative15)) {
12938
13240
  return null;
12939
13241
  }
12940
13242
  let stats;
12941
13243
  try {
12942
- stats = fs15__namespace.lstatSync(resolved);
13244
+ stats = fs16__namespace.lstatSync(resolved);
12943
13245
  } catch {
12944
13246
  return null;
12945
13247
  }
12946
13248
  if (!stats.isFile()) return null;
12947
13249
  try {
12948
- if (path16__namespace.dirname(fs15__namespace.realpathSync(resolved)) !== fs15__namespace.realpathSync(partsDir)) return null;
13250
+ if (path17__namespace.dirname(fs16__namespace.realpathSync(resolved)) !== fs16__namespace.realpathSync(partsDir)) return null;
12949
13251
  } catch {
12950
13252
  return null;
12951
13253
  }
@@ -12953,10 +13255,10 @@ function partPathFor(workspace, filename) {
12953
13255
  }
12954
13256
  function readManifest3(workspace) {
12955
13257
  const file = manifestPathFor(workspace);
12956
- const shown = path16__namespace.relative(workspace.root, file).split(path16__namespace.sep).join("/") || file;
13258
+ const shown = path17__namespace.relative(workspace.root, file).split(path17__namespace.sep).join("/") || file;
12957
13259
  let stats;
12958
13260
  try {
12959
- stats = fs15__namespace.statSync(file);
13261
+ stats = fs16__namespace.statSync(file);
12960
13262
  } catch {
12961
13263
  return {
12962
13264
  ok: false,
@@ -12970,7 +13272,7 @@ function readManifest3(workspace) {
12970
13272
  }
12971
13273
  let raw;
12972
13274
  try {
12973
- raw = fs15__namespace.readFileSync(file, "utf8");
13275
+ raw = fs16__namespace.readFileSync(file, "utf8");
12974
13276
  } catch (error) {
12975
13277
  return {
12976
13278
  ok: false,
@@ -13082,7 +13384,7 @@ function formatBytes(bytes) {
13082
13384
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
13083
13385
  }
13084
13386
  function relativeFor(workspace, absolute) {
13085
- return path16__namespace.relative(workspace.root, absolute).split(path16__namespace.sep).join("/");
13387
+ return path17__namespace.relative(workspace.root, absolute).split(path17__namespace.sep).join("/");
13086
13388
  }
13087
13389
  function capped(values, limit = 20) {
13088
13390
  return { count: values.length, sample: values.slice(0, limit) };
@@ -13101,13 +13403,13 @@ function summarizeDrift(drift) {
13101
13403
  function toRelativePath(root, value) {
13102
13404
  const cleaned = value.trim();
13103
13405
  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)) {
13406
+ const resolvedRoot = path17__namespace.resolve(root);
13407
+ const absolute = path17__namespace.resolve(resolvedRoot, cleaned);
13408
+ const relative15 = path17__namespace.relative(resolvedRoot, absolute);
13409
+ if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path17__namespace.sep}`) || path17__namespace.isAbsolute(relative15)) {
13108
13410
  return null;
13109
13411
  }
13110
- return relative15.split(path16__namespace.sep).join("/");
13412
+ return relative15.split(path17__namespace.sep).join("/");
13111
13413
  }
13112
13414
  function symbolsOf(entry) {
13113
13415
  const summary = entry.summary;
@@ -13337,7 +13639,7 @@ var generateTool = {
13337
13639
  if (!result.ok) return failure(result.message);
13338
13640
  const summary = result.summary;
13339
13641
  forgetManifest(manifestPathFor(workspace));
13340
- const written = relativeFor(workspace, path16__namespace.resolve(workspace.root, workspace.config.outDir));
13642
+ const written = relativeFor(workspace, path17__namespace.resolve(workspace.root, workspace.config.outDir));
13341
13643
  const lines = [
13342
13644
  `Wrote ${written}/`,
13343
13645
  `Files: ${summary.totalFiles} included, ${summary.skippedCount} skipped, ${plural(summary.partsCount, "part")}`,
@@ -13738,7 +14040,7 @@ var readTool = {
13738
14040
  }
13739
14041
  let partText;
13740
14042
  try {
13741
- partText = fs15__namespace.readFileSync(partPath, "utf8");
14043
+ partText = fs16__namespace.readFileSync(partPath, "utf8");
13742
14044
  } catch {
13743
14045
  return failure(
13744
14046
  `${entry.part} could not be read, so the snapshot is damaged. Run snapshot_generate to rebuild it.`
@@ -14043,6 +14345,8 @@ var VALIDATE_OPTIONS = [
14043
14345
  "large-file-bytes",
14044
14346
  "max-monolith-bytes",
14045
14347
  "max-parts",
14348
+ "brief",
14349
+ "prompt-task",
14046
14350
  "include-monolith",
14047
14351
  "include-sensitive-files",
14048
14352
  "skip-artifacts",
@@ -14070,6 +14374,8 @@ var COMMAND_OPTION_SCOPE = {
14070
14374
  "max-monolith-bytes",
14071
14375
  "attachment-slots",
14072
14376
  "max-parts",
14377
+ "brief",
14378
+ "prompt-task",
14073
14379
  "include-monolith",
14074
14380
  "include-sensitive-files",
14075
14381
  "skip-artifacts",
@@ -14512,6 +14818,20 @@ function buildAgentContract() {
14512
14818
  appliesTo: optionAppliesTo("attachment-slots"),
14513
14819
  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
14820
  },
14821
+ {
14822
+ flag: "--brief",
14823
+ type: "string",
14824
+ default: "unset",
14825
+ appliesTo: optionAppliesTo("brief"),
14826
+ 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."
14827
+ },
14828
+ {
14829
+ flag: "--prompt-task",
14830
+ type: "string",
14831
+ default: "audit",
14832
+ appliesTo: optionAppliesTo("prompt-task"),
14833
+ summary: "Which job the brief is written for: audit (default), review or explain. It changes the opening section, not the standard."
14834
+ },
14515
14835
  {
14516
14836
  flag: "--max-parts",
14517
14837
  type: "number",
@@ -14732,6 +15052,8 @@ function buildAgentContract() {
14732
15052
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
14733
15053
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
14734
15054
  { key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
15055
+ { 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." },
15056
+ { 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
15057
  { 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
15058
  { 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
15059
  { 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 +15321,17 @@ var LEGACY_AGENTS_MARKER = "<!-- codebase-snapshot:skill:start -->";
14999
15321
  function targetPath(cwd, target) {
15000
15322
  switch (target) {
15001
15323
  case "claude":
15002
- return path16__namespace.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15324
+ return path17__namespace.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15003
15325
  case "cursor":
15004
- return path16__namespace.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15326
+ return path17__namespace.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15005
15327
  }
15006
15328
  }
15007
15329
  function assertWritableInsideRepository(cwd, filePath) {
15008
- const root = fs15__namespace.realpathSync(cwd);
15009
- const shown = path16__namespace.relative(root, filePath) || filePath;
15330
+ const root = fs16__namespace.realpathSync(cwd);
15331
+ const shown = path17__namespace.relative(root, filePath) || filePath;
15010
15332
  let stat = null;
15011
15333
  try {
15012
- stat = fs15__namespace.lstatSync(filePath);
15334
+ stat = fs16__namespace.lstatSync(filePath);
15013
15335
  } catch {
15014
15336
  stat = null;
15015
15337
  }
@@ -15025,32 +15347,32 @@ function assertWritableInsideRepository(cwd, filePath) {
15025
15347
  }
15026
15348
  let existing = filePath;
15027
15349
  const missing = [];
15028
- while (!fs15__namespace.existsSync(existing)) {
15029
- missing.unshift(path16__namespace.basename(existing));
15030
- const parent = path16__namespace.dirname(existing);
15350
+ while (!fs16__namespace.existsSync(existing)) {
15351
+ missing.unshift(path17__namespace.basename(existing));
15352
+ const parent = path17__namespace.dirname(existing);
15031
15353
  if (parent === existing) break;
15032
15354
  existing = parent;
15033
15355
  }
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}`)) {
15356
+ const realAncestor = fs16__namespace.realpathSync(existing);
15357
+ const resolved = missing.length === 0 ? realAncestor : path17__namespace.join(realAncestor, ...missing);
15358
+ if (resolved !== root && !resolved.startsWith(`${root}${path17__namespace.sep}`)) {
15037
15359
  throw new Error(
15038
15360
  `${REFUSED}: ${shown} resolves outside the repository (${resolved}). Move it back inside ${root}, or remove the link, and run again.`
15039
15361
  );
15040
15362
  }
15041
15363
  }
15042
15364
  function writeIfChanged(target, filePath, content) {
15043
- const existing = fs15__namespace.existsSync(filePath) ? fs15__namespace.readFileSync(filePath, "utf8") : null;
15365
+ const existing = fs16__namespace.existsSync(filePath) ? fs16__namespace.readFileSync(filePath, "utf8") : null;
15044
15366
  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");
15367
+ fs16__namespace.mkdirSync(path17__namespace.dirname(filePath), { recursive: true });
15368
+ fs16__namespace.writeFileSync(filePath, content, "utf8");
15047
15369
  return { target, path: filePath, action: existing === null ? "created" : "updated" };
15048
15370
  }
15049
15371
  function legacyAgentsNote(cwd) {
15050
- const filePath = path16__namespace.join(cwd, "AGENTS.md");
15372
+ const filePath = path17__namespace.join(cwd, "AGENTS.md");
15051
15373
  try {
15052
- if (!fs15__namespace.existsSync(filePath)) return null;
15053
- if (!fs15__namespace.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15374
+ if (!fs16__namespace.existsSync(filePath)) return null;
15375
+ if (!fs16__namespace.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15054
15376
  } catch {
15055
15377
  return null;
15056
15378
  }
@@ -15062,9 +15384,9 @@ function installSkill(cwd, target = "all") {
15062
15384
  const notes = [];
15063
15385
  const wanted = target === "all" ? ["claude", "cursor"] : [target];
15064
15386
  for (const item of wanted) assertWritableInsideRepository(cwd, targetPath(cwd, item));
15065
- const createsSomething = wanted.some((item) => !fs15__namespace.existsSync(targetPath(cwd, item)));
15387
+ const createsSomething = wanted.some((item) => !fs16__namespace.existsSync(targetPath(cwd, item)));
15066
15388
  if (createsSomething) {
15067
- assertWritableInsideRepository(cwd, path16__namespace.join(cwd, ".gitignore"));
15389
+ assertWritableInsideRepository(cwd, path17__namespace.join(cwd, ".gitignore"));
15068
15390
  }
15069
15391
  for (const item of wanted) {
15070
15392
  written.push(writeIfChanged(item, targetPath(cwd, item), skill));
@@ -15225,7 +15547,7 @@ async function workspaceFor(context) {
15225
15547
  }
15226
15548
  function readFileIfPresent(file) {
15227
15549
  try {
15228
- return fs15__namespace.readFileSync(file, "utf8");
15550
+ return fs16__namespace.readFileSync(file, "utf8");
15229
15551
  } catch {
15230
15552
  return null;
15231
15553
  }
@@ -15321,7 +15643,7 @@ function buildResourceProvider() {
15321
15643
  const report = REPORT_URIS.get(uri);
15322
15644
  if (report) {
15323
15645
  const text2 = readFileIfPresent(
15324
- path16__namespace.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15646
+ path17__namespace.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15325
15647
  );
15326
15648
  if (text2 === null) return null;
15327
15649
  return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, REPORT_ADVICE) };
@@ -15343,7 +15665,7 @@ function buildResourceProvider() {
15343
15665
  if (partPath === null) return null;
15344
15666
  let partBytes;
15345
15667
  try {
15346
- partBytes = fs15__namespace.statSync(partPath).size;
15668
+ partBytes = fs16__namespace.statSync(partPath).size;
15347
15669
  } catch {
15348
15670
  return null;
15349
15671
  }
@@ -15379,52 +15701,52 @@ function validateArguments(schema, value) {
15379
15701
  }
15380
15702
  return problems;
15381
15703
  }
15382
- function checkValue(path22, schema, value) {
15704
+ function checkValue(path23, schema, value) {
15383
15705
  if (schema.enum && !schema.enum.includes(value)) {
15384
- return [`"${path22}" must be one of: ${schema.enum.join(", ")}`];
15706
+ return [`"${path23}" must be one of: ${schema.enum.join(", ")}`];
15385
15707
  }
15386
15708
  switch (schema.type) {
15387
15709
  case "string": {
15388
- if (typeof value !== "string") return [`"${path22}" must be a string`];
15710
+ if (typeof value !== "string") return [`"${path23}" must be a string`];
15389
15711
  const problems = [];
15390
15712
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
15391
- problems.push(`"${path22}" must be at least ${schema.minLength} character(s)`);
15713
+ problems.push(`"${path23}" must be at least ${schema.minLength} character(s)`);
15392
15714
  }
15393
15715
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
15394
- problems.push(`"${path22}" must be at most ${schema.maxLength} character(s)`);
15716
+ problems.push(`"${path23}" must be at most ${schema.maxLength} character(s)`);
15395
15717
  }
15396
15718
  return problems;
15397
15719
  }
15398
15720
  case "number":
15399
15721
  case "integer": {
15400
15722
  if (typeof value !== "number" || Number.isNaN(value)) {
15401
- return [`"${path22}" must be a number`];
15723
+ return [`"${path23}" must be a number`];
15402
15724
  }
15403
15725
  if (schema.type === "integer" && !Number.isInteger(value)) {
15404
- return [`"${path22}" must be an integer`];
15726
+ return [`"${path23}" must be an integer`];
15405
15727
  }
15406
15728
  const problems = [];
15407
15729
  if (schema.minimum !== void 0 && value < schema.minimum) {
15408
- problems.push(`"${path22}" must be >= ${schema.minimum}`);
15730
+ problems.push(`"${path23}" must be >= ${schema.minimum}`);
15409
15731
  }
15410
15732
  if (schema.maximum !== void 0 && value > schema.maximum) {
15411
- problems.push(`"${path22}" must be <= ${schema.maximum}`);
15733
+ problems.push(`"${path23}" must be <= ${schema.maximum}`);
15412
15734
  }
15413
15735
  return problems;
15414
15736
  }
15415
15737
  case "boolean":
15416
- return typeof value === "boolean" ? [] : [`"${path22}" must be a boolean`];
15738
+ return typeof value === "boolean" ? [] : [`"${path23}" must be a boolean`];
15417
15739
  case "array": {
15418
- if (!Array.isArray(value)) return [`"${path22}" must be an array`];
15740
+ if (!Array.isArray(value)) return [`"${path23}" must be an array`];
15419
15741
  if (!schema.items) return [];
15420
15742
  const problems = [];
15421
15743
  value.forEach((item, index) => {
15422
- problems.push(...checkValue(`${path22}[${index}]`, schema.items, item));
15744
+ problems.push(...checkValue(`${path23}[${index}]`, schema.items, item));
15423
15745
  });
15424
15746
  return problems;
15425
15747
  }
15426
15748
  case "object":
15427
- return isJsonObject(value) ? [] : [`"${path22}" must be an object`];
15749
+ return isJsonObject(value) ? [] : [`"${path23}" must be an object`];
15428
15750
  default:
15429
15751
  return [];
15430
15752
  }
@@ -16000,6 +16322,8 @@ var CLI_OPTIONS = {
16000
16322
  "max-monolith-bytes": { type: "string" },
16001
16323
  "attachment-slots": { type: "string" },
16002
16324
  "max-parts": { type: "string" },
16325
+ brief: { type: "string" },
16326
+ "prompt-task": { type: "string" },
16003
16327
  "include-monolith": { type: "boolean" },
16004
16328
  "include-sensitive-files": { type: "boolean" },
16005
16329
  "skip-artifacts": { type: "string" },
@@ -16078,6 +16402,9 @@ Options:
16078
16402
  0 = no limit); PROMPT.md plans the delivery to fit
16079
16403
  --max-parts <n> Experimental: grow the part budget until the snapshot has at
16080
16404
  most n parts, instead of adding parts as the code grows
16405
+ --brief <path> Owner-written half of PROMPT.md (stakes, system, history,
16406
+ bar, calibration); merged at fixed slots
16407
+ --prompt-task <task> audit | review | explain - which job the brief is for
16081
16408
  --skip-artifacts <names> Comma-separated artifacts to omit
16082
16409
  (readme, manifest, parts, navigation,
16083
16410
  projectTree, audit, monolith)
@@ -16162,6 +16489,13 @@ function parseCountOption(raw, optionName, minimum = 0) {
16162
16489
  }
16163
16490
  return value;
16164
16491
  }
16492
+ function parsePromptTask(value) {
16493
+ if (value === void 0) return void 0;
16494
+ if (value === "audit" || value === "review" || value === "explain") return value;
16495
+ throw new UsageError(
16496
+ '--prompt-task expects audit, review or explain, received "' + value + '".'
16497
+ );
16498
+ }
16165
16499
  function parseArtifactList(raw, flag) {
16166
16500
  const names = raw.split(",").map((name) => name.trim()).filter(Boolean);
16167
16501
  if (names.length === 0) {
@@ -16226,10 +16560,10 @@ function parseCliArgs(argv) {
16226
16560
  }
16227
16561
  if (values.cwd !== void 0) {
16228
16562
  const target = String(values.cwd);
16229
- if (!fs15__namespace.existsSync(target)) {
16563
+ if (!fs16__namespace.existsSync(target)) {
16230
16564
  throw new UsageError(`--cwd directory does not exist: ${target}`);
16231
16565
  }
16232
- if (!fs15__namespace.statSync(target).isDirectory()) {
16566
+ if (!fs16__namespace.statSync(target).isDirectory()) {
16233
16567
  throw new UsageError(`--cwd is not a directory: ${target}`);
16234
16568
  }
16235
16569
  }
@@ -16375,7 +16709,7 @@ function parseCliArgs(argv) {
16375
16709
  install: values.install === true,
16376
16710
  noInstall: values["no-install"] === true,
16377
16711
  target: values.target === void 0 ? void 0 : String(values.target),
16378
- cwd: values.cwd === void 0 ? process.cwd() : path16__namespace.resolve(String(values.cwd)),
16712
+ cwd: values.cwd === void 0 ? process.cwd() : path17__namespace.resolve(String(values.cwd)),
16379
16713
  outDir: values["out-dir"] === void 0 ? void 0 : String(values["out-dir"]),
16380
16714
  includeMonolith: values["include-monolith"] === true || onlyNamesMonolith === true ? true : void 0,
16381
16715
  includeSensitiveFiles: values["include-sensitive-files"] === true ? true : void 0,
@@ -16408,6 +16742,8 @@ function parseCliArgs(argv) {
16408
16742
  "attachment-slots"
16409
16743
  ),
16410
16744
  maxParts: parseCountOption(values["max-parts"], "max-parts", 1),
16745
+ brief: values.brief === void 0 ? void 0 : String(values.brief),
16746
+ promptTask: parsePromptTask(values["prompt-task"]),
16411
16747
  skipArtifacts,
16412
16748
  onlyArtifacts,
16413
16749
  discovery: isDiscoveryMode(rawDiscovery) ? rawDiscovery : void 0,
@@ -16461,9 +16797,9 @@ function splitList(value) {
16461
16797
  return value.split(",").map((entry) => entry.trim()).filter(Boolean);
16462
16798
  }
16463
16799
  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;
16800
+ const absolute = path17__namespace.resolve(cwd, outDir, ...segments);
16801
+ const relative15 = path17__namespace.relative(cwd, absolute);
16802
+ if (relative15 && !relative15.startsWith("..") && !path17__namespace.isAbsolute(relative15)) return relative15;
16467
16803
  return absolute;
16468
16804
  }
16469
16805
  function nextStepHint(cwd, scriptsAddedNow) {
@@ -16471,7 +16807,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
16471
16807
  if (!hasScript) {
16472
16808
  try {
16473
16809
  const parsed = JSON.parse(
16474
- stripJsonComments(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"))
16810
+ stripJsonComments(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"))
16475
16811
  );
16476
16812
  hasScript = typeof parsed.scripts?.snapshot === "string";
16477
16813
  } catch {
@@ -16479,8 +16815,8 @@ function nextStepHint(cwd, scriptsAddedNow) {
16479
16815
  }
16480
16816
  }
16481
16817
  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`);
16818
+ const bin = path17__namespace.join(cwd, "node_modules", ".bin", "codebase-snapshot");
16819
+ const installed = fs16__namespace.existsSync(bin) || fs16__namespace.existsSync(`${bin}.cmd`);
16484
16820
  return installed ? "npm run snapshot" : "npm install && npm run snapshot";
16485
16821
  }
16486
16822
  function presetSummary(init) {
@@ -16516,7 +16852,7 @@ async function runInitCommand(invocation) {
16516
16852
  if (hook) for (const note of hook.notes) info(` ${note}`);
16517
16853
  return 0;
16518
16854
  }
16519
- info(`\u2705 Created ${path16__namespace.basename(result.configPath)} (${presetSummary(result)})`);
16855
+ info(`\u2705 Created ${path17__namespace.basename(result.configPath)} (${presetSummary(result)})`);
16520
16856
  if (result.scripts.length > 0) info(` Added npm scripts: ${result.scripts.join(", ")}`);
16521
16857
  if (result.dependency.added && result.dependency.range !== null) {
16522
16858
  info(` Added devDependency: ${result.dependency.name} ${result.dependency.range}`);
@@ -16539,18 +16875,18 @@ async function runInitCommand(invocation) {
16539
16875
  function generatorOrigin(cwd) {
16540
16876
  try {
16541
16877
  const pkg = JSON.parse(
16542
- stripJsonComments(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"))
16878
+ stripJsonComments(fs16__namespace.readFileSync(path17__namespace.join(cwd, "package.json"), "utf8"))
16543
16879
  );
16544
16880
  const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
16545
16881
  if (typeof spec === "string") return `project dependency ${spec}`;
16546
16882
  } catch {
16547
16883
  }
16548
16884
  const entry = process.argv[1] ?? "";
16549
- if (entry.includes("_npx") || entry.includes(`${path16__namespace.sep}npx${path16__namespace.sep}`)) return "via npx";
16885
+ if (entry.includes("_npx") || entry.includes(`${path17__namespace.sep}npx${path17__namespace.sep}`)) return "via npx";
16550
16886
  return "global or direct install";
16551
16887
  }
16552
16888
  function detectPackageManager(cwd) {
16553
- const has = (name) => fs15__namespace.existsSync(path16__namespace.join(cwd, name));
16889
+ const has = (name) => fs16__namespace.existsSync(path17__namespace.join(cwd, name));
16554
16890
  if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
16555
16891
  if (has("pnpm-lock.yaml")) return { name: "pnpm", command: "pnpm", args: ["install"] };
16556
16892
  if (has("yarn.lock")) return { name: "yarn", command: "yarn", args: ["install"] };
@@ -16667,7 +17003,7 @@ async function runSetupCommand(invocation, options = {}) {
16667
17003
  }
16668
17004
  info("\n\u{1F9EA} Dry run \u2014 setup would:");
16669
17005
  info(
16670
- ` 1. ${init.reused ? `keep ${path16__namespace.basename(keptConfigPath)}` : `write ${path16__namespace.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
17006
+ ` 1. ${init.reused ? `keep ${path17__namespace.basename(keptConfigPath)}` : `write ${path17__namespace.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
16671
17007
  );
16672
17008
  info(" 2. add the npm scripts, the devDependency and the .gitignore entries");
16673
17009
  if (manager !== null) info(` 3. install with ${manager}`);
@@ -16680,9 +17016,9 @@ async function runSetupCommand(invocation, options = {}) {
16680
17016
  if (invocation.format !== "json") {
16681
17017
  if (!interactive) info(`\u{1F680} Setup for: ${invocation.cwd}`);
16682
17018
  if (init.reused) {
16683
- info(`\u267B Keeping ${path16__namespace.basename(keptConfigPath)}`);
17019
+ info(`\u267B Keeping ${path17__namespace.basename(keptConfigPath)}`);
16684
17020
  } else {
16685
- info(`\u2705 Created ${path16__namespace.basename(keptConfigPath)} (${presetSummary(init)})`);
17021
+ info(`\u2705 Created ${path17__namespace.basename(keptConfigPath)} (${presetSummary(init)})`);
16686
17022
  }
16687
17023
  if (init.scripts.length > 0) info(` Added npm scripts: ${init.scripts.join(", ")}`);
16688
17024
  if (init.dependency.added && init.dependency.range !== null) {
@@ -16696,7 +17032,7 @@ async function runSetupCommand(invocation, options = {}) {
16696
17032
  info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
16697
17033
  }
16698
17034
  }
16699
- const hasManifest = fs15__namespace.existsSync(path16__namespace.join(invocation.cwd, "package.json"));
17035
+ const hasManifest = fs16__namespace.existsSync(path17__namespace.join(invocation.cwd, "package.json"));
16700
17036
  let install = null;
16701
17037
  if (invocation.noInstall) {
16702
17038
  if (invocation.format !== "json") info(" Skipped the install (--no-install)");
@@ -16739,6 +17075,10 @@ async function runSetupCommand(invocation, options = {}) {
16739
17075
  if (invocation.maxParts !== void 0) {
16740
17076
  generateArgs.push("--max-parts", String(invocation.maxParts));
16741
17077
  }
17078
+ if (invocation.brief !== void 0) generateArgs.push("--brief", invocation.brief);
17079
+ if (invocation.promptTask !== void 0) {
17080
+ generateArgs.push("--prompt-task", invocation.promptTask);
17081
+ }
16742
17082
  if (invocation.skeleton === true) generateArgs.push("--skeleton");
16743
17083
  if (invocation.sarif === true) generateArgs.push("--sarif");
16744
17084
  if (invocation.noUpdateCheck) generateArgs.push("--no-update-check");
@@ -16824,7 +17164,7 @@ function runSkillCommand(invocation) {
16824
17164
  }
16825
17165
  info(`\u2705 Agent skill installed (${SKILL_NAME}):`);
16826
17166
  for (const item of result.written) {
16827
- const shown = path16__namespace.relative(invocation.cwd, item.path) || item.path;
17167
+ const shown = path17__namespace.relative(invocation.cwd, item.path) || item.path;
16828
17168
  info(` - ${item.action.padEnd(9)} ${shown}`);
16829
17169
  }
16830
17170
  if (result.gitignored.length > 0) {
@@ -16945,7 +17285,7 @@ ${USAGE}
16945
17285
  return runSkillCommand(invocation);
16946
17286
  }
16947
17287
  if (invocation.command === "mcp") {
16948
- return await runStdioServer({ cwd: path16__namespace.resolve(invocation.cwd) });
17288
+ return await runStdioServer({ cwd: path17__namespace.resolve(invocation.cwd) });
16949
17289
  }
16950
17290
  if (invocation.command === "setup") {
16951
17291
  return runSetupCommand(invocation);
@@ -16964,7 +17304,7 @@ ${USAGE}
16964
17304
  );
16965
17305
  }
16966
17306
  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}`);
17307
+ if (loaded.file) info(`\u2699 Using config ${path17__namespace.relative(process.cwd(), loaded.file) || loaded.file}`);
16968
17308
  let resolved;
16969
17309
  try {
16970
17310
  resolved = resolveConfig(
@@ -16983,6 +17323,8 @@ ${USAGE}
16983
17323
  maxMonolithBytes: invocation.maxMonolithBytes,
16984
17324
  attachmentSlots: invocation.attachmentSlots,
16985
17325
  maxParts: invocation.maxParts,
17326
+ brief: invocation.brief,
17327
+ promptTask: invocation.promptTask,
16986
17328
  skipArtifacts: invocation.skipArtifacts,
16987
17329
  // `--only-artifacts` is forwarded as itself, not only as the derived suppression list:
16988
17330
  // suppression cannot switch an artifact *on*, so a config that had turned one of the
@@ -17006,13 +17348,13 @@ ${USAGE}
17006
17348
  return result.valid ? 0 : 1;
17007
17349
  }
17008
17350
  if (invocation.command === "report") {
17009
- const manifestPath = path16__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17010
- if (!fs15__namespace.existsSync(manifestPath)) {
17351
+ const manifestPath = path17__namespace.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17352
+ if (!fs16__namespace.existsSync(manifestPath)) {
17011
17353
  return fail(invocation.format, `Manifest not found at ${manifestPath}. Run generate first.`);
17012
17354
  }
17013
17355
  let manifest;
17014
17356
  try {
17015
- manifest = JSON.parse(fs15__namespace.readFileSync(manifestPath, "utf8"));
17357
+ manifest = JSON.parse(fs16__namespace.readFileSync(manifestPath, "utf8"));
17016
17358
  } catch (err) {
17017
17359
  return fail(invocation.format, `Could not read ${manifestPath}: ${err.message}`);
17018
17360
  }
@@ -17216,19 +17558,19 @@ function finishWatchRun(state, now) {
17216
17558
  };
17217
17559
  }
17218
17560
  function comparablePath(value) {
17219
- const absolute = path16__namespace.resolve(value);
17561
+ const absolute = path17__namespace.resolve(value);
17220
17562
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
17221
17563
  }
17222
17564
  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);
17565
+ const relative15 = path17__namespace.relative(parent, candidate);
17566
+ return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path17__namespace.sep}`) && !path17__namespace.isAbsolute(relative15);
17225
17567
  }
17226
17568
  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));
17569
+ const absolute = comparablePath(path17__namespace.resolve(paths.cwd, candidate));
17570
+ const outDir = comparablePath(path17__namespace.resolve(paths.cwd, paths.outDir));
17571
+ const tmpDir = comparablePath(path17__namespace.resolve(paths.cwd, paths.tmpDir));
17230
17572
  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);
17573
+ const offsets = [path17__namespace.basename(outDir), path17__namespace.basename(tmpDir)].filter((name) => name.length > 0);
17232
17574
  const leftover = absolute.split(/[\\/]+/).some(
17233
17575
  (segment) => offsets.some(
17234
17576
  (name) => segment.startsWith(`${name}.backup-`) || segment.startsWith(`${name}.partial-`)
@@ -17251,8 +17593,8 @@ function decideWatchEvent(state, event, paths) {
17251
17593
  function watchPathsFor(config) {
17252
17594
  return {
17253
17595
  cwd: config.cwd,
17254
- outDir: path16__namespace.resolve(config.cwd, config.outDir),
17255
- tmpDir: path16__namespace.resolve(config.cwd, config.tmpDir)
17596
+ outDir: path17__namespace.resolve(config.cwd, config.outDir),
17597
+ tmpDir: path17__namespace.resolve(config.cwd, config.tmpDir)
17256
17598
  };
17257
17599
  }
17258
17600
  function watchSupportProblem(platform = process.platform, version = process.versions.node) {
@@ -17310,6 +17652,8 @@ async function runWatchLoop(invocation, resolved, options) {
17310
17652
  maxMonolithBytes: invocation.maxMonolithBytes,
17311
17653
  attachmentSlots: invocation.attachmentSlots,
17312
17654
  maxParts: invocation.maxParts,
17655
+ brief: invocation.brief,
17656
+ promptTask: invocation.promptTask,
17313
17657
  skipArtifacts: invocation.skipArtifacts,
17314
17658
  onlyArtifacts: invocation.onlyArtifacts,
17315
17659
  discovery: invocation.discovery,
@@ -17338,11 +17682,11 @@ async function runWatchLoop(invocation, resolved, options) {
17338
17682
  info("\u{1F440} Watching for changes. Press Ctrl+C to stop.");
17339
17683
  let watcher;
17340
17684
  try {
17341
- watcher = fs15__namespace.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17685
+ watcher = fs16__namespace.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17342
17686
  const decision = decideWatchEvent(
17343
17687
  state,
17344
17688
  {
17345
- path: filename ? path16__namespace.resolve(resolved.cwd, filename.toString()) : null,
17689
+ path: filename ? path17__namespace.resolve(resolved.cwd, filename.toString()) : null,
17346
17690
  now: performance.now()
17347
17691
  },
17348
17692
  paths
@@ -17381,7 +17725,7 @@ async function runWatchLoop(invocation, resolved, options) {
17381
17725
  return 0;
17382
17726
  }
17383
17727
  var entryFile = process.argv[1] ?? "";
17384
- var entryName = path16__namespace.basename(entryFile).toLowerCase();
17728
+ var entryName = path17__namespace.basename(entryFile).toLowerCase();
17385
17729
  var invokedDirectly = entryName === "cli.js" || entryName === "cli.cjs";
17386
17730
  if (invokedDirectly) {
17387
17731
  void main().then(