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/bin.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  // src/cli.ts
4
4
  import { spawnSync } from "child_process";
5
- import * as fs20 from "fs";
6
- import * as path21 from "path";
5
+ import * as fs21 from "fs";
6
+ import * as path22 from "path";
7
7
  import { parseArgs } from "util";
8
8
 
9
9
  // src/diff.ts
@@ -2191,7 +2191,7 @@ function applySpansKeepingQuotes(line, spans) {
2191
2191
 
2192
2192
  // src/version.ts
2193
2193
  var GENERATOR_NAME = "codebase-snapshot";
2194
- var GENERATOR_VERSION = "0.11.0";
2194
+ var GENERATOR_VERSION = "0.12.0";
2195
2195
  var SCHEMA_VERSION = "3.0.0";
2196
2196
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2197
2197
  function isOurGeneratorName(name) {
@@ -2639,11 +2639,14 @@ function defaultIgnoreReason(relativePath, toolDirNames = DEFAULT_TOOL_DIR_NAMES
2639
2639
  }
2640
2640
  return null;
2641
2641
  }
2642
- function recentCommitSubjects(cwd, limit = 10) {
2642
+ var COMMIT_BODY_LIMIT = 400;
2643
+ function recentCommits(cwd, limit = 10) {
2643
2644
  try {
2644
2645
  const stdout = childProcess.execFileSync(
2645
2646
  "git",
2646
- ["log", "-n", String(limit), "--pretty=%s", "--no-color"],
2647
+ // \x1f between fields and \x1e between records: neither can appear in a commit message, so
2648
+ // the parse cannot be confused by a message that contains a newline or a dash.
2649
+ ["log", "-n", String(limit), "--pretty=format:%s%x1f%b%x1e", "--no-color"],
2647
2650
  {
2648
2651
  cwd,
2649
2652
  stdio: ["ignore", "pipe", "ignore"],
@@ -2651,7 +2654,16 @@ function recentCommitSubjects(cwd, limit = 10) {
2651
2654
  maxBuffer: GIT_OUTPUT_LIMIT
2652
2655
  }
2653
2656
  );
2654
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
2657
+ return stdout.split("").map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
2658
+ const separator = record.indexOf("");
2659
+ const subject = separator === -1 ? record : record.slice(0, separator);
2660
+ const rawBody = separator === -1 ? "" : record.slice(separator + 1);
2661
+ const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ");
2662
+ return {
2663
+ subject: subject.trim(),
2664
+ body: body.length > COMMIT_BODY_LIMIT ? body.slice(0, COMMIT_BODY_LIMIT - 1) + "\u2026" : body
2665
+ };
2666
+ }).filter((commit) => commit.subject.length > 0);
2655
2667
  } catch {
2656
2668
  return [];
2657
2669
  }
@@ -3099,7 +3111,7 @@ import * as path6 from "path";
3099
3111
 
3100
3112
  // src/config.ts
3101
3113
  import * as fs3 from "fs";
3102
- import { createHash } from "crypto";
3114
+ import { createHash as createHash2 } from "crypto";
3103
3115
  import { createRequire } from "module";
3104
3116
  import * as path3 from "path";
3105
3117
  import { pathToFileURL } from "url";
@@ -3276,6 +3288,80 @@ function summarizeMarkdown(content) {
3276
3288
  };
3277
3289
  }
3278
3290
 
3291
+ // src/generator/brief.ts
3292
+ import { createHash } from "crypto";
3293
+ var OWNER_SECTIONS = ["Stakes", "The system", "What came before", "The bar", "Calibration"];
3294
+ var RESERVED_SECTIONS = [
3295
+ "The job",
3296
+ "What you have",
3297
+ "Coverage",
3298
+ "What a useful answer contains",
3299
+ "This snapshot",
3300
+ "Attaching this",
3301
+ "Your task"
3302
+ ];
3303
+ function parseOwnerBrief(filePath, text2) {
3304
+ const problems = [];
3305
+ const source = text2.replace(/^\uFEFF/, "");
3306
+ const preamble = [];
3307
+ const sections = [];
3308
+ let current = null;
3309
+ for (const line of source.split(/\r?\n/)) {
3310
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
3311
+ if (heading) {
3312
+ current = { heading: heading[1], body: [] };
3313
+ sections.push(current);
3314
+ continue;
3315
+ }
3316
+ if (current) current.body.push(line);
3317
+ else preamble.push(line);
3318
+ }
3319
+ const recognised = {};
3320
+ const notes = [];
3321
+ const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
3322
+ const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
3323
+ const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
3324
+ const seen = /* @__PURE__ */ new Set();
3325
+ for (const section of sections) {
3326
+ const body = section.body.join("\n").trim();
3327
+ const key = canonical(section.heading);
3328
+ if (seen.has(key)) {
3329
+ problems.push(
3330
+ `the brief defines "${section.heading}" twice; a section cannot say two things.`
3331
+ );
3332
+ continue;
3333
+ }
3334
+ seen.add(key);
3335
+ if (canonicalReserved.has(key)) {
3336
+ problems.push(
3337
+ `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.`
3338
+ );
3339
+ continue;
3340
+ }
3341
+ const ownerName = canonicalOwner.get(key);
3342
+ if (ownerName !== void 0) {
3343
+ recognised[ownerName] = body;
3344
+ continue;
3345
+ }
3346
+ notes.push({ heading: section.heading, body });
3347
+ }
3348
+ const preambleText = preamble.join("\n").trim();
3349
+ return {
3350
+ brief: {
3351
+ path: filePath,
3352
+ digest: createHash("sha256").update(text2, "utf8").digest("hex"),
3353
+ ...recognised["Stakes"] ? { stakes: recognised["Stakes"] } : {},
3354
+ ...recognised["The system"] ? { system: recognised["The system"] } : {},
3355
+ ...recognised["What came before"] ? { history: recognised["What came before"] } : {},
3356
+ ...recognised["The bar"] ? { bar: recognised["The bar"] } : {},
3357
+ ...recognised["Calibration"] ? { calibration: recognised["Calibration"] } : {},
3358
+ notes,
3359
+ ...preambleText.length > 0 ? { preamble: preambleText } : {}
3360
+ },
3361
+ problems
3362
+ };
3363
+ }
3364
+
3279
3365
  // src/tokenize.ts
3280
3366
  var WORD_RUN = /[A-Za-z0-9_]+/g;
3281
3367
  var SINGLE_TOKEN = /[^\sA-Za-z0-9_]/g;
@@ -3390,6 +3476,8 @@ function normalizeResolvedConfig(config) {
3390
3476
  // is re-validated because the number reaches a rendered artifact.
3391
3477
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3392
3478
  maxParts: resolveMaxParts(config.maxParts),
3479
+ promptTask: resolvePromptTask(config.promptTask),
3480
+ ...config.brief === void 0 ? {} : { brief: config.brief },
3393
3481
  includeMonolith: artifacts.monolith,
3394
3482
  secretRules: compileSecretRules(config.secretRules),
3395
3483
  artifacts,
@@ -3460,6 +3548,7 @@ var CONFIG_KEY_NAMES = [
3460
3548
  "artifacts",
3461
3549
  "attachmentSlots",
3462
3550
  "branch",
3551
+ "brief",
3463
3552
  "budgets",
3464
3553
  "changedSince",
3465
3554
  "cwd",
@@ -3481,6 +3570,7 @@ var CONFIG_KEY_NAMES = [
3481
3570
  "outDir",
3482
3571
  "preset",
3483
3572
  "previewHeadLines",
3573
+ "promptTask",
3484
3574
  "staged",
3485
3575
  "previewTailLines",
3486
3576
  "secretRules",
@@ -3531,7 +3621,7 @@ function readConfigExport(exported, file) {
3531
3621
  var lastModuleConfig = null;
3532
3622
  function moduleConfigKey(fullPath) {
3533
3623
  try {
3534
- return createHash("sha256").update(fs3.readFileSync(fullPath)).digest("hex").slice(0, 24);
3624
+ return createHash2("sha256").update(fs3.readFileSync(fullPath)).digest("hex").slice(0, 24);
3535
3625
  } catch {
3536
3626
  try {
3537
3627
  const stats = fs3.statSync(fullPath);
@@ -3765,6 +3855,38 @@ function resolveMaxParts(value) {
3765
3855
  }
3766
3856
  return value;
3767
3857
  }
3858
+ function resolvePromptTask(value) {
3859
+ if (value === void 0 || value === null) return "audit";
3860
+ if (value === "audit" || value === "review" || value === "explain") return value;
3861
+ throw new Error(
3862
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
3863
+ );
3864
+ }
3865
+ function readConfiguredBrief(cwd, value) {
3866
+ if (value === void 0 || value === null) return void 0;
3867
+ if (typeof value !== "string" || value.trim().length === 0) {
3868
+ throw new Error(
3869
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
3870
+ );
3871
+ }
3872
+ const filePath = path3.resolve(cwd, value);
3873
+ let text2;
3874
+ try {
3875
+ if (!fs3.statSync(filePath).isFile()) throw new Error("not a file");
3876
+ text2 = fs3.readFileSync(filePath, "utf8");
3877
+ } catch {
3878
+ throw new Error(
3879
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
3880
+ );
3881
+ }
3882
+ const parsed = parseOwnerBrief(value, text2);
3883
+ if (parsed.problems.length > 0) {
3884
+ throw new Error(
3885
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
3886
+ );
3887
+ }
3888
+ return parsed.brief;
3889
+ }
3768
3890
  function strictPositiveInteger(value, fallback, label) {
3769
3891
  if (value === void 0) return fallback;
3770
3892
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -4124,6 +4246,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4124
4246
  configuredSensitiveFiles,
4125
4247
  "`includeSensitiveFiles`"
4126
4248
  );
4249
+ const configuredBrief = readConfiguredBrief(
4250
+ cwd,
4251
+ cliOptions?.brief ?? userConfig?.brief
4252
+ );
4127
4253
  const presetExclude = [
4128
4254
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
4129
4255
  ];
@@ -4147,6 +4273,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4147
4273
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4148
4274
  ),
4149
4275
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4276
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
4277
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
4150
4278
  ...changedSince === void 0 ? {} : { changedSince },
4151
4279
  ...staged ? { staged } : {},
4152
4280
  ...withDependents ? { withDependents } : {},
@@ -4232,6 +4360,12 @@ function configDigest(config) {
4232
4360
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4233
4361
  // material would change the digest of every snapshot taken before the setting existed.
4234
4362
  ...config.maxParts === null ? {} : { maxParts: config.maxParts },
4363
+ // The default value is omitted for the same reason: a snapshot taken before the setting
4364
+ // existed kept the audit job, so it must keep the digest it was written with.
4365
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
4366
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
4367
+ // reader to do, so a changed brief is drift exactly like a changed budget.
4368
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
4235
4369
  artifacts: config.artifacts,
4236
4370
  include: config.include,
4237
4371
  excludePatterns: config.excludePatterns,
@@ -4270,7 +4404,7 @@ function configDigest(config) {
4270
4404
  (rule) => `${rule.rule}:${rule.pattern.source}/${rule.pattern.flags}:${rule.valueGroup ?? ""}`
4271
4405
  ).sort()
4272
4406
  };
4273
- return createHash("sha256").update(JSON.stringify(material)).digest("hex");
4407
+ return createHash2("sha256").update(JSON.stringify(material)).digest("hex");
4274
4408
  }
4275
4409
 
4276
4410
  // src/scanner/changed.ts
@@ -4318,7 +4452,7 @@ function resolveChangedScope(cwd, request) {
4318
4452
  const descriptions = [];
4319
4453
  if (request.changedSince !== void 0) {
4320
4454
  assertUsableRef(request.changedSince);
4321
- for (const path22 of gitPaths(cwd, [
4455
+ for (const path23 of gitPaths(cwd, [
4322
4456
  "diff",
4323
4457
  "--name-only",
4324
4458
  "-z",
@@ -4326,9 +4460,9 @@ function resolveChangedScope(cwd, request) {
4326
4460
  `${request.changedSince}...HEAD`,
4327
4461
  "--"
4328
4462
  ])) {
4329
- paths.add(path22);
4463
+ paths.add(path23);
4330
4464
  }
4331
- for (const path22 of gitPaths(cwd, [
4465
+ for (const path23 of gitPaths(cwd, [
4332
4466
  "diff",
4333
4467
  "--name-only",
4334
4468
  "-z",
@@ -4336,15 +4470,15 @@ function resolveChangedScope(cwd, request) {
4336
4470
  "HEAD",
4337
4471
  "--"
4338
4472
  ])) {
4339
- paths.add(path22);
4473
+ paths.add(path23);
4340
4474
  }
4341
- for (const path22 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4342
- paths.add(path22);
4475
+ for (const path23 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4476
+ paths.add(path23);
4343
4477
  }
4344
4478
  descriptions.push(`changed since ${request.changedSince}`);
4345
4479
  }
4346
4480
  if (request.staged === true) {
4347
- for (const path22 of gitPaths(cwd, [
4481
+ for (const path23 of gitPaths(cwd, [
4348
4482
  "diff",
4349
4483
  "--cached",
4350
4484
  "--name-only",
@@ -4352,10 +4486,10 @@ function resolveChangedScope(cwd, request) {
4352
4486
  "--relative",
4353
4487
  "--"
4354
4488
  ])) {
4355
- paths.add(path22);
4356
- stagedPaths.add(path22);
4489
+ paths.add(path23);
4490
+ stagedPaths.add(path23);
4357
4491
  }
4358
- for (const path22 of gitPaths(cwd, [
4492
+ for (const path23 of gitPaths(cwd, [
4359
4493
  "diff",
4360
4494
  "--cached",
4361
4495
  "--name-only",
@@ -4364,7 +4498,7 @@ function resolveChangedScope(cwd, request) {
4364
4498
  "--diff-filter=D",
4365
4499
  "--"
4366
4500
  ])) {
4367
- deletedPaths.add(path22);
4501
+ deletedPaths.add(path23);
4368
4502
  }
4369
4503
  descriptions.push("staged");
4370
4504
  }
@@ -5190,9 +5324,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
5190
5324
  var jvmProfile = {
5191
5325
  id: "jvm",
5192
5326
  extensions: [".java", ".kt", ".kts", ".scala"],
5193
- summarize(path22, content) {
5327
+ summarize(path23, content) {
5194
5328
  const summary = emptySummary();
5195
- const lower = path22.toLowerCase();
5329
+ const lower = path23.toLowerCase();
5196
5330
  const isJava = lower.endsWith(".java");
5197
5331
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
5198
5332
  eachLine(content, (line) => {
@@ -5513,17 +5647,17 @@ var rustProfile = {
5513
5647
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script>/gi;
5514
5648
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
5515
5649
  var ASTRO_FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?=\r?\n|$)/;
5516
- function componentName(path22) {
5517
- const base = path22.split("/").pop() ?? path22;
5650
+ function componentName(path23) {
5651
+ const base = path23.split("/").pop() ?? path23;
5518
5652
  return base.replace(/\.[^.]+$/, "");
5519
5653
  }
5520
5654
  var sfcProfile = {
5521
5655
  id: "sfc",
5522
5656
  extensions: [".vue", ".svelte", ".astro"],
5523
- summarize(path22, content) {
5657
+ summarize(path23, content) {
5524
5658
  let script = "";
5525
- let usesJsx = path22.toLowerCase().endsWith(".astro");
5526
- if (path22.toLowerCase().endsWith(".astro")) {
5659
+ let usesJsx = path23.toLowerCase().endsWith(".astro");
5660
+ if (path23.toLowerCase().endsWith(".astro")) {
5527
5661
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
5528
5662
  if (frontmatter) script += `${frontmatter[1]}
5529
5663
  `;
@@ -5533,7 +5667,7 @@ var sfcProfile = {
5533
5667
  script += `${match[2]}
5534
5668
  `;
5535
5669
  }
5536
- const name = componentName(path22);
5670
+ const name = componentName(path23);
5537
5671
  if (!script.trim()) {
5538
5672
  const summary2 = emptySummary();
5539
5673
  if (name) {
@@ -5724,15 +5858,15 @@ for (const profile of LANGUAGE_PROFILES) {
5724
5858
  BY_EXTENSION.set(extension.toLowerCase(), profile);
5725
5859
  }
5726
5860
  }
5727
- function profileForPath(path22) {
5728
- const lower = path22.toLowerCase();
5861
+ function profileForPath(path23) {
5862
+ const lower = path23.toLowerCase();
5729
5863
  const dot = lower.lastIndexOf(".");
5730
5864
  if (dot === -1) return null;
5731
5865
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
5732
5866
  }
5733
- function summarizeWithProfile(path22, content) {
5734
- const profile = profileForPath(path22);
5735
- 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;
5736
5870
  }
5737
5871
 
5738
5872
  // src/scanner/binary.ts
@@ -7961,6 +8095,10 @@ function renderConfig(answers) {
7961
8095
  // Experimental: grow the per-part budget until the snapshot fits this many parts, instead of
7962
8096
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
7963
8097
  // maxParts: 10,
8098
+ // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
8099
+ // brief: "docs/brief.md",
8100
+ // Which job the brief is written for: audit, review or explain.
8101
+ // promptTask: "audit",
7964
8102
  // afterGenerate: (manifest) => { /* write your own artifact */ }
7965
8103
  hooks: {},
7966
8104
  };
@@ -8999,9 +9137,9 @@ async function runWithStdoutCapture(fn) {
8999
9137
  }
9000
9138
 
9001
9139
  // src/index.ts
9002
- import * as fs15 from "fs";
9140
+ import * as fs16 from "fs";
9003
9141
  import * as os2 from "os";
9004
- import * as path16 from "path";
9142
+ import * as path17 from "path";
9005
9143
 
9006
9144
  // src/generator/audit.ts
9007
9145
  function generateAuditReport(manifest, secretFindings, secretRules) {
@@ -9782,9 +9920,15 @@ var UNLIMITED_SLOTS = 0;
9782
9920
  var ENTRY_POINT = /(^|\/)(index|cli|main|bin|server|app|mod)\.[cm]?[jt]sx?$/;
9783
9921
  var TEST_PATH = /(^|\/)(tests?|__tests__)\//;
9784
9922
  var TEST_FILE = /\.(test|spec)\.[^.]+$/;
9785
- function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMENT_SLOTS, history = []) {
9923
+ function generatePrompt(manifest, artifacts, context = {}) {
9924
+ const slots = context.slots ?? DEFAULT_ATTACHMENT_SLOTS;
9925
+ const task = context.task ?? "audit";
9926
+ const history = context.history ?? [];
9927
+ const overview = context.overview ?? { releases: [] };
9928
+ const brief = context.brief;
9786
9929
  const wrote = (name) => artifacts?.[name] !== false;
9787
9930
  const code = (value) => inlineCode(escapeControls(value));
9931
+ const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
9788
9932
  const lines = [
9789
9933
  "# PROMPT.md",
9790
9934
  "",
@@ -9800,30 +9944,22 @@ function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMEN
9800
9944
  "You are working on a codebase you cannot clone, run or grep. Everything you know about it comes",
9801
9945
  "from the snapshot that follows this instruction. Where these notes and the snapshot disagree,",
9802
9946
  "the snapshot is what exists.",
9803
- "",
9804
- "## The job",
9805
- "",
9806
- "Find what is still wrong or will break. How you read the code is yours to decide - by",
9807
- "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
9808
- "honest account of what you covered and what you did not.",
9809
- "",
9810
- 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,",
9811
- 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.",
9812
- 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.",
9813
- "",
9814
- "If the task at the end asks for something narrower - explain a file, review a change, answer a",
9815
- "question - that task wins. The standard and the coverage duty below still apply to it.",
9816
9947
  ""
9817
9948
  ];
9949
+ if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
9950
+ lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
9951
+ lines.push(...stakesSection(brief, code));
9818
9952
  lines.push(...haveSection(wrote), "");
9819
- lines.push(...systemSection(manifest, code), "");
9820
- lines.push(...historySection(history), "");
9821
- lines.push(...barSection(), "");
9953
+ lines.push(...whatThisIsSection(overview), "");
9954
+ lines.push(...systemSection(manifest, code, brief), "");
9955
+ lines.push(...historySection(history, brief, code), "");
9956
+ lines.push(...barSection(brief, code), "");
9822
9957
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
9823
9958
  lines.push(...answerSection(), "");
9824
- lines.push(...calibrationSection(), "");
9959
+ lines.push(...calibrationSection(brief, code), "");
9960
+ lines.push(...ownerNotesSection(brief, code));
9825
9961
  lines.push(...snapshotSection(manifest, code), "");
9826
- lines.push(...deliverySection(manifest, wrote("parts"), attachmentSlots));
9962
+ lines.push(...deliverySection(manifest, wrote("parts"), slots));
9827
9963
  lines.push(
9828
9964
  "## Your task",
9829
9965
  "",
@@ -9900,8 +10036,11 @@ function haveSection(wrote) {
9900
10036
  out.push(...bullets);
9901
10037
  return out;
9902
10038
  }
9903
- function systemSection(manifest, code) {
10039
+ function systemSection(manifest, code, brief) {
9904
10040
  const out = ["## The system", ""];
10041
+ if (brief?.system !== void 0) {
10042
+ out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
10043
+ }
9905
10044
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
9906
10045
  if (layers.length > 0) {
9907
10046
  const shown = layers.slice(0, MAX_LAYER_ROWS).map(([name, count]) => code(name) + " " + formatNumber(count));
@@ -9916,7 +10055,7 @@ function systemSection(manifest, code) {
9916
10055
  " A change here reaches the most call sites; read it before judging anything that uses it."
9917
10056
  );
9918
10057
  }
9919
- 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);
10058
+ 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);
9920
10059
  out.push(
9921
10060
  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"
9922
10061
  );
@@ -9959,8 +10098,9 @@ function systemSection(manifest, code) {
9959
10098
  }
9960
10099
  return out;
9961
10100
  }
9962
- function historySection(history) {
10101
+ function historySection(history, brief, code) {
9963
10102
  const out = ["## What came before", ""];
10103
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
9964
10104
  if (history.length === 0) {
9965
10105
  out.push(
9966
10106
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -9969,15 +10109,21 @@ function historySection(history) {
9969
10109
  return out;
9970
10110
  }
9971
10111
  out.push(
9972
- "Commit subjects, newest first. They are claims by whoever wrote them, not evidence - the code",
9973
- "beside them is the evidence. If one of these fixes looks incomplete, quote the lines and say",
9974
- "which call site it missed.",
10112
+ "The last " + formatNumber(history.length) + " commit(s), newest first. Subjects and bodies are",
10113
+ "claims by whoever wrote them, not evidence - the code beside them is the evidence. If one of",
10114
+ "these fixes looks incomplete, quote the lines and say which call site it missed.",
9975
10115
  ""
9976
10116
  );
9977
- for (const subject of history) out.push("- " + subject);
10117
+ for (const commit of history) {
10118
+ out.push("- " + commit.subject);
10119
+ if (commit.body.length > 0) out.push(" " + commit.body);
10120
+ }
9978
10121
  return out;
9979
10122
  }
9980
- function barSection() {
10123
+ function barSection(brief, code) {
10124
+ if (brief?.bar !== void 0) {
10125
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
10126
+ }
9981
10127
  return [
9982
10128
  "## The bar",
9983
10129
  "",
@@ -10035,7 +10181,10 @@ function answerSection() {
10035
10181
  " the gap you filled by asking instead of guessing."
10036
10182
  ];
10037
10183
  }
10038
- function calibrationSection() {
10184
+ function calibrationSection(brief, code) {
10185
+ if (brief?.calibration !== void 0) {
10186
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
10187
+ }
10039
10188
  return [
10040
10189
  "## Calibration",
10041
10190
  "",
@@ -10050,6 +10199,84 @@ function calibrationSection() {
10050
10199
  "None of these throw. All are invisible in a summary."
10051
10200
  ];
10052
10201
  }
10202
+ function jobSection(task, hasHistory) {
10203
+ const out = ["## The job", ""];
10204
+ if (task === "audit") {
10205
+ out.push(
10206
+ "Find what is still wrong or will break. How you read the code is yours to decide - by",
10207
+ "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
10208
+ "honest account of what you covered and what you did not.",
10209
+ ""
10210
+ );
10211
+ if (hasHistory) {
10212
+ out.push(
10213
+ "Another pass of the same findings is worth nothing. This repository carries a record of",
10214
+ "what was already fixed, below. Verify that those fixes hold instead of rediscovering them,",
10215
+ "and treat a variant of one at a different call site as a new finding."
10216
+ );
10217
+ } else {
10218
+ out.push(
10219
+ "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
10220
+ "so you cannot tell what has already been tried. Do not assume this is the first attempt."
10221
+ );
10222
+ }
10223
+ out.push(
10224
+ "",
10225
+ "If the task at the end asks for something narrower - explain a file, review a change, answer",
10226
+ "a question - that task wins. The standard and the coverage duty below still apply to it."
10227
+ );
10228
+ } else if (task === "review") {
10229
+ out.push(
10230
+ "Review the change or the area named in the task against this snapshot. Report what breaks,",
10231
+ "what the change claims but does not do, and what a reader would believe that the code does",
10232
+ "not support. Restating the diff is not a review; the standard and the coverage duty below",
10233
+ "still apply."
10234
+ );
10235
+ } else {
10236
+ out.push(
10237
+ "Explain how the part of the system named in the task works: the data flow, the boundaries",
10238
+ "and the invariants it depends on. Cite the lines. If the snapshot does not contain what you",
10239
+ "need, say which file you need rather than reconstructing it from the shape of the names."
10240
+ );
10241
+ }
10242
+ return out;
10243
+ }
10244
+ function stakesSection(brief, code) {
10245
+ if (brief?.stakes === void 0) return [];
10246
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
10247
+ }
10248
+ function whatThisIsSection(overview) {
10249
+ const body = [];
10250
+ if (overview.description !== void 0) {
10251
+ body.push("- Declared in `package.json`: " + overview.description);
10252
+ }
10253
+ if (overview.summary !== void 0) {
10254
+ body.push("- From the `README.md` first paragraph: " + overview.summary);
10255
+ }
10256
+ if (overview.releases.length > 0) {
10257
+ body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
10258
+ }
10259
+ if (body.length === 0) return [];
10260
+ return [
10261
+ "## What this is",
10262
+ "",
10263
+ ...body,
10264
+ "",
10265
+ "Those are the project's own claims, not evidence about the code.",
10266
+ ""
10267
+ ];
10268
+ }
10269
+ function ownerNotesSection(brief, code) {
10270
+ if (brief === void 0 || brief.notes.length === 0) return [];
10271
+ const out = ["## Owner notes", ""];
10272
+ for (const note of brief.notes) {
10273
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
10274
+ }
10275
+ return out;
10276
+ }
10277
+ function ownerBlock(text2, path23, code) {
10278
+ return ["> Written by the project owner in " + code(path23) + ", not generated.", "", text2];
10279
+ }
10053
10280
  function snapshotSection(manifest, code) {
10054
10281
  const out = ["## This snapshot", ""];
10055
10282
  out.push("- Fingerprint: " + code(manifest.fingerprint) + " - quote it verbatim in your answer.");
@@ -10363,12 +10590,68 @@ function treeTruncationWarnings(treeText) {
10363
10590
  return warnings;
10364
10591
  }
10365
10592
 
10366
- // src/update-check.ts
10593
+ // src/generator/overview.ts
10367
10594
  import * as fs13 from "fs";
10595
+ import * as path13 from "path";
10596
+ var SUMMARY_LIMIT = 400;
10597
+ var MAX_RELEASES = 2;
10598
+ function readProjectOverview(cwd) {
10599
+ return {
10600
+ ...readDescription(cwd),
10601
+ ...readSummary(cwd),
10602
+ releases: readReleases(cwd)
10603
+ };
10604
+ }
10605
+ function readText(file) {
10606
+ try {
10607
+ return fs13.readFileSync(file, "utf8");
10608
+ } catch {
10609
+ return null;
10610
+ }
10611
+ }
10612
+ function readDescription(cwd) {
10613
+ const raw = readText(path13.join(cwd, "package.json"));
10614
+ if (raw === null) return {};
10615
+ try {
10616
+ const parsed = JSON.parse(stripJsonComments(raw));
10617
+ return typeof parsed.description === "string" && parsed.description.trim().length > 0 ? { description: parsed.description.trim() } : {};
10618
+ } catch {
10619
+ return {};
10620
+ }
10621
+ }
10622
+ function readSummary(cwd) {
10623
+ const raw = readText(path13.join(cwd, "README.md"));
10624
+ if (raw === null) return {};
10625
+ const lines = raw.split(/\r?\n/);
10626
+ const paragraph = [];
10627
+ for (const line of lines) {
10628
+ const trimmed = line.trim();
10629
+ if (paragraph.length === 0) {
10630
+ if (trimmed.length === 0) continue;
10631
+ if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^</.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
10632
+ if (/^\[[^\]]+\]:/.test(trimmed)) continue;
10633
+ } else if (trimmed.length === 0 || /^#/.test(trimmed)) {
10634
+ break;
10635
+ }
10636
+ paragraph.push(trimmed);
10637
+ }
10638
+ const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
10639
+ if (summary.length === 0) return {};
10640
+ return { summary: summary.length > SUMMARY_LIMIT ? summary.slice(0, SUMMARY_LIMIT - 1) + "\u2026" : summary };
10641
+ }
10642
+ function readReleases(cwd) {
10643
+ const raw = readText(path13.join(cwd, "CHANGELOG.md"));
10644
+ if (raw === null) return [];
10645
+ const headings = raw.split(/\r?\n/).filter((line) => /^##\s+\S/.test(line)).map((line) => line.replace(/^##\s+/, "").trim());
10646
+ return headings.slice(0, MAX_RELEASES);
10647
+ }
10648
+
10649
+ // src/update-check.ts
10650
+ import * as fs14 from "fs";
10368
10651
  import * as http from "http";
10369
10652
  import * as https from "https";
10370
10653
  import * as os from "os";
10371
- import * as path13 from "path";
10654
+ import * as path14 from "path";
10372
10655
  var PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
10373
10656
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
10374
10657
  var UP_TO_DATE_INTERVAL_MS = 60 * 60 * 1e3;
@@ -10417,17 +10700,17 @@ function isNewer(candidate, current) {
10417
10700
  }
10418
10701
  function cacheDirectory(env = process.env, platform = process.platform) {
10419
10702
  if (platform === "win32") {
10420
- const base2 = env.LOCALAPPDATA ?? path13.join(os.homedir(), "AppData", "Local");
10421
- return path13.join(base2, "codebase-snapshot");
10703
+ const base2 = env.LOCALAPPDATA ?? path14.join(os.homedir(), "AppData", "Local");
10704
+ return path14.join(base2, "codebase-snapshot");
10422
10705
  }
10423
10706
  if (platform === "darwin") {
10424
- return path13.join(os.homedir(), "Library", "Caches", "codebase-snapshot");
10707
+ return path14.join(os.homedir(), "Library", "Caches", "codebase-snapshot");
10425
10708
  }
10426
- const base = env.XDG_CACHE_HOME ?? path13.join(os.homedir(), ".cache");
10427
- return path13.join(base, "codebase-snapshot");
10709
+ const base = env.XDG_CACHE_HOME ?? path14.join(os.homedir(), ".cache");
10710
+ return path14.join(base, "codebase-snapshot");
10428
10711
  }
10429
10712
  function cacheFilePath(env = process.env) {
10430
- return path13.join(cacheDirectory(env), "update-check.json");
10713
+ return path14.join(cacheDirectory(env), "update-check.json");
10431
10714
  }
10432
10715
  function shouldCheck(argv, env) {
10433
10716
  const disabled = ["1", "true", "yes"].includes(
@@ -10457,7 +10740,7 @@ function shouldCheck(argv, env) {
10457
10740
  function readCache(file) {
10458
10741
  let raw;
10459
10742
  try {
10460
- raw = fs13.readFileSync(file, "utf8");
10743
+ raw = fs14.readFileSync(file, "utf8");
10461
10744
  } catch {
10462
10745
  return null;
10463
10746
  }
@@ -10474,8 +10757,8 @@ function readCache(file) {
10474
10757
  }
10475
10758
  function writeCache(file, entry) {
10476
10759
  try {
10477
- fs13.mkdirSync(path13.dirname(file), { recursive: true });
10478
- fs13.writeFileSync(file, `${JSON.stringify(entry)}
10760
+ fs14.mkdirSync(path14.dirname(file), { recursive: true });
10761
+ fs14.writeFileSync(file, `${JSON.stringify(entry)}
10479
10762
  `, "utf8");
10480
10763
  } catch {
10481
10764
  }
@@ -10568,8 +10851,8 @@ function formatUpdateNotice(notice, kind) {
10568
10851
 
10569
10852
  // src/agent/hook.ts
10570
10853
  import * as childProcess2 from "child_process";
10571
- import * as fs14 from "fs";
10572
- import * as path14 from "path";
10854
+ import * as fs15 from "fs";
10855
+ import * as path15 from "path";
10573
10856
  var HOOK_MARKER = `# ${GENERATOR_NAME}: pre-commit snapshot check`;
10574
10857
  function shellQuote(value) {
10575
10858
  return value.replace(/[\\"`$]/g, (character) => `\\${character}`);
@@ -10611,36 +10894,36 @@ fi
10611
10894
  `;
10612
10895
  }
10613
10896
  function gitDirectory(cwd) {
10614
- const dotGit = path14.join(cwd, ".git");
10897
+ const dotGit = path15.join(cwd, ".git");
10615
10898
  let stats;
10616
10899
  try {
10617
- stats = fs14.statSync(dotGit);
10900
+ stats = fs15.statSync(dotGit);
10618
10901
  } catch {
10619
10902
  return null;
10620
10903
  }
10621
10904
  if (stats.isDirectory()) return dotGit;
10622
10905
  if (!stats.isFile()) return null;
10623
10906
  try {
10624
- const contents = fs14.readFileSync(dotGit, "utf8");
10907
+ const contents = fs15.readFileSync(dotGit, "utf8");
10625
10908
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
10626
10909
  if (!match) return null;
10627
10910
  const target = match[1];
10628
- const resolved = path14.isAbsolute(target.trim()) ? target.trim() : path14.join(cwd, target.trim());
10629
- if (!fs14.statSync(resolved).isDirectory()) return null;
10630
- if (isInside2(path14.resolve(cwd), path14.resolve(resolved))) return resolved;
10631
- return isRegisteredWorktree(path14.resolve(resolved), cwd) ? resolved : null;
10911
+ const resolved = path15.isAbsolute(target.trim()) ? target.trim() : path15.join(cwd, target.trim());
10912
+ if (!fs15.statSync(resolved).isDirectory()) return null;
10913
+ if (isInside2(path15.resolve(cwd), path15.resolve(resolved))) return resolved;
10914
+ return isRegisteredWorktree(path15.resolve(resolved), cwd) ? resolved : null;
10632
10915
  } catch {
10633
10916
  return null;
10634
10917
  }
10635
10918
  }
10636
10919
  function isInside2(parent, child) {
10637
- const relative15 = path14.relative(parent, child);
10638
- return relative15 === "" || !relative15.startsWith("..") && !path14.isAbsolute(relative15);
10920
+ const relative15 = path15.relative(parent, child);
10921
+ return relative15 === "" || !relative15.startsWith("..") && !path15.isAbsolute(relative15);
10639
10922
  }
10640
10923
  function isRegisteredWorktree(gitDir, cwd) {
10641
10924
  try {
10642
- const back = fs14.readFileSync(path14.join(gitDir, "gitdir"), "utf8").trim();
10643
- return path14.resolve(gitDir, back) === path14.join(path14.resolve(cwd), ".git");
10925
+ const back = fs15.readFileSync(path15.join(gitDir, "gitdir"), "utf8").trim();
10926
+ return path15.resolve(gitDir, back) === path15.join(path15.resolve(cwd), ".git");
10644
10927
  } catch {
10645
10928
  return false;
10646
10929
  }
@@ -10661,10 +10944,10 @@ function gitOutput(cwd, args) {
10661
10944
  function configuredHooksDirectory(cwd) {
10662
10945
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
10663
10946
  if (hooks === null) return null;
10664
- const resolved = path14.resolve(cwd, hooks);
10947
+ const resolved = path15.resolve(cwd, hooks);
10665
10948
  const common = gitOutput(cwd, ["rev-parse", "--git-common-dir"]);
10666
- const commonDir = common === null ? null : path14.resolve(cwd, common);
10667
- if (isInside2(path14.resolve(cwd), resolved)) return { dir: resolved };
10949
+ const commonDir = common === null ? null : path15.resolve(cwd, common);
10950
+ if (isInside2(path15.resolve(cwd), resolved)) return { dir: resolved };
10668
10951
  if (commonDir !== null && isInside2(commonDir, resolved)) return { dir: resolved };
10669
10952
  return {
10670
10953
  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.`
@@ -10685,10 +10968,10 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10685
10968
  ]
10686
10969
  };
10687
10970
  }
10688
- const hooksDir = configured === null ? path14.join(gitDir, "hooks") : configured.dir;
10689
- const hookPath = path14.join(hooksDir, "pre-commit");
10971
+ const hooksDir = configured === null ? path15.join(gitDir, "hooks") : configured.dir;
10972
+ const hookPath = path15.join(hooksDir, "pre-commit");
10690
10973
  try {
10691
- fs14.mkdirSync(hooksDir, { recursive: true });
10974
+ fs15.mkdirSync(hooksDir, { recursive: true });
10692
10975
  } catch (err) {
10693
10976
  return {
10694
10977
  path: hookPath,
@@ -10698,7 +10981,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10698
10981
  }
10699
10982
  let existing = null;
10700
10983
  try {
10701
- existing = fs14.readFileSync(hookPath, "utf8");
10984
+ existing = fs15.readFileSync(hookPath, "utf8");
10702
10985
  } catch {
10703
10986
  existing = null;
10704
10987
  }
@@ -10713,8 +10996,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10713
10996
  };
10714
10997
  }
10715
10998
  try {
10716
- fs14.writeFileSync(hookPath, hookScript(outDir), "utf8");
10717
- fs14.chmodSync(hookPath, 493);
10999
+ fs15.writeFileSync(hookPath, hookScript(outDir), "utf8");
11000
+ fs15.chmodSync(hookPath, 493);
10718
11001
  } catch (err) {
10719
11002
  return {
10720
11003
  path: hookPath,
@@ -10732,11 +11015,11 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10732
11015
  }
10733
11016
 
10734
11017
  // src/mcp/generate-worker.ts
10735
- import * as path15 from "path";
11018
+ import * as path16 from "path";
10736
11019
  import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "url";
10737
11020
  import { Worker } from "worker_threads";
10738
11021
  function workerEntry(directory, isCjs) {
10739
- const entry = path15.join(directory, isCjs ? "index.cjs" : "index.js");
11022
+ const entry = path16.join(directory, isCjs ? "index.cjs" : "index.js");
10740
11023
  return { path: entry, url: pathToFileURL2(entry).href };
10741
11024
  }
10742
11025
  var WORKER_SOURCE = `
@@ -10803,7 +11086,7 @@ function generateInWorker(cwd, cliOptions, options = {}) {
10803
11086
  resolve12(result);
10804
11087
  };
10805
11088
  const isCjs = typeof __dirname !== "undefined";
10806
- const directory = isCjs ? __dirname : path15.dirname(fileURLToPath(import.meta.url));
11089
+ const directory = isCjs ? __dirname : path16.dirname(fileURLToPath(import.meta.url));
10807
11090
  try {
10808
11091
  worker = new Worker(WORKER_SOURCE, {
10809
11092
  eval: true,
@@ -10838,23 +11121,23 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
10838
11121
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
10839
11122
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
10840
11123
  var fileDerivationBytes = 0;
10841
- function takeDerivation(path22, hash, settings) {
10842
- const cached = FILE_DERIVATIONS.get(path22);
11124
+ function takeDerivation(path23, hash, settings) {
11125
+ const cached = FILE_DERIVATIONS.get(path23);
10843
11126
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
10844
- FILE_DERIVATIONS.delete(path22);
10845
- FILE_DERIVATIONS.set(path22, cached);
11127
+ FILE_DERIVATIONS.delete(path23);
11128
+ FILE_DERIVATIONS.set(path23, cached);
10846
11129
  return cached;
10847
11130
  }
10848
- function rememberDerivation(path22, hash, settings, derivation) {
11131
+ function rememberDerivation(path23, hash, settings, derivation) {
10849
11132
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
10850
11133
  const bytes = bodyBytes * 2 + 512;
10851
11134
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
10852
- const previous = FILE_DERIVATIONS.get(path22);
11135
+ const previous = FILE_DERIVATIONS.get(path23);
10853
11136
  if (previous !== void 0) {
10854
- FILE_DERIVATIONS.delete(path22);
11137
+ FILE_DERIVATIONS.delete(path23);
10855
11138
  fileDerivationBytes -= previous.bytes;
10856
11139
  } else {
10857
- FILE_DERIVATIONS.delete(path22);
11140
+ FILE_DERIVATIONS.delete(path23);
10858
11141
  }
10859
11142
  while (fileDerivationBytes + bytes > FILE_DERIVATION_LIMIT_BYTES) {
10860
11143
  const oldest = FILE_DERIVATIONS.keys().next();
@@ -10863,7 +11146,7 @@ function rememberDerivation(path22, hash, settings, derivation) {
10863
11146
  FILE_DERIVATIONS.delete(oldest.value);
10864
11147
  if (evicted !== void 0) fileDerivationBytes -= evicted.bytes;
10865
11148
  }
10866
- FILE_DERIVATIONS.set(path22, { ...derivation, hash, settings, bytes });
11149
+ FILE_DERIVATIONS.set(path23, { ...derivation, hash, settings, bytes });
10867
11150
  fileDerivationBytes += bytes;
10868
11151
  }
10869
11152
  function derivationSettings(config) {
@@ -11115,11 +11398,11 @@ function verifyInMemory(files, parts, unaccounted) {
11115
11398
  return errors;
11116
11399
  }
11117
11400
  function resolveSafeOutputDirs(config) {
11118
- const cwd = path16.resolve(config.cwd);
11119
- const outDir = path16.resolve(cwd, config.outDir);
11120
- const tmpDir = path16.resolve(cwd, config.tmpDir);
11121
- const root = path16.parse(cwd).root;
11122
- const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path16.sep}`);
11401
+ const cwd = path17.resolve(config.cwd);
11402
+ const outDir = path17.resolve(cwd, config.outDir);
11403
+ const tmpDir = path17.resolve(cwd, config.tmpDir);
11404
+ const root = path17.parse(cwd).root;
11405
+ const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path17.sep}`);
11123
11406
  const reject = (reason) => {
11124
11407
  throw new Error(
11125
11408
  `Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
@@ -11159,6 +11442,28 @@ function maskSummaryStrings(value, secretRules) {
11159
11442
  function maskPathText(value, secretRules) {
11160
11443
  return findSecretInPath(value, secretRules)?.masked ?? value;
11161
11444
  }
11445
+ function maskOwnerBrief(brief, secretRules) {
11446
+ if (brief === void 0) return void 0;
11447
+ const mask = (value) => maskPathText(value, secretRules);
11448
+ return {
11449
+ ...brief,
11450
+ ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11451
+ ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11452
+ ...brief.history === void 0 ? {} : { history: mask(brief.history) },
11453
+ ...brief.bar === void 0 ? {} : { bar: mask(brief.bar) },
11454
+ ...brief.calibration === void 0 ? {} : { calibration: mask(brief.calibration) },
11455
+ ...brief.preamble === void 0 ? {} : { preamble: mask(brief.preamble) },
11456
+ notes: brief.notes.map((note) => ({ heading: note.heading, body: mask(note.body) }))
11457
+ };
11458
+ }
11459
+ function maskOverview(overview, secretRules) {
11460
+ const mask = (value) => maskPathText(value, secretRules);
11461
+ return {
11462
+ ...overview.description === void 0 ? {} : { description: mask(overview.description) },
11463
+ ...overview.summary === void 0 ? {} : { summary: mask(overview.summary) },
11464
+ releases: overview.releases.map(mask)
11465
+ };
11466
+ }
11162
11467
  function maskSkipRecords(records, secretRules) {
11163
11468
  return maskSkipPaths(records, secretRules);
11164
11469
  }
@@ -11179,14 +11484,14 @@ function listEntries(dir) {
11179
11484
  const walk = (absolute, prefix) => {
11180
11485
  let children;
11181
11486
  try {
11182
- children = fs15.readdirSync(absolute, { withFileTypes: true });
11487
+ children = fs16.readdirSync(absolute, { withFileTypes: true });
11183
11488
  } catch {
11184
11489
  return;
11185
11490
  }
11186
11491
  for (const child of children) {
11187
11492
  const relative15 = prefix === "" ? child.name : `${prefix}/${child.name}`;
11188
11493
  entries.push(relative15);
11189
- if (child.isDirectory()) walk(path16.join(absolute, child.name), relative15);
11494
+ if (child.isDirectory()) walk(path17.join(absolute, child.name), relative15);
11190
11495
  }
11191
11496
  };
11192
11497
  walk(dir, "");
@@ -11198,10 +11503,10 @@ function markerInventory(dir, written) {
11198
11503
  for (const entry of entries) {
11199
11504
  if (entry === OWNERSHIP_MARKER) continue;
11200
11505
  if (isIgnorableEntry(entry)) continue;
11201
- const full = path16.join(dir, ...entry.split("/"));
11506
+ const full = path17.join(dir, ...entry.split("/"));
11202
11507
  let stats;
11203
11508
  try {
11204
- stats = fs15.lstatSync(full);
11509
+ stats = fs16.lstatSync(full);
11205
11510
  } catch {
11206
11511
  continue;
11207
11512
  }
@@ -11213,7 +11518,7 @@ function markerInventory(dir, written) {
11213
11518
  }
11214
11519
  let digest;
11215
11520
  try {
11216
- digest = sha256Hex2(fs15.readFileSync(full));
11521
+ digest = sha256Hex2(fs16.readFileSync(full));
11217
11522
  } catch {
11218
11523
  continue;
11219
11524
  }
@@ -11234,15 +11539,15 @@ function markerPayload(dir, state, id, createdAt, written) {
11234
11539
  entries,
11235
11540
  files
11236
11541
  };
11237
- const manifestPath = path16.join(dir, "manifest.json");
11238
- if (fs15.existsSync(manifestPath)) {
11239
- marker2.manifestSha256 = sha256Hex2(fs15.readFileSync(manifestPath));
11542
+ const manifestPath = path17.join(dir, "manifest.json");
11543
+ if (fs16.existsSync(manifestPath)) {
11544
+ marker2.manifestSha256 = sha256Hex2(fs16.readFileSync(manifestPath));
11240
11545
  }
11241
11546
  return marker2;
11242
11547
  }
11243
11548
  function writeOwnershipMarker(dir, marker2) {
11244
- fs15.writeFileSync(
11245
- path16.join(dir, OWNERSHIP_MARKER),
11549
+ fs16.writeFileSync(
11550
+ path17.join(dir, OWNERSHIP_MARKER),
11246
11551
  `${JSON.stringify(marker2, null, 2)}
11247
11552
  `,
11248
11553
  "utf8"
@@ -11254,13 +11559,13 @@ function markerBelongsTo(dir, id) {
11254
11559
  return evidence.marker.id === id;
11255
11560
  }
11256
11561
  function readOwnershipMarker(dir) {
11257
- const markerPath = path16.join(dir, OWNERSHIP_MARKER);
11258
- if (!fs15.existsSync(markerPath)) {
11562
+ const markerPath = path17.join(dir, OWNERSHIP_MARKER);
11563
+ if (!fs16.existsSync(markerPath)) {
11259
11564
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
11260
11565
  }
11261
11566
  let raw;
11262
11567
  try {
11263
- raw = fs15.readFileSync(markerPath, "utf8");
11568
+ raw = fs16.readFileSync(markerPath, "utf8");
11264
11569
  } catch {
11265
11570
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
11266
11571
  }
@@ -11360,10 +11665,10 @@ function verifyMarkerInventory(dir, entries, files) {
11360
11665
  for (const entry of entries) {
11361
11666
  if (entry === OWNERSHIP_MARKER) continue;
11362
11667
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
11363
- const full = path16.join(dir, ...entry.split("/"));
11668
+ const full = path17.join(dir, ...entry.split("/"));
11364
11669
  let stats;
11365
11670
  try {
11366
- stats = fs15.lstatSync(full);
11671
+ stats = fs16.lstatSync(full);
11367
11672
  } catch {
11368
11673
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
11369
11674
  }
@@ -11388,7 +11693,7 @@ function verifyMarkerInventory(dir, entries, files) {
11388
11693
  }
11389
11694
  let digest;
11390
11695
  try {
11391
- digest = sha256Hex2(fs15.readFileSync(full));
11696
+ digest = sha256Hex2(fs16.readFileSync(full));
11392
11697
  } catch {
11393
11698
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
11394
11699
  }
@@ -11409,12 +11714,12 @@ function assessSnapshotDirectory(dir) {
11409
11714
  marker: marker2
11410
11715
  };
11411
11716
  }
11412
- const manifestPath = path16.join(dir, "manifest.json");
11413
- const hasManifest = fs15.existsSync(manifestPath);
11717
+ const manifestPath = path17.join(dir, "manifest.json");
11718
+ const hasManifest = fs16.existsSync(manifestPath);
11414
11719
  if (hasManifest) {
11415
11720
  let raw;
11416
11721
  try {
11417
- raw = fs15.readFileSync(manifestPath, "utf8");
11722
+ raw = fs16.readFileSync(manifestPath, "utf8");
11418
11723
  } catch {
11419
11724
  return {
11420
11725
  owned: false,
@@ -11509,13 +11814,13 @@ function containsNoFiles(dir) {
11509
11814
  const current = pending.pop();
11510
11815
  let entries;
11511
11816
  try {
11512
- entries = fs15.readdirSync(current, { withFileTypes: true });
11817
+ entries = fs16.readdirSync(current, { withFileTypes: true });
11513
11818
  } catch {
11514
11819
  return false;
11515
11820
  }
11516
11821
  for (const entry of entries) {
11517
11822
  if (entry.isDirectory()) {
11518
- pending.push(path16.join(current, entry.name));
11823
+ pending.push(path17.join(current, entry.name));
11519
11824
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
11520
11825
  return false;
11521
11826
  }
@@ -11524,13 +11829,13 @@ function containsNoFiles(dir) {
11524
11829
  return true;
11525
11830
  }
11526
11831
  function assertReplaceable(target, label, secretRules) {
11527
- if (!fs15.existsSync(target)) return;
11528
- if (!fs15.statSync(target).isDirectory()) {
11832
+ if (!fs16.existsSync(target)) return;
11833
+ if (!fs16.statSync(target).isDirectory()) {
11529
11834
  throw new Error(
11530
11835
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
11531
11836
  );
11532
11837
  }
11533
- const entries = fs15.readdirSync(target);
11838
+ const entries = fs16.readdirSync(target);
11534
11839
  if (entries.length === 0) return;
11535
11840
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
11536
11841
  if (containsNoFiles(target)) return;
@@ -11550,18 +11855,18 @@ function assertReplaceable(target, label, secretRules) {
11550
11855
  );
11551
11856
  }
11552
11857
  function assertStagingRootUsable(tmpDir, secretRules) {
11553
- if (!fs15.existsSync(tmpDir)) return;
11554
- if (!fs15.statSync(tmpDir).isDirectory()) {
11858
+ if (!fs16.existsSync(tmpDir)) return;
11859
+ if (!fs16.statSync(tmpDir).isDirectory()) {
11555
11860
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
11556
11861
  }
11557
- const entries = fs15.readdirSync(tmpDir);
11862
+ const entries = fs16.readdirSync(tmpDir);
11558
11863
  if (entries.length === 0) return;
11559
11864
  const foreign = entries.filter((name) => {
11560
- const full = path16.join(tmpDir, name);
11865
+ const full = path17.join(tmpDir, name);
11561
11866
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
11562
11867
  let stats;
11563
11868
  try {
11564
- stats = fs15.statSync(full);
11869
+ stats = fs16.statSync(full);
11565
11870
  } catch {
11566
11871
  return true;
11567
11872
  }
@@ -11569,7 +11874,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11569
11874
  const { marker: marker2 } = readOwnershipMarker(full);
11570
11875
  if (marker2) return false;
11571
11876
  try {
11572
- return fs15.readdirSync(full).length > 0;
11877
+ return fs16.readdirSync(full).length > 0;
11573
11878
  } catch {
11574
11879
  return true;
11575
11880
  }
@@ -11584,13 +11889,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11584
11889
  function cleanStaleRunDirs(tmpDir) {
11585
11890
  let entries;
11586
11891
  try {
11587
- entries = fs15.readdirSync(tmpDir);
11892
+ entries = fs16.readdirSync(tmpDir);
11588
11893
  } catch {
11589
11894
  return;
11590
11895
  }
11591
11896
  for (const name of entries) {
11592
11897
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
11593
- const full = path16.join(tmpDir, name);
11898
+ const full = path17.join(tmpDir, name);
11594
11899
  const { marker: marker2 } = readOwnershipMarker(full);
11595
11900
  if (marker2) {
11596
11901
  const created = Date.parse(marker2.createdAt);
@@ -11598,33 +11903,33 @@ function cleanStaleRunDirs(tmpDir) {
11598
11903
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
11599
11904
  if (aged || abandoned) {
11600
11905
  try {
11601
- fs15.rmSync(full, { recursive: true, force: true });
11906
+ fs16.rmSync(full, { recursive: true, force: true });
11602
11907
  } catch {
11603
11908
  }
11604
11909
  }
11605
11910
  continue;
11606
11911
  }
11607
11912
  try {
11608
- if (fs15.readdirSync(full).length === 0) fs15.rmSync(full, { recursive: true, force: true });
11913
+ if (fs16.readdirSync(full).length === 0) fs16.rmSync(full, { recursive: true, force: true });
11609
11914
  } catch {
11610
11915
  }
11611
11916
  }
11612
11917
  }
11613
11918
  function removeIfEmpty(dir) {
11614
11919
  try {
11615
- if (fs15.readdirSync(dir).length === 0) fs15.rmSync(dir, { recursive: true, force: true });
11920
+ if (fs16.readdirSync(dir).length === 0) fs16.rmSync(dir, { recursive: true, force: true });
11616
11921
  } catch {
11617
11922
  }
11618
11923
  }
11619
11924
  function ensureParentDirectory(target, label) {
11620
- const parent = path16.dirname(target);
11621
- if (fs15.existsSync(parent) && !fs15.statSync(parent).isDirectory()) {
11925
+ const parent = path17.dirname(target);
11926
+ if (fs16.existsSync(parent) && !fs16.statSync(parent).isDirectory()) {
11622
11927
  throw new Error(
11623
11928
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
11624
11929
  );
11625
11930
  }
11626
11931
  try {
11627
- fs15.mkdirSync(parent, { recursive: true });
11932
+ fs16.mkdirSync(parent, { recursive: true });
11628
11933
  } catch (err) {
11629
11934
  throw new Error(
11630
11935
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -11682,17 +11987,17 @@ function acquireRunLock(stagingRoot) {
11682
11987
  `;
11683
11988
  for (let attempt = 0; attempt < 2; attempt += 1) {
11684
11989
  try {
11685
- const handle = fs15.openSync(lockPath, "wx");
11990
+ const handle = fs16.openSync(lockPath, "wx");
11686
11991
  try {
11687
- fs15.writeSync(handle, payload);
11992
+ fs16.writeSync(handle, payload);
11688
11993
  } finally {
11689
- fs15.closeSync(handle);
11994
+ fs16.closeSync(handle);
11690
11995
  }
11691
11996
  const stopHeartbeat = startLockHeartbeat(lockPath);
11692
11997
  return () => {
11693
11998
  stopHeartbeat();
11694
11999
  try {
11695
- fs15.rmSync(lockPath, { force: true });
12000
+ fs16.rmSync(lockPath, { force: true });
11696
12001
  } catch {
11697
12002
  }
11698
12003
  };
@@ -11712,26 +12017,26 @@ function lockKeyFor(stagingRoot) {
11712
12017
  return sha256Hex2(key).slice(0, 16);
11713
12018
  }
11714
12019
  function canonicalLockTarget(targetPath2) {
11715
- const resolved = path16.resolve(targetPath2);
12020
+ const resolved = path17.resolve(targetPath2);
11716
12021
  let existing = resolved;
11717
12022
  const tail = [];
11718
12023
  for (; ; ) {
11719
12024
  try {
11720
- return path16.join(fs15.realpathSync(existing), ...tail);
12025
+ return path17.join(fs16.realpathSync(existing), ...tail);
11721
12026
  } catch {
11722
- const parent = path16.dirname(existing);
12027
+ const parent = path17.dirname(existing);
11723
12028
  if (parent === existing) return resolved;
11724
- tail.unshift(path16.basename(existing));
12029
+ tail.unshift(path17.basename(existing));
11725
12030
  existing = parent;
11726
12031
  }
11727
12032
  }
11728
12033
  }
11729
12034
  function lockPathFor(stagingRoot) {
11730
- return path16.join(os2.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
12035
+ return path17.join(os2.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11731
12036
  }
11732
12037
  function lockHeartbeatAgeMs(lockPath) {
11733
12038
  try {
11734
- return Date.now() - fs15.statSync(lockPath).mtimeMs;
12039
+ return Date.now() - fs16.statSync(lockPath).mtimeMs;
11735
12040
  } catch {
11736
12041
  return Number.POSITIVE_INFINITY;
11737
12042
  }
@@ -11739,7 +12044,7 @@ function lockHeartbeatAgeMs(lockPath) {
11739
12044
  function lockOwnerIsGone(lockPath) {
11740
12045
  let raw;
11741
12046
  try {
11742
- raw = fs15.readFileSync(lockPath, "utf8");
12047
+ raw = fs16.readFileSync(lockPath, "utf8");
11743
12048
  } catch {
11744
12049
  return false;
11745
12050
  }
@@ -11761,16 +12066,16 @@ function lockOwnerIsGone(lockPath) {
11761
12066
  function reclaimStaleLock(lockPath) {
11762
12067
  let before;
11763
12068
  try {
11764
- before = fs15.statSync(lockPath);
12069
+ before = fs16.statSync(lockPath);
11765
12070
  } catch {
11766
12071
  return true;
11767
12072
  }
11768
12073
  if (!lockOwnerIsGone(lockPath)) return false;
11769
12074
  try {
11770
- const current = fs15.statSync(lockPath);
12075
+ const current = fs16.statSync(lockPath);
11771
12076
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
11772
12077
  if (!sameFile) return false;
11773
- fs15.rmSync(lockPath, { force: true });
12078
+ fs16.rmSync(lockPath, { force: true });
11774
12079
  return true;
11775
12080
  } catch {
11776
12081
  return false;
@@ -11781,12 +12086,12 @@ function lockFileIsAncient(lockPath) {
11781
12086
  }
11782
12087
  function writeManifestAtomically(manifestPath, manifest) {
11783
12088
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
11784
- fs15.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
12089
+ fs16.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11785
12090
  try {
11786
- fs15.renameSync(tempPath, manifestPath);
12091
+ fs16.renameSync(tempPath, manifestPath);
11787
12092
  } catch (err) {
11788
12093
  try {
11789
- fs15.rmSync(tempPath, { force: true });
12094
+ fs16.rmSync(tempPath, { force: true });
11790
12095
  } catch {
11791
12096
  }
11792
12097
  throw err;
@@ -11811,21 +12116,21 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap) {
11811
12116
  }
11812
12117
  }
11813
12118
  function recoverInterruptedPublish(outDir) {
11814
- if (fs15.existsSync(outDir)) return;
11815
- const parent = path16.dirname(outDir);
11816
- const base = path16.basename(outDir);
12119
+ if (fs16.existsSync(outDir)) return;
12120
+ const parent = path17.dirname(outDir);
12121
+ const base = path17.basename(outDir);
11817
12122
  let backups;
11818
12123
  try {
11819
- backups = fs15.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
12124
+ backups = fs16.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
11820
12125
  } catch {
11821
12126
  return;
11822
12127
  }
11823
12128
  if (backups.length !== 1) return;
11824
- const backupDir = path16.join(parent, backups[0]);
12129
+ const backupDir = path17.join(parent, backups[0]);
11825
12130
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
11826
12131
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
11827
12132
  try {
11828
- fs15.renameSync(backupDir, outDir);
12133
+ fs16.renameSync(backupDir, outDir);
11829
12134
  process.stderr.write(
11830
12135
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
11831
12136
  `
@@ -11835,16 +12140,16 @@ function recoverInterruptedPublish(outDir) {
11835
12140
  }
11836
12141
  function swapOnce(stagingDir, outDir, beforeSwap) {
11837
12142
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
11838
- const hadPrevious = fs15.existsSync(outDir);
12143
+ const hadPrevious = fs16.existsSync(outDir);
11839
12144
  if (hadPrevious) beforeSwap?.();
11840
12145
  let movedAside = false;
11841
12146
  if (hadPrevious) {
11842
12147
  try {
11843
- fs15.renameSync(outDir, backupDir);
12148
+ fs16.renameSync(outDir, backupDir);
11844
12149
  movedAside = true;
11845
12150
  } catch (err) {
11846
12151
  if (!isLockError(err)) throw err;
11847
- fs15.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
12152
+ fs16.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
11848
12153
  process.stderr.write(
11849
12154
  `\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.
11850
12155
  `
@@ -11853,26 +12158,26 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11853
12158
  }
11854
12159
  try {
11855
12160
  try {
11856
- fs15.renameSync(stagingDir, outDir);
12161
+ fs16.renameSync(stagingDir, outDir);
11857
12162
  } catch (err) {
11858
12163
  if (err.code !== "EXDEV") throw err;
11859
12164
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
11860
12165
  try {
11861
- fs15.cpSync(stagingDir, partialDir, { recursive: true });
11862
- fs15.renameSync(partialDir, outDir);
11863
- fs15.rmSync(stagingDir, { recursive: true, force: true });
12166
+ fs16.cpSync(stagingDir, partialDir, { recursive: true });
12167
+ fs16.renameSync(partialDir, outDir);
12168
+ fs16.rmSync(stagingDir, { recursive: true, force: true });
11864
12169
  } catch (copyErr) {
11865
12170
  try {
11866
- fs15.rmSync(partialDir, { recursive: true, force: true });
12171
+ fs16.rmSync(partialDir, { recursive: true, force: true });
11867
12172
  } catch {
11868
12173
  }
11869
12174
  throw copyErr;
11870
12175
  }
11871
12176
  }
11872
12177
  } catch (err) {
11873
- if (hadPrevious && movedAside && fs15.existsSync(backupDir)) {
11874
- if (fs15.existsSync(outDir)) fs15.rmSync(outDir, { recursive: true, force: true });
11875
- fs15.renameSync(backupDir, outDir);
12178
+ if (hadPrevious && movedAside && fs16.existsSync(backupDir)) {
12179
+ if (fs16.existsSync(outDir)) fs16.rmSync(outDir, { recursive: true, force: true });
12180
+ fs16.renameSync(backupDir, outDir);
11876
12181
  } else if (hadPrevious && !movedAside) {
11877
12182
  process.stderr.write(
11878
12183
  `\u26A0 The previous snapshot at ${outDir} was removed and the new one could not be moved into place. It is complete at ${stagingDir}.
@@ -11883,7 +12188,7 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11883
12188
  }
11884
12189
  if (hadPrevious) {
11885
12190
  try {
11886
- fs15.rmSync(backupDir, { recursive: true, force: true });
12191
+ fs16.rmSync(backupDir, { recursive: true, force: true });
11887
12192
  } catch (err) {
11888
12193
  process.stderr.write(
11889
12194
  `\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.
@@ -12041,7 +12346,7 @@ function generateSnapshot(configInput, options) {
12041
12346
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
12042
12347
  // output — but only at these exact paths, not at every directory that shares the name.
12043
12348
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
12044
- (directory) => path16.relative(config.cwd, path16.resolve(config.cwd, directory)).replace(/\\/g, "/")
12349
+ (directory) => path17.relative(config.cwd, path17.resolve(config.cwd, directory)).replace(/\\/g, "/")
12045
12350
  ).filter((relative15) => relative15.length > 0 && !relative15.startsWith("..")),
12046
12351
  // A staged path can be absent from the working tree while its index blob exists. Discovery
12047
12352
  // lists the working tree, so those paths would never reach the scan at all.
@@ -12070,7 +12375,7 @@ function generateSnapshot(configInput, options) {
12070
12375
  let totalSizeBytes = 0;
12071
12376
  let largeFileCount = 0;
12072
12377
  for (const relativePath of candidateFiles) {
12073
- const absolutePath = path16.join(config.cwd, relativePath);
12378
+ const absolutePath = path17.join(config.cwd, relativePath);
12074
12379
  const fromIndex = stagedPaths.has(relativePath);
12075
12380
  let buffer;
12076
12381
  let sizeBytes;
@@ -12101,9 +12406,9 @@ function generateSnapshot(configInput, options) {
12101
12406
  } else {
12102
12407
  let stats;
12103
12408
  try {
12104
- stats = fs15.statSync(absolutePath);
12409
+ stats = fs16.statSync(absolutePath);
12105
12410
  if (!stats.isFile()) {
12106
- const nestedRepository = stats.isDirectory() && fs15.existsSync(path16.join(absolutePath, ".git"));
12411
+ const nestedRepository = stats.isDirectory() && fs16.existsSync(path17.join(absolutePath, ".git"));
12107
12412
  skipped.push(
12108
12413
  nestedRepository ? {
12109
12414
  path: relativePath,
@@ -12139,7 +12444,7 @@ function generateSnapshot(configInput, options) {
12139
12444
  continue;
12140
12445
  }
12141
12446
  try {
12142
- buffer = fs15.readFileSync(absolutePath);
12447
+ buffer = fs16.readFileSync(absolutePath);
12143
12448
  } catch (err) {
12144
12449
  const code = err.code;
12145
12450
  skipped.push({
@@ -12268,14 +12573,14 @@ function generateSnapshot(configInput, options) {
12268
12573
  (finding) => finding.path === void 0 || keep.has(finding.path)
12269
12574
  );
12270
12575
  retain(encodingNotes, (note) => keep.has(note.path));
12271
- retain(oversizeSummaryPaths, (path22) => keep.has(path22));
12272
- retain(previewSummaryPaths, (path22) => keep.has(path22));
12576
+ retain(oversizeSummaryPaths, (path23) => keep.has(path23));
12577
+ retain(previewSummaryPaths, (path23) => keep.has(path23));
12273
12578
  retain(fileWarnings, (warning) => keep.has(warning.path));
12274
- for (const path22 of [...monolithBodies.keys()]) {
12275
- if (!keep.has(path22)) monolithBodies.delete(path22);
12579
+ for (const path23 of [...monolithBodies.keys()]) {
12580
+ if (!keep.has(path23)) monolithBodies.delete(path23);
12276
12581
  }
12277
- for (const path22 of [...skippedSummaryImports.keys()]) {
12278
- if (!keep.has(path22)) skippedSummaryImports.delete(path22);
12582
+ for (const path23 of [...skippedSummaryImports.keys()]) {
12583
+ if (!keep.has(path23)) skippedSummaryImports.delete(path23);
12279
12584
  }
12280
12585
  }
12281
12586
  if (changedScope !== null) {
@@ -12414,6 +12719,8 @@ function generateSnapshot(configInput, options) {
12414
12719
  // omitted from `digest` when it is off so an existing snapshot does not start reporting
12415
12720
  // configuration drift.
12416
12721
  maxParts: config.maxParts ?? null,
12722
+ promptTask: config.promptTask,
12723
+ ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12417
12724
  discovery: config.discovery ?? "auto",
12418
12725
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12419
12726
  // describes the run has to name it.
@@ -12544,14 +12851,16 @@ function generateSnapshot(configInput, options) {
12544
12851
  if (auditText !== null) manifest.artifacts.audit = artifactRecord(auditText);
12545
12852
  const readmeText = artifacts.readme ? generateReadme(manifest, artifacts) : null;
12546
12853
  if (readmeText !== null) manifest.artifacts.readme = artifactRecord(readmeText);
12547
- const promptText = artifacts.prompt ? generatePrompt(
12548
- manifest,
12549
- artifacts,
12550
- config.attachmentSlots,
12551
- // Commit subjects are user input and reach an artifact, so they go through the same
12552
- // masking as every other name the run reproduces.
12553
- recentCommitSubjects(config.cwd).map((subject) => maskPathText(subject, config.secretRules))
12554
- ) : null;
12854
+ const promptText = artifacts.prompt ? generatePrompt(manifest, artifacts, {
12855
+ slots: config.attachmentSlots,
12856
+ task: config.promptTask,
12857
+ brief: maskOwnerBrief(config.brief, config.secretRules),
12858
+ history: recentCommits(config.cwd).map((commit) => ({
12859
+ subject: maskPathText(commit.subject, config.secretRules),
12860
+ body: maskPathText(commit.body, config.secretRules)
12861
+ })),
12862
+ overview: maskOverview(readProjectOverview(config.cwd), config.secretRules)
12863
+ }) : null;
12555
12864
  if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
12556
12865
  if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
12557
12866
  let monolithJson = null;
@@ -12627,12 +12936,12 @@ function generateSnapshot(configInput, options) {
12627
12936
  let releaseDeferred = false;
12628
12937
  try {
12629
12938
  ensureParentDirectory(outDir, "outDir");
12630
- fs15.mkdirSync(tmpDir, { recursive: true });
12939
+ fs16.mkdirSync(tmpDir, { recursive: true });
12631
12940
  cleanStaleRunDirs(tmpDir);
12632
12941
  const snapshotId = crypto4.randomUUID();
12633
12942
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
12634
- stagingDir = path16.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12635
- fs15.mkdirSync(stagingDir);
12943
+ stagingDir = path17.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12944
+ fs16.mkdirSync(stagingDir);
12636
12945
  writeOwnershipMarker(stagingDir, {
12637
12946
  generator: GENERATOR_NAME,
12638
12947
  version: GENERATOR_VERSION,
@@ -12642,30 +12951,30 @@ function generateSnapshot(configInput, options) {
12642
12951
  id: snapshotId,
12643
12952
  pid: process.pid
12644
12953
  });
12645
- const partsDir = path16.join(stagingDir, "parts");
12646
- const reportsDir = path16.join(stagingDir, "reports");
12647
- if (artifacts.parts) fs15.mkdirSync(partsDir, { recursive: true });
12954
+ const partsDir = path17.join(stagingDir, "parts");
12955
+ const reportsDir = path17.join(stagingDir, "reports");
12956
+ if (artifacts.parts) fs16.mkdirSync(partsDir, { recursive: true });
12648
12957
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || config.sarif === true) {
12649
- fs15.mkdirSync(reportsDir, { recursive: true });
12958
+ fs16.mkdirSync(reportsDir, { recursive: true });
12650
12959
  }
12651
12960
  const writtenArtifacts = /* @__PURE__ */ new Map();
12652
12961
  const writeArtifact = (targetDir, relativeEntry, data) => {
12653
- const full = path16.join(targetDir, ...relativeEntry.split("/"));
12654
- fs15.writeFileSync(full, data, "utf8");
12655
- const stats = fs15.statSync(full);
12962
+ const full = path17.join(targetDir, ...relativeEntry.split("/"));
12963
+ fs16.writeFileSync(full, data, "utf8");
12964
+ const stats = fs16.statSync(full);
12656
12965
  writtenArtifacts.set(relativeEntry, {
12657
12966
  digest: { path: relativeEntry, bytes: stats.size, sha256: sha256Hex2(data) },
12658
12967
  mtimeMs: stats.mtimeMs
12659
12968
  });
12660
12969
  };
12661
12970
  const recordArtifact = (targetDir, relativeEntry) => {
12662
- const full = path16.join(targetDir, ...relativeEntry.split("/"));
12663
- const stats = fs15.statSync(full);
12971
+ const full = path17.join(targetDir, ...relativeEntry.split("/"));
12972
+ const stats = fs16.statSync(full);
12664
12973
  writtenArtifacts.set(relativeEntry, {
12665
12974
  digest: {
12666
12975
  path: relativeEntry,
12667
12976
  bytes: stats.size,
12668
- sha256: sha256Hex2(fs15.readFileSync(full))
12977
+ sha256: sha256Hex2(fs16.readFileSync(full))
12669
12978
  },
12670
12979
  mtimeMs: stats.mtimeMs
12671
12980
  });
@@ -12713,7 +13022,7 @@ function generateSnapshot(configInput, options) {
12713
13022
  const shipHookState = () => {
12714
13023
  if (!markerBelongsTo(outDir, snapshotId)) return;
12715
13024
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
12716
- writeManifestAtomically(path16.join(outDir, "manifest.json"), manifest);
13025
+ writeManifestAtomically(path17.join(outDir, "manifest.json"), manifest);
12717
13026
  recordArtifact(outDir, "manifest.json");
12718
13027
  }
12719
13028
  writeOwnershipMarker(
@@ -12756,7 +13065,7 @@ function generateSnapshot(configInput, options) {
12756
13065
  } catch (err) {
12757
13066
  if (stagingDir !== null) {
12758
13067
  try {
12759
- fs15.rmSync(stagingDir, { recursive: true, force: true });
13068
+ fs16.rmSync(stagingDir, { recursive: true, force: true });
12760
13069
  } catch {
12761
13070
  }
12762
13071
  }
@@ -12771,8 +13080,8 @@ function generateSnapshot(configInput, options) {
12771
13080
  var pendingHooks = /* @__PURE__ */ new Map();
12772
13081
 
12773
13082
  // src/mcp/tools.ts
12774
- import * as fs17 from "fs";
12775
- import * as path18 from "path";
13083
+ import * as fs18 from "fs";
13084
+ import * as path19 from "path";
12776
13085
 
12777
13086
  // src/mcp/part.ts
12778
13087
  var FILE_HEADING = "### FILE: ";
@@ -12854,8 +13163,8 @@ function findSection(sections, relativePath) {
12854
13163
  if (exact) return exact;
12855
13164
  const foldedPath = rendered.toLowerCase();
12856
13165
  const folded = sections.filter((section) => {
12857
- const path22 = section.path.toLowerCase();
12858
- return path22 === relativePath.toLowerCase() || path22 === foldedPath;
13166
+ const path23 = section.path.toLowerCase();
13167
+ return path23 === relativePath.toLowerCase() || path23 === foldedPath;
12859
13168
  });
12860
13169
  return folded.length === 1 ? folded[0] : null;
12861
13170
  }
@@ -12879,15 +13188,15 @@ function windowText(body, fromLine, lineCount) {
12879
13188
  }
12880
13189
 
12881
13190
  // src/mcp/workspace.ts
12882
- import * as fs16 from "fs";
12883
- import * as path17 from "path";
13191
+ import * as fs17 from "fs";
13192
+ import * as path18 from "path";
12884
13193
  function foldForComparison(value) {
12885
13194
  return process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
12886
13195
  }
12887
13196
  function canonicalPath(value) {
12888
- const absolute = path17.resolve(value);
13197
+ const absolute = path18.resolve(value);
12889
13198
  try {
12890
- return fs16.realpathSync(absolute);
13199
+ return fs17.realpathSync(absolute);
12891
13200
  } catch {
12892
13201
  return absolute;
12893
13202
  }
@@ -12895,29 +13204,29 @@ function canonicalPath(value) {
12895
13204
  function isInside3(parent, child) {
12896
13205
  const foldedParent = foldForComparison(parent);
12897
13206
  const foldedChild = foldForComparison(child);
12898
- return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path17.sep}`);
13207
+ return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path18.sep}`);
12899
13208
  }
12900
13209
  function resolveThroughExistingAncestor(target) {
12901
13210
  let existing = target;
12902
13211
  const missing = [];
12903
- while (!fs16.existsSync(existing)) {
12904
- missing.unshift(path17.basename(existing));
12905
- const parent = path17.dirname(existing);
13212
+ while (!fs17.existsSync(existing)) {
13213
+ missing.unshift(path18.basename(existing));
13214
+ const parent = path18.dirname(existing);
12906
13215
  if (parent === existing) break;
12907
13216
  existing = parent;
12908
13217
  }
12909
13218
  const resolved = canonicalPath(existing);
12910
- return missing.length === 0 ? resolved : path17.join(resolved, ...missing);
13219
+ return missing.length === 0 ? resolved : path18.join(resolved, ...missing);
12911
13220
  }
12912
13221
  function resolveRoot(requested, context) {
12913
13222
  if (requested !== void 0 && (typeof requested !== "string" || requested.trim().length === 0)) {
12914
13223
  return { ok: false, message: '"root" must be a non-empty string when provided.' };
12915
13224
  }
12916
13225
  const wanted = typeof requested === "string" ? requested.trim() : context.cwd;
12917
- const absolute = path17.resolve(context.cwd, wanted);
13226
+ const absolute = path18.resolve(context.cwd, wanted);
12918
13227
  let stats;
12919
13228
  try {
12920
- stats = fs16.statSync(absolute);
13229
+ stats = fs17.statSync(absolute);
12921
13230
  } catch {
12922
13231
  return { ok: false, message: `"${wanted}" does not exist, so it cannot be a repository root.` };
12923
13232
  }
@@ -12969,7 +13278,7 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
12969
13278
  }
12970
13279
  const requested = overrides.outDir.trim();
12971
13280
  const permitted = allowedRoots !== void 0 && allowedRoots.length > 0 ? allowedRoots : [root];
12972
- const resolved = resolveThroughExistingAncestor(path17.resolve(root, requested));
13281
+ const resolved = resolveThroughExistingAncestor(path18.resolve(root, requested));
12973
13282
  if (!permitted.some((allowed) => isInside3(canonicalPath(allowed), resolved))) {
12974
13283
  const shown = permitted.map((allowed) => canonicalPath(allowed)).join(", ");
12975
13284
  return {
@@ -13002,25 +13311,25 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
13002
13311
  var MANIFEST_CACHE_LIMIT = 8;
13003
13312
  var manifestCache = /* @__PURE__ */ new Map();
13004
13313
  function manifestPathFor(workspace) {
13005
- return path17.resolve(workspace.root, workspace.config.outDir, "manifest.json");
13314
+ return path18.resolve(workspace.root, workspace.config.outDir, "manifest.json");
13006
13315
  }
13007
13316
  function partPathFor(workspace, filename) {
13008
13317
  if (filename.length === 0 || filename.includes("\0")) return null;
13009
- const partsDir = path17.resolve(workspace.root, workspace.config.outDir, "parts");
13010
- const resolved = path17.resolve(partsDir, filename);
13011
- const relative15 = path17.relative(partsDir, resolved);
13012
- if (relative15.length === 0 || relative15.includes(path17.sep) || relative15.includes("/") || relative15.includes("\\") || path17.isAbsolute(relative15)) {
13318
+ const partsDir = path18.resolve(workspace.root, workspace.config.outDir, "parts");
13319
+ const resolved = path18.resolve(partsDir, filename);
13320
+ const relative15 = path18.relative(partsDir, resolved);
13321
+ if (relative15.length === 0 || relative15.includes(path18.sep) || relative15.includes("/") || relative15.includes("\\") || path18.isAbsolute(relative15)) {
13013
13322
  return null;
13014
13323
  }
13015
13324
  let stats;
13016
13325
  try {
13017
- stats = fs16.lstatSync(resolved);
13326
+ stats = fs17.lstatSync(resolved);
13018
13327
  } catch {
13019
13328
  return null;
13020
13329
  }
13021
13330
  if (!stats.isFile()) return null;
13022
13331
  try {
13023
- if (path17.dirname(fs16.realpathSync(resolved)) !== fs16.realpathSync(partsDir)) return null;
13332
+ if (path18.dirname(fs17.realpathSync(resolved)) !== fs17.realpathSync(partsDir)) return null;
13024
13333
  } catch {
13025
13334
  return null;
13026
13335
  }
@@ -13028,10 +13337,10 @@ function partPathFor(workspace, filename) {
13028
13337
  }
13029
13338
  function readManifest3(workspace) {
13030
13339
  const file = manifestPathFor(workspace);
13031
- const shown = path17.relative(workspace.root, file).split(path17.sep).join("/") || file;
13340
+ const shown = path18.relative(workspace.root, file).split(path18.sep).join("/") || file;
13032
13341
  let stats;
13033
13342
  try {
13034
- stats = fs16.statSync(file);
13343
+ stats = fs17.statSync(file);
13035
13344
  } catch {
13036
13345
  return {
13037
13346
  ok: false,
@@ -13045,7 +13354,7 @@ function readManifest3(workspace) {
13045
13354
  }
13046
13355
  let raw;
13047
13356
  try {
13048
- raw = fs16.readFileSync(file, "utf8");
13357
+ raw = fs17.readFileSync(file, "utf8");
13049
13358
  } catch (error) {
13050
13359
  return {
13051
13360
  ok: false,
@@ -13157,7 +13466,7 @@ function formatBytes(bytes) {
13157
13466
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
13158
13467
  }
13159
13468
  function relativeFor(workspace, absolute) {
13160
- return path18.relative(workspace.root, absolute).split(path18.sep).join("/");
13469
+ return path19.relative(workspace.root, absolute).split(path19.sep).join("/");
13161
13470
  }
13162
13471
  function capped(values, limit = 20) {
13163
13472
  return { count: values.length, sample: values.slice(0, limit) };
@@ -13176,13 +13485,13 @@ function summarizeDrift(drift) {
13176
13485
  function toRelativePath(root, value) {
13177
13486
  const cleaned = value.trim();
13178
13487
  if (cleaned.length === 0 || cleaned.includes("\0")) return null;
13179
- const resolvedRoot = path18.resolve(root);
13180
- const absolute = path18.resolve(resolvedRoot, cleaned);
13181
- const relative15 = path18.relative(resolvedRoot, absolute);
13182
- if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative15)) {
13488
+ const resolvedRoot = path19.resolve(root);
13489
+ const absolute = path19.resolve(resolvedRoot, cleaned);
13490
+ const relative15 = path19.relative(resolvedRoot, absolute);
13491
+ if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path19.sep}`) || path19.isAbsolute(relative15)) {
13183
13492
  return null;
13184
13493
  }
13185
- return relative15.split(path18.sep).join("/");
13494
+ return relative15.split(path19.sep).join("/");
13186
13495
  }
13187
13496
  function symbolsOf(entry) {
13188
13497
  const summary = entry.summary;
@@ -13412,7 +13721,7 @@ var generateTool = {
13412
13721
  if (!result.ok) return failure(result.message);
13413
13722
  const summary = result.summary;
13414
13723
  forgetManifest(manifestPathFor(workspace));
13415
- const written = relativeFor(workspace, path18.resolve(workspace.root, workspace.config.outDir));
13724
+ const written = relativeFor(workspace, path19.resolve(workspace.root, workspace.config.outDir));
13416
13725
  const lines = [
13417
13726
  `Wrote ${written}/`,
13418
13727
  `Files: ${summary.totalFiles} included, ${summary.skippedCount} skipped, ${plural(summary.partsCount, "part")}`,
@@ -13813,7 +14122,7 @@ var readTool = {
13813
14122
  }
13814
14123
  let partText;
13815
14124
  try {
13816
- partText = fs17.readFileSync(partPath, "utf8");
14125
+ partText = fs18.readFileSync(partPath, "utf8");
13817
14126
  } catch {
13818
14127
  return failure(
13819
14128
  `${entry.part} could not be read, so the snapshot is damaged. Run snapshot_generate to rebuild it.`
@@ -14122,6 +14431,8 @@ var VALIDATE_OPTIONS = [
14122
14431
  "large-file-bytes",
14123
14432
  "max-monolith-bytes",
14124
14433
  "max-parts",
14434
+ "brief",
14435
+ "prompt-task",
14125
14436
  "include-monolith",
14126
14437
  "include-sensitive-files",
14127
14438
  "skip-artifacts",
@@ -14149,6 +14460,8 @@ var COMMAND_OPTION_SCOPE = {
14149
14460
  "max-monolith-bytes",
14150
14461
  "attachment-slots",
14151
14462
  "max-parts",
14463
+ "brief",
14464
+ "prompt-task",
14152
14465
  "include-monolith",
14153
14466
  "include-sensitive-files",
14154
14467
  "skip-artifacts",
@@ -14591,6 +14904,20 @@ function buildAgentContract() {
14591
14904
  appliesTo: optionAppliesTo("attachment-slots"),
14592
14905
  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."
14593
14906
  },
14907
+ {
14908
+ flag: "--brief",
14909
+ type: "string",
14910
+ default: "unset",
14911
+ appliesTo: optionAppliesTo("brief"),
14912
+ 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."
14913
+ },
14914
+ {
14915
+ flag: "--prompt-task",
14916
+ type: "string",
14917
+ default: "audit",
14918
+ appliesTo: optionAppliesTo("prompt-task"),
14919
+ summary: "Which job the brief is written for: audit (default), review or explain. It changes the opening section, not the standard."
14920
+ },
14594
14921
  {
14595
14922
  flag: "--max-parts",
14596
14923
  type: "number",
@@ -14811,6 +15138,8 @@ function buildAgentContract() {
14811
15138
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
14812
15139
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
14813
15140
  { key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
15141
+ { 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." },
15142
+ { 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." },
14814
15143
  { 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." },
14815
15144
  { 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." },
14816
15145
  { 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." },
@@ -14912,8 +15241,8 @@ function buildAgentContract() {
14912
15241
  }
14913
15242
 
14914
15243
  // src/agent/install-skill.ts
14915
- import * as fs18 from "fs";
14916
- import * as path19 from "path";
15244
+ import * as fs19 from "fs";
15245
+ import * as path20 from "path";
14917
15246
 
14918
15247
  // src/agent/skill.ts
14919
15248
  var PACKAGE_NAME2 = "codebase-snapshot";
@@ -15082,17 +15411,17 @@ var LEGACY_AGENTS_MARKER = "<!-- codebase-snapshot:skill:start -->";
15082
15411
  function targetPath(cwd, target) {
15083
15412
  switch (target) {
15084
15413
  case "claude":
15085
- return path19.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15414
+ return path20.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15086
15415
  case "cursor":
15087
- return path19.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15416
+ return path20.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15088
15417
  }
15089
15418
  }
15090
15419
  function assertWritableInsideRepository(cwd, filePath) {
15091
- const root = fs18.realpathSync(cwd);
15092
- const shown = path19.relative(root, filePath) || filePath;
15420
+ const root = fs19.realpathSync(cwd);
15421
+ const shown = path20.relative(root, filePath) || filePath;
15093
15422
  let stat = null;
15094
15423
  try {
15095
- stat = fs18.lstatSync(filePath);
15424
+ stat = fs19.lstatSync(filePath);
15096
15425
  } catch {
15097
15426
  stat = null;
15098
15427
  }
@@ -15108,32 +15437,32 @@ function assertWritableInsideRepository(cwd, filePath) {
15108
15437
  }
15109
15438
  let existing = filePath;
15110
15439
  const missing = [];
15111
- while (!fs18.existsSync(existing)) {
15112
- missing.unshift(path19.basename(existing));
15113
- const parent = path19.dirname(existing);
15440
+ while (!fs19.existsSync(existing)) {
15441
+ missing.unshift(path20.basename(existing));
15442
+ const parent = path20.dirname(existing);
15114
15443
  if (parent === existing) break;
15115
15444
  existing = parent;
15116
15445
  }
15117
- const realAncestor = fs18.realpathSync(existing);
15118
- const resolved = missing.length === 0 ? realAncestor : path19.join(realAncestor, ...missing);
15119
- if (resolved !== root && !resolved.startsWith(`${root}${path19.sep}`)) {
15446
+ const realAncestor = fs19.realpathSync(existing);
15447
+ const resolved = missing.length === 0 ? realAncestor : path20.join(realAncestor, ...missing);
15448
+ if (resolved !== root && !resolved.startsWith(`${root}${path20.sep}`)) {
15120
15449
  throw new Error(
15121
15450
  `${REFUSED}: ${shown} resolves outside the repository (${resolved}). Move it back inside ${root}, or remove the link, and run again.`
15122
15451
  );
15123
15452
  }
15124
15453
  }
15125
15454
  function writeIfChanged(target, filePath, content) {
15126
- const existing = fs18.existsSync(filePath) ? fs18.readFileSync(filePath, "utf8") : null;
15455
+ const existing = fs19.existsSync(filePath) ? fs19.readFileSync(filePath, "utf8") : null;
15127
15456
  if (existing === content) return { target, path: filePath, action: "unchanged" };
15128
- fs18.mkdirSync(path19.dirname(filePath), { recursive: true });
15129
- fs18.writeFileSync(filePath, content, "utf8");
15457
+ fs19.mkdirSync(path20.dirname(filePath), { recursive: true });
15458
+ fs19.writeFileSync(filePath, content, "utf8");
15130
15459
  return { target, path: filePath, action: existing === null ? "created" : "updated" };
15131
15460
  }
15132
15461
  function legacyAgentsNote(cwd) {
15133
- const filePath = path19.join(cwd, "AGENTS.md");
15462
+ const filePath = path20.join(cwd, "AGENTS.md");
15134
15463
  try {
15135
- if (!fs18.existsSync(filePath)) return null;
15136
- if (!fs18.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15464
+ if (!fs19.existsSync(filePath)) return null;
15465
+ if (!fs19.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15137
15466
  } catch {
15138
15467
  return null;
15139
15468
  }
@@ -15145,9 +15474,9 @@ function installSkill(cwd, target = "all") {
15145
15474
  const notes = [];
15146
15475
  const wanted = target === "all" ? ["claude", "cursor"] : [target];
15147
15476
  for (const item of wanted) assertWritableInsideRepository(cwd, targetPath(cwd, item));
15148
- const createsSomething = wanted.some((item) => !fs18.existsSync(targetPath(cwd, item)));
15477
+ const createsSomething = wanted.some((item) => !fs19.existsSync(targetPath(cwd, item)));
15149
15478
  if (createsSomething) {
15150
- assertWritableInsideRepository(cwd, path19.join(cwd, ".gitignore"));
15479
+ assertWritableInsideRepository(cwd, path20.join(cwd, ".gitignore"));
15151
15480
  }
15152
15481
  for (const item of wanted) {
15153
15482
  written.push(writeIfChanged(item, targetPath(cwd, item), skill));
@@ -15261,8 +15590,8 @@ function negotiateLegacyVersion(requested) {
15261
15590
  }
15262
15591
 
15263
15592
  // src/mcp/resources.ts
15264
- import * as fs19 from "fs";
15265
- import * as path20 from "path";
15593
+ import * as fs20 from "fs";
15594
+ import * as path21 from "path";
15266
15595
  var MAX_RESOURCE_BYTES = 512 * 1024;
15267
15596
  var ResourceTooLargeError = class extends Error {
15268
15597
  constructor(uri, bytes, limit, message) {
@@ -15312,7 +15641,7 @@ async function workspaceFor(context) {
15312
15641
  }
15313
15642
  function readFileIfPresent(file) {
15314
15643
  try {
15315
- return fs19.readFileSync(file, "utf8");
15644
+ return fs20.readFileSync(file, "utf8");
15316
15645
  } catch {
15317
15646
  return null;
15318
15647
  }
@@ -15408,7 +15737,7 @@ function buildResourceProvider() {
15408
15737
  const report = REPORT_URIS.get(uri);
15409
15738
  if (report) {
15410
15739
  const text2 = readFileIfPresent(
15411
- path20.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15740
+ path21.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15412
15741
  );
15413
15742
  if (text2 === null) return null;
15414
15743
  return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, REPORT_ADVICE) };
@@ -15430,7 +15759,7 @@ function buildResourceProvider() {
15430
15759
  if (partPath === null) return null;
15431
15760
  let partBytes;
15432
15761
  try {
15433
- partBytes = fs19.statSync(partPath).size;
15762
+ partBytes = fs20.statSync(partPath).size;
15434
15763
  } catch {
15435
15764
  return null;
15436
15765
  }
@@ -15466,52 +15795,52 @@ function validateArguments(schema, value) {
15466
15795
  }
15467
15796
  return problems;
15468
15797
  }
15469
- function checkValue(path22, schema, value) {
15798
+ function checkValue(path23, schema, value) {
15470
15799
  if (schema.enum && !schema.enum.includes(value)) {
15471
- return [`"${path22}" must be one of: ${schema.enum.join(", ")}`];
15800
+ return [`"${path23}" must be one of: ${schema.enum.join(", ")}`];
15472
15801
  }
15473
15802
  switch (schema.type) {
15474
15803
  case "string": {
15475
- if (typeof value !== "string") return [`"${path22}" must be a string`];
15804
+ if (typeof value !== "string") return [`"${path23}" must be a string`];
15476
15805
  const problems = [];
15477
15806
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
15478
- problems.push(`"${path22}" must be at least ${schema.minLength} character(s)`);
15807
+ problems.push(`"${path23}" must be at least ${schema.minLength} character(s)`);
15479
15808
  }
15480
15809
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
15481
- problems.push(`"${path22}" must be at most ${schema.maxLength} character(s)`);
15810
+ problems.push(`"${path23}" must be at most ${schema.maxLength} character(s)`);
15482
15811
  }
15483
15812
  return problems;
15484
15813
  }
15485
15814
  case "number":
15486
15815
  case "integer": {
15487
15816
  if (typeof value !== "number" || Number.isNaN(value)) {
15488
- return [`"${path22}" must be a number`];
15817
+ return [`"${path23}" must be a number`];
15489
15818
  }
15490
15819
  if (schema.type === "integer" && !Number.isInteger(value)) {
15491
- return [`"${path22}" must be an integer`];
15820
+ return [`"${path23}" must be an integer`];
15492
15821
  }
15493
15822
  const problems = [];
15494
15823
  if (schema.minimum !== void 0 && value < schema.minimum) {
15495
- problems.push(`"${path22}" must be >= ${schema.minimum}`);
15824
+ problems.push(`"${path23}" must be >= ${schema.minimum}`);
15496
15825
  }
15497
15826
  if (schema.maximum !== void 0 && value > schema.maximum) {
15498
- problems.push(`"${path22}" must be <= ${schema.maximum}`);
15827
+ problems.push(`"${path23}" must be <= ${schema.maximum}`);
15499
15828
  }
15500
15829
  return problems;
15501
15830
  }
15502
15831
  case "boolean":
15503
- return typeof value === "boolean" ? [] : [`"${path22}" must be a boolean`];
15832
+ return typeof value === "boolean" ? [] : [`"${path23}" must be a boolean`];
15504
15833
  case "array": {
15505
- if (!Array.isArray(value)) return [`"${path22}" must be an array`];
15834
+ if (!Array.isArray(value)) return [`"${path23}" must be an array`];
15506
15835
  if (!schema.items) return [];
15507
15836
  const problems = [];
15508
15837
  value.forEach((item, index) => {
15509
- problems.push(...checkValue(`${path22}[${index}]`, schema.items, item));
15838
+ problems.push(...checkValue(`${path23}[${index}]`, schema.items, item));
15510
15839
  });
15511
15840
  return problems;
15512
15841
  }
15513
15842
  case "object":
15514
- return isJsonObject(value) ? [] : [`"${path22}" must be an object`];
15843
+ return isJsonObject(value) ? [] : [`"${path23}" must be an object`];
15515
15844
  default:
15516
15845
  return [];
15517
15846
  }
@@ -16089,6 +16418,8 @@ var CLI_OPTIONS = {
16089
16418
  "max-monolith-bytes": { type: "string" },
16090
16419
  "attachment-slots": { type: "string" },
16091
16420
  "max-parts": { type: "string" },
16421
+ brief: { type: "string" },
16422
+ "prompt-task": { type: "string" },
16092
16423
  "include-monolith": { type: "boolean" },
16093
16424
  "include-sensitive-files": { type: "boolean" },
16094
16425
  "skip-artifacts": { type: "string" },
@@ -16167,6 +16498,9 @@ Options:
16167
16498
  0 = no limit); PROMPT.md plans the delivery to fit
16168
16499
  --max-parts <n> Experimental: grow the part budget until the snapshot has at
16169
16500
  most n parts, instead of adding parts as the code grows
16501
+ --brief <path> Owner-written half of PROMPT.md (stakes, system, history,
16502
+ bar, calibration); merged at fixed slots
16503
+ --prompt-task <task> audit | review | explain - which job the brief is for
16170
16504
  --skip-artifacts <names> Comma-separated artifacts to omit
16171
16505
  (readme, manifest, parts, navigation,
16172
16506
  projectTree, audit, monolith)
@@ -16239,6 +16573,13 @@ function parseCountOption(raw, optionName, minimum = 0) {
16239
16573
  }
16240
16574
  return value;
16241
16575
  }
16576
+ function parsePromptTask(value) {
16577
+ if (value === void 0) return void 0;
16578
+ if (value === "audit" || value === "review" || value === "explain") return value;
16579
+ throw new UsageError(
16580
+ '--prompt-task expects audit, review or explain, received "' + value + '".'
16581
+ );
16582
+ }
16242
16583
  function parseArtifactList(raw, flag) {
16243
16584
  const names = raw.split(",").map((name) => name.trim()).filter(Boolean);
16244
16585
  if (names.length === 0) {
@@ -16303,10 +16644,10 @@ function parseCliArgs(argv) {
16303
16644
  }
16304
16645
  if (values.cwd !== void 0) {
16305
16646
  const target = String(values.cwd);
16306
- if (!fs20.existsSync(target)) {
16647
+ if (!fs21.existsSync(target)) {
16307
16648
  throw new UsageError(`--cwd directory does not exist: ${target}`);
16308
16649
  }
16309
- if (!fs20.statSync(target).isDirectory()) {
16650
+ if (!fs21.statSync(target).isDirectory()) {
16310
16651
  throw new UsageError(`--cwd is not a directory: ${target}`);
16311
16652
  }
16312
16653
  }
@@ -16452,7 +16793,7 @@ function parseCliArgs(argv) {
16452
16793
  install: values.install === true,
16453
16794
  noInstall: values["no-install"] === true,
16454
16795
  target: values.target === void 0 ? void 0 : String(values.target),
16455
- cwd: values.cwd === void 0 ? process.cwd() : path21.resolve(String(values.cwd)),
16796
+ cwd: values.cwd === void 0 ? process.cwd() : path22.resolve(String(values.cwd)),
16456
16797
  outDir: values["out-dir"] === void 0 ? void 0 : String(values["out-dir"]),
16457
16798
  includeMonolith: values["include-monolith"] === true || onlyNamesMonolith === true ? true : void 0,
16458
16799
  includeSensitiveFiles: values["include-sensitive-files"] === true ? true : void 0,
@@ -16485,6 +16826,8 @@ function parseCliArgs(argv) {
16485
16826
  "attachment-slots"
16486
16827
  ),
16487
16828
  maxParts: parseCountOption(values["max-parts"], "max-parts", 1),
16829
+ brief: values.brief === void 0 ? void 0 : String(values.brief),
16830
+ promptTask: parsePromptTask(values["prompt-task"]),
16488
16831
  skipArtifacts,
16489
16832
  onlyArtifacts,
16490
16833
  discovery: isDiscoveryMode(rawDiscovery) ? rawDiscovery : void 0,
@@ -16538,9 +16881,9 @@ function splitList(value) {
16538
16881
  return value.split(",").map((entry) => entry.trim()).filter(Boolean);
16539
16882
  }
16540
16883
  function displayOutPath(cwd, outDir, ...segments) {
16541
- const absolute = path21.resolve(cwd, outDir, ...segments);
16542
- const relative15 = path21.relative(cwd, absolute);
16543
- if (relative15 && !relative15.startsWith("..") && !path21.isAbsolute(relative15)) return relative15;
16884
+ const absolute = path22.resolve(cwd, outDir, ...segments);
16885
+ const relative15 = path22.relative(cwd, absolute);
16886
+ if (relative15 && !relative15.startsWith("..") && !path22.isAbsolute(relative15)) return relative15;
16544
16887
  return absolute;
16545
16888
  }
16546
16889
  function nextStepHint(cwd, scriptsAddedNow) {
@@ -16548,7 +16891,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
16548
16891
  if (!hasScript) {
16549
16892
  try {
16550
16893
  const parsed = JSON.parse(
16551
- stripJsonComments(fs20.readFileSync(path21.join(cwd, "package.json"), "utf8"))
16894
+ stripJsonComments(fs21.readFileSync(path22.join(cwd, "package.json"), "utf8"))
16552
16895
  );
16553
16896
  hasScript = typeof parsed.scripts?.snapshot === "string";
16554
16897
  } catch {
@@ -16556,8 +16899,8 @@ function nextStepHint(cwd, scriptsAddedNow) {
16556
16899
  }
16557
16900
  }
16558
16901
  if (!hasScript) return `npx ${GENERATOR_NAME} generate`;
16559
- const bin = path21.join(cwd, "node_modules", ".bin", "codebase-snapshot");
16560
- const installed = fs20.existsSync(bin) || fs20.existsSync(`${bin}.cmd`);
16902
+ const bin = path22.join(cwd, "node_modules", ".bin", "codebase-snapshot");
16903
+ const installed = fs21.existsSync(bin) || fs21.existsSync(`${bin}.cmd`);
16561
16904
  return installed ? "npm run snapshot" : "npm install && npm run snapshot";
16562
16905
  }
16563
16906
  function presetSummary(init) {
@@ -16593,7 +16936,7 @@ async function runInitCommand(invocation) {
16593
16936
  if (hook) for (const note of hook.notes) info(` ${note}`);
16594
16937
  return 0;
16595
16938
  }
16596
- info(`\u2705 Created ${path21.basename(result.configPath)} (${presetSummary(result)})`);
16939
+ info(`\u2705 Created ${path22.basename(result.configPath)} (${presetSummary(result)})`);
16597
16940
  if (result.scripts.length > 0) info(` Added npm scripts: ${result.scripts.join(", ")}`);
16598
16941
  if (result.dependency.added && result.dependency.range !== null) {
16599
16942
  info(` Added devDependency: ${result.dependency.name} ${result.dependency.range}`);
@@ -16616,18 +16959,18 @@ async function runInitCommand(invocation) {
16616
16959
  function generatorOrigin(cwd) {
16617
16960
  try {
16618
16961
  const pkg = JSON.parse(
16619
- stripJsonComments(fs20.readFileSync(path21.join(cwd, "package.json"), "utf8"))
16962
+ stripJsonComments(fs21.readFileSync(path22.join(cwd, "package.json"), "utf8"))
16620
16963
  );
16621
16964
  const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
16622
16965
  if (typeof spec === "string") return `project dependency ${spec}`;
16623
16966
  } catch {
16624
16967
  }
16625
16968
  const entry = process.argv[1] ?? "";
16626
- if (entry.includes("_npx") || entry.includes(`${path21.sep}npx${path21.sep}`)) return "via npx";
16969
+ if (entry.includes("_npx") || entry.includes(`${path22.sep}npx${path22.sep}`)) return "via npx";
16627
16970
  return "global or direct install";
16628
16971
  }
16629
16972
  function detectPackageManager(cwd) {
16630
- const has = (name) => fs20.existsSync(path21.join(cwd, name));
16973
+ const has = (name) => fs21.existsSync(path22.join(cwd, name));
16631
16974
  if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
16632
16975
  if (has("pnpm-lock.yaml")) return { name: "pnpm", command: "pnpm", args: ["install"] };
16633
16976
  if (has("yarn.lock")) return { name: "yarn", command: "yarn", args: ["install"] };
@@ -16744,7 +17087,7 @@ async function runSetupCommand(invocation, options = {}) {
16744
17087
  }
16745
17088
  info("\n\u{1F9EA} Dry run \u2014 setup would:");
16746
17089
  info(
16747
- ` 1. ${init.reused ? `keep ${path21.basename(keptConfigPath)}` : `write ${path21.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
17090
+ ` 1. ${init.reused ? `keep ${path22.basename(keptConfigPath)}` : `write ${path22.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
16748
17091
  );
16749
17092
  info(" 2. add the npm scripts, the devDependency and the .gitignore entries");
16750
17093
  if (manager !== null) info(` 3. install with ${manager}`);
@@ -16757,9 +17100,9 @@ async function runSetupCommand(invocation, options = {}) {
16757
17100
  if (invocation.format !== "json") {
16758
17101
  if (!interactive) info(`\u{1F680} Setup for: ${invocation.cwd}`);
16759
17102
  if (init.reused) {
16760
- info(`\u267B Keeping ${path21.basename(keptConfigPath)}`);
17103
+ info(`\u267B Keeping ${path22.basename(keptConfigPath)}`);
16761
17104
  } else {
16762
- info(`\u2705 Created ${path21.basename(keptConfigPath)} (${presetSummary(init)})`);
17105
+ info(`\u2705 Created ${path22.basename(keptConfigPath)} (${presetSummary(init)})`);
16763
17106
  }
16764
17107
  if (init.scripts.length > 0) info(` Added npm scripts: ${init.scripts.join(", ")}`);
16765
17108
  if (init.dependency.added && init.dependency.range !== null) {
@@ -16773,7 +17116,7 @@ async function runSetupCommand(invocation, options = {}) {
16773
17116
  info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
16774
17117
  }
16775
17118
  }
16776
- const hasManifest = fs20.existsSync(path21.join(invocation.cwd, "package.json"));
17119
+ const hasManifest = fs21.existsSync(path22.join(invocation.cwd, "package.json"));
16777
17120
  let install = null;
16778
17121
  if (invocation.noInstall) {
16779
17122
  if (invocation.format !== "json") info(" Skipped the install (--no-install)");
@@ -16816,6 +17159,10 @@ async function runSetupCommand(invocation, options = {}) {
16816
17159
  if (invocation.maxParts !== void 0) {
16817
17160
  generateArgs.push("--max-parts", String(invocation.maxParts));
16818
17161
  }
17162
+ if (invocation.brief !== void 0) generateArgs.push("--brief", invocation.brief);
17163
+ if (invocation.promptTask !== void 0) {
17164
+ generateArgs.push("--prompt-task", invocation.promptTask);
17165
+ }
16819
17166
  if (invocation.skeleton === true) generateArgs.push("--skeleton");
16820
17167
  if (invocation.sarif === true) generateArgs.push("--sarif");
16821
17168
  if (invocation.noUpdateCheck) generateArgs.push("--no-update-check");
@@ -16901,7 +17248,7 @@ function runSkillCommand(invocation) {
16901
17248
  }
16902
17249
  info(`\u2705 Agent skill installed (${SKILL_NAME}):`);
16903
17250
  for (const item of result.written) {
16904
- const shown = path21.relative(invocation.cwd, item.path) || item.path;
17251
+ const shown = path22.relative(invocation.cwd, item.path) || item.path;
16905
17252
  info(` - ${item.action.padEnd(9)} ${shown}`);
16906
17253
  }
16907
17254
  if (result.gitignored.length > 0) {
@@ -17022,7 +17369,7 @@ ${USAGE}
17022
17369
  return runSkillCommand(invocation);
17023
17370
  }
17024
17371
  if (invocation.command === "mcp") {
17025
- return await runStdioServer({ cwd: path21.resolve(invocation.cwd) });
17372
+ return await runStdioServer({ cwd: path22.resolve(invocation.cwd) });
17026
17373
  }
17027
17374
  if (invocation.command === "setup") {
17028
17375
  return runSetupCommand(invocation);
@@ -17041,7 +17388,7 @@ ${USAGE}
17041
17388
  );
17042
17389
  }
17043
17390
  for (const warning of loaded.warnings) warn(`\u26A0 Config: ${warning}`);
17044
- if (loaded.file) info(`\u2699 Using config ${path21.relative(process.cwd(), loaded.file) || loaded.file}`);
17391
+ if (loaded.file) info(`\u2699 Using config ${path22.relative(process.cwd(), loaded.file) || loaded.file}`);
17045
17392
  let resolved;
17046
17393
  try {
17047
17394
  resolved = resolveConfig(
@@ -17060,6 +17407,8 @@ ${USAGE}
17060
17407
  maxMonolithBytes: invocation.maxMonolithBytes,
17061
17408
  attachmentSlots: invocation.attachmentSlots,
17062
17409
  maxParts: invocation.maxParts,
17410
+ brief: invocation.brief,
17411
+ promptTask: invocation.promptTask,
17063
17412
  skipArtifacts: invocation.skipArtifacts,
17064
17413
  // `--only-artifacts` is forwarded as itself, not only as the derived suppression list:
17065
17414
  // suppression cannot switch an artifact *on*, so a config that had turned one of the
@@ -17083,13 +17432,13 @@ ${USAGE}
17083
17432
  return result.valid ? 0 : 1;
17084
17433
  }
17085
17434
  if (invocation.command === "report") {
17086
- const manifestPath = path21.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17087
- if (!fs20.existsSync(manifestPath)) {
17435
+ const manifestPath = path22.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17436
+ if (!fs21.existsSync(manifestPath)) {
17088
17437
  return fail(invocation.format, `Manifest not found at ${manifestPath}. Run generate first.`);
17089
17438
  }
17090
17439
  let manifest;
17091
17440
  try {
17092
- manifest = JSON.parse(fs20.readFileSync(manifestPath, "utf8"));
17441
+ manifest = JSON.parse(fs21.readFileSync(manifestPath, "utf8"));
17093
17442
  } catch (err) {
17094
17443
  return fail(invocation.format, `Could not read ${manifestPath}: ${err.message}`);
17095
17444
  }
@@ -17293,19 +17642,19 @@ function finishWatchRun(state, now) {
17293
17642
  };
17294
17643
  }
17295
17644
  function comparablePath(value) {
17296
- const absolute = path21.resolve(value);
17645
+ const absolute = path22.resolve(value);
17297
17646
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
17298
17647
  }
17299
17648
  function isSameOrInside(parent, candidate) {
17300
- const relative15 = path21.relative(parent, candidate);
17301
- return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path21.sep}`) && !path21.isAbsolute(relative15);
17649
+ const relative15 = path22.relative(parent, candidate);
17650
+ return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path22.sep}`) && !path22.isAbsolute(relative15);
17302
17651
  }
17303
17652
  function isGeneratedWatchPath(candidate, paths) {
17304
- const absolute = comparablePath(path21.resolve(paths.cwd, candidate));
17305
- const outDir = comparablePath(path21.resolve(paths.cwd, paths.outDir));
17306
- const tmpDir = comparablePath(path21.resolve(paths.cwd, paths.tmpDir));
17653
+ const absolute = comparablePath(path22.resolve(paths.cwd, candidate));
17654
+ const outDir = comparablePath(path22.resolve(paths.cwd, paths.outDir));
17655
+ const tmpDir = comparablePath(path22.resolve(paths.cwd, paths.tmpDir));
17307
17656
  if (isSameOrInside(outDir, absolute) || isSameOrInside(tmpDir, absolute)) return true;
17308
- const offsets = [path21.basename(outDir), path21.basename(tmpDir)].filter((name) => name.length > 0);
17657
+ const offsets = [path22.basename(outDir), path22.basename(tmpDir)].filter((name) => name.length > 0);
17309
17658
  const leftover = absolute.split(/[\\/]+/).some(
17310
17659
  (segment) => offsets.some(
17311
17660
  (name) => segment.startsWith(`${name}.backup-`) || segment.startsWith(`${name}.partial-`)
@@ -17328,8 +17677,8 @@ function decideWatchEvent(state, event, paths) {
17328
17677
  function watchPathsFor(config) {
17329
17678
  return {
17330
17679
  cwd: config.cwd,
17331
- outDir: path21.resolve(config.cwd, config.outDir),
17332
- tmpDir: path21.resolve(config.cwd, config.tmpDir)
17680
+ outDir: path22.resolve(config.cwd, config.outDir),
17681
+ tmpDir: path22.resolve(config.cwd, config.tmpDir)
17333
17682
  };
17334
17683
  }
17335
17684
  function watchSupportProblem(platform = process.platform, version = process.versions.node) {
@@ -17387,6 +17736,8 @@ async function runWatchLoop(invocation, resolved, options) {
17387
17736
  maxMonolithBytes: invocation.maxMonolithBytes,
17388
17737
  attachmentSlots: invocation.attachmentSlots,
17389
17738
  maxParts: invocation.maxParts,
17739
+ brief: invocation.brief,
17740
+ promptTask: invocation.promptTask,
17390
17741
  skipArtifacts: invocation.skipArtifacts,
17391
17742
  onlyArtifacts: invocation.onlyArtifacts,
17392
17743
  discovery: invocation.discovery,
@@ -17416,11 +17767,11 @@ async function runWatchLoop(invocation, resolved, options) {
17416
17767
  if (!options.generatedAlready) void regenerate();
17417
17768
  let watcher;
17418
17769
  try {
17419
- watcher = fs20.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17770
+ watcher = fs21.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17420
17771
  const decision = decideWatchEvent(
17421
17772
  state,
17422
17773
  {
17423
- path: filename ? path21.resolve(resolved.cwd, filename.toString()) : null,
17774
+ path: filename ? path22.resolve(resolved.cwd, filename.toString()) : null,
17424
17775
  now: performance.now()
17425
17776
  },
17426
17777
  paths
@@ -17459,7 +17810,7 @@ async function runWatchLoop(invocation, resolved, options) {
17459
17810
  return 0;
17460
17811
  }
17461
17812
  var entryFile = process.argv[1] ?? "";
17462
- var entryName = path21.basename(entryFile).toLowerCase();
17813
+ var entryName = path22.basename(entryFile).toLowerCase();
17463
17814
  var invokedDirectly = entryName === "cli.js" || entryName === "cli.cjs";
17464
17815
  if (invokedDirectly) {
17465
17816
  void main().then(