codebase-snapshot 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -2220,7 +2220,7 @@ function applySpansKeepingQuotes(line, spans) {
2220
2220
 
2221
2221
  // src/version.ts
2222
2222
  var GENERATOR_NAME = "codebase-snapshot";
2223
- var GENERATOR_VERSION = "0.12.1";
2223
+ var GENERATOR_VERSION = "0.12.2";
2224
2224
  var SCHEMA_VERSION = "3.0.0";
2225
2225
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2226
2226
  function isOurGeneratorName(name) {
@@ -3329,7 +3329,23 @@ function parseOwnerBrief(filePath, text2) {
3329
3329
  const preamble = [];
3330
3330
  const sections = [];
3331
3331
  let current = null;
3332
+ let fence = null;
3332
3333
  for (const line of source.split(/\r?\n/)) {
3334
+ const fenceLine = /^ {0,3}(`{3,}|~{3,})/.exec(line);
3335
+ if (fenceLine) {
3336
+ const marker2 = fenceLine[1];
3337
+ const char = marker2[0];
3338
+ if (fence === null) fence = { char, length: marker2.length };
3339
+ else if (char === fence.char && marker2.length >= fence.length) fence = null;
3340
+ if (current) current.body.push(line);
3341
+ else preamble.push(line);
3342
+ continue;
3343
+ }
3344
+ if (fence !== null) {
3345
+ if (current) current.body.push(line);
3346
+ else preamble.push(line);
3347
+ continue;
3348
+ }
3333
3349
  const heading = /^##\s+(.+?)\s*$/.exec(line);
3334
3350
  if (heading) {
3335
3351
  current = { heading: heading[1], body: [] };
@@ -3341,7 +3357,7 @@ function parseOwnerBrief(filePath, text2) {
3341
3357
  }
3342
3358
  const recognised = {};
3343
3359
  const notes = [];
3344
- const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
3360
+ const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
3345
3361
  const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
3346
3362
  const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
3347
3363
  const seen = /* @__PURE__ */ new Set();
@@ -3885,6 +3901,7 @@ function resolvePromptTask(value) {
3885
3901
  'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
3886
3902
  );
3887
3903
  }
3904
+ var MAX_BRIEF_BYTES = 64 * 1024;
3888
3905
  function readConfiguredBrief(cwd, value) {
3889
3906
  if (value === void 0 || value === null) return void 0;
3890
3907
  if (typeof value !== "string" || value.trim().length === 0) {
@@ -3902,6 +3919,12 @@ function readConfiguredBrief(cwd, value) {
3902
3919
  'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
3903
3920
  );
3904
3921
  }
3922
+ const bytes = Buffer.byteLength(text2, "utf8");
3923
+ if (bytes > MAX_BRIEF_BYTES) {
3924
+ throw new Error(
3925
+ 'brief "' + value + '" is ' + bytes + " bytes; the limit is " + MAX_BRIEF_BYTES + ". Keep it to what a reader can act on, or move the detail into a document the snapshot carries."
3926
+ );
3927
+ }
3905
3928
  const parsed = parseOwnerBrief(value, text2);
3906
3929
  if (parsed.problems.length > 0) {
3907
3930
  throw new Error(
@@ -6281,6 +6304,32 @@ function describeManifestShapeProblem(value) {
6281
6304
  if (!config || typeof config !== "object" || Array.isArray(config)) {
6282
6305
  return 'missing "config" object';
6283
6306
  }
6307
+ const recordedConfig = config;
6308
+ const promptTask = recordedConfig.promptTask;
6309
+ if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
6310
+ return '`config.promptTask` must be "audit", "review" or "explain"';
6311
+ }
6312
+ const recordedBrief = recordedConfig.brief;
6313
+ if (recordedBrief !== void 0) {
6314
+ if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
6315
+ return "`config.brief` must be an object";
6316
+ }
6317
+ const briefRecord = recordedBrief;
6318
+ if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
6319
+ return "`config.brief.path` must be a non-empty string";
6320
+ }
6321
+ if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
6322
+ return "`config.brief.digest` must be a sha256 hex digest";
6323
+ }
6324
+ }
6325
+ const recordedSlots = recordedConfig.attachmentSlots;
6326
+ if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
6327
+ return "`config.attachmentSlots` must be a non-negative integer";
6328
+ }
6329
+ const recordedMaxParts = recordedConfig.maxParts;
6330
+ if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
6331
+ return "`config.maxParts` must be a positive integer or null";
6332
+ }
6284
6333
  const budgets = candidate.budgets;
6285
6334
  if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
6286
6335
  return 'missing "budgets" object';
@@ -9885,6 +9934,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
9885
9934
  const brief = context.brief;
9886
9935
  const wrote = (name) => artifacts?.[name] !== false;
9887
9936
  const code = (value) => inlineCode(escapeControls(value));
9937
+ const text2 = (value) => escapeControls(value);
9888
9938
  const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
9889
9939
  const lines = [
9890
9940
  "# PROMPT.md",
@@ -9903,18 +9953,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
9903
9953
  "the snapshot is what exists.",
9904
9954
  ""
9905
9955
  ];
9906
- if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
9956
+ if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
9907
9957
  lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
9908
- lines.push(...stakesSection(brief, code));
9958
+ lines.push(...stakesSection(brief, code, text2));
9909
9959
  lines.push(...haveSection(wrote), "");
9910
- lines.push(...whatThisIsSection(overview), "");
9911
- lines.push(...systemSection(manifest, code, brief), "");
9912
- lines.push(...historySection(history, brief, code), "");
9913
- lines.push(...barSection(brief, code), "");
9960
+ lines.push(...whatThisIsSection(overview, text2), "");
9961
+ lines.push(...systemSection(manifest, code, brief, text2), "");
9962
+ lines.push(...historySection(history, brief, code, text2), "");
9963
+ lines.push(...barSection(brief, code, text2), "");
9914
9964
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
9915
9965
  lines.push(...answerSection(), "");
9916
- lines.push(...calibrationSection(brief, code), "");
9917
- lines.push(...ownerNotesSection(brief, code));
9966
+ lines.push(...calibrationSection(brief, code, text2), "");
9967
+ lines.push(...ownerNotesSection(brief, code, text2));
9918
9968
  lines.push(...snapshotSection(manifest, code), "");
9919
9969
  lines.push(...deliverySection(manifest, wrote("parts"), slots));
9920
9970
  lines.push(
@@ -9993,10 +10043,10 @@ function haveSection(wrote) {
9993
10043
  out.push(...bullets);
9994
10044
  return out;
9995
10045
  }
9996
- function systemSection(manifest, code, brief) {
10046
+ function systemSection(manifest, code, brief, escape) {
9997
10047
  const out = ["## The system", ""];
9998
10048
  if (brief?.system !== void 0) {
9999
- out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
10049
+ out.push(...ownerBlock(brief.system, brief.path, code, escape), "", "What the index records:", "");
10000
10050
  }
10001
10051
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
10002
10052
  if (layers.length > 0) {
@@ -10055,9 +10105,9 @@ function systemSection(manifest, code, brief) {
10055
10105
  }
10056
10106
  return out;
10057
10107
  }
10058
- function historySection(history, brief, code) {
10108
+ function historySection(history, brief, code, escape) {
10059
10109
  const out = ["## What came before", ""];
10060
- if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
10110
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
10061
10111
  if (history.length === 0) {
10062
10112
  out.push(
10063
10113
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -10072,14 +10122,14 @@ function historySection(history, brief, code) {
10072
10122
  ""
10073
10123
  );
10074
10124
  for (const commit of history) {
10075
- out.push("- " + commit.subject);
10076
- if (commit.body.length > 0) out.push(" " + commit.body);
10125
+ out.push("- " + escape(commit.subject));
10126
+ if (commit.body.length > 0) out.push(" " + escape(commit.body));
10077
10127
  }
10078
10128
  return out;
10079
10129
  }
10080
- function barSection(brief, code) {
10130
+ function barSection(brief, code, text2) {
10081
10131
  if (brief?.bar !== void 0) {
10082
- return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
10132
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
10083
10133
  }
10084
10134
  return [
10085
10135
  "## The bar",
@@ -10138,9 +10188,9 @@ function answerSection() {
10138
10188
  " the gap you filled by asking instead of guessing."
10139
10189
  ];
10140
10190
  }
10141
- function calibrationSection(brief, code) {
10191
+ function calibrationSection(brief, code, text2) {
10142
10192
  if (brief?.calibration !== void 0) {
10143
- return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
10193
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
10144
10194
  }
10145
10195
  return [
10146
10196
  "## Calibration",
@@ -10198,20 +10248,20 @@ function jobSection(task, hasHistory) {
10198
10248
  }
10199
10249
  return out;
10200
10250
  }
10201
- function stakesSection(brief, code) {
10251
+ function stakesSection(brief, code, text2) {
10202
10252
  if (brief?.stakes === void 0) return [];
10203
- return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
10253
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
10204
10254
  }
10205
- function whatThisIsSection(overview) {
10255
+ function whatThisIsSection(overview, escape) {
10206
10256
  const body = [];
10207
10257
  if (overview.description !== void 0) {
10208
- body.push("- Declared in `package.json`: " + overview.description);
10258
+ body.push("- Declared in `package.json`: " + escape(overview.description));
10209
10259
  }
10210
10260
  if (overview.summary !== void 0) {
10211
- body.push("- From the `README.md` first paragraph: " + overview.summary);
10261
+ body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
10212
10262
  }
10213
10263
  if (overview.releases.length > 0) {
10214
- body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
10264
+ body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
10215
10265
  }
10216
10266
  if (body.length === 0) return [];
10217
10267
  return [
@@ -10223,16 +10273,16 @@ function whatThisIsSection(overview) {
10223
10273
  ""
10224
10274
  ];
10225
10275
  }
10226
- function ownerNotesSection(brief, code) {
10276
+ function ownerNotesSection(brief, code, text2) {
10227
10277
  if (brief === void 0 || brief.notes.length === 0) return [];
10228
10278
  const out = ["## Owner notes", ""];
10229
10279
  for (const note of brief.notes) {
10230
- out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
10280
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
10231
10281
  }
10232
10282
  return out;
10233
10283
  }
10234
- function ownerBlock(text2, path23, code) {
10235
- return ["> Written by the project owner in " + code(path23) + ", not generated.", "", text2];
10284
+ function ownerBlock(body, path23, code, escape) {
10285
+ return ["> Written by the project owner in " + code(path23) + ", not generated.", "", escape(body)];
10236
10286
  }
10237
10287
  function snapshotSection(manifest, code) {
10238
10288
  const out = ["## This snapshot", ""];
@@ -11389,6 +11439,7 @@ function maskOwnerBrief(brief, secretRules) {
11389
11439
  const mask = (value) => maskPathText(value, secretRules);
11390
11440
  return {
11391
11441
  ...brief,
11442
+ path: mask(brief.path),
11392
11443
  ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11393
11444
  ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11394
11445
  ...brief.history === void 0 ? {} : { history: mask(brief.history) },
@@ -12662,7 +12713,9 @@ function generateSnapshot(configInput, options) {
12662
12713
  // configuration drift.
12663
12714
  maxParts: config.maxParts ?? null,
12664
12715
  promptTask: config.promptTask,
12665
- ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12716
+ // The path is user input like every other name in this block: a credential-shaped
12717
+ // directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
12718
+ ...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
12666
12719
  discovery: config.discovery ?? "auto",
12667
12720
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12668
12721
  // describes the run has to name it.
@@ -14839,7 +14892,7 @@ function buildAgentContract() {
14839
14892
  type: "string",
14840
14893
  default: "unset",
14841
14894
  appliesTo: optionAppliesTo("brief"),
14842
- summary: "Path to the owner-written half of PROMPT.md: Stakes, The system, What came before, The bar and Calibration replace or extend the generated prose; any other heading is kept as Owner notes. The measured headings cannot be redefined. A missing file is an error and an edited file is config drift."
14895
+ 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; fenced code is content, not headings. The file is capped at 64 KiB. A missing file is an error and an edited file is config drift."
14843
14896
  },
14844
14897
  {
14845
14898
  flag: "--prompt-task",
@@ -15542,6 +15595,8 @@ function ensureSingleRead(uri, text2, advice) {
15542
15595
  }
15543
15596
  var MANIFEST_ADVICE = "Cutting a JSON document at the limit leaves invalid JSON, so this resource is never truncated. Use the snapshot_locate, snapshot_read and snapshot_status tools instead \u2014 they read the manifest directly \u2014 or read manifest.json from the snapshot directory.";
15544
15597
  var PART_ADVICE = "A part cut at the limit is a fragment of a file, not the file. Use snapshot_locate to find the file inside this part that you need, then snapshot_read for a bounded window of it.";
15598
+ var PROMPT_URI = "snapshot://prompt";
15599
+ var PROMPT_ADVICE = "PROMPT.md is written whole and never truncated; regenerate it with snapshot_generate, then read it from the snapshot directory.";
15545
15600
  var REPORT_ADVICE = "A report cut at the limit would look complete and would not be. Read it from the snapshot directory instead: the file on disk is complete.";
15546
15601
  var PART_URI = /^snapshot:\/\/parts\/(\d+)$/;
15547
15602
  var REPORT_URIS = /* @__PURE__ */ new Map([
@@ -15592,6 +15647,13 @@ function buildResourceProvider() {
15592
15647
  title: "Agent skill",
15593
15648
  description: "Usage guidance for an agent working with this tool.",
15594
15649
  mimeType: "text/markdown"
15650
+ },
15651
+ {
15652
+ uri: PROMPT_URI,
15653
+ name: "prompt",
15654
+ title: "Snapshot brief",
15655
+ description: "The brief for this snapshot: the job, what the snapshot contains, what it omits, the history it was built from and the standard the answer is held to. Read this before the parts; it names which part holds which file.",
15656
+ mimeType: "text/markdown"
15595
15657
  }
15596
15658
  ];
15597
15659
  for (const [uri, report] of REPORT_URIS) {
@@ -15656,6 +15718,13 @@ function buildResourceProvider() {
15656
15718
  }
15657
15719
  const workspace = await workspaceFor(context);
15658
15720
  if ("error" in workspace) return null;
15721
+ if (uri === PROMPT_URI) {
15722
+ const text2 = readFileIfPresent(
15723
+ path17__namespace.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
15724
+ );
15725
+ if (text2 === null) return null;
15726
+ return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, PROMPT_ADVICE) };
15727
+ }
15659
15728
  const report = REPORT_URIS.get(uri);
15660
15729
  if (report) {
15661
15730
  const text2 = readFileIfPresent(
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-BXWV2OXE.js';
2
- export { buildAgentContract } from './chunk-BXWV2OXE.js';
3
- import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-H4FSGTEW.js';
1
+ import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-BITMWXYS.js';
2
+ export { buildAgentContract } from './chunk-BITMWXYS.js';
3
+ import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-74ZAF64D.js';
4
4
  import { spawnSync } from 'child_process';
5
5
  import * as fs from 'fs';
6
6
  import * as path2 from 'path';
package/dist/index.cjs CHANGED
@@ -1766,7 +1766,23 @@ function parseOwnerBrief(filePath, text2) {
1766
1766
  const preamble = [];
1767
1767
  const sections = [];
1768
1768
  let current = null;
1769
+ let fence = null;
1769
1770
  for (const line of source.split(/\r?\n/)) {
1771
+ const fenceLine = /^ {0,3}(`{3,}|~{3,})/.exec(line);
1772
+ if (fenceLine) {
1773
+ const marker2 = fenceLine[1];
1774
+ const char = marker2[0];
1775
+ if (fence === null) fence = { char, length: marker2.length };
1776
+ else if (char === fence.char && marker2.length >= fence.length) fence = null;
1777
+ if (current) current.body.push(line);
1778
+ else preamble.push(line);
1779
+ continue;
1780
+ }
1781
+ if (fence !== null) {
1782
+ if (current) current.body.push(line);
1783
+ else preamble.push(line);
1784
+ continue;
1785
+ }
1770
1786
  const heading = /^##\s+(.+?)\s*$/.exec(line);
1771
1787
  if (heading) {
1772
1788
  current = { heading: heading[1], body: [] };
@@ -1778,7 +1794,7 @@ function parseOwnerBrief(filePath, text2) {
1778
1794
  }
1779
1795
  const recognised = {};
1780
1796
  const notes = [];
1781
- const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
1797
+ const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
1782
1798
  const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
1783
1799
  const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
1784
1800
  const seen = /* @__PURE__ */ new Set();
@@ -3994,7 +4010,7 @@ function applySpansKeepingQuotes(line, spans) {
3994
4010
 
3995
4011
  // src/version.ts
3996
4012
  var GENERATOR_NAME = "codebase-snapshot";
3997
- var GENERATOR_VERSION = "0.12.1";
4013
+ var GENERATOR_VERSION = "0.12.2";
3998
4014
  var SCHEMA_VERSION = "3.0.0";
3999
4015
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
4000
4016
  function isOurGeneratorName(name) {
@@ -5401,6 +5417,7 @@ function resolvePromptTask(value) {
5401
5417
  'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
5402
5418
  );
5403
5419
  }
5420
+ var MAX_BRIEF_BYTES = 64 * 1024;
5404
5421
  function readConfiguredBrief(cwd, value) {
5405
5422
  if (value === void 0 || value === null) return void 0;
5406
5423
  if (typeof value !== "string" || value.trim().length === 0) {
@@ -5418,6 +5435,12 @@ function readConfiguredBrief(cwd, value) {
5418
5435
  'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
5419
5436
  );
5420
5437
  }
5438
+ const bytes = Buffer.byteLength(text2, "utf8");
5439
+ if (bytes > MAX_BRIEF_BYTES) {
5440
+ throw new Error(
5441
+ 'brief "' + value + '" is ' + bytes + " bytes; the limit is " + MAX_BRIEF_BYTES + ". Keep it to what a reader can act on, or move the detail into a document the snapshot carries."
5442
+ );
5443
+ }
5421
5444
  const parsed = parseOwnerBrief(value, text2);
5422
5445
  if (parsed.problems.length > 0) {
5423
5446
  throw new Error(
@@ -6884,6 +6907,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
6884
6907
  const brief = context.brief;
6885
6908
  const wrote = (name) => artifacts?.[name] !== false;
6886
6909
  const code = (value) => inlineCode(escapeControls(value));
6910
+ const text2 = (value) => escapeControls(value);
6887
6911
  const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
6888
6912
  const lines = [
6889
6913
  "# PROMPT.md",
@@ -6902,18 +6926,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
6902
6926
  "the snapshot is what exists.",
6903
6927
  ""
6904
6928
  ];
6905
- if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
6929
+ if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
6906
6930
  lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
6907
- lines.push(...stakesSection(brief, code));
6931
+ lines.push(...stakesSection(brief, code, text2));
6908
6932
  lines.push(...haveSection(wrote), "");
6909
- lines.push(...whatThisIsSection(overview), "");
6910
- lines.push(...systemSection(manifest, code, brief), "");
6911
- lines.push(...historySection(history, brief, code), "");
6912
- lines.push(...barSection(brief, code), "");
6933
+ lines.push(...whatThisIsSection(overview, text2), "");
6934
+ lines.push(...systemSection(manifest, code, brief, text2), "");
6935
+ lines.push(...historySection(history, brief, code, text2), "");
6936
+ lines.push(...barSection(brief, code, text2), "");
6913
6937
  lines.push(...coverageSection(manifest, code, wrote("audit")), "");
6914
6938
  lines.push(...answerSection(), "");
6915
- lines.push(...calibrationSection(brief, code), "");
6916
- lines.push(...ownerNotesSection(brief, code));
6939
+ lines.push(...calibrationSection(brief, code, text2), "");
6940
+ lines.push(...ownerNotesSection(brief, code, text2));
6917
6941
  lines.push(...snapshotSection(manifest, code), "");
6918
6942
  lines.push(...deliverySection(manifest, wrote("parts"), slots));
6919
6943
  lines.push(
@@ -6992,10 +7016,10 @@ function haveSection(wrote) {
6992
7016
  out.push(...bullets);
6993
7017
  return out;
6994
7018
  }
6995
- function systemSection(manifest, code, brief) {
7019
+ function systemSection(manifest, code, brief, escape) {
6996
7020
  const out = ["## The system", ""];
6997
7021
  if (brief?.system !== void 0) {
6998
- out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
7022
+ out.push(...ownerBlock(brief.system, brief.path, code, escape), "", "What the index records:", "");
6999
7023
  }
7000
7024
  const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
7001
7025
  if (layers.length > 0) {
@@ -7054,9 +7078,9 @@ function systemSection(manifest, code, brief) {
7054
7078
  }
7055
7079
  return out;
7056
7080
  }
7057
- function historySection(history, brief, code) {
7081
+ function historySection(history, brief, code, escape) {
7058
7082
  const out = ["## What came before", ""];
7059
- if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
7083
+ if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
7060
7084
  if (history.length === 0) {
7061
7085
  out.push(
7062
7086
  "No history was readable: this is not a git checkout, or git could not be run. Nothing about",
@@ -7071,14 +7095,14 @@ function historySection(history, brief, code) {
7071
7095
  ""
7072
7096
  );
7073
7097
  for (const commit of history) {
7074
- out.push("- " + commit.subject);
7075
- if (commit.body.length > 0) out.push(" " + commit.body);
7098
+ out.push("- " + escape(commit.subject));
7099
+ if (commit.body.length > 0) out.push(" " + escape(commit.body));
7076
7100
  }
7077
7101
  return out;
7078
7102
  }
7079
- function barSection(brief, code) {
7103
+ function barSection(brief, code, text2) {
7080
7104
  if (brief?.bar !== void 0) {
7081
- return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
7105
+ return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
7082
7106
  }
7083
7107
  return [
7084
7108
  "## The bar",
@@ -7137,9 +7161,9 @@ function answerSection() {
7137
7161
  " the gap you filled by asking instead of guessing."
7138
7162
  ];
7139
7163
  }
7140
- function calibrationSection(brief, code) {
7164
+ function calibrationSection(brief, code, text2) {
7141
7165
  if (brief?.calibration !== void 0) {
7142
- return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
7166
+ return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
7143
7167
  }
7144
7168
  return [
7145
7169
  "## Calibration",
@@ -7197,20 +7221,20 @@ function jobSection(task, hasHistory) {
7197
7221
  }
7198
7222
  return out;
7199
7223
  }
7200
- function stakesSection(brief, code) {
7224
+ function stakesSection(brief, code, text2) {
7201
7225
  if (brief?.stakes === void 0) return [];
7202
- return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
7226
+ return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
7203
7227
  }
7204
- function whatThisIsSection(overview) {
7228
+ function whatThisIsSection(overview, escape) {
7205
7229
  const body = [];
7206
7230
  if (overview.description !== void 0) {
7207
- body.push("- Declared in `package.json`: " + overview.description);
7231
+ body.push("- Declared in `package.json`: " + escape(overview.description));
7208
7232
  }
7209
7233
  if (overview.summary !== void 0) {
7210
- body.push("- From the `README.md` first paragraph: " + overview.summary);
7234
+ body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
7211
7235
  }
7212
7236
  if (overview.releases.length > 0) {
7213
- body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
7237
+ body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
7214
7238
  }
7215
7239
  if (body.length === 0) return [];
7216
7240
  return [
@@ -7222,16 +7246,16 @@ function whatThisIsSection(overview) {
7222
7246
  ""
7223
7247
  ];
7224
7248
  }
7225
- function ownerNotesSection(brief, code) {
7249
+ function ownerNotesSection(brief, code, text2) {
7226
7250
  if (brief === void 0 || brief.notes.length === 0) return [];
7227
7251
  const out = ["## Owner notes", ""];
7228
7252
  for (const note of brief.notes) {
7229
- out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
7253
+ out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
7230
7254
  }
7231
7255
  return out;
7232
7256
  }
7233
- function ownerBlock(text2, path18, code) {
7234
- return ["> Written by the project owner in " + code(path18) + ", not generated.", "", text2];
7257
+ function ownerBlock(body, path18, code, escape) {
7258
+ return ["> Written by the project owner in " + code(path18) + ", not generated.", "", escape(body)];
7235
7259
  }
7236
7260
  function snapshotSection(manifest, code) {
7237
7261
  const out = ["## This snapshot", ""];
@@ -8098,6 +8122,32 @@ function describeManifestShapeProblem(value) {
8098
8122
  if (!config || typeof config !== "object" || Array.isArray(config)) {
8099
8123
  return 'missing "config" object';
8100
8124
  }
8125
+ const recordedConfig = config;
8126
+ const promptTask = recordedConfig.promptTask;
8127
+ if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
8128
+ return '`config.promptTask` must be "audit", "review" or "explain"';
8129
+ }
8130
+ const recordedBrief = recordedConfig.brief;
8131
+ if (recordedBrief !== void 0) {
8132
+ if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
8133
+ return "`config.brief` must be an object";
8134
+ }
8135
+ const briefRecord = recordedBrief;
8136
+ if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
8137
+ return "`config.brief.path` must be a non-empty string";
8138
+ }
8139
+ if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
8140
+ return "`config.brief.digest` must be a sha256 hex digest";
8141
+ }
8142
+ }
8143
+ const recordedSlots = recordedConfig.attachmentSlots;
8144
+ if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
8145
+ return "`config.attachmentSlots` must be a non-negative integer";
8146
+ }
8147
+ const recordedMaxParts = recordedConfig.maxParts;
8148
+ if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
8149
+ return "`config.maxParts` must be a positive integer or null";
8150
+ }
8101
8151
  const budgets = candidate.budgets;
8102
8152
  if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
8103
8153
  return 'missing "budgets" object';
@@ -11341,6 +11391,7 @@ function maskOwnerBrief(brief, secretRules) {
11341
11391
  const mask = (value) => maskPathText(value, secretRules);
11342
11392
  return {
11343
11393
  ...brief,
11394
+ path: mask(brief.path),
11344
11395
  ...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
11345
11396
  ...brief.system === void 0 ? {} : { system: mask(brief.system) },
11346
11397
  ...brief.history === void 0 ? {} : { history: mask(brief.history) },
@@ -12614,7 +12665,9 @@ function generateSnapshot(configInput, options) {
12614
12665
  // configuration drift.
12615
12666
  maxParts: config.maxParts ?? null,
12616
12667
  promptTask: config.promptTask,
12617
- ...config.brief === void 0 ? {} : { brief: { path: config.brief.path, digest: config.brief.digest } },
12668
+ // The path is user input like every other name in this block: a credential-shaped
12669
+ // directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
12670
+ ...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
12618
12671
  discovery: config.discovery ?? "auto",
12619
12672
  // A changed-files scope decides which files are in the snapshot, so the manifest that
12620
12673
  // describes the run has to name it.
package/dist/index.d.cts CHANGED
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
548
548
  * `package.json` carries the same version; `npm run verify` compares the two.
549
549
  */
550
550
  declare const GENERATOR_NAME = "codebase-snapshot";
551
- declare const GENERATOR_VERSION = "0.12.1";
551
+ declare const GENERATOR_VERSION = "0.12.2";
552
552
  /**
553
553
  * The manifest and ownership-marker schema this build writes and understands.
554
554
  *
package/dist/index.d.ts CHANGED
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
548
548
  * `package.json` carries the same version; `npm run verify` compares the two.
549
549
  */
550
550
  declare const GENERATOR_NAME = "codebase-snapshot";
551
- declare const GENERATOR_VERSION = "0.12.1";
551
+ declare const GENERATOR_VERSION = "0.12.2";
552
552
  /**
553
553
  * The manifest and ownership-marker schema this build writes and understands.
554
554
  *
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-H4FSGTEW.js';
1
+ export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-74ZAF64D.js';