codebase-snapshot 0.10.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, P as PartMetadata, F as FileEntry, T as TextEncoding, d as SecretFinding, V as ValidationResult, e as Manifest, A as ArtifactSelection } from './types-BoWneA7n.cjs';
2
- export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as IncompleteFile, h as ManifestArtifact, i as ManifestConfigSnapshot, j as ManifestIndexes, k as ManifestTotals, l as Mode, O as OutputFormat, m as PartFileEntry, n as ResolvedArtifacts, o as ResolvedBudgets, p as SecretRuleInput, q as SkipReason, r as SummaryQuality, s as TruncationReason, t as ValidationDrift } from './types-BoWneA7n.cjs';
1
+ import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, A as ArtifactSelection } from './types-c0tLF2WC.cjs';
2
+ export { g as BudgetConfig, H as HooksConfig, I as InclusionMode, h as IncompleteFile, i as ManifestArtifact, j as ManifestConfigSnapshot, k as ManifestIndexes, l as ManifestTotals, m as Mode, O as OutputFormat, n as OwnerBrief, o as PartFileEntry, P as PromptTask, p as ResolvedArtifacts, q as ResolvedBudgets, r as SecretRuleInput, s as SkipReason, t as SummaryQuality, u as TruncationReason, v as ValidationDrift } from './types-c0tLF2WC.cjs';
3
3
  export { w as workerEntry } from './generate-worker-BK4uJx7Z.cjs';
4
4
 
5
5
  interface GitInfo {
@@ -210,7 +210,7 @@ declare const MIN_MAX_PART_BYTES = 4096;
210
210
  */
211
211
  declare const MIN_MAX_PART_TOKENS: number;
212
212
  /** Every artifact this package can write, in the order it is written. */
213
- declare const ARTIFACT_NAMES: readonly ["readme", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
213
+ declare const ARTIFACT_NAMES: readonly ["readme", "prompt", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
214
214
  /**
215
215
  * Parses a byte budget.
216
216
  *
@@ -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.10.2";
551
+ declare const GENERATOR_VERSION = "0.12.0";
552
552
  /**
553
553
  * The manifest and ownership-marker schema this build writes and understands.
554
554
  *
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, P as PartMetadata, F as FileEntry, T as TextEncoding, d as SecretFinding, V as ValidationResult, e as Manifest, A as ArtifactSelection } from './types-BoWneA7n.js';
2
- export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as IncompleteFile, h as ManifestArtifact, i as ManifestConfigSnapshot, j as ManifestIndexes, k as ManifestTotals, l as Mode, O as OutputFormat, m as PartFileEntry, n as ResolvedArtifacts, o as ResolvedBudgets, p as SecretRuleInput, q as SkipReason, r as SummaryQuality, s as TruncationReason, t as ValidationDrift } from './types-BoWneA7n.js';
1
+ import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, A as ArtifactSelection } from './types-c0tLF2WC.js';
2
+ export { g as BudgetConfig, H as HooksConfig, I as InclusionMode, h as IncompleteFile, i as ManifestArtifact, j as ManifestConfigSnapshot, k as ManifestIndexes, l as ManifestTotals, m as Mode, O as OutputFormat, n as OwnerBrief, o as PartFileEntry, P as PromptTask, p as ResolvedArtifacts, q as ResolvedBudgets, r as SecretRuleInput, s as SkipReason, t as SummaryQuality, u as TruncationReason, v as ValidationDrift } from './types-c0tLF2WC.js';
3
3
  export { w as workerEntry } from './generate-worker-BK4uJx7Z.js';
4
4
 
5
5
  interface GitInfo {
@@ -210,7 +210,7 @@ declare const MIN_MAX_PART_BYTES = 4096;
210
210
  */
211
211
  declare const MIN_MAX_PART_TOKENS: number;
212
212
  /** Every artifact this package can write, in the order it is written. */
213
- declare const ARTIFACT_NAMES: readonly ["readme", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
213
+ declare const ARTIFACT_NAMES: readonly ["readme", "prompt", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
214
214
  /**
215
215
  * Parses a byte budget.
216
216
  *
@@ -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.10.2";
551
+ declare const GENERATOR_VERSION = "0.12.0";
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-5AV7OR3J.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-6HXDYIJS.js';
package/dist/mcp.cjs CHANGED
@@ -278,6 +278,77 @@ function stripTrailingCommas(text) {
278
278
  }
279
279
  return out;
280
280
  }
281
+ var OWNER_SECTIONS = ["Stakes", "The system", "What came before", "The bar", "Calibration"];
282
+ var RESERVED_SECTIONS = [
283
+ "The job",
284
+ "What you have",
285
+ "Coverage",
286
+ "What a useful answer contains",
287
+ "This snapshot",
288
+ "Attaching this",
289
+ "Your task"
290
+ ];
291
+ function parseOwnerBrief(filePath, text) {
292
+ const problems = [];
293
+ const source = text.replace(/^\uFEFF/, "");
294
+ const preamble = [];
295
+ const sections = [];
296
+ let current = null;
297
+ for (const line of source.split(/\r?\n/)) {
298
+ const heading = /^##\s+(.+?)\s*$/.exec(line);
299
+ if (heading) {
300
+ current = { heading: heading[1], body: [] };
301
+ sections.push(current);
302
+ continue;
303
+ }
304
+ if (current) current.body.push(line);
305
+ else preamble.push(line);
306
+ }
307
+ const recognised = {};
308
+ const notes = [];
309
+ const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
310
+ const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
311
+ const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
312
+ const seen = /* @__PURE__ */ new Set();
313
+ for (const section of sections) {
314
+ const body = section.body.join("\n").trim();
315
+ const key = canonical(section.heading);
316
+ if (seen.has(key)) {
317
+ problems.push(
318
+ `the brief defines "${section.heading}" twice; a section cannot say two things.`
319
+ );
320
+ continue;
321
+ }
322
+ seen.add(key);
323
+ if (canonicalReserved.has(key)) {
324
+ problems.push(
325
+ `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.`
326
+ );
327
+ continue;
328
+ }
329
+ const ownerName = canonicalOwner.get(key);
330
+ if (ownerName !== void 0) {
331
+ recognised[ownerName] = body;
332
+ continue;
333
+ }
334
+ notes.push({ heading: section.heading, body });
335
+ }
336
+ const preambleText = preamble.join("\n").trim();
337
+ return {
338
+ brief: {
339
+ path: filePath,
340
+ digest: crypto.createHash("sha256").update(text, "utf8").digest("hex"),
341
+ ...recognised["Stakes"] ? { stakes: recognised["Stakes"] } : {},
342
+ ...recognised["The system"] ? { system: recognised["The system"] } : {},
343
+ ...recognised["What came before"] ? { history: recognised["What came before"] } : {},
344
+ ...recognised["The bar"] ? { bar: recognised["The bar"] } : {},
345
+ ...recognised["Calibration"] ? { calibration: recognised["Calibration"] } : {},
346
+ notes,
347
+ ...preambleText.length > 0 ? { preamble: preambleText } : {}
348
+ },
349
+ problems
350
+ };
351
+ }
281
352
  var MANIFEST_FILES = [
282
353
  "package.json",
283
354
  "pyproject.toml",
@@ -2451,7 +2522,7 @@ function applySpansKeepingQuotes(line, spans) {
2451
2522
 
2452
2523
  // src/version.ts
2453
2524
  var GENERATOR_NAME = "codebase-snapshot";
2454
- var GENERATOR_VERSION = "0.10.2";
2525
+ var GENERATOR_VERSION = "0.12.0";
2455
2526
  var SCHEMA_VERSION = "3.0.0";
2456
2527
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2457
2528
  function isOurGeneratorName(name) {
@@ -3406,6 +3477,12 @@ function normalizeResolvedConfig(config) {
3406
3477
  return markResolvedConfig({
3407
3478
  ...config,
3408
3479
  discovery,
3480
+ // A spread copy built before the field existed carries no value; the default applies, and it
3481
+ // is re-validated because the number reaches a rendered artifact.
3482
+ attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3483
+ maxParts: resolveMaxParts(config.maxParts),
3484
+ promptTask: resolvePromptTask(config.promptTask),
3485
+ ...config.brief === void 0 ? {} : { brief: config.brief },
3409
3486
  includeMonolith: artifacts.monolith,
3410
3487
  secretRules: compileSecretRules(config.secretRules),
3411
3488
  artifacts,
@@ -3474,7 +3551,9 @@ function describeValue2(value) {
3474
3551
  var isThenable = (value) => typeof value.then === "function";
3475
3552
  var CONFIG_KEY_NAMES = [
3476
3553
  "artifacts",
3554
+ "attachmentSlots",
3477
3555
  "branch",
3556
+ "brief",
3478
3557
  "budgets",
3479
3558
  "changedSince",
3480
3559
  "cwd",
@@ -3491,10 +3570,12 @@ var CONFIG_KEY_NAMES = [
3491
3570
  "layersMode",
3492
3571
  "maxMonolithBytes",
3493
3572
  "maxPartBytes",
3573
+ "maxParts",
3494
3574
  "maxPartTokens",
3495
3575
  "outDir",
3496
3576
  "preset",
3497
3577
  "previewHeadLines",
3578
+ "promptTask",
3498
3579
  "staged",
3499
3580
  "previewTailLines",
3500
3581
  "secretRules",
@@ -3689,6 +3770,7 @@ var MIN_MAX_PART_BYTES = 4096;
3689
3770
  var MIN_MAX_PART_TOKENS = MIN_MAX_PART_BYTES / 4;
3690
3771
  var ARTIFACT_NAMES = [
3691
3772
  "readme",
3773
+ "prompt",
3692
3774
  "manifest",
3693
3775
  "parts",
3694
3776
  "navigation",
@@ -3698,6 +3780,7 @@ var ARTIFACT_NAMES = [
3698
3780
  ];
3699
3781
  var DEFAULT_ARTIFACTS = {
3700
3782
  readme: true,
3783
+ prompt: true,
3701
3784
  manifest: true,
3702
3785
  parts: true,
3703
3786
  navigation: true,
@@ -3758,6 +3841,57 @@ function resolveArtifacts(requested, skipped, includeMonolith, monolithOverride,
3758
3841
  }
3759
3842
  return artifacts;
3760
3843
  }
3844
+ var DEFAULT_ATTACHMENT_SLOTS = 10;
3845
+ function resolveAttachmentSlots(value) {
3846
+ if (value === void 0 || value === null) return DEFAULT_ATTACHMENT_SLOTS;
3847
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
3848
+ throw new Error(
3849
+ "attachmentSlots must be a whole number, with 0 meaning no limit (received " + describeValue2(value) + ")."
3850
+ );
3851
+ }
3852
+ return value;
3853
+ }
3854
+ function resolveMaxParts(value) {
3855
+ if (value === void 0 || value === null) return null;
3856
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 1) {
3857
+ throw new Error(
3858
+ "maxParts must be a whole number of parts, or null to disable it (received " + describeValue2(value) + ")."
3859
+ );
3860
+ }
3861
+ return value;
3862
+ }
3863
+ function resolvePromptTask(value) {
3864
+ if (value === void 0 || value === null) return "audit";
3865
+ if (value === "audit" || value === "review" || value === "explain") return value;
3866
+ throw new Error(
3867
+ 'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
3868
+ );
3869
+ }
3870
+ function readConfiguredBrief(cwd, value) {
3871
+ if (value === void 0 || value === null) return void 0;
3872
+ if (typeof value !== "string" || value.trim().length === 0) {
3873
+ throw new Error(
3874
+ "brief must be a path to a markdown file (received " + describeValue2(value) + ")."
3875
+ );
3876
+ }
3877
+ const filePath = path5__namespace.resolve(cwd, value);
3878
+ let text;
3879
+ try {
3880
+ if (!fs2__namespace.statSync(filePath).isFile()) throw new Error("not a file");
3881
+ text = fs2__namespace.readFileSync(filePath, "utf8");
3882
+ } catch {
3883
+ throw new Error(
3884
+ 'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
3885
+ );
3886
+ }
3887
+ const parsed = parseOwnerBrief(value, text);
3888
+ if (parsed.problems.length > 0) {
3889
+ throw new Error(
3890
+ 'brief "' + value + '" cannot be used:\n - ' + parsed.problems.join("\n - ")
3891
+ );
3892
+ }
3893
+ return parsed.brief;
3894
+ }
3761
3895
  function strictPositiveInteger(value, fallback, label) {
3762
3896
  if (value === void 0) return fallback;
3763
3897
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -4117,6 +4251,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4117
4251
  configuredSensitiveFiles,
4118
4252
  "`includeSensitiveFiles`"
4119
4253
  );
4254
+ const configuredBrief = readConfiguredBrief(
4255
+ cwd,
4256
+ cliOptions?.brief ?? userConfig?.brief
4257
+ );
4120
4258
  const presetExclude = [
4121
4259
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
4122
4260
  ];
@@ -4136,6 +4274,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4136
4274
  "maxMonolithBytes"
4137
4275
  ),
4138
4276
  includeSensitiveFiles,
4277
+ attachmentSlots: resolveAttachmentSlots(
4278
+ cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4279
+ ),
4280
+ maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4281
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
4282
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
4139
4283
  ...changedSince === void 0 ? {} : { changedSince },
4140
4284
  ...staged ? { staged } : {},
4141
4285
  ...withDependents ? { withDependents } : {},
@@ -4218,6 +4362,15 @@ function configDigest(config) {
4218
4362
  includeMonolith: config.includeMonolith,
4219
4363
  maxMonolithBytes: config.maxMonolithBytes ?? null,
4220
4364
  includeSensitiveFiles: config.includeSensitiveFiles,
4365
+ // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4366
+ // material would change the digest of every snapshot taken before the setting existed.
4367
+ ...config.maxParts === null ? {} : { maxParts: config.maxParts },
4368
+ // The default value is omitted for the same reason: a snapshot taken before the setting
4369
+ // existed kept the audit job, so it must keep the digest it was written with.
4370
+ ...config.promptTask === "audit" ? {} : { promptTask: config.promptTask },
4371
+ // The owner brief is instruction, not payload, but it changes what the snapshot tells a
4372
+ // reader to do, so a changed brief is drift exactly like a changed budget.
4373
+ ...config.brief === void 0 ? {} : { brief: config.brief.digest },
4221
4374
  artifacts: config.artifacts,
4222
4375
  include: config.include,
4223
4376
  excludePatterns: config.excludePatterns,
@@ -6964,7 +7117,8 @@ function validateSnapshot(configInput) {
6964
7117
  );
6965
7118
  }
6966
7119
  }
6967
- if (manifest.budgets && manifest.budgets.maxPartBytes !== config.maxPartBytes) {
7120
+ const ceilingDerivedByMaxParts = (manifest.config?.maxParts ?? null) !== null;
7121
+ if (!ceilingDerivedByMaxParts && manifest.budgets && manifest.budgets.maxPartBytes !== config.maxPartBytes) {
6968
7122
  totalsMismatches.push(
6969
7123
  `budgets.maxPartBytes: manifest ${manifest.budgets.maxPartBytes} vs current ${config.maxPartBytes}`
6970
7124
  );
@@ -6993,6 +7147,7 @@ function validateSnapshot(configInput) {
6993
7147
  }
6994
7148
  const declaredArtifacts = [
6995
7149
  ["README.md", manifest.artifacts?.readme],
7150
+ ["PROMPT.md", manifest.artifacts?.prompt],
6996
7151
  ["reports/navigation.md", manifest.artifacts?.navigation],
6997
7152
  ["reports/project-tree.md", manifest.artifacts?.projectTree],
6998
7153
  ["reports/audit.md", manifest.artifacts?.audit],
@@ -8694,6 +8849,9 @@ var VALIDATE_OPTIONS = [
8694
8849
  "max-part-tokens",
8695
8850
  "large-file-bytes",
8696
8851
  "max-monolith-bytes",
8852
+ "max-parts",
8853
+ "brief",
8854
+ "prompt-task",
8697
8855
  "include-monolith",
8698
8856
  "include-sensitive-files",
8699
8857
  "skip-artifacts",
@@ -8719,6 +8877,10 @@ var COMMAND_OPTION_SCOPE = {
8719
8877
  "max-part-tokens",
8720
8878
  "large-file-bytes",
8721
8879
  "max-monolith-bytes",
8880
+ "attachment-slots",
8881
+ "max-parts",
8882
+ "brief",
8883
+ "prompt-task",
8722
8884
  "include-monolith",
8723
8885
  "include-sensitive-files",
8724
8886
  "skip-artifacts",
@@ -8864,6 +9026,7 @@ var PACKAGE_NAME = "codebase-snapshot";
8864
9026
  var MAJOR_VERSION = GENERATOR_VERSION.split(".")[0];
8865
9027
  var ARTIFACT_SUMMARY = {
8866
9028
  readme: "README.md describing the snapshot at the output root.",
9029
+ prompt: "PROMPT.md: the instruction sheet to paste with the snapshot, rendered from its manifest.",
8867
9030
  manifest: "manifest.json: machine-readable index of every file, part, hash and config.",
8868
9031
  parts: "parts/*.md: the packed, budget-limited markdown parts that carry the code.",
8869
9032
  navigation: "reports/navigation.md: links between parts and layers.",
@@ -8873,6 +9036,7 @@ var ARTIFACT_SUMMARY = {
8873
9036
  };
8874
9037
  var ARTIFACT_DEFAULTS = {
8875
9038
  readme: true,
9039
+ prompt: true,
8876
9040
  manifest: true,
8877
9041
  parts: true,
8878
9042
  navigation: true,
@@ -8944,9 +9108,9 @@ function buildAgentContract() {
8944
9108
  {
8945
9109
  step: 6,
8946
9110
  id: "consume",
8947
- run: "read ./snapshot/parts/*.md, then ./snapshot/manifest.json, then ./snapshot/reports/audit.md",
9111
+ run: "read ./snapshot/PROMPT.md first, then ./snapshot/parts/*.md, ./snapshot/manifest.json and ./snapshot/reports/audit.md",
8948
9112
  expect: "the code, the index of what was included, and the risk findings",
8949
- notes: "manifest.json.files[] lists every included file with layer, kind, language, part and summary. manifest.skipped[] explains every file that was left out and why; manifest.incomplete[] lists every included file that is not present in full, with its missing line ranges."
9113
+ notes: "manifest.json.files[] lists every included file with layer, kind, language, part and summary. manifest.skipped[] explains every file that was left out and why; manifest.incomplete[] lists every included file that is not present in full, with its missing line ranges. PROMPT.md is the instruction sheet for whoever reads the snapshot; it is rendered from the manifest, so it names this run's omissions rather than describing snapshots in general."
8950
9114
  }
8951
9115
  ],
8952
9116
  commands: [
@@ -9083,6 +9247,34 @@ function buildAgentContract() {
9083
9247
  appliesTo: optionAppliesTo("discovery"),
9084
9248
  summary: "How files are discovered: auto (git when usable), git (require git), walk (read .gitignore files directly, including nested ones; the escape hatch for a .git that cannot be listed)."
9085
9249
  },
9250
+ {
9251
+ flag: "--attachment-slots",
9252
+ type: "number",
9253
+ default: "10",
9254
+ appliesTo: optionAppliesTo("attachment-slots"),
9255
+ 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."
9256
+ },
9257
+ {
9258
+ flag: "--brief",
9259
+ type: "string",
9260
+ default: "unset",
9261
+ appliesTo: optionAppliesTo("brief"),
9262
+ 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."
9263
+ },
9264
+ {
9265
+ flag: "--prompt-task",
9266
+ type: "string",
9267
+ default: "audit",
9268
+ appliesTo: optionAppliesTo("prompt-task"),
9269
+ summary: "Which job the brief is written for: audit (default), review or explain. It changes the opening section, not the standard."
9270
+ },
9271
+ {
9272
+ flag: "--max-parts",
9273
+ type: "number",
9274
+ default: "unset",
9275
+ appliesTo: optionAppliesTo("max-parts"),
9276
+ summary: "Experimental: grow the per-part budget until the snapshot has at most this many parts. The budget it settles on is recorded in manifest.budgets.maxPartBytes and may exceed maxPartBytes; a warning says so."
9277
+ },
9086
9278
  {
9087
9279
  flag: "--skip-artifacts",
9088
9280
  type: "string",
@@ -9296,6 +9488,10 @@ function buildAgentContract() {
9296
9488
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
9297
9489
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
9298
9490
  { key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
9491
+ { 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." },
9492
+ { 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." },
9493
+ { 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." },
9494
+ { 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." },
9299
9495
  { 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." },
9300
9496
  { key: "artifacts", type: "object", default: "all on except monolith", summary: "Per-artifact opt-out." },
9301
9497
  { key: "budgets", type: "object", default: "{ default, byLayer }", summary: "Per-layer byte budgets." },
@@ -9310,6 +9506,7 @@ function buildAgentContract() {
9310
9506
  output: {
9311
9507
  layout: [
9312
9508
  "<outDir>/README.md",
9509
+ "<outDir>/PROMPT.md",
9313
9510
  "<outDir>/manifest.json",
9314
9511
  "<outDir>/parts/part-NNN.md",
9315
9512
  "<outDir>/reports/project-tree.md",
@@ -9323,6 +9520,7 @@ function buildAgentContract() {
9323
9520
  "indexes.imports.byFile includes previewed files (their import specifiers are still extracted); such an entry carries `exportsOmitted: true` instead of pretending it exports nothing.",
9324
9521
  "validate re-checks manifest.incomplete[] against files[] and refuses a manifest whose two statements of what is missing disagree.",
9325
9522
  "manifest.skipped[] carries the path and the exact reason it was excluded.",
9523
+ "PROMPT.md is rendered from the manifest of the run that wrote it \u2014 its parts, partial files, skip tallies and fingerprint are that run's \u2014 and manifest.artifacts.prompt records its digest, so an edited prompt fails validate.",
9326
9524
  `The output directory is replaced atomically; ${MIN_MAX_PART_BYTES} bytes is the smallest legal budget.`
9327
9525
  ]
9328
9526
  },
@@ -9493,6 +9691,10 @@ do not assume the repository is broken.
9493
9691
  - \`snapshot/reports/audit.md\` \u2014 secrets found, large files, parse diagnostics, git
9494
9692
  state. Read this before you quote code back to a user.
9495
9693
  - \`snapshot/reports/project-tree.md\` and \`navigation.md\` \u2014 structure and cross-links.
9694
+ - \`snapshot/PROMPT.md\` \u2014 the instruction sheet to hand to the model that receives the
9695
+ snapshot: paste it with the parts. It is rendered from this run's manifest and names the
9696
+ parts, the partial files and the fingerprint, so do not rewrite it by hand \u2014 \`validate\`
9697
+ fails when it was edited.
9496
9698
 
9497
9699
  ## Project types
9498
9700
 
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
- export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-5EYBTBFY.js';
2
- export { generateInWorker } from './chunk-5AV7OR3J.js';
1
+ export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-5FPYVWP3.js';
2
+ export { generateInWorker } from './chunk-6HXDYIJS.js';
@@ -374,6 +374,24 @@ interface ManifestConfigSnapshot {
374
374
  */
375
375
  maxMonolithBytes?: number | null;
376
376
  includeSensitiveFiles: boolean;
377
+ /**
378
+ * The file-slot ceiling `PROMPT.md` was planned for; `0` for no limit.
379
+ *
380
+ * Recorded so the manifest states the destination the instructions were written for, and
381
+ * optional because a manifest written before this was recorded has no such key. It is not part
382
+ * of `configDigest`: the payload is identical either way, and a new delivery preference must not
383
+ * make an existing snapshot fail `validate` as configuration drift.
384
+ */
385
+ attachmentSlots?: number;
386
+ /** The part-count ceiling the run enforced, `null` when the experimental mode was off. */
387
+ maxParts?: number | null;
388
+ /** Which job the brief was written for. */
389
+ promptTask?: PromptTask;
390
+ /** The owner brief this run was given, by path and digest. */
391
+ brief?: {
392
+ path: string;
393
+ digest: string;
394
+ };
377
395
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
378
396
  discovery?: DiscoveryMode;
379
397
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -467,6 +485,7 @@ interface Manifest {
467
485
  * recorded has no key; a current manifest records every artifact it wrote.
468
486
  */
469
487
  readme?: ManifestArtifact;
488
+ prompt?: ManifestArtifact;
470
489
  navigation?: ManifestArtifact;
471
490
  projectTree?: ManifestArtifact;
472
491
  audit?: ManifestArtifact;
@@ -510,9 +529,37 @@ interface LayerRule {
510
529
  * is the one exception, because it duplicates the entire payload: it follows
511
530
  * `includeMonolith` (off by default) unless set here explicitly.
512
531
  */
532
+ /**
533
+ * The job the brief is written for.
534
+ *
535
+ * The standard and the coverage duty are the same in all three; what changes is what the
536
+ * reader is asked to produce, in the opening section of the brief.
537
+ */
538
+ type PromptTask = "audit" | "review" | "explain";
539
+ /** The owner-written half of the brief, parsed and hashed. */
540
+ interface OwnerBrief {
541
+ /** Path as the user wrote it, for provenance. */
542
+ path: string;
543
+ /** sha256 of the file as read, so changing it is configuration drift. */
544
+ digest: string;
545
+ stakes?: string;
546
+ system?: string;
547
+ history?: string;
548
+ bar?: string;
549
+ calibration?: string;
550
+ /** Headings the merge did not recognise, kept rather than dropped. */
551
+ notes: Array<{
552
+ heading: string;
553
+ body: string;
554
+ }>;
555
+ /** Text before the first heading, when there is any. */
556
+ preamble?: string;
557
+ }
513
558
  interface ArtifactSelection {
514
559
  /** `README.md` — the orientation page for humans and models. */
515
560
  readme?: boolean;
561
+ /** `PROMPT.md` — the instruction sheet a snapshot is pasted with. */
562
+ prompt?: boolean;
516
563
  /** `manifest.json` — the registry `validate` and `report` read. */
517
564
  manifest?: boolean;
518
565
  /** `parts/part-XXX.md` — the partitioned code payload. */
@@ -572,6 +619,33 @@ interface SnapshotConfig {
572
619
  maxMonolithBytes?: ByteSize | null;
573
620
  /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
574
621
  includeSensitiveFiles?: boolean;
622
+ /**
623
+ * Files the destination accepts in one message; 10 by default, `0` for no limit.
624
+ *
625
+ * `PROMPT.md` plans the delivery to fit: which parts to attach, what to leave behind, and the
626
+ * part budget that would merge them. The payload is unchanged by this setting — only the
627
+ * instructions and the plan that ships with it.
628
+ */
629
+ attachmentSlots?: number;
630
+ /**
631
+ * Experimental: the most parts a snapshot may have.
632
+ *
633
+ * Off by default. When set, the partitioner grows the per-part budget until the run fits this
634
+ * many parts, which is how a repository that keeps growing keeps its shape instead of adding a
635
+ * twelfth file to a chat that takes ten. The budget it settles on is recorded in
636
+ * `manifest.budgets.maxPartBytes` and may exceed the configured `maxPartBytes`; a warning says
637
+ * so, because a larger part is more tokens for the destination to swallow at once.
638
+ */
639
+ maxParts?: number | null;
640
+ /**
641
+ * Path to the owner-written half of the brief, relative to `cwd`.
642
+ *
643
+ * The generated brief can state the job, the map and the standard; it cannot say what the
644
+ * software is for or what has already gone wrong. That is judgement, and it is supplied here.
645
+ */
646
+ brief?: string;
647
+ /** Which job the brief is written for. Defaults to `audit`. */
648
+ promptTask?: PromptTask;
575
649
  /**
576
650
  * How files are discovered; `auto` picks git when it can list files and walks the tree
577
651
  * otherwise.
@@ -644,6 +718,14 @@ interface ResolvedSnapshotConfig {
644
718
  includeMonolith: boolean;
645
719
  maxMonolithBytes: number | null;
646
720
  includeSensitiveFiles: boolean;
721
+ /** Files the destination accepts in one message; `0` means no limit. */
722
+ attachmentSlots: number;
723
+ /** The part-count ceiling, or `null` when the experimental mode is off. */
724
+ maxParts: number | null;
725
+ /** The job the brief is written for. */
726
+ promptTask: PromptTask;
727
+ /** The parsed owner brief, when one was configured. */
728
+ brief?: OwnerBrief;
647
729
  /**
648
730
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
649
731
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -689,6 +771,14 @@ interface CliOptions {
689
771
  includeMonolith?: boolean;
690
772
  includeSensitiveFiles?: boolean;
691
773
  maxMonolithBytes?: number | null;
774
+ /** `--attachment-slots`: how many files the destination accepts. */
775
+ attachmentSlots?: number;
776
+ /** `--max-parts`: the experimental part-count ceiling. */
777
+ maxParts?: number | null;
778
+ /** `--brief`: path to the owner-written half of the brief. */
779
+ brief?: string;
780
+ /** `--prompt-task`: which job the brief is written for. */
781
+ promptTask?: PromptTask;
692
782
  maxPartBytes?: number;
693
783
  maxPartTokens?: ByteSize | null;
694
784
  largeFileBytes?: number;
@@ -738,4 +828,4 @@ interface ValidationResult {
738
828
  warnings: string[];
739
829
  }
740
830
 
741
- export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SecretRule as S, TextEncoding as T, ValidationResult as V, SkipRecord as a, SourceSummary as b, SnapshotConfig as c, SecretFinding as d, Manifest as e, BudgetConfig as f, IncompleteFile as g, ManifestArtifact as h, ManifestConfigSnapshot as i, ManifestIndexes as j, ManifestTotals as k, Mode as l, PartFileEntry as m, ResolvedArtifacts as n, ResolvedBudgets as o, SecretRuleInput as p, SkipReason as q, SummaryQuality as r, TruncationReason as s, ValidationDrift as t };
831
+ export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PromptTask as P, ResolvedSnapshotConfig as R, SecretRule as S, TextEncoding as T, ValidationResult as V, SkipRecord as a, SourceSummary as b, SnapshotConfig as c, PartMetadata as d, SecretFinding as e, Manifest as f, BudgetConfig as g, IncompleteFile as h, ManifestArtifact as i, ManifestConfigSnapshot as j, ManifestIndexes as k, ManifestTotals as l, Mode as m, OwnerBrief as n, PartFileEntry as o, ResolvedArtifacts as p, ResolvedBudgets as q, SecretRuleInput as r, SkipReason as s, SummaryQuality as t, TruncationReason as u, ValidationDrift as v };