codebase-snapshot 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.1";
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,23 @@ 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 truncateAtSentence(text2, limit) {
2644
+ if (text2.length <= limit) return text2;
2645
+ const window = text2.slice(0, limit);
2646
+ const sentence = Math.max(window.lastIndexOf(". "), window.lastIndexOf("; "));
2647
+ if (sentence > limit / 3) return window.slice(0, sentence + 1).trim();
2648
+ const space = window.lastIndexOf(" ");
2649
+ if (space > limit / 3) return window.slice(0, space).trim() + "\u2026";
2650
+ return window.trim() + "\u2026";
2651
+ }
2652
+ function recentCommits(cwd, limit = 10) {
2643
2653
  try {
2644
2654
  const stdout = childProcess.execFileSync(
2645
2655
  "git",
2646
- ["log", "-n", String(limit), "--pretty=%s", "--no-color"],
2656
+ // \x1f between fields and \x1e between records: neither can appear in a commit message, so
2657
+ // the parse cannot be confused by a message that contains a newline or a dash.
2658
+ ["log", "-n", String(limit), "--pretty=format:%s%x1f%b%x1e", "--no-color"],
2647
2659
  {
2648
2660
  cwd,
2649
2661
  stdio: ["ignore", "pipe", "ignore"],
@@ -2651,7 +2663,16 @@ function recentCommitSubjects(cwd, limit = 10) {
2651
2663
  maxBuffer: GIT_OUTPUT_LIMIT
2652
2664
  }
2653
2665
  );
2654
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
2666
+ return stdout.split("").map((record) => record.replace(/^\n+/, "")).filter((record) => record.length > 0).map((record) => {
2667
+ const separator = record.indexOf("");
2668
+ const subject = separator === -1 ? record : record.slice(0, separator);
2669
+ const rawBody = separator === -1 ? "" : record.slice(separator + 1);
2670
+ const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ").replace(/\s*\|\s*/g, " ").replace(/\s+/g, " ").trim();
2671
+ return {
2672
+ subject: subject.trim(),
2673
+ body: truncateAtSentence(body, COMMIT_BODY_LIMIT)
2674
+ };
2675
+ }).filter((commit) => commit.subject.length > 0);
2655
2676
  } catch {
2656
2677
  return [];
2657
2678
  }
@@ -3099,7 +3120,7 @@ import * as path6 from "path";
3099
3120
 
3100
3121
  // src/config.ts
3101
3122
  import * as fs3 from "fs";
3102
- import { createHash } from "crypto";
3123
+ import { createHash as createHash2 } from "crypto";
3103
3124
  import { createRequire } from "module";
3104
3125
  import * as path3 from "path";
3105
3126
  import { pathToFileURL } from "url";
@@ -3276,6 +3297,80 @@ function summarizeMarkdown(content) {
3276
3297
  };
3277
3298
  }
3278
3299
 
3300
+ // src/generator/brief.ts
3301
+ import { createHash } from "crypto";
3302
+ var OWNER_SECTIONS = ["Stakes", "The system", "What came before", "The bar", "Calibration"];
3303
+ var RESERVED_SECTIONS = [
3304
+ "The job",
3305
+ "What you have",
3306
+ "Coverage",
3307
+ "What a useful answer contains",
3308
+ "This snapshot",
3309
+ "Attaching this",
3310
+ "Your task"
3311
+ ];
3312
+ function parseOwnerBrief(filePath, text2) {
3313
+ const problems = [];
3314
+ const source = text2.replace(/^\uFEFF/, "");
3315
+ const preamble = [];
3316
+ const sections = [];
3317
+ let current = null;
3318
+ for (const line of source.split(/\r?\n/)) {
3319
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
3320
+ if (heading) {
3321
+ current = { heading: heading[1], body: [] };
3322
+ sections.push(current);
3323
+ continue;
3324
+ }
3325
+ if (current) current.body.push(line);
3326
+ else preamble.push(line);
3327
+ }
3328
+ const recognised = {};
3329
+ const notes = [];
3330
+ const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
3331
+ const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
3332
+ const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
3333
+ const seen = /* @__PURE__ */ new Set();
3334
+ for (const section of sections) {
3335
+ const body = section.body.join("\n").trim();
3336
+ const key = canonical(section.heading);
3337
+ if (seen.has(key)) {
3338
+ problems.push(
3339
+ `the brief defines "${section.heading}" twice; a section cannot say two things.`
3340
+ );
3341
+ continue;
3342
+ }
3343
+ seen.add(key);
3344
+ if (canonicalReserved.has(key)) {
3345
+ problems.push(
3346
+ `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.`
3347
+ );
3348
+ continue;
3349
+ }
3350
+ const ownerName = canonicalOwner.get(key);
3351
+ if (ownerName !== void 0) {
3352
+ recognised[ownerName] = body;
3353
+ continue;
3354
+ }
3355
+ notes.push({ heading: section.heading, body });
3356
+ }
3357
+ const preambleText = preamble.join("\n").trim();
3358
+ return {
3359
+ brief: {
3360
+ path: filePath,
3361
+ digest: createHash("sha256").update(text2, "utf8").digest("hex"),
3362
+ ...recognised["Stakes"] ? { stakes: recognised["Stakes"] } : {},
3363
+ ...recognised["The system"] ? { system: recognised["The system"] } : {},
3364
+ ...recognised["What came before"] ? { history: recognised["What came before"] } : {},
3365
+ ...recognised["The bar"] ? { bar: recognised["The bar"] } : {},
3366
+ ...recognised["Calibration"] ? { calibration: recognised["Calibration"] } : {},
3367
+ notes,
3368
+ ...preambleText.length > 0 ? { preamble: preambleText } : {}
3369
+ },
3370
+ problems
3371
+ };
3372
+ }
3373
+
3279
3374
  // src/tokenize.ts
3280
3375
  var WORD_RUN = /[A-Za-z0-9_]+/g;
3281
3376
  var SINGLE_TOKEN = /[^\sA-Za-z0-9_]/g;
@@ -3390,6 +3485,8 @@ function normalizeResolvedConfig(config) {
3390
3485
  // is re-validated because the number reaches a rendered artifact.
3391
3486
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3392
3487
  maxParts: resolveMaxParts(config.maxParts),
3488
+ promptTask: resolvePromptTask(config.promptTask),
3489
+ ...config.brief === void 0 ? {} : { brief: config.brief },
3393
3490
  includeMonolith: artifacts.monolith,
3394
3491
  secretRules: compileSecretRules(config.secretRules),
3395
3492
  artifacts,
@@ -3460,6 +3557,7 @@ var CONFIG_KEY_NAMES = [
3460
3557
  "artifacts",
3461
3558
  "attachmentSlots",
3462
3559
  "branch",
3560
+ "brief",
3463
3561
  "budgets",
3464
3562
  "changedSince",
3465
3563
  "cwd",
@@ -3481,6 +3579,7 @@ var CONFIG_KEY_NAMES = [
3481
3579
  "outDir",
3482
3580
  "preset",
3483
3581
  "previewHeadLines",
3582
+ "promptTask",
3484
3583
  "staged",
3485
3584
  "previewTailLines",
3486
3585
  "secretRules",
@@ -3531,7 +3630,7 @@ function readConfigExport(exported, file) {
3531
3630
  var lastModuleConfig = null;
3532
3631
  function moduleConfigKey(fullPath) {
3533
3632
  try {
3534
- return createHash("sha256").update(fs3.readFileSync(fullPath)).digest("hex").slice(0, 24);
3633
+ return createHash2("sha256").update(fs3.readFileSync(fullPath)).digest("hex").slice(0, 24);
3535
3634
  } catch {
3536
3635
  try {
3537
3636
  const stats = fs3.statSync(fullPath);
@@ -3765,6 +3864,38 @@ function resolveMaxParts(value) {
3765
3864
  }
3766
3865
  return value;
3767
3866
  }
3867
+ function resolvePromptTask(value) {
3868
+ if (value === void 0 || value === null) return "audit";
3869
+ if (value === "audit" || value === "review" || value === "explain") return value;
3870
+ throw new Error(
3871
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
3872
+ );
3873
+ }
3874
+ function readConfiguredBrief(cwd, value) {
3875
+ if (value === void 0 || value === null) return void 0;
3876
+ if (typeof value !== "string" || value.trim().length === 0) {
3877
+ throw new Error(
3878
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
3879
+ );
3880
+ }
3881
+ const filePath = path3.resolve(cwd, value);
3882
+ let text2;
3883
+ try {
3884
+ if (!fs3.statSync(filePath).isFile()) throw new Error("not a file");
3885
+ text2 = fs3.readFileSync(filePath, "utf8");
3886
+ } catch {
3887
+ throw new Error(
3888
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
3889
+ );
3890
+ }
3891
+ const parsed = parseOwnerBrief(value, text2);
3892
+ if (parsed.problems.length > 0) {
3893
+ throw new Error(
3894
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
3895
+ );
3896
+ }
3897
+ return parsed.brief;
3898
+ }
3768
3899
  function strictPositiveInteger(value, fallback, label) {
3769
3900
  if (value === void 0) return fallback;
3770
3901
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -4124,6 +4255,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4124
4255
  configuredSensitiveFiles,
4125
4256
  "`includeSensitiveFiles`"
4126
4257
  );
4258
+ const configuredBrief = readConfiguredBrief(
4259
+ cwd,
4260
+ cliOptions?.brief ?? userConfig?.brief
4261
+ );
4127
4262
  const presetExclude = [
4128
4263
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
4129
4264
  ];
@@ -4147,6 +4282,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4147
4282
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4148
4283
  ),
4149
4284
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4285
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
4286
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
4150
4287
  ...changedSince === void 0 ? {} : { changedSince },
4151
4288
  ...staged ? { staged } : {},
4152
4289
  ...withDependents ? { withDependents } : {},
@@ -4232,6 +4369,12 @@ function configDigest(config) {
4232
4369
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4233
4370
  // material would change the digest of every snapshot taken before the setting existed.
4234
4371
  ...config.maxParts === null ? {} : { maxParts: config.maxParts },
4372
+ // The default value is omitted for the same reason: a snapshot taken before the setting
4373
+ // existed kept the audit job, so it must keep the digest it was written with.
4374
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
4375
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
4376
+ // reader to do, so a changed brief is drift exactly like a changed budget.
4377
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
4235
4378
  artifacts: config.artifacts,
4236
4379
  include: config.include,
4237
4380
  excludePatterns: config.excludePatterns,
@@ -4270,7 +4413,7 @@ function configDigest(config) {
4270
4413
  (rule) => `${rule.rule}:${rule.pattern.source}/${rule.pattern.flags}:${rule.valueGroup ?? ""}`
4271
4414
  ).sort()
4272
4415
  };
4273
- return createHash("sha256").update(JSON.stringify(material)).digest("hex");
4416
+ return createHash2("sha256").update(JSON.stringify(material)).digest("hex");
4274
4417
  }
4275
4418
 
4276
4419
  // src/scanner/changed.ts
@@ -4318,7 +4461,7 @@ function resolveChangedScope(cwd, request) {
4318
4461
  const descriptions = [];
4319
4462
  if (request.changedSince !== void 0) {
4320
4463
  assertUsableRef(request.changedSince);
4321
- for (const path22 of gitPaths(cwd, [
4464
+ for (const path23 of gitPaths(cwd, [
4322
4465
  "diff",
4323
4466
  "--name-only",
4324
4467
  "-z",
@@ -4326,9 +4469,9 @@ function resolveChangedScope(cwd, request) {
4326
4469
  `${request.changedSince}...HEAD`,
4327
4470
  "--"
4328
4471
  ])) {
4329
- paths.add(path22);
4472
+ paths.add(path23);
4330
4473
  }
4331
- for (const path22 of gitPaths(cwd, [
4474
+ for (const path23 of gitPaths(cwd, [
4332
4475
  "diff",
4333
4476
  "--name-only",
4334
4477
  "-z",
@@ -4336,15 +4479,15 @@ function resolveChangedScope(cwd, request) {
4336
4479
  "HEAD",
4337
4480
  "--"
4338
4481
  ])) {
4339
- paths.add(path22);
4482
+ paths.add(path23);
4340
4483
  }
4341
- for (const path22 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4342
- paths.add(path22);
4484
+ for (const path23 of gitPaths(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])) {
4485
+ paths.add(path23);
4343
4486
  }
4344
4487
  descriptions.push(`changed since ${request.changedSince}`);
4345
4488
  }
4346
4489
  if (request.staged === true) {
4347
- for (const path22 of gitPaths(cwd, [
4490
+ for (const path23 of gitPaths(cwd, [
4348
4491
  "diff",
4349
4492
  "--cached",
4350
4493
  "--name-only",
@@ -4352,10 +4495,10 @@ function resolveChangedScope(cwd, request) {
4352
4495
  "--relative",
4353
4496
  "--"
4354
4497
  ])) {
4355
- paths.add(path22);
4356
- stagedPaths.add(path22);
4498
+ paths.add(path23);
4499
+ stagedPaths.add(path23);
4357
4500
  }
4358
- for (const path22 of gitPaths(cwd, [
4501
+ for (const path23 of gitPaths(cwd, [
4359
4502
  "diff",
4360
4503
  "--cached",
4361
4504
  "--name-only",
@@ -4364,7 +4507,7 @@ function resolveChangedScope(cwd, request) {
4364
4507
  "--diff-filter=D",
4365
4508
  "--"
4366
4509
  ])) {
4367
- deletedPaths.add(path22);
4510
+ deletedPaths.add(path23);
4368
4511
  }
4369
4512
  descriptions.push("staged");
4370
4513
  }
@@ -5190,9 +5333,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
5190
5333
  var jvmProfile = {
5191
5334
  id: "jvm",
5192
5335
  extensions: [".java", ".kt", ".kts", ".scala"],
5193
- summarize(path22, content) {
5336
+ summarize(path23, content) {
5194
5337
  const summary = emptySummary();
5195
- const lower = path22.toLowerCase();
5338
+ const lower = path23.toLowerCase();
5196
5339
  const isJava = lower.endsWith(".java");
5197
5340
  const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
5198
5341
  eachLine(content, (line) => {
@@ -5513,17 +5656,17 @@ var rustProfile = {
5513
5656
  var SCRIPT_BLOCK = /<script([^>]*)>([\s\S]*?)<\/script>/gi;
5514
5657
  var JSX_LANG = /\blang\s*=\s*["']?[tj]sx\b/i;
5515
5658
  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;
5659
+ function componentName(path23) {
5660
+ const base = path23.split("/").pop() ?? path23;
5518
5661
  return base.replace(/\.[^.]+$/, "");
5519
5662
  }
5520
5663
  var sfcProfile = {
5521
5664
  id: "sfc",
5522
5665
  extensions: [".vue", ".svelte", ".astro"],
5523
- summarize(path22, content) {
5666
+ summarize(path23, content) {
5524
5667
  let script = "";
5525
- let usesJsx = path22.toLowerCase().endsWith(".astro");
5526
- if (path22.toLowerCase().endsWith(".astro")) {
5668
+ let usesJsx = path23.toLowerCase().endsWith(".astro");
5669
+ if (path23.toLowerCase().endsWith(".astro")) {
5527
5670
  const frontmatter = ASTRO_FRONTMATTER.exec(content);
5528
5671
  if (frontmatter) script += `${frontmatter[1]}
5529
5672
  `;
@@ -5533,7 +5676,7 @@ var sfcProfile = {
5533
5676
  script += `${match[2]}
5534
5677
  `;
5535
5678
  }
5536
- const name = componentName(path22);
5679
+ const name = componentName(path23);
5537
5680
  if (!script.trim()) {
5538
5681
  const summary2 = emptySummary();
5539
5682
  if (name) {
@@ -5724,15 +5867,15 @@ for (const profile of LANGUAGE_PROFILES) {
5724
5867
  BY_EXTENSION.set(extension.toLowerCase(), profile);
5725
5868
  }
5726
5869
  }
5727
- function profileForPath(path22) {
5728
- const lower = path22.toLowerCase();
5870
+ function profileForPath(path23) {
5871
+ const lower = path23.toLowerCase();
5729
5872
  const dot = lower.lastIndexOf(".");
5730
5873
  if (dot === -1) return null;
5731
5874
  return BY_EXTENSION.get(lower.slice(dot)) ?? null;
5732
5875
  }
5733
- function summarizeWithProfile(path22, content) {
5734
- const profile = profileForPath(path22);
5735
- return profile ? profile.summarize(path22, content) : null;
5876
+ function summarizeWithProfile(path23, content) {
5877
+ const profile = profileForPath(path23);
5878
+ return profile ? profile.summarize(path23, content) : null;
5736
5879
  }
5737
5880
 
5738
5881
  // src/scanner/binary.ts
@@ -7961,6 +8104,10 @@ function renderConfig(answers) {
7961
8104
  // Experimental: grow the per-part budget until the snapshot fits this many parts, instead of
7962
8105
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
7963
8106
  // maxParts: 10,
8107
+ // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
8108
+ // brief: "docs/brief.md",
8109
+ // Which job the brief is written for: audit, review or explain.
8110
+ // promptTask: "audit",
7964
8111
  // afterGenerate: (manifest) => { /* write your own artifact */ }
7965
8112
  hooks: {},
7966
8113
  };
@@ -8999,9 +9146,9 @@ async function runWithStdoutCapture(fn) {
8999
9146
  }
9000
9147
 
9001
9148
  // src/index.ts
9002
- import * as fs15 from "fs";
9149
+ import * as fs16 from "fs";
9003
9150
  import * as os2 from "os";
9004
- import * as path16 from "path";
9151
+ import * as path17 from "path";
9005
9152
 
9006
9153
  // src/generator/audit.ts
9007
9154
  function generateAuditReport(manifest, secretFindings, secretRules) {
@@ -9782,9 +9929,15 @@ var UNLIMITED_SLOTS = 0;
9782
9929
  var ENTRY_POINT = /(^|\/)(index|cli|main|bin|server|app|mod)\.[cm]?[jt]sx?$/;
9783
9930
  var TEST_PATH = /(^|\/)(tests?|__tests__)\//;
9784
9931
  var TEST_FILE = /\.(test|spec)\.[^.]+$/;
9785
- function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMENT_SLOTS, history = []) {
9932
+ function generatePrompt(manifest, artifacts, context = {}) {
9933
+ const slots = context.slots ?? DEFAULT_ATTACHMENT_SLOTS;
9934
+ const task = context.task ?? "audit";
9935
+ const history = context.history ?? [];
9936
+ const overview = context.overview ?? { releases: [] };
9937
+ const brief = context.brief;
9786
9938
  const wrote = (name) => artifacts?.[name] !== false;
9787
9939
  const code = (value) => inlineCode(escapeControls(value));
9940
+ const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
9788
9941
  const lines = [
9789
9942
  "# PROMPT.md",
9790
9943
  "",
@@ -9800,30 +9953,22 @@ function generatePrompt(manifest, artifacts, attachmentSlots = DEFAULT_ATTACHMEN
9800
9953
  "You are working on a codebase you cannot clone, run or grep. Everything you know about it comes",
9801
9954
  "from the snapshot that follows this instruction. Where these notes and the snapshot disagree,",
9802
9955
  "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
9956
  ""
9817
9957
  ];
9958
+ if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
9959
+ lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
9960
+ lines.push(...stakesSection(brief, code));
9818
9961
  lines.push(...haveSection(wrote), "");
9819
- lines.push(...systemSection(manifest, code), "");
9820
- lines.push(...historySection(history), "");
9821
- lines.push(...barSection(), "");
9962
+ lines.push(...whatThisIsSection(overview), "");
9963
+ lines.push(...systemSection(manifest, code, brief), "");
9964
+ lines.push(...historySection(history, brief, code), "");
9965
+ lines.push(...barSection(brief, code), "");
9822
9966
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
9823
9967
  lines.push(...answerSection(), "");
9824
- lines.push(...calibrationSection(), "");
9968
+ lines.push(...calibrationSection(brief, code), "");
9969
+ lines.push(...ownerNotesSection(brief, code));
9825
9970
  lines.push(...snapshotSection(manifest, code), "");
9826
- lines.push(...deliverySection(manifest, wrote("parts"), attachmentSlots));
9971
+ lines.push(...deliverySection(manifest, wrote("parts"), slots));
9827
9972
  lines.push(
9828
9973
  "## Your task",
9829
9974
  "",
@@ -9900,8 +10045,11 @@ function haveSection(wrote) {
9900
10045
  out.push(...bullets);
9901
10046
  return out;
9902
10047
  }
9903
- function systemSection(manifest, code) {
10048
+ function systemSection(manifest, code, brief) {
9904
10049
  const out = ["## The system", ""];
10050
+ if (brief?.system !== void 0) {
10051
+ out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
10052
+ }
9905
10053
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
9906
10054
  if (layers.length > 0) {
9907
10055
  const shown = layers.slice(0, MAX_LAYER_ROWS).map(([name, count]) => code(name) + " " + formatNumber(count));
@@ -9916,7 +10064,7 @@ function systemSection(manifest, code) {
9916
10064
  " A change here reaches the most call sites; read it before judging anything that uses it."
9917
10065
  );
9918
10066
  }
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);
10067
+ 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
10068
  out.push(
9921
10069
  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
10070
  );
@@ -9959,8 +10107,9 @@ function systemSection(manifest, code) {
9959
10107
  }
9960
10108
  return out;
9961
10109
  }
9962
- function historySection(history) {
10110
+ function historySection(history, brief, code) {
9963
10111
  const out = ["## What came before", ""];
10112
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
9964
10113
  if (history.length === 0) {
9965
10114
  out.push(
9966
10115
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -9969,15 +10118,21 @@ function historySection(history) {
9969
10118
  return out;
9970
10119
  }
9971
10120
  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.",
10121
+ "The last " + formatNumber(history.length) + " " + (history.length === 1 ? "commit" : "commits") + ", newest first. Subjects and bodies are claims",
10122
+ "by whoever wrote them, not evidence - the code beside them is the evidence. If one of these",
10123
+ "fixes looks incomplete, quote the lines and say which call site it missed.",
9975
10124
  ""
9976
10125
  );
9977
- for (const subject of history) out.push("- " + subject);
10126
+ for (const commit of history) {
10127
+ out.push("- " + commit.subject);
10128
+ if (commit.body.length > 0) out.push(" " + commit.body);
10129
+ }
9978
10130
  return out;
9979
10131
  }
9980
- function barSection() {
10132
+ function barSection(brief, code) {
10133
+ if (brief?.bar !== void 0) {
10134
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
10135
+ }
9981
10136
  return [
9982
10137
  "## The bar",
9983
10138
  "",
@@ -10035,7 +10190,10 @@ function answerSection() {
10035
10190
  " the gap you filled by asking instead of guessing."
10036
10191
  ];
10037
10192
  }
10038
- function calibrationSection() {
10193
+ function calibrationSection(brief, code) {
10194
+ if (brief?.calibration !== void 0) {
10195
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
10196
+ }
10039
10197
  return [
10040
10198
  "## Calibration",
10041
10199
  "",
@@ -10050,6 +10208,84 @@ function calibrationSection() {
10050
10208
  "None of these throw. All are invisible in a summary."
10051
10209
  ];
10052
10210
  }
10211
+ function jobSection(task, hasHistory) {
10212
+ const out = ["## The job", ""];
10213
+ if (task === "audit") {
10214
+ out.push(
10215
+ "Find what is still wrong or will break. How you read the code is yours to decide - by",
10216
+ "subsystem, by data flow, by the invariants you derive yourself. What you owe in return is an",
10217
+ "honest account of what you covered and what you did not.",
10218
+ ""
10219
+ );
10220
+ if (hasHistory) {
10221
+ out.push(
10222
+ "Another pass of the same findings is worth nothing. This repository carries a record of",
10223
+ "what was already fixed, below. Verify that those fixes hold instead of rediscovering them,",
10224
+ "and treat a variant of one at a different call site as a new finding."
10225
+ );
10226
+ } else {
10227
+ out.push(
10228
+ "Another pass of the same findings is worth nothing, but no earlier round is readable here,",
10229
+ "so you cannot tell what has already been tried. Do not assume this is the first attempt."
10230
+ );
10231
+ }
10232
+ out.push(
10233
+ "",
10234
+ "If the task at the end asks for something narrower - explain a file, review a change, answer",
10235
+ "a question - that task wins. The standard and the coverage duty below still apply to it."
10236
+ );
10237
+ } else if (task === "review") {
10238
+ out.push(
10239
+ "Review the change or the area named in the task against this snapshot. Report what breaks,",
10240
+ "what the change claims but does not do, and what a reader would believe that the code does",
10241
+ "not support. Restating the diff is not a review; the standard and the coverage duty below",
10242
+ "still apply."
10243
+ );
10244
+ } else {
10245
+ out.push(
10246
+ "Explain how the part of the system named in the task works: the data flow, the boundaries",
10247
+ "and the invariants it depends on. Cite the lines. If the snapshot does not contain what you",
10248
+ "need, say which file you need rather than reconstructing it from the shape of the names."
10249
+ );
10250
+ }
10251
+ return out;
10252
+ }
10253
+ function stakesSection(brief, code) {
10254
+ if (brief?.stakes === void 0) return [];
10255
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
10256
+ }
10257
+ function whatThisIsSection(overview) {
10258
+ const body = [];
10259
+ if (overview.description !== void 0) {
10260
+ body.push("- Declared in `package.json`: " + overview.description);
10261
+ }
10262
+ if (overview.summary !== void 0) {
10263
+ body.push("- From the `README.md` first paragraph: " + overview.summary);
10264
+ }
10265
+ if (overview.releases.length > 0) {
10266
+ body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
10267
+ }
10268
+ if (body.length === 0) return [];
10269
+ return [
10270
+ "## What this is",
10271
+ "",
10272
+ ...body,
10273
+ "",
10274
+ "Those are the project's own claims, not evidence about the code.",
10275
+ ""
10276
+ ];
10277
+ }
10278
+ function ownerNotesSection(brief, code) {
10279
+ if (brief === void 0 || brief.notes.length === 0) return [];
10280
+ const out = ["## Owner notes", ""];
10281
+ for (const note of brief.notes) {
10282
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
10283
+ }
10284
+ return out;
10285
+ }
10286
+ function ownerBlock(text2, path23, code) {
10287
+ return ["> Written by the project owner in " + code(path23) + ", not generated.", "", text2];
10288
+ }
10053
10289
  function snapshotSection(manifest, code) {
10054
10290
  const out = ["## This snapshot", ""];
10055
10291
  out.push("- Fingerprint: " + code(manifest.fingerprint) + " - quote it verbatim in your answer.");
@@ -10148,7 +10384,8 @@ function deliverySection(manifest, partsWritten, slots) {
10148
10384
  );
10149
10385
  if (parts > 1) {
10150
10386
  out.push(
10151
- " Either raise `--max-part-bytes` to merge the parts, or set `--max-parts " + slots + "` and let the parts grow to the count instead."
10387
+ " Either raise `--max-part-bytes` to merge the parts, or set",
10388
+ " `--max-parts " + slots + "` and let the parts grow to the count instead."
10152
10389
  );
10153
10390
  }
10154
10391
  } else {
@@ -10363,12 +10600,74 @@ function treeTruncationWarnings(treeText) {
10363
10600
  return warnings;
10364
10601
  }
10365
10602
 
10366
- // src/update-check.ts
10603
+ // src/generator/overview.ts
10367
10604
  import * as fs13 from "fs";
10605
+ import * as path13 from "path";
10606
+ var SUMMARY_LIMIT = 400;
10607
+ var MAX_RELEASES = 2;
10608
+ function readProjectOverview(cwd) {
10609
+ return {
10610
+ ...readDescription(cwd),
10611
+ ...readSummary(cwd),
10612
+ releases: readReleases(cwd)
10613
+ };
10614
+ }
10615
+ function readText(file) {
10616
+ try {
10617
+ return fs13.readFileSync(file, "utf8");
10618
+ } catch {
10619
+ return null;
10620
+ }
10621
+ }
10622
+ function readDescription(cwd) {
10623
+ const raw = readText(path13.join(cwd, "package.json"));
10624
+ if (raw === null) return {};
10625
+ try {
10626
+ const parsed = JSON.parse(stripJsonComments(raw));
10627
+ return typeof parsed.description === "string" && parsed.description.trim().length > 0 ? { description: parsed.description.trim() } : {};
10628
+ } catch {
10629
+ return {};
10630
+ }
10631
+ }
10632
+ function readSummary(cwd) {
10633
+ const raw = readText(path13.join(cwd, "README.md"));
10634
+ if (raw === null) return {};
10635
+ const text2 = raw.replace(/<h[1-6][^>]*>[\s\S]*?<\/h[1-6]>/gi, "\n").replace(/<\/(p|div|section|header|footer|li)>/gi, "\n").replace(/<br\s*\/?>/gi, " ").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
10636
+ const paragraph = [];
10637
+ for (const line of text2.split(/\r?\n/)) {
10638
+ const trimmed = line.trim();
10639
+ if (paragraph.length === 0) {
10640
+ if (trimmed.length === 0) continue;
10641
+ if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
10642
+ if (/^\[[^\]]+\]:/.test(trimmed)) continue;
10643
+ } else if (trimmed.length === 0 || /^#/.test(trimmed)) {
10644
+ break;
10645
+ }
10646
+ paragraph.push(trimmed);
10647
+ }
10648
+ const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
10649
+ if (summary.length === 0) return {};
10650
+ return { summary: truncate(summary, SUMMARY_LIMIT) };
10651
+ }
10652
+ function truncate(text2, limit) {
10653
+ if (text2.length <= limit) return text2;
10654
+ const window = text2.slice(0, limit);
10655
+ const space = window.lastIndexOf(" ");
10656
+ return (space > limit / 2 ? window.slice(0, space) : window).trim() + "\u2026";
10657
+ }
10658
+ function readReleases(cwd) {
10659
+ const raw = readText(path13.join(cwd, "CHANGELOG.md"));
10660
+ if (raw === null) return [];
10661
+ const headings = raw.split(/\r?\n/).map((line) => /^##\s+(.+?)\s*$/.exec(line)?.[1]?.trim()).filter((heading) => heading !== void 0 && /^v?\d+\.\d+/.test(heading));
10662
+ return headings.slice(0, MAX_RELEASES);
10663
+ }
10664
+
10665
+ // src/update-check.ts
10666
+ import * as fs14 from "fs";
10368
10667
  import * as http from "http";
10369
10668
  import * as https from "https";
10370
10669
  import * as os from "os";
10371
- import * as path13 from "path";
10670
+ import * as path14 from "path";
10372
10671
  var PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
10373
10672
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
10374
10673
  var UP_TO_DATE_INTERVAL_MS = 60 * 60 * 1e3;
@@ -10417,17 +10716,17 @@ function isNewer(candidate, current) {
10417
10716
  }
10418
10717
  function cacheDirectory(env = process.env, platform = process.platform) {
10419
10718
  if (platform === "win32") {
10420
- const base2 = env.LOCALAPPDATA ?? path13.join(os.homedir(), "AppData", "Local");
10421
- return path13.join(base2, "codebase-snapshot");
10719
+ const base2 = env.LOCALAPPDATA ?? path14.join(os.homedir(), "AppData", "Local");
10720
+ return path14.join(base2, "codebase-snapshot");
10422
10721
  }
10423
10722
  if (platform === "darwin") {
10424
- return path13.join(os.homedir(), "Library", "Caches", "codebase-snapshot");
10723
+ return path14.join(os.homedir(), "Library", "Caches", "codebase-snapshot");
10425
10724
  }
10426
- const base = env.XDG_CACHE_HOME ?? path13.join(os.homedir(), ".cache");
10427
- return path13.join(base, "codebase-snapshot");
10725
+ const base = env.XDG_CACHE_HOME ?? path14.join(os.homedir(), ".cache");
10726
+ return path14.join(base, "codebase-snapshot");
10428
10727
  }
10429
10728
  function cacheFilePath(env = process.env) {
10430
- return path13.join(cacheDirectory(env), "update-check.json");
10729
+ return path14.join(cacheDirectory(env), "update-check.json");
10431
10730
  }
10432
10731
  function shouldCheck(argv, env) {
10433
10732
  const disabled = ["1", "true", "yes"].includes(
@@ -10457,7 +10756,7 @@ function shouldCheck(argv, env) {
10457
10756
  function readCache(file) {
10458
10757
  let raw;
10459
10758
  try {
10460
- raw = fs13.readFileSync(file, "utf8");
10759
+ raw = fs14.readFileSync(file, "utf8");
10461
10760
  } catch {
10462
10761
  return null;
10463
10762
  }
@@ -10474,8 +10773,8 @@ function readCache(file) {
10474
10773
  }
10475
10774
  function writeCache(file, entry) {
10476
10775
  try {
10477
- fs13.mkdirSync(path13.dirname(file), { recursive: true });
10478
- fs13.writeFileSync(file, `${JSON.stringify(entry)}
10776
+ fs14.mkdirSync(path14.dirname(file), { recursive: true });
10777
+ fs14.writeFileSync(file, `${JSON.stringify(entry)}
10479
10778
  `, "utf8");
10480
10779
  } catch {
10481
10780
  }
@@ -10568,8 +10867,8 @@ function formatUpdateNotice(notice, kind) {
10568
10867
 
10569
10868
  // src/agent/hook.ts
10570
10869
  import * as childProcess2 from "child_process";
10571
- import * as fs14 from "fs";
10572
- import * as path14 from "path";
10870
+ import * as fs15 from "fs";
10871
+ import * as path15 from "path";
10573
10872
  var HOOK_MARKER = `# ${GENERATOR_NAME}: pre-commit snapshot check`;
10574
10873
  function shellQuote(value) {
10575
10874
  return value.replace(/[\\"`$]/g, (character) => `\\${character}`);
@@ -10611,36 +10910,36 @@ fi
10611
10910
  `;
10612
10911
  }
10613
10912
  function gitDirectory(cwd) {
10614
- const dotGit = path14.join(cwd, ".git");
10913
+ const dotGit = path15.join(cwd, ".git");
10615
10914
  let stats;
10616
10915
  try {
10617
- stats = fs14.statSync(dotGit);
10916
+ stats = fs15.statSync(dotGit);
10618
10917
  } catch {
10619
10918
  return null;
10620
10919
  }
10621
10920
  if (stats.isDirectory()) return dotGit;
10622
10921
  if (!stats.isFile()) return null;
10623
10922
  try {
10624
- const contents = fs14.readFileSync(dotGit, "utf8");
10923
+ const contents = fs15.readFileSync(dotGit, "utf8");
10625
10924
  const match = /^gitdir:\s*(.+)$/m.exec(contents);
10626
10925
  if (!match) return null;
10627
10926
  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;
10927
+ const resolved = path15.isAbsolute(target.trim()) ? target.trim() : path15.join(cwd, target.trim());
10928
+ if (!fs15.statSync(resolved).isDirectory()) return null;
10929
+ if (isInside2(path15.resolve(cwd), path15.resolve(resolved))) return resolved;
10930
+ return isRegisteredWorktree(path15.resolve(resolved), cwd) ? resolved : null;
10632
10931
  } catch {
10633
10932
  return null;
10634
10933
  }
10635
10934
  }
10636
10935
  function isInside2(parent, child) {
10637
- const relative15 = path14.relative(parent, child);
10638
- return relative15 === "" || !relative15.startsWith("..") && !path14.isAbsolute(relative15);
10936
+ const relative15 = path15.relative(parent, child);
10937
+ return relative15 === "" || !relative15.startsWith("..") && !path15.isAbsolute(relative15);
10639
10938
  }
10640
10939
  function isRegisteredWorktree(gitDir, cwd) {
10641
10940
  try {
10642
- const back = fs14.readFileSync(path14.join(gitDir, "gitdir"), "utf8").trim();
10643
- return path14.resolve(gitDir, back) === path14.join(path14.resolve(cwd), ".git");
10941
+ const back = fs15.readFileSync(path15.join(gitDir, "gitdir"), "utf8").trim();
10942
+ return path15.resolve(gitDir, back) === path15.join(path15.resolve(cwd), ".git");
10644
10943
  } catch {
10645
10944
  return false;
10646
10945
  }
@@ -10661,10 +10960,10 @@ function gitOutput(cwd, args) {
10661
10960
  function configuredHooksDirectory(cwd) {
10662
10961
  const hooks = gitOutput(cwd, ["rev-parse", "--git-path", "hooks"]);
10663
10962
  if (hooks === null) return null;
10664
- const resolved = path14.resolve(cwd, hooks);
10963
+ const resolved = path15.resolve(cwd, hooks);
10665
10964
  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 };
10965
+ const commonDir = common === null ? null : path15.resolve(cwd, common);
10966
+ if (isInside2(path15.resolve(cwd), resolved)) return { dir: resolved };
10668
10967
  if (commonDir !== null && isInside2(commonDir, resolved)) return { dir: resolved };
10669
10968
  return {
10670
10969
  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 +10984,10 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10685
10984
  ]
10686
10985
  };
10687
10986
  }
10688
- const hooksDir = configured === null ? path14.join(gitDir, "hooks") : configured.dir;
10689
- const hookPath = path14.join(hooksDir, "pre-commit");
10987
+ const hooksDir = configured === null ? path15.join(gitDir, "hooks") : configured.dir;
10988
+ const hookPath = path15.join(hooksDir, "pre-commit");
10690
10989
  try {
10691
- fs14.mkdirSync(hooksDir, { recursive: true });
10990
+ fs15.mkdirSync(hooksDir, { recursive: true });
10692
10991
  } catch (err) {
10693
10992
  return {
10694
10993
  path: hookPath,
@@ -10698,7 +10997,7 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10698
10997
  }
10699
10998
  let existing = null;
10700
10999
  try {
10701
- existing = fs14.readFileSync(hookPath, "utf8");
11000
+ existing = fs15.readFileSync(hookPath, "utf8");
10702
11001
  } catch {
10703
11002
  existing = null;
10704
11003
  }
@@ -10713,8 +11012,8 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10713
11012
  };
10714
11013
  }
10715
11014
  try {
10716
- fs14.writeFileSync(hookPath, hookScript(outDir), "utf8");
10717
- fs14.chmodSync(hookPath, 493);
11015
+ fs15.writeFileSync(hookPath, hookScript(outDir), "utf8");
11016
+ fs15.chmodSync(hookPath, 493);
10718
11017
  } catch (err) {
10719
11018
  return {
10720
11019
  path: hookPath,
@@ -10732,11 +11031,11 @@ function installPreCommitHook(cwd, outDir = "snapshot") {
10732
11031
  }
10733
11032
 
10734
11033
  // src/mcp/generate-worker.ts
10735
- import * as path15 from "path";
11034
+ import * as path16 from "path";
10736
11035
  import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "url";
10737
11036
  import { Worker } from "worker_threads";
10738
11037
  function workerEntry(directory, isCjs) {
10739
- const entry = path15.join(directory, isCjs ? "index.cjs" : "index.js");
11038
+ const entry = path16.join(directory, isCjs ? "index.cjs" : "index.js");
10740
11039
  return { path: entry, url: pathToFileURL2(entry).href };
10741
11040
  }
10742
11041
  var WORKER_SOURCE = `
@@ -10803,7 +11102,7 @@ function generateInWorker(cwd, cliOptions, options = {}) {
10803
11102
  resolve12(result);
10804
11103
  };
10805
11104
  const isCjs = typeof __dirname !== "undefined";
10806
- const directory = isCjs ? __dirname : path15.dirname(fileURLToPath(import.meta.url));
11105
+ const directory = isCjs ? __dirname : path16.dirname(fileURLToPath(import.meta.url));
10807
11106
  try {
10808
11107
  worker = new Worker(WORKER_SOURCE, {
10809
11108
  eval: true,
@@ -10838,23 +11137,23 @@ var SUMMARY_MAX_SOURCE_BYTES2 = SUMMARY_MAX_SOURCE_BYTES;
10838
11137
  var FILE_DERIVATIONS = /* @__PURE__ */ new Map();
10839
11138
  var FILE_DERIVATION_LIMIT_BYTES = 64 * 1024 * 1024;
10840
11139
  var fileDerivationBytes = 0;
10841
- function takeDerivation(path22, hash, settings) {
10842
- const cached = FILE_DERIVATIONS.get(path22);
11140
+ function takeDerivation(path23, hash, settings) {
11141
+ const cached = FILE_DERIVATIONS.get(path23);
10843
11142
  if (cached === void 0 || cached.hash !== hash || cached.settings !== settings) return void 0;
10844
- FILE_DERIVATIONS.delete(path22);
10845
- FILE_DERIVATIONS.set(path22, cached);
11143
+ FILE_DERIVATIONS.delete(path23);
11144
+ FILE_DERIVATIONS.set(path23, cached);
10846
11145
  return cached;
10847
11146
  }
10848
- function rememberDerivation(path22, hash, settings, derivation) {
11147
+ function rememberDerivation(path23, hash, settings, derivation) {
10849
11148
  const bodyBytes = derivation.finalContent === derivation.redacted ? derivation.redacted.length : derivation.redacted.length + derivation.finalContent.length;
10850
11149
  const bytes = bodyBytes * 2 + 512;
10851
11150
  if (bytes > FILE_DERIVATION_LIMIT_BYTES / 4) return;
10852
- const previous = FILE_DERIVATIONS.get(path22);
11151
+ const previous = FILE_DERIVATIONS.get(path23);
10853
11152
  if (previous !== void 0) {
10854
- FILE_DERIVATIONS.delete(path22);
11153
+ FILE_DERIVATIONS.delete(path23);
10855
11154
  fileDerivationBytes -= previous.bytes;
10856
11155
  } else {
10857
- FILE_DERIVATIONS.delete(path22);
11156
+ FILE_DERIVATIONS.delete(path23);
10858
11157
  }
10859
11158
  while (fileDerivationBytes + bytes > FILE_DERIVATION_LIMIT_BYTES) {
10860
11159
  const oldest = FILE_DERIVATIONS.keys().next();
@@ -10863,7 +11162,7 @@ function rememberDerivation(path22, hash, settings, derivation) {
10863
11162
  FILE_DERIVATIONS.delete(oldest.value);
10864
11163
  if (evicted !== void 0) fileDerivationBytes -= evicted.bytes;
10865
11164
  }
10866
- FILE_DERIVATIONS.set(path22, { ...derivation, hash, settings, bytes });
11165
+ FILE_DERIVATIONS.set(path23, { ...derivation, hash, settings, bytes });
10867
11166
  fileDerivationBytes += bytes;
10868
11167
  }
10869
11168
  function derivationSettings(config) {
@@ -11115,11 +11414,11 @@ function verifyInMemory(files, parts, unaccounted) {
11115
11414
  return errors;
11116
11415
  }
11117
11416
  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}`);
11417
+ const cwd = path17.resolve(config.cwd);
11418
+ const outDir = path17.resolve(cwd, config.outDir);
11419
+ const tmpDir = path17.resolve(cwd, config.tmpDir);
11420
+ const root = path17.parse(cwd).root;
11421
+ const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path17.sep}`);
11123
11422
  const reject = (reason) => {
11124
11423
  throw new Error(
11125
11424
  `Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
@@ -11159,6 +11458,28 @@ function maskSummaryStrings(value, secretRules) {
11159
11458
  function maskPathText(value, secretRules) {
11160
11459
  return findSecretInPath(value, secretRules)?.masked ?? value;
11161
11460
  }
11461
+ function maskOwnerBrief(brief, secretRules) {
11462
+ if (brief === void 0) return void 0;
11463
+ const mask = (value) => maskPathText(value, secretRules);
11464
+ return {
11465
+ ...brief,
11466
+ ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11467
+ ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11468
+ ...brief.history === void 0 ? {} : { history: mask(brief.history) },
11469
+ ...brief.bar === void 0 ? {} : { bar: mask(brief.bar) },
11470
+ ...brief.calibration === void 0 ? {} : { calibration: mask(brief.calibration) },
11471
+ ...brief.preamble === void 0 ? {} : { preamble: mask(brief.preamble) },
11472
+ notes: brief.notes.map((note) => ({ heading: note.heading, body: mask(note.body) }))
11473
+ };
11474
+ }
11475
+ function maskOverview(overview, secretRules) {
11476
+ const mask = (value) => maskPathText(value, secretRules);
11477
+ return {
11478
+ ...overview.description === void 0 ? {} : { description: mask(overview.description) },
11479
+ ...overview.summary === void 0 ? {} : { summary: mask(overview.summary) },
11480
+ releases: overview.releases.map(mask)
11481
+ };
11482
+ }
11162
11483
  function maskSkipRecords(records, secretRules) {
11163
11484
  return maskSkipPaths(records, secretRules);
11164
11485
  }
@@ -11179,14 +11500,14 @@ function listEntries(dir) {
11179
11500
  const walk = (absolute, prefix) => {
11180
11501
  let children;
11181
11502
  try {
11182
- children = fs15.readdirSync(absolute, { withFileTypes: true });
11503
+ children = fs16.readdirSync(absolute, { withFileTypes: true });
11183
11504
  } catch {
11184
11505
  return;
11185
11506
  }
11186
11507
  for (const child of children) {
11187
11508
  const relative15 = prefix === "" ? child.name : `${prefix}/${child.name}`;
11188
11509
  entries.push(relative15);
11189
- if (child.isDirectory()) walk(path16.join(absolute, child.name), relative15);
11510
+ if (child.isDirectory()) walk(path17.join(absolute, child.name), relative15);
11190
11511
  }
11191
11512
  };
11192
11513
  walk(dir, "");
@@ -11198,10 +11519,10 @@ function markerInventory(dir, written) {
11198
11519
  for (const entry of entries) {
11199
11520
  if (entry === OWNERSHIP_MARKER) continue;
11200
11521
  if (isIgnorableEntry(entry)) continue;
11201
- const full = path16.join(dir, ...entry.split("/"));
11522
+ const full = path17.join(dir, ...entry.split("/"));
11202
11523
  let stats;
11203
11524
  try {
11204
- stats = fs15.lstatSync(full);
11525
+ stats = fs16.lstatSync(full);
11205
11526
  } catch {
11206
11527
  continue;
11207
11528
  }
@@ -11213,7 +11534,7 @@ function markerInventory(dir, written) {
11213
11534
  }
11214
11535
  let digest;
11215
11536
  try {
11216
- digest = sha256Hex2(fs15.readFileSync(full));
11537
+ digest = sha256Hex2(fs16.readFileSync(full));
11217
11538
  } catch {
11218
11539
  continue;
11219
11540
  }
@@ -11234,15 +11555,15 @@ function markerPayload(dir, state, id, createdAt, written) {
11234
11555
  entries,
11235
11556
  files
11236
11557
  };
11237
- const manifestPath = path16.join(dir, "manifest.json");
11238
- if (fs15.existsSync(manifestPath)) {
11239
- marker2.manifestSha256 = sha256Hex2(fs15.readFileSync(manifestPath));
11558
+ const manifestPath = path17.join(dir, "manifest.json");
11559
+ if (fs16.existsSync(manifestPath)) {
11560
+ marker2.manifestSha256 = sha256Hex2(fs16.readFileSync(manifestPath));
11240
11561
  }
11241
11562
  return marker2;
11242
11563
  }
11243
11564
  function writeOwnershipMarker(dir, marker2) {
11244
- fs15.writeFileSync(
11245
- path16.join(dir, OWNERSHIP_MARKER),
11565
+ fs16.writeFileSync(
11566
+ path17.join(dir, OWNERSHIP_MARKER),
11246
11567
  `${JSON.stringify(marker2, null, 2)}
11247
11568
  `,
11248
11569
  "utf8"
@@ -11254,13 +11575,13 @@ function markerBelongsTo(dir, id) {
11254
11575
  return evidence.marker.id === id;
11255
11576
  }
11256
11577
  function readOwnershipMarker(dir) {
11257
- const markerPath = path16.join(dir, OWNERSHIP_MARKER);
11258
- if (!fs15.existsSync(markerPath)) {
11578
+ const markerPath = path17.join(dir, OWNERSHIP_MARKER);
11579
+ if (!fs16.existsSync(markerPath)) {
11259
11580
  return { marker: null, problem: "it holds no .codebase-snapshot marker" };
11260
11581
  }
11261
11582
  let raw;
11262
11583
  try {
11263
- raw = fs15.readFileSync(markerPath, "utf8");
11584
+ raw = fs16.readFileSync(markerPath, "utf8");
11264
11585
  } catch {
11265
11586
  return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
11266
11587
  }
@@ -11360,10 +11681,10 @@ function verifyMarkerInventory(dir, entries, files) {
11360
11681
  for (const entry of entries) {
11361
11682
  if (entry === OWNERSHIP_MARKER) continue;
11362
11683
  if (IGNORABLE_ENTRIES.has(entry.slice(entry.lastIndexOf("/") + 1))) continue;
11363
- const full = path16.join(dir, ...entry.split("/"));
11684
+ const full = path17.join(dir, ...entry.split("/"));
11364
11685
  let stats;
11365
11686
  try {
11366
- stats = fs15.lstatSync(full);
11687
+ stats = fs16.lstatSync(full);
11367
11688
  } catch {
11368
11689
  return `its .codebase-snapshot inventory lists ${entry}, which cannot be read`;
11369
11690
  }
@@ -11388,7 +11709,7 @@ function verifyMarkerInventory(dir, entries, files) {
11388
11709
  }
11389
11710
  let digest;
11390
11711
  try {
11391
- digest = sha256Hex2(fs15.readFileSync(full));
11712
+ digest = sha256Hex2(fs16.readFileSync(full));
11392
11713
  } catch {
11393
11714
  return `its .codebase-snapshot inventory cannot verify ${entry}: the file could not be read`;
11394
11715
  }
@@ -11409,12 +11730,12 @@ function assessSnapshotDirectory(dir) {
11409
11730
  marker: marker2
11410
11731
  };
11411
11732
  }
11412
- const manifestPath = path16.join(dir, "manifest.json");
11413
- const hasManifest = fs15.existsSync(manifestPath);
11733
+ const manifestPath = path17.join(dir, "manifest.json");
11734
+ const hasManifest = fs16.existsSync(manifestPath);
11414
11735
  if (hasManifest) {
11415
11736
  let raw;
11416
11737
  try {
11417
- raw = fs15.readFileSync(manifestPath, "utf8");
11738
+ raw = fs16.readFileSync(manifestPath, "utf8");
11418
11739
  } catch {
11419
11740
  return {
11420
11741
  owned: false,
@@ -11509,13 +11830,13 @@ function containsNoFiles(dir) {
11509
11830
  const current = pending.pop();
11510
11831
  let entries;
11511
11832
  try {
11512
- entries = fs15.readdirSync(current, { withFileTypes: true });
11833
+ entries = fs16.readdirSync(current, { withFileTypes: true });
11513
11834
  } catch {
11514
11835
  return false;
11515
11836
  }
11516
11837
  for (const entry of entries) {
11517
11838
  if (entry.isDirectory()) {
11518
- pending.push(path16.join(current, entry.name));
11839
+ pending.push(path17.join(current, entry.name));
11519
11840
  } else if (!IGNORABLE_ENTRIES.has(entry.name)) {
11520
11841
  return false;
11521
11842
  }
@@ -11524,13 +11845,13 @@ function containsNoFiles(dir) {
11524
11845
  return true;
11525
11846
  }
11526
11847
  function assertReplaceable(target, label, secretRules) {
11527
- if (!fs15.existsSync(target)) return;
11528
- if (!fs15.statSync(target).isDirectory()) {
11848
+ if (!fs16.existsSync(target)) return;
11849
+ if (!fs16.statSync(target).isDirectory()) {
11529
11850
  throw new Error(
11530
11851
  `Refusing to write into ${label} ${target}: it exists but is not a directory.`
11531
11852
  );
11532
11853
  }
11533
- const entries = fs15.readdirSync(target);
11854
+ const entries = fs16.readdirSync(target);
11534
11855
  if (entries.length === 0) return;
11535
11856
  if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
11536
11857
  if (containsNoFiles(target)) return;
@@ -11550,18 +11871,18 @@ function assertReplaceable(target, label, secretRules) {
11550
11871
  );
11551
11872
  }
11552
11873
  function assertStagingRootUsable(tmpDir, secretRules) {
11553
- if (!fs15.existsSync(tmpDir)) return;
11554
- if (!fs15.statSync(tmpDir).isDirectory()) {
11874
+ if (!fs16.existsSync(tmpDir)) return;
11875
+ if (!fs16.statSync(tmpDir).isDirectory()) {
11555
11876
  throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
11556
11877
  }
11557
- const entries = fs15.readdirSync(tmpDir);
11878
+ const entries = fs16.readdirSync(tmpDir);
11558
11879
  if (entries.length === 0) return;
11559
11880
  const foreign = entries.filter((name) => {
11560
- const full = path16.join(tmpDir, name);
11881
+ const full = path17.join(tmpDir, name);
11561
11882
  if (!name.startsWith(RUN_DIR_PREFIX)) return true;
11562
11883
  let stats;
11563
11884
  try {
11564
- stats = fs15.statSync(full);
11885
+ stats = fs16.statSync(full);
11565
11886
  } catch {
11566
11887
  return true;
11567
11888
  }
@@ -11569,7 +11890,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11569
11890
  const { marker: marker2 } = readOwnershipMarker(full);
11570
11891
  if (marker2) return false;
11571
11892
  try {
11572
- return fs15.readdirSync(full).length > 0;
11893
+ return fs16.readdirSync(full).length > 0;
11573
11894
  } catch {
11574
11895
  return true;
11575
11896
  }
@@ -11584,13 +11905,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
11584
11905
  function cleanStaleRunDirs(tmpDir) {
11585
11906
  let entries;
11586
11907
  try {
11587
- entries = fs15.readdirSync(tmpDir);
11908
+ entries = fs16.readdirSync(tmpDir);
11588
11909
  } catch {
11589
11910
  return;
11590
11911
  }
11591
11912
  for (const name of entries) {
11592
11913
  if (!name.startsWith(RUN_DIR_PREFIX)) continue;
11593
- const full = path16.join(tmpDir, name);
11914
+ const full = path17.join(tmpDir, name);
11594
11915
  const { marker: marker2 } = readOwnershipMarker(full);
11595
11916
  if (marker2) {
11596
11917
  const created = Date.parse(marker2.createdAt);
@@ -11598,33 +11919,33 @@ function cleanStaleRunDirs(tmpDir) {
11598
11919
  const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
11599
11920
  if (aged || abandoned) {
11600
11921
  try {
11601
- fs15.rmSync(full, { recursive: true, force: true });
11922
+ fs16.rmSync(full, { recursive: true, force: true });
11602
11923
  } catch {
11603
11924
  }
11604
11925
  }
11605
11926
  continue;
11606
11927
  }
11607
11928
  try {
11608
- if (fs15.readdirSync(full).length === 0) fs15.rmSync(full, { recursive: true, force: true });
11929
+ if (fs16.readdirSync(full).length === 0) fs16.rmSync(full, { recursive: true, force: true });
11609
11930
  } catch {
11610
11931
  }
11611
11932
  }
11612
11933
  }
11613
11934
  function removeIfEmpty(dir) {
11614
11935
  try {
11615
- if (fs15.readdirSync(dir).length === 0) fs15.rmSync(dir, { recursive: true, force: true });
11936
+ if (fs16.readdirSync(dir).length === 0) fs16.rmSync(dir, { recursive: true, force: true });
11616
11937
  } catch {
11617
11938
  }
11618
11939
  }
11619
11940
  function ensureParentDirectory(target, label) {
11620
- const parent = path16.dirname(target);
11621
- if (fs15.existsSync(parent) && !fs15.statSync(parent).isDirectory()) {
11941
+ const parent = path17.dirname(target);
11942
+ if (fs16.existsSync(parent) && !fs16.statSync(parent).isDirectory()) {
11622
11943
  throw new Error(
11623
11944
  `Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
11624
11945
  );
11625
11946
  }
11626
11947
  try {
11627
- fs15.mkdirSync(parent, { recursive: true });
11948
+ fs16.mkdirSync(parent, { recursive: true });
11628
11949
  } catch (err) {
11629
11950
  throw new Error(
11630
11951
  `Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
@@ -11682,17 +12003,17 @@ function acquireRunLock(stagingRoot) {
11682
12003
  `;
11683
12004
  for (let attempt = 0; attempt < 2; attempt += 1) {
11684
12005
  try {
11685
- const handle = fs15.openSync(lockPath, "wx");
12006
+ const handle = fs16.openSync(lockPath, "wx");
11686
12007
  try {
11687
- fs15.writeSync(handle, payload);
12008
+ fs16.writeSync(handle, payload);
11688
12009
  } finally {
11689
- fs15.closeSync(handle);
12010
+ fs16.closeSync(handle);
11690
12011
  }
11691
12012
  const stopHeartbeat = startLockHeartbeat(lockPath);
11692
12013
  return () => {
11693
12014
  stopHeartbeat();
11694
12015
  try {
11695
- fs15.rmSync(lockPath, { force: true });
12016
+ fs16.rmSync(lockPath, { force: true });
11696
12017
  } catch {
11697
12018
  }
11698
12019
  };
@@ -11712,26 +12033,26 @@ function lockKeyFor(stagingRoot) {
11712
12033
  return sha256Hex2(key).slice(0, 16);
11713
12034
  }
11714
12035
  function canonicalLockTarget(targetPath2) {
11715
- const resolved = path16.resolve(targetPath2);
12036
+ const resolved = path17.resolve(targetPath2);
11716
12037
  let existing = resolved;
11717
12038
  const tail = [];
11718
12039
  for (; ; ) {
11719
12040
  try {
11720
- return path16.join(fs15.realpathSync(existing), ...tail);
12041
+ return path17.join(fs16.realpathSync(existing), ...tail);
11721
12042
  } catch {
11722
- const parent = path16.dirname(existing);
12043
+ const parent = path17.dirname(existing);
11723
12044
  if (parent === existing) return resolved;
11724
- tail.unshift(path16.basename(existing));
12045
+ tail.unshift(path17.basename(existing));
11725
12046
  existing = parent;
11726
12047
  }
11727
12048
  }
11728
12049
  }
11729
12050
  function lockPathFor(stagingRoot) {
11730
- return path16.join(os2.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
12051
+ return path17.join(os2.tmpdir(), `codebase-snapshot-${lockKeyFor(stagingRoot)}.lock`);
11731
12052
  }
11732
12053
  function lockHeartbeatAgeMs(lockPath) {
11733
12054
  try {
11734
- return Date.now() - fs15.statSync(lockPath).mtimeMs;
12055
+ return Date.now() - fs16.statSync(lockPath).mtimeMs;
11735
12056
  } catch {
11736
12057
  return Number.POSITIVE_INFINITY;
11737
12058
  }
@@ -11739,7 +12060,7 @@ function lockHeartbeatAgeMs(lockPath) {
11739
12060
  function lockOwnerIsGone(lockPath) {
11740
12061
  let raw;
11741
12062
  try {
11742
- raw = fs15.readFileSync(lockPath, "utf8");
12063
+ raw = fs16.readFileSync(lockPath, "utf8");
11743
12064
  } catch {
11744
12065
  return false;
11745
12066
  }
@@ -11761,16 +12082,16 @@ function lockOwnerIsGone(lockPath) {
11761
12082
  function reclaimStaleLock(lockPath) {
11762
12083
  let before;
11763
12084
  try {
11764
- before = fs15.statSync(lockPath);
12085
+ before = fs16.statSync(lockPath);
11765
12086
  } catch {
11766
12087
  return true;
11767
12088
  }
11768
12089
  if (!lockOwnerIsGone(lockPath)) return false;
11769
12090
  try {
11770
- const current = fs15.statSync(lockPath);
12091
+ const current = fs16.statSync(lockPath);
11771
12092
  const sameFile = current.ino === before.ino && current.birthtimeMs === before.birthtimeMs && current.mtimeMs === before.mtimeMs;
11772
12093
  if (!sameFile) return false;
11773
- fs15.rmSync(lockPath, { force: true });
12094
+ fs16.rmSync(lockPath, { force: true });
11774
12095
  return true;
11775
12096
  } catch {
11776
12097
  return false;
@@ -11781,12 +12102,12 @@ function lockFileIsAncient(lockPath) {
11781
12102
  }
11782
12103
  function writeManifestAtomically(manifestPath, manifest) {
11783
12104
  const tempPath = `${manifestPath}.${process.pid}.tmp`;
11784
- fs15.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
12105
+ fs16.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
11785
12106
  try {
11786
- fs15.renameSync(tempPath, manifestPath);
12107
+ fs16.renameSync(tempPath, manifestPath);
11787
12108
  } catch (err) {
11788
12109
  try {
11789
- fs15.rmSync(tempPath, { force: true });
12110
+ fs16.rmSync(tempPath, { force: true });
11790
12111
  } catch {
11791
12112
  }
11792
12113
  throw err;
@@ -11811,21 +12132,21 @@ function swapIntoPlace(stagingDir, outDir, beforeSwap) {
11811
12132
  }
11812
12133
  }
11813
12134
  function recoverInterruptedPublish(outDir) {
11814
- if (fs15.existsSync(outDir)) return;
11815
- const parent = path16.dirname(outDir);
11816
- const base = path16.basename(outDir);
12135
+ if (fs16.existsSync(outDir)) return;
12136
+ const parent = path17.dirname(outDir);
12137
+ const base = path17.basename(outDir);
11817
12138
  let backups;
11818
12139
  try {
11819
- backups = fs15.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
12140
+ backups = fs16.readdirSync(parent).filter((name) => name.startsWith(`${base}.backup-`));
11820
12141
  } catch {
11821
12142
  return;
11822
12143
  }
11823
12144
  if (backups.length !== 1) return;
11824
- const backupDir = path16.join(parent, backups[0]);
12145
+ const backupDir = path17.join(parent, backups[0]);
11825
12146
  const { marker: marker2, problem } = readOwnershipMarker(backupDir);
11826
12147
  if (problem !== null || marker2 === null || marker2.state !== "complete") return;
11827
12148
  try {
11828
- fs15.renameSync(backupDir, outDir);
12149
+ fs16.renameSync(backupDir, outDir);
11829
12150
  process.stderr.write(
11830
12151
  `\u26A0 Recovered ${outDir} from ${backupDir}, left by an interrupted run. That snapshot is the one from before the interrupted run.
11831
12152
  `
@@ -11835,16 +12156,16 @@ function recoverInterruptedPublish(outDir) {
11835
12156
  }
11836
12157
  function swapOnce(stagingDir, outDir, beforeSwap) {
11837
12158
  const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
11838
- const hadPrevious = fs15.existsSync(outDir);
12159
+ const hadPrevious = fs16.existsSync(outDir);
11839
12160
  if (hadPrevious) beforeSwap?.();
11840
12161
  let movedAside = false;
11841
12162
  if (hadPrevious) {
11842
12163
  try {
11843
- fs15.renameSync(outDir, backupDir);
12164
+ fs16.renameSync(outDir, backupDir);
11844
12165
  movedAside = true;
11845
12166
  } catch (err) {
11846
12167
  if (!isLockError(err)) throw err;
11847
- fs15.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
12168
+ fs16.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
11848
12169
  process.stderr.write(
11849
12170
  `\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
12171
  `
@@ -11853,26 +12174,26 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11853
12174
  }
11854
12175
  try {
11855
12176
  try {
11856
- fs15.renameSync(stagingDir, outDir);
12177
+ fs16.renameSync(stagingDir, outDir);
11857
12178
  } catch (err) {
11858
12179
  if (err.code !== "EXDEV") throw err;
11859
12180
  const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
11860
12181
  try {
11861
- fs15.cpSync(stagingDir, partialDir, { recursive: true });
11862
- fs15.renameSync(partialDir, outDir);
11863
- fs15.rmSync(stagingDir, { recursive: true, force: true });
12182
+ fs16.cpSync(stagingDir, partialDir, { recursive: true });
12183
+ fs16.renameSync(partialDir, outDir);
12184
+ fs16.rmSync(stagingDir, { recursive: true, force: true });
11864
12185
  } catch (copyErr) {
11865
12186
  try {
11866
- fs15.rmSync(partialDir, { recursive: true, force: true });
12187
+ fs16.rmSync(partialDir, { recursive: true, force: true });
11867
12188
  } catch {
11868
12189
  }
11869
12190
  throw copyErr;
11870
12191
  }
11871
12192
  }
11872
12193
  } 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);
12194
+ if (hadPrevious && movedAside && fs16.existsSync(backupDir)) {
12195
+ if (fs16.existsSync(outDir)) fs16.rmSync(outDir, { recursive: true, force: true });
12196
+ fs16.renameSync(backupDir, outDir);
11876
12197
  } else if (hadPrevious && !movedAside) {
11877
12198
  process.stderr.write(
11878
12199
  `\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 +12204,7 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
11883
12204
  }
11884
12205
  if (hadPrevious) {
11885
12206
  try {
11886
- fs15.rmSync(backupDir, { recursive: true, force: true });
12207
+ fs16.rmSync(backupDir, { recursive: true, force: true });
11887
12208
  } catch (err) {
11888
12209
  process.stderr.write(
11889
12210
  `\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 +12362,7 @@ function generateSnapshot(configInput, options) {
12041
12362
  // first run cannot have marked them yet, so the name alone keeps a run from recording its own
12042
12363
  // output — but only at these exact paths, not at every directory that shares the name.
12043
12364
  toolOwnedPaths: [config.outDir, config.tmpDir].map(
12044
- (directory) => path16.relative(config.cwd, path16.resolve(config.cwd, directory)).replace(/\\/g, "/")
12365
+ (directory) => path17.relative(config.cwd, path17.resolve(config.cwd, directory)).replace(/\\/g, "/")
12045
12366
  ).filter((relative15) => relative15.length > 0 && !relative15.startsWith("..")),
12046
12367
  // A staged path can be absent from the working tree while its index blob exists. Discovery
12047
12368
  // lists the working tree, so those paths would never reach the scan at all.
@@ -12070,7 +12391,7 @@ function generateSnapshot(configInput, options) {
12070
12391
  let totalSizeBytes = 0;
12071
12392
  let largeFileCount = 0;
12072
12393
  for (const relativePath of candidateFiles) {
12073
- const absolutePath = path16.join(config.cwd, relativePath);
12394
+ const absolutePath = path17.join(config.cwd, relativePath);
12074
12395
  const fromIndex = stagedPaths.has(relativePath);
12075
12396
  let buffer;
12076
12397
  let sizeBytes;
@@ -12101,9 +12422,9 @@ function generateSnapshot(configInput, options) {
12101
12422
  } else {
12102
12423
  let stats;
12103
12424
  try {
12104
- stats = fs15.statSync(absolutePath);
12425
+ stats = fs16.statSync(absolutePath);
12105
12426
  if (!stats.isFile()) {
12106
- const nestedRepository = stats.isDirectory() && fs15.existsSync(path16.join(absolutePath, ".git"));
12427
+ const nestedRepository = stats.isDirectory() && fs16.existsSync(path17.join(absolutePath, ".git"));
12107
12428
  skipped.push(
12108
12429
  nestedRepository ? {
12109
12430
  path: relativePath,
@@ -12139,7 +12460,7 @@ function generateSnapshot(configInput, options) {
12139
12460
  continue;
12140
12461
  }
12141
12462
  try {
12142
- buffer = fs15.readFileSync(absolutePath);
12463
+ buffer = fs16.readFileSync(absolutePath);
12143
12464
  } catch (err) {
12144
12465
  const code = err.code;
12145
12466
  skipped.push({
@@ -12268,14 +12589,14 @@ function generateSnapshot(configInput, options) {
12268
12589
  (finding) => finding.path === void 0 || keep.has(finding.path)
12269
12590
  );
12270
12591
  retain(encodingNotes, (note) => keep.has(note.path));
12271
- retain(oversizeSummaryPaths, (path22) => keep.has(path22));
12272
- retain(previewSummaryPaths, (path22) => keep.has(path22));
12592
+ retain(oversizeSummaryPaths, (path23) => keep.has(path23));
12593
+ retain(previewSummaryPaths, (path23) => keep.has(path23));
12273
12594
  retain(fileWarnings, (warning) => keep.has(warning.path));
12274
- for (const path22 of [...monolithBodies.keys()]) {
12275
- if (!keep.has(path22)) monolithBodies.delete(path22);
12595
+ for (const path23 of [...monolithBodies.keys()]) {
12596
+ if (!keep.has(path23)) monolithBodies.delete(path23);
12276
12597
  }
12277
- for (const path22 of [...skippedSummaryImports.keys()]) {
12278
- if (!keep.has(path22)) skippedSummaryImports.delete(path22);
12598
+ for (const path23 of [...skippedSummaryImports.keys()]) {
12599
+ if (!keep.has(path23)) skippedSummaryImports.delete(path23);
12279
12600
  }
12280
12601
  }
12281
12602
  if (changedScope !== null) {
@@ -12414,6 +12735,8 @@ function generateSnapshot(configInput, options) {
12414
12735
  // omitted from `digest` when it is off so an existing snapshot does not start reporting
12415
12736
  // configuration drift.
12416
12737
  maxParts: config.maxParts ?? null,
12738
+ promptTask: config.promptTask,
12739
+ ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12417
12740
  discovery: config.discovery ?? "auto",
12418
12741
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12419
12742
  // describes the run has to name it.
@@ -12544,14 +12867,16 @@ function generateSnapshot(configInput, options) {
12544
12867
  if (auditText !== null) manifest.artifacts.audit = artifactRecord(auditText);
12545
12868
  const readmeText = artifacts.readme ? generateReadme(manifest, artifacts) : null;
12546
12869
  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;
12870
+ const promptText = artifacts.prompt ? generatePrompt(manifest, artifacts, {
12871
+ slots: config.attachmentSlots,
12872
+ task: config.promptTask,
12873
+ brief: maskOwnerBrief(config.brief, config.secretRules),
12874
+ history: recentCommits(config.cwd).map((commit) => ({
12875
+ subject: maskPathText(commit.subject, config.secretRules),
12876
+ body: maskPathText(commit.body, config.secretRules)
12877
+ })),
12878
+ overview: maskOverview(readProjectOverview(config.cwd), config.secretRules)
12879
+ }) : null;
12555
12880
  if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
12556
12881
  if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
12557
12882
  let monolithJson = null;
@@ -12627,12 +12952,12 @@ function generateSnapshot(configInput, options) {
12627
12952
  let releaseDeferred = false;
12628
12953
  try {
12629
12954
  ensureParentDirectory(outDir, "outDir");
12630
- fs15.mkdirSync(tmpDir, { recursive: true });
12955
+ fs16.mkdirSync(tmpDir, { recursive: true });
12631
12956
  cleanStaleRunDirs(tmpDir);
12632
12957
  const snapshotId = crypto4.randomUUID();
12633
12958
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
12634
- stagingDir = path16.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12635
- fs15.mkdirSync(stagingDir);
12959
+ stagingDir = path17.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
12960
+ fs16.mkdirSync(stagingDir);
12636
12961
  writeOwnershipMarker(stagingDir, {
12637
12962
  generator: GENERATOR_NAME,
12638
12963
  version: GENERATOR_VERSION,
@@ -12642,30 +12967,30 @@ function generateSnapshot(configInput, options) {
12642
12967
  id: snapshotId,
12643
12968
  pid: process.pid
12644
12969
  });
12645
- const partsDir = path16.join(stagingDir, "parts");
12646
- const reportsDir = path16.join(stagingDir, "reports");
12647
- if (artifacts.parts) fs15.mkdirSync(partsDir, { recursive: true });
12970
+ const partsDir = path17.join(stagingDir, "parts");
12971
+ const reportsDir = path17.join(stagingDir, "reports");
12972
+ if (artifacts.parts) fs16.mkdirSync(partsDir, { recursive: true });
12648
12973
  if (artifacts.navigation || artifacts.projectTree || artifacts.audit || config.sarif === true) {
12649
- fs15.mkdirSync(reportsDir, { recursive: true });
12974
+ fs16.mkdirSync(reportsDir, { recursive: true });
12650
12975
  }
12651
12976
  const writtenArtifacts = /* @__PURE__ */ new Map();
12652
12977
  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);
12978
+ const full = path17.join(targetDir, ...relativeEntry.split("/"));
12979
+ fs16.writeFileSync(full, data, "utf8");
12980
+ const stats = fs16.statSync(full);
12656
12981
  writtenArtifacts.set(relativeEntry, {
12657
12982
  digest: { path: relativeEntry, bytes: stats.size, sha256: sha256Hex2(data) },
12658
12983
  mtimeMs: stats.mtimeMs
12659
12984
  });
12660
12985
  };
12661
12986
  const recordArtifact = (targetDir, relativeEntry) => {
12662
- const full = path16.join(targetDir, ...relativeEntry.split("/"));
12663
- const stats = fs15.statSync(full);
12987
+ const full = path17.join(targetDir, ...relativeEntry.split("/"));
12988
+ const stats = fs16.statSync(full);
12664
12989
  writtenArtifacts.set(relativeEntry, {
12665
12990
  digest: {
12666
12991
  path: relativeEntry,
12667
12992
  bytes: stats.size,
12668
- sha256: sha256Hex2(fs15.readFileSync(full))
12993
+ sha256: sha256Hex2(fs16.readFileSync(full))
12669
12994
  },
12670
12995
  mtimeMs: stats.mtimeMs
12671
12996
  });
@@ -12713,7 +13038,7 @@ function generateSnapshot(configInput, options) {
12713
13038
  const shipHookState = () => {
12714
13039
  if (!markerBelongsTo(outDir, snapshotId)) return;
12715
13040
  if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
12716
- writeManifestAtomically(path16.join(outDir, "manifest.json"), manifest);
13041
+ writeManifestAtomically(path17.join(outDir, "manifest.json"), manifest);
12717
13042
  recordArtifact(outDir, "manifest.json");
12718
13043
  }
12719
13044
  writeOwnershipMarker(
@@ -12756,7 +13081,7 @@ function generateSnapshot(configInput, options) {
12756
13081
  } catch (err) {
12757
13082
  if (stagingDir !== null) {
12758
13083
  try {
12759
- fs15.rmSync(stagingDir, { recursive: true, force: true });
13084
+ fs16.rmSync(stagingDir, { recursive: true, force: true });
12760
13085
  } catch {
12761
13086
  }
12762
13087
  }
@@ -12771,8 +13096,8 @@ function generateSnapshot(configInput, options) {
12771
13096
  var pendingHooks = /* @__PURE__ */ new Map();
12772
13097
 
12773
13098
  // src/mcp/tools.ts
12774
- import * as fs17 from "fs";
12775
- import * as path18 from "path";
13099
+ import * as fs18 from "fs";
13100
+ import * as path19 from "path";
12776
13101
 
12777
13102
  // src/mcp/part.ts
12778
13103
  var FILE_HEADING = "### FILE: ";
@@ -12854,8 +13179,8 @@ function findSection(sections, relativePath) {
12854
13179
  if (exact) return exact;
12855
13180
  const foldedPath = rendered.toLowerCase();
12856
13181
  const folded = sections.filter((section) => {
12857
- const path22 = section.path.toLowerCase();
12858
- return path22 === relativePath.toLowerCase() || path22 === foldedPath;
13182
+ const path23 = section.path.toLowerCase();
13183
+ return path23 === relativePath.toLowerCase() || path23 === foldedPath;
12859
13184
  });
12860
13185
  return folded.length === 1 ? folded[0] : null;
12861
13186
  }
@@ -12879,15 +13204,15 @@ function windowText(body, fromLine, lineCount) {
12879
13204
  }
12880
13205
 
12881
13206
  // src/mcp/workspace.ts
12882
- import * as fs16 from "fs";
12883
- import * as path17 from "path";
13207
+ import * as fs17 from "fs";
13208
+ import * as path18 from "path";
12884
13209
  function foldForComparison(value) {
12885
13210
  return process.platform === "win32" || process.platform === "darwin" ? value.toLowerCase() : value;
12886
13211
  }
12887
13212
  function canonicalPath(value) {
12888
- const absolute = path17.resolve(value);
13213
+ const absolute = path18.resolve(value);
12889
13214
  try {
12890
- return fs16.realpathSync(absolute);
13215
+ return fs17.realpathSync(absolute);
12891
13216
  } catch {
12892
13217
  return absolute;
12893
13218
  }
@@ -12895,29 +13220,29 @@ function canonicalPath(value) {
12895
13220
  function isInside3(parent, child) {
12896
13221
  const foldedParent = foldForComparison(parent);
12897
13222
  const foldedChild = foldForComparison(child);
12898
- return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path17.sep}`);
13223
+ return foldedChild === foldedParent || foldedChild.startsWith(`${foldedParent}${path18.sep}`);
12899
13224
  }
12900
13225
  function resolveThroughExistingAncestor(target) {
12901
13226
  let existing = target;
12902
13227
  const missing = [];
12903
- while (!fs16.existsSync(existing)) {
12904
- missing.unshift(path17.basename(existing));
12905
- const parent = path17.dirname(existing);
13228
+ while (!fs17.existsSync(existing)) {
13229
+ missing.unshift(path18.basename(existing));
13230
+ const parent = path18.dirname(existing);
12906
13231
  if (parent === existing) break;
12907
13232
  existing = parent;
12908
13233
  }
12909
13234
  const resolved = canonicalPath(existing);
12910
- return missing.length === 0 ? resolved : path17.join(resolved, ...missing);
13235
+ return missing.length === 0 ? resolved : path18.join(resolved, ...missing);
12911
13236
  }
12912
13237
  function resolveRoot(requested, context) {
12913
13238
  if (requested !== void 0 && (typeof requested !== "string" || requested.trim().length === 0)) {
12914
13239
  return { ok: false, message: '"root" must be a non-empty string when provided.' };
12915
13240
  }
12916
13241
  const wanted = typeof requested === "string" ? requested.trim() : context.cwd;
12917
- const absolute = path17.resolve(context.cwd, wanted);
13242
+ const absolute = path18.resolve(context.cwd, wanted);
12918
13243
  let stats;
12919
13244
  try {
12920
- stats = fs16.statSync(absolute);
13245
+ stats = fs17.statSync(absolute);
12921
13246
  } catch {
12922
13247
  return { ok: false, message: `"${wanted}" does not exist, so it cannot be a repository root.` };
12923
13248
  }
@@ -12969,7 +13294,7 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
12969
13294
  }
12970
13295
  const requested = overrides.outDir.trim();
12971
13296
  const permitted = allowedRoots !== void 0 && allowedRoots.length > 0 ? allowedRoots : [root];
12972
- const resolved = resolveThroughExistingAncestor(path17.resolve(root, requested));
13297
+ const resolved = resolveThroughExistingAncestor(path18.resolve(root, requested));
12973
13298
  if (!permitted.some((allowed) => isInside3(canonicalPath(allowed), resolved))) {
12974
13299
  const shown = permitted.map((allowed) => canonicalPath(allowed)).join(", ");
12975
13300
  return {
@@ -13002,25 +13327,25 @@ async function openWorkspace(root, overrides = {}, allowedRoots, options = {}) {
13002
13327
  var MANIFEST_CACHE_LIMIT = 8;
13003
13328
  var manifestCache = /* @__PURE__ */ new Map();
13004
13329
  function manifestPathFor(workspace) {
13005
- return path17.resolve(workspace.root, workspace.config.outDir, "manifest.json");
13330
+ return path18.resolve(workspace.root, workspace.config.outDir, "manifest.json");
13006
13331
  }
13007
13332
  function partPathFor(workspace, filename) {
13008
13333
  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)) {
13334
+ const partsDir = path18.resolve(workspace.root, workspace.config.outDir, "parts");
13335
+ const resolved = path18.resolve(partsDir, filename);
13336
+ const relative15 = path18.relative(partsDir, resolved);
13337
+ if (relative15.length === 0 || relative15.includes(path18.sep) || relative15.includes("/") || relative15.includes("\\") || path18.isAbsolute(relative15)) {
13013
13338
  return null;
13014
13339
  }
13015
13340
  let stats;
13016
13341
  try {
13017
- stats = fs16.lstatSync(resolved);
13342
+ stats = fs17.lstatSync(resolved);
13018
13343
  } catch {
13019
13344
  return null;
13020
13345
  }
13021
13346
  if (!stats.isFile()) return null;
13022
13347
  try {
13023
- if (path17.dirname(fs16.realpathSync(resolved)) !== fs16.realpathSync(partsDir)) return null;
13348
+ if (path18.dirname(fs17.realpathSync(resolved)) !== fs17.realpathSync(partsDir)) return null;
13024
13349
  } catch {
13025
13350
  return null;
13026
13351
  }
@@ -13028,10 +13353,10 @@ function partPathFor(workspace, filename) {
13028
13353
  }
13029
13354
  function readManifest3(workspace) {
13030
13355
  const file = manifestPathFor(workspace);
13031
- const shown = path17.relative(workspace.root, file).split(path17.sep).join("/") || file;
13356
+ const shown = path18.relative(workspace.root, file).split(path18.sep).join("/") || file;
13032
13357
  let stats;
13033
13358
  try {
13034
- stats = fs16.statSync(file);
13359
+ stats = fs17.statSync(file);
13035
13360
  } catch {
13036
13361
  return {
13037
13362
  ok: false,
@@ -13045,7 +13370,7 @@ function readManifest3(workspace) {
13045
13370
  }
13046
13371
  let raw;
13047
13372
  try {
13048
- raw = fs16.readFileSync(file, "utf8");
13373
+ raw = fs17.readFileSync(file, "utf8");
13049
13374
  } catch (error) {
13050
13375
  return {
13051
13376
  ok: false,
@@ -13157,7 +13482,7 @@ function formatBytes(bytes) {
13157
13482
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
13158
13483
  }
13159
13484
  function relativeFor(workspace, absolute) {
13160
- return path18.relative(workspace.root, absolute).split(path18.sep).join("/");
13485
+ return path19.relative(workspace.root, absolute).split(path19.sep).join("/");
13161
13486
  }
13162
13487
  function capped(values, limit = 20) {
13163
13488
  return { count: values.length, sample: values.slice(0, limit) };
@@ -13176,13 +13501,13 @@ function summarizeDrift(drift) {
13176
13501
  function toRelativePath(root, value) {
13177
13502
  const cleaned = value.trim();
13178
13503
  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)) {
13504
+ const resolvedRoot = path19.resolve(root);
13505
+ const absolute = path19.resolve(resolvedRoot, cleaned);
13506
+ const relative15 = path19.relative(resolvedRoot, absolute);
13507
+ if (relative15 === "" || relative15 === ".." || relative15.startsWith(`..${path19.sep}`) || path19.isAbsolute(relative15)) {
13183
13508
  return null;
13184
13509
  }
13185
- return relative15.split(path18.sep).join("/");
13510
+ return relative15.split(path19.sep).join("/");
13186
13511
  }
13187
13512
  function symbolsOf(entry) {
13188
13513
  const summary = entry.summary;
@@ -13412,7 +13737,7 @@ var generateTool = {
13412
13737
  if (!result.ok) return failure(result.message);
13413
13738
  const summary = result.summary;
13414
13739
  forgetManifest(manifestPathFor(workspace));
13415
- const written = relativeFor(workspace, path18.resolve(workspace.root, workspace.config.outDir));
13740
+ const written = relativeFor(workspace, path19.resolve(workspace.root, workspace.config.outDir));
13416
13741
  const lines = [
13417
13742
  `Wrote ${written}/`,
13418
13743
  `Files: ${summary.totalFiles} included, ${summary.skippedCount} skipped, ${plural(summary.partsCount, "part")}`,
@@ -13813,7 +14138,7 @@ var readTool = {
13813
14138
  }
13814
14139
  let partText;
13815
14140
  try {
13816
- partText = fs17.readFileSync(partPath, "utf8");
14141
+ partText = fs18.readFileSync(partPath, "utf8");
13817
14142
  } catch {
13818
14143
  return failure(
13819
14144
  `${entry.part} could not be read, so the snapshot is damaged. Run snapshot_generate to rebuild it.`
@@ -14122,6 +14447,8 @@ var VALIDATE_OPTIONS = [
14122
14447
  "large-file-bytes",
14123
14448
  "max-monolith-bytes",
14124
14449
  "max-parts",
14450
+ "brief",
14451
+ "prompt-task",
14125
14452
  "include-monolith",
14126
14453
  "include-sensitive-files",
14127
14454
  "skip-artifacts",
@@ -14149,6 +14476,8 @@ var COMMAND_OPTION_SCOPE = {
14149
14476
  "max-monolith-bytes",
14150
14477
  "attachment-slots",
14151
14478
  "max-parts",
14479
+ "brief",
14480
+ "prompt-task",
14152
14481
  "include-monolith",
14153
14482
  "include-sensitive-files",
14154
14483
  "skip-artifacts",
@@ -14591,6 +14920,20 @@ function buildAgentContract() {
14591
14920
  appliesTo: optionAppliesTo("attachment-slots"),
14592
14921
  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
14922
  },
14923
+ {
14924
+ flag: "--brief",
14925
+ type: "string",
14926
+ default: "unset",
14927
+ appliesTo: optionAppliesTo("brief"),
14928
+ 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."
14929
+ },
14930
+ {
14931
+ flag: "--prompt-task",
14932
+ type: "string",
14933
+ default: "audit",
14934
+ appliesTo: optionAppliesTo("prompt-task"),
14935
+ summary: "Which job the brief is written for: audit (default), review or explain. It changes the opening section, not the standard."
14936
+ },
14594
14937
  {
14595
14938
  flag: "--max-parts",
14596
14939
  type: "number",
@@ -14811,6 +15154,8 @@ function buildAgentContract() {
14811
15154
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
14812
15155
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
14813
15156
  { key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
15157
+ { 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." },
15158
+ { 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
15159
  { 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
15160
  { 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
15161
  { 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 +15257,8 @@ function buildAgentContract() {
14912
15257
  }
14913
15258
 
14914
15259
  // src/agent/install-skill.ts
14915
- import * as fs18 from "fs";
14916
- import * as path19 from "path";
15260
+ import * as fs19 from "fs";
15261
+ import * as path20 from "path";
14917
15262
 
14918
15263
  // src/agent/skill.ts
14919
15264
  var PACKAGE_NAME2 = "codebase-snapshot";
@@ -15082,17 +15427,17 @@ var LEGACY_AGENTS_MARKER = "<!-- codebase-snapshot:skill:start -->";
15082
15427
  function targetPath(cwd, target) {
15083
15428
  switch (target) {
15084
15429
  case "claude":
15085
- return path19.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15430
+ return path20.join(cwd, ".claude", "skills", SKILL_NAME, "SKILL.md");
15086
15431
  case "cursor":
15087
- return path19.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15432
+ return path20.join(cwd, ".cursor", "rules", `${SKILL_NAME}.mdc`);
15088
15433
  }
15089
15434
  }
15090
15435
  function assertWritableInsideRepository(cwd, filePath) {
15091
- const root = fs18.realpathSync(cwd);
15092
- const shown = path19.relative(root, filePath) || filePath;
15436
+ const root = fs19.realpathSync(cwd);
15437
+ const shown = path20.relative(root, filePath) || filePath;
15093
15438
  let stat = null;
15094
15439
  try {
15095
- stat = fs18.lstatSync(filePath);
15440
+ stat = fs19.lstatSync(filePath);
15096
15441
  } catch {
15097
15442
  stat = null;
15098
15443
  }
@@ -15108,32 +15453,32 @@ function assertWritableInsideRepository(cwd, filePath) {
15108
15453
  }
15109
15454
  let existing = filePath;
15110
15455
  const missing = [];
15111
- while (!fs18.existsSync(existing)) {
15112
- missing.unshift(path19.basename(existing));
15113
- const parent = path19.dirname(existing);
15456
+ while (!fs19.existsSync(existing)) {
15457
+ missing.unshift(path20.basename(existing));
15458
+ const parent = path20.dirname(existing);
15114
15459
  if (parent === existing) break;
15115
15460
  existing = parent;
15116
15461
  }
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}`)) {
15462
+ const realAncestor = fs19.realpathSync(existing);
15463
+ const resolved = missing.length === 0 ? realAncestor : path20.join(realAncestor, ...missing);
15464
+ if (resolved !== root && !resolved.startsWith(`${root}${path20.sep}`)) {
15120
15465
  throw new Error(
15121
15466
  `${REFUSED}: ${shown} resolves outside the repository (${resolved}). Move it back inside ${root}, or remove the link, and run again.`
15122
15467
  );
15123
15468
  }
15124
15469
  }
15125
15470
  function writeIfChanged(target, filePath, content) {
15126
- const existing = fs18.existsSync(filePath) ? fs18.readFileSync(filePath, "utf8") : null;
15471
+ const existing = fs19.existsSync(filePath) ? fs19.readFileSync(filePath, "utf8") : null;
15127
15472
  if (existing === content) return { target, path: filePath, action: "unchanged" };
15128
- fs18.mkdirSync(path19.dirname(filePath), { recursive: true });
15129
- fs18.writeFileSync(filePath, content, "utf8");
15473
+ fs19.mkdirSync(path20.dirname(filePath), { recursive: true });
15474
+ fs19.writeFileSync(filePath, content, "utf8");
15130
15475
  return { target, path: filePath, action: existing === null ? "created" : "updated" };
15131
15476
  }
15132
15477
  function legacyAgentsNote(cwd) {
15133
- const filePath = path19.join(cwd, "AGENTS.md");
15478
+ const filePath = path20.join(cwd, "AGENTS.md");
15134
15479
  try {
15135
- if (!fs18.existsSync(filePath)) return null;
15136
- if (!fs18.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15480
+ if (!fs19.existsSync(filePath)) return null;
15481
+ if (!fs19.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
15137
15482
  } catch {
15138
15483
  return null;
15139
15484
  }
@@ -15145,9 +15490,9 @@ function installSkill(cwd, target = "all") {
15145
15490
  const notes = [];
15146
15491
  const wanted = target === "all" ? ["claude", "cursor"] : [target];
15147
15492
  for (const item of wanted) assertWritableInsideRepository(cwd, targetPath(cwd, item));
15148
- const createsSomething = wanted.some((item) => !fs18.existsSync(targetPath(cwd, item)));
15493
+ const createsSomething = wanted.some((item) => !fs19.existsSync(targetPath(cwd, item)));
15149
15494
  if (createsSomething) {
15150
- assertWritableInsideRepository(cwd, path19.join(cwd, ".gitignore"));
15495
+ assertWritableInsideRepository(cwd, path20.join(cwd, ".gitignore"));
15151
15496
  }
15152
15497
  for (const item of wanted) {
15153
15498
  written.push(writeIfChanged(item, targetPath(cwd, item), skill));
@@ -15261,8 +15606,8 @@ function negotiateLegacyVersion(requested) {
15261
15606
  }
15262
15607
 
15263
15608
  // src/mcp/resources.ts
15264
- import * as fs19 from "fs";
15265
- import * as path20 from "path";
15609
+ import * as fs20 from "fs";
15610
+ import * as path21 from "path";
15266
15611
  var MAX_RESOURCE_BYTES = 512 * 1024;
15267
15612
  var ResourceTooLargeError = class extends Error {
15268
15613
  constructor(uri, bytes, limit, message) {
@@ -15312,7 +15657,7 @@ async function workspaceFor(context) {
15312
15657
  }
15313
15658
  function readFileIfPresent(file) {
15314
15659
  try {
15315
- return fs19.readFileSync(file, "utf8");
15660
+ return fs20.readFileSync(file, "utf8");
15316
15661
  } catch {
15317
15662
  return null;
15318
15663
  }
@@ -15408,7 +15753,7 @@ function buildResourceProvider() {
15408
15753
  const report = REPORT_URIS.get(uri);
15409
15754
  if (report) {
15410
15755
  const text2 = readFileIfPresent(
15411
- path20.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15756
+ path21.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
15412
15757
  );
15413
15758
  if (text2 === null) return null;
15414
15759
  return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, REPORT_ADVICE) };
@@ -15430,7 +15775,7 @@ function buildResourceProvider() {
15430
15775
  if (partPath === null) return null;
15431
15776
  let partBytes;
15432
15777
  try {
15433
- partBytes = fs19.statSync(partPath).size;
15778
+ partBytes = fs20.statSync(partPath).size;
15434
15779
  } catch {
15435
15780
  return null;
15436
15781
  }
@@ -15466,52 +15811,52 @@ function validateArguments(schema, value) {
15466
15811
  }
15467
15812
  return problems;
15468
15813
  }
15469
- function checkValue(path22, schema, value) {
15814
+ function checkValue(path23, schema, value) {
15470
15815
  if (schema.enum && !schema.enum.includes(value)) {
15471
- return [`"${path22}" must be one of: ${schema.enum.join(", ")}`];
15816
+ return [`"${path23}" must be one of: ${schema.enum.join(", ")}`];
15472
15817
  }
15473
15818
  switch (schema.type) {
15474
15819
  case "string": {
15475
- if (typeof value !== "string") return [`"${path22}" must be a string`];
15820
+ if (typeof value !== "string") return [`"${path23}" must be a string`];
15476
15821
  const problems = [];
15477
15822
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
15478
- problems.push(`"${path22}" must be at least ${schema.minLength} character(s)`);
15823
+ problems.push(`"${path23}" must be at least ${schema.minLength} character(s)`);
15479
15824
  }
15480
15825
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
15481
- problems.push(`"${path22}" must be at most ${schema.maxLength} character(s)`);
15826
+ problems.push(`"${path23}" must be at most ${schema.maxLength} character(s)`);
15482
15827
  }
15483
15828
  return problems;
15484
15829
  }
15485
15830
  case "number":
15486
15831
  case "integer": {
15487
15832
  if (typeof value !== "number" || Number.isNaN(value)) {
15488
- return [`"${path22}" must be a number`];
15833
+ return [`"${path23}" must be a number`];
15489
15834
  }
15490
15835
  if (schema.type === "integer" && !Number.isInteger(value)) {
15491
- return [`"${path22}" must be an integer`];
15836
+ return [`"${path23}" must be an integer`];
15492
15837
  }
15493
15838
  const problems = [];
15494
15839
  if (schema.minimum !== void 0 && value < schema.minimum) {
15495
- problems.push(`"${path22}" must be >= ${schema.minimum}`);
15840
+ problems.push(`"${path23}" must be >= ${schema.minimum}`);
15496
15841
  }
15497
15842
  if (schema.maximum !== void 0 && value > schema.maximum) {
15498
- problems.push(`"${path22}" must be <= ${schema.maximum}`);
15843
+ problems.push(`"${path23}" must be <= ${schema.maximum}`);
15499
15844
  }
15500
15845
  return problems;
15501
15846
  }
15502
15847
  case "boolean":
15503
- return typeof value === "boolean" ? [] : [`"${path22}" must be a boolean`];
15848
+ return typeof value === "boolean" ? [] : [`"${path23}" must be a boolean`];
15504
15849
  case "array": {
15505
- if (!Array.isArray(value)) return [`"${path22}" must be an array`];
15850
+ if (!Array.isArray(value)) return [`"${path23}" must be an array`];
15506
15851
  if (!schema.items) return [];
15507
15852
  const problems = [];
15508
15853
  value.forEach((item, index) => {
15509
- problems.push(...checkValue(`${path22}[${index}]`, schema.items, item));
15854
+ problems.push(...checkValue(`${path23}[${index}]`, schema.items, item));
15510
15855
  });
15511
15856
  return problems;
15512
15857
  }
15513
15858
  case "object":
15514
- return isJsonObject(value) ? [] : [`"${path22}" must be an object`];
15859
+ return isJsonObject(value) ? [] : [`"${path23}" must be an object`];
15515
15860
  default:
15516
15861
  return [];
15517
15862
  }
@@ -16089,6 +16434,8 @@ var CLI_OPTIONS = {
16089
16434
  "max-monolith-bytes": { type: "string" },
16090
16435
  "attachment-slots": { type: "string" },
16091
16436
  "max-parts": { type: "string" },
16437
+ brief: { type: "string" },
16438
+ "prompt-task": { type: "string" },
16092
16439
  "include-monolith": { type: "boolean" },
16093
16440
  "include-sensitive-files": { type: "boolean" },
16094
16441
  "skip-artifacts": { type: "string" },
@@ -16167,6 +16514,9 @@ Options:
16167
16514
  0 = no limit); PROMPT.md plans the delivery to fit
16168
16515
  --max-parts <n> Experimental: grow the part budget until the snapshot has at
16169
16516
  most n parts, instead of adding parts as the code grows
16517
+ --brief <path> Owner-written half of PROMPT.md (stakes, system, history,
16518
+ bar, calibration); merged at fixed slots
16519
+ --prompt-task <task> audit | review | explain - which job the brief is for
16170
16520
  --skip-artifacts <names> Comma-separated artifacts to omit
16171
16521
  (readme, manifest, parts, navigation,
16172
16522
  projectTree, audit, monolith)
@@ -16239,6 +16589,13 @@ function parseCountOption(raw, optionName, minimum = 0) {
16239
16589
  }
16240
16590
  return value;
16241
16591
  }
16592
+ function parsePromptTask(value) {
16593
+ if (value === void 0) return void 0;
16594
+ if (value === "audit" || value === "review" || value === "explain") return value;
16595
+ throw new UsageError(
16596
+ '--prompt-task expects audit, review or explain, received "' + value + '".'
16597
+ );
16598
+ }
16242
16599
  function parseArtifactList(raw, flag) {
16243
16600
  const names = raw.split(",").map((name) => name.trim()).filter(Boolean);
16244
16601
  if (names.length === 0) {
@@ -16303,10 +16660,10 @@ function parseCliArgs(argv) {
16303
16660
  }
16304
16661
  if (values.cwd !== void 0) {
16305
16662
  const target = String(values.cwd);
16306
- if (!fs20.existsSync(target)) {
16663
+ if (!fs21.existsSync(target)) {
16307
16664
  throw new UsageError(`--cwd directory does not exist: ${target}`);
16308
16665
  }
16309
- if (!fs20.statSync(target).isDirectory()) {
16666
+ if (!fs21.statSync(target).isDirectory()) {
16310
16667
  throw new UsageError(`--cwd is not a directory: ${target}`);
16311
16668
  }
16312
16669
  }
@@ -16452,7 +16809,7 @@ function parseCliArgs(argv) {
16452
16809
  install: values.install === true,
16453
16810
  noInstall: values["no-install"] === true,
16454
16811
  target: values.target === void 0 ? void 0 : String(values.target),
16455
- cwd: values.cwd === void 0 ? process.cwd() : path21.resolve(String(values.cwd)),
16812
+ cwd: values.cwd === void 0 ? process.cwd() : path22.resolve(String(values.cwd)),
16456
16813
  outDir: values["out-dir"] === void 0 ? void 0 : String(values["out-dir"]),
16457
16814
  includeMonolith: values["include-monolith"] === true || onlyNamesMonolith === true ? true : void 0,
16458
16815
  includeSensitiveFiles: values["include-sensitive-files"] === true ? true : void 0,
@@ -16485,6 +16842,8 @@ function parseCliArgs(argv) {
16485
16842
  "attachment-slots"
16486
16843
  ),
16487
16844
  maxParts: parseCountOption(values["max-parts"], "max-parts", 1),
16845
+ brief: values.brief === void 0 ? void 0 : String(values.brief),
16846
+ promptTask: parsePromptTask(values["prompt-task"]),
16488
16847
  skipArtifacts,
16489
16848
  onlyArtifacts,
16490
16849
  discovery: isDiscoveryMode(rawDiscovery) ? rawDiscovery : void 0,
@@ -16538,9 +16897,9 @@ function splitList(value) {
16538
16897
  return value.split(",").map((entry) => entry.trim()).filter(Boolean);
16539
16898
  }
16540
16899
  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;
16900
+ const absolute = path22.resolve(cwd, outDir, ...segments);
16901
+ const relative15 = path22.relative(cwd, absolute);
16902
+ if (relative15 && !relative15.startsWith("..") && !path22.isAbsolute(relative15)) return relative15;
16544
16903
  return absolute;
16545
16904
  }
16546
16905
  function nextStepHint(cwd, scriptsAddedNow) {
@@ -16548,7 +16907,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
16548
16907
  if (!hasScript) {
16549
16908
  try {
16550
16909
  const parsed = JSON.parse(
16551
- stripJsonComments(fs20.readFileSync(path21.join(cwd, "package.json"), "utf8"))
16910
+ stripJsonComments(fs21.readFileSync(path22.join(cwd, "package.json"), "utf8"))
16552
16911
  );
16553
16912
  hasScript = typeof parsed.scripts?.snapshot === "string";
16554
16913
  } catch {
@@ -16556,8 +16915,8 @@ function nextStepHint(cwd, scriptsAddedNow) {
16556
16915
  }
16557
16916
  }
16558
16917
  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`);
16918
+ const bin = path22.join(cwd, "node_modules", ".bin", "codebase-snapshot");
16919
+ const installed = fs21.existsSync(bin) || fs21.existsSync(`${bin}.cmd`);
16561
16920
  return installed ? "npm run snapshot" : "npm install && npm run snapshot";
16562
16921
  }
16563
16922
  function presetSummary(init) {
@@ -16593,7 +16952,7 @@ async function runInitCommand(invocation) {
16593
16952
  if (hook) for (const note of hook.notes) info(` ${note}`);
16594
16953
  return 0;
16595
16954
  }
16596
- info(`\u2705 Created ${path21.basename(result.configPath)} (${presetSummary(result)})`);
16955
+ info(`\u2705 Created ${path22.basename(result.configPath)} (${presetSummary(result)})`);
16597
16956
  if (result.scripts.length > 0) info(` Added npm scripts: ${result.scripts.join(", ")}`);
16598
16957
  if (result.dependency.added && result.dependency.range !== null) {
16599
16958
  info(` Added devDependency: ${result.dependency.name} ${result.dependency.range}`);
@@ -16616,18 +16975,18 @@ async function runInitCommand(invocation) {
16616
16975
  function generatorOrigin(cwd) {
16617
16976
  try {
16618
16977
  const pkg = JSON.parse(
16619
- stripJsonComments(fs20.readFileSync(path21.join(cwd, "package.json"), "utf8"))
16978
+ stripJsonComments(fs21.readFileSync(path22.join(cwd, "package.json"), "utf8"))
16620
16979
  );
16621
16980
  const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
16622
16981
  if (typeof spec === "string") return `project dependency ${spec}`;
16623
16982
  } catch {
16624
16983
  }
16625
16984
  const entry = process.argv[1] ?? "";
16626
- if (entry.includes("_npx") || entry.includes(`${path21.sep}npx${path21.sep}`)) return "via npx";
16985
+ if (entry.includes("_npx") || entry.includes(`${path22.sep}npx${path22.sep}`)) return "via npx";
16627
16986
  return "global or direct install";
16628
16987
  }
16629
16988
  function detectPackageManager(cwd) {
16630
- const has = (name) => fs20.existsSync(path21.join(cwd, name));
16989
+ const has = (name) => fs21.existsSync(path22.join(cwd, name));
16631
16990
  if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
16632
16991
  if (has("pnpm-lock.yaml")) return { name: "pnpm", command: "pnpm", args: ["install"] };
16633
16992
  if (has("yarn.lock")) return { name: "yarn", command: "yarn", args: ["install"] };
@@ -16744,7 +17103,7 @@ async function runSetupCommand(invocation, options = {}) {
16744
17103
  }
16745
17104
  info("\n\u{1F9EA} Dry run \u2014 setup would:");
16746
17105
  info(
16747
- ` 1. ${init.reused ? `keep ${path21.basename(keptConfigPath)}` : `write ${path21.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
17106
+ ` 1. ${init.reused ? `keep ${path22.basename(keptConfigPath)}` : `write ${path22.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
16748
17107
  );
16749
17108
  info(" 2. add the npm scripts, the devDependency and the .gitignore entries");
16750
17109
  if (manager !== null) info(` 3. install with ${manager}`);
@@ -16757,9 +17116,9 @@ async function runSetupCommand(invocation, options = {}) {
16757
17116
  if (invocation.format !== "json") {
16758
17117
  if (!interactive) info(`\u{1F680} Setup for: ${invocation.cwd}`);
16759
17118
  if (init.reused) {
16760
- info(`\u267B Keeping ${path21.basename(keptConfigPath)}`);
17119
+ info(`\u267B Keeping ${path22.basename(keptConfigPath)}`);
16761
17120
  } else {
16762
- info(`\u2705 Created ${path21.basename(keptConfigPath)} (${presetSummary(init)})`);
17121
+ info(`\u2705 Created ${path22.basename(keptConfigPath)} (${presetSummary(init)})`);
16763
17122
  }
16764
17123
  if (init.scripts.length > 0) info(` Added npm scripts: ${init.scripts.join(", ")}`);
16765
17124
  if (init.dependency.added && init.dependency.range !== null) {
@@ -16773,7 +17132,7 @@ async function runSetupCommand(invocation, options = {}) {
16773
17132
  info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
16774
17133
  }
16775
17134
  }
16776
- const hasManifest = fs20.existsSync(path21.join(invocation.cwd, "package.json"));
17135
+ const hasManifest = fs21.existsSync(path22.join(invocation.cwd, "package.json"));
16777
17136
  let install = null;
16778
17137
  if (invocation.noInstall) {
16779
17138
  if (invocation.format !== "json") info(" Skipped the install (--no-install)");
@@ -16816,6 +17175,10 @@ async function runSetupCommand(invocation, options = {}) {
16816
17175
  if (invocation.maxParts !== void 0) {
16817
17176
  generateArgs.push("--max-parts", String(invocation.maxParts));
16818
17177
  }
17178
+ if (invocation.brief !== void 0) generateArgs.push("--brief", invocation.brief);
17179
+ if (invocation.promptTask !== void 0) {
17180
+ generateArgs.push("--prompt-task", invocation.promptTask);
17181
+ }
16819
17182
  if (invocation.skeleton === true) generateArgs.push("--skeleton");
16820
17183
  if (invocation.sarif === true) generateArgs.push("--sarif");
16821
17184
  if (invocation.noUpdateCheck) generateArgs.push("--no-update-check");
@@ -16901,7 +17264,7 @@ function runSkillCommand(invocation) {
16901
17264
  }
16902
17265
  info(`\u2705 Agent skill installed (${SKILL_NAME}):`);
16903
17266
  for (const item of result.written) {
16904
- const shown = path21.relative(invocation.cwd, item.path) || item.path;
17267
+ const shown = path22.relative(invocation.cwd, item.path) || item.path;
16905
17268
  info(` - ${item.action.padEnd(9)} ${shown}`);
16906
17269
  }
16907
17270
  if (result.gitignored.length > 0) {
@@ -17022,7 +17385,7 @@ ${USAGE}
17022
17385
  return runSkillCommand(invocation);
17023
17386
  }
17024
17387
  if (invocation.command === "mcp") {
17025
- return await runStdioServer({ cwd: path21.resolve(invocation.cwd) });
17388
+ return await runStdioServer({ cwd: path22.resolve(invocation.cwd) });
17026
17389
  }
17027
17390
  if (invocation.command === "setup") {
17028
17391
  return runSetupCommand(invocation);
@@ -17041,7 +17404,7 @@ ${USAGE}
17041
17404
  );
17042
17405
  }
17043
17406
  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}`);
17407
+ if (loaded.file) info(`\u2699 Using config ${path22.relative(process.cwd(), loaded.file) || loaded.file}`);
17045
17408
  let resolved;
17046
17409
  try {
17047
17410
  resolved = resolveConfig(
@@ -17060,6 +17423,8 @@ ${USAGE}
17060
17423
  maxMonolithBytes: invocation.maxMonolithBytes,
17061
17424
  attachmentSlots: invocation.attachmentSlots,
17062
17425
  maxParts: invocation.maxParts,
17426
+ brief: invocation.brief,
17427
+ promptTask: invocation.promptTask,
17063
17428
  skipArtifacts: invocation.skipArtifacts,
17064
17429
  // `--only-artifacts` is forwarded as itself, not only as the derived suppression list:
17065
17430
  // suppression cannot switch an artifact *on*, so a config that had turned one of the
@@ -17083,13 +17448,13 @@ ${USAGE}
17083
17448
  return result.valid ? 0 : 1;
17084
17449
  }
17085
17450
  if (invocation.command === "report") {
17086
- const manifestPath = path21.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17087
- if (!fs20.existsSync(manifestPath)) {
17451
+ const manifestPath = path22.resolve(resolved.cwd, resolved.outDir, "manifest.json");
17452
+ if (!fs21.existsSync(manifestPath)) {
17088
17453
  return fail(invocation.format, `Manifest not found at ${manifestPath}. Run generate first.`);
17089
17454
  }
17090
17455
  let manifest;
17091
17456
  try {
17092
- manifest = JSON.parse(fs20.readFileSync(manifestPath, "utf8"));
17457
+ manifest = JSON.parse(fs21.readFileSync(manifestPath, "utf8"));
17093
17458
  } catch (err) {
17094
17459
  return fail(invocation.format, `Could not read ${manifestPath}: ${err.message}`);
17095
17460
  }
@@ -17293,19 +17658,19 @@ function finishWatchRun(state, now) {
17293
17658
  };
17294
17659
  }
17295
17660
  function comparablePath(value) {
17296
- const absolute = path21.resolve(value);
17661
+ const absolute = path22.resolve(value);
17297
17662
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
17298
17663
  }
17299
17664
  function isSameOrInside(parent, candidate) {
17300
- const relative15 = path21.relative(parent, candidate);
17301
- return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path21.sep}`) && !path21.isAbsolute(relative15);
17665
+ const relative15 = path22.relative(parent, candidate);
17666
+ return relative15 === "" || relative15 !== ".." && !relative15.startsWith(`..${path22.sep}`) && !path22.isAbsolute(relative15);
17302
17667
  }
17303
17668
  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));
17669
+ const absolute = comparablePath(path22.resolve(paths.cwd, candidate));
17670
+ const outDir = comparablePath(path22.resolve(paths.cwd, paths.outDir));
17671
+ const tmpDir = comparablePath(path22.resolve(paths.cwd, paths.tmpDir));
17307
17672
  if (isSameOrInside(outDir, absolute) || isSameOrInside(tmpDir, absolute)) return true;
17308
- const offsets = [path21.basename(outDir), path21.basename(tmpDir)].filter((name) => name.length > 0);
17673
+ const offsets = [path22.basename(outDir), path22.basename(tmpDir)].filter((name) => name.length > 0);
17309
17674
  const leftover = absolute.split(/[\\/]+/).some(
17310
17675
  (segment) => offsets.some(
17311
17676
  (name) => segment.startsWith(`${name}.backup-`) || segment.startsWith(`${name}.partial-`)
@@ -17328,8 +17693,8 @@ function decideWatchEvent(state, event, paths) {
17328
17693
  function watchPathsFor(config) {
17329
17694
  return {
17330
17695
  cwd: config.cwd,
17331
- outDir: path21.resolve(config.cwd, config.outDir),
17332
- tmpDir: path21.resolve(config.cwd, config.tmpDir)
17696
+ outDir: path22.resolve(config.cwd, config.outDir),
17697
+ tmpDir: path22.resolve(config.cwd, config.tmpDir)
17333
17698
  };
17334
17699
  }
17335
17700
  function watchSupportProblem(platform = process.platform, version = process.versions.node) {
@@ -17387,6 +17752,8 @@ async function runWatchLoop(invocation, resolved, options) {
17387
17752
  maxMonolithBytes: invocation.maxMonolithBytes,
17388
17753
  attachmentSlots: invocation.attachmentSlots,
17389
17754
  maxParts: invocation.maxParts,
17755
+ brief: invocation.brief,
17756
+ promptTask: invocation.promptTask,
17390
17757
  skipArtifacts: invocation.skipArtifacts,
17391
17758
  onlyArtifacts: invocation.onlyArtifacts,
17392
17759
  discovery: invocation.discovery,
@@ -17416,11 +17783,11 @@ async function runWatchLoop(invocation, resolved, options) {
17416
17783
  if (!options.generatedAlready) void regenerate();
17417
17784
  let watcher;
17418
17785
  try {
17419
- watcher = fs20.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17786
+ watcher = fs21.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
17420
17787
  const decision = decideWatchEvent(
17421
17788
  state,
17422
17789
  {
17423
- path: filename ? path21.resolve(resolved.cwd, filename.toString()) : null,
17790
+ path: filename ? path22.resolve(resolved.cwd, filename.toString()) : null,
17424
17791
  now: performance.now()
17425
17792
  },
17426
17793
  paths
@@ -17459,7 +17826,7 @@ async function runWatchLoop(invocation, resolved, options) {
17459
17826
  return 0;
17460
17827
  }
17461
17828
  var entryFile = process.argv[1] ?? "";
17462
- var entryName = path21.basename(entryFile).toLowerCase();
17829
+ var entryName = path22.basename(entryFile).toLowerCase();
17463
17830
  var invokedDirectly = entryName === "cli.js" || entryName === "cli.cjs";
17464
17831
  if (invokedDirectly) {
17465
17832
  void main().then(