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/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-DGWw3SH2.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-DGWw3SH2.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 {
@@ -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.11.0";
551
+ declare const GENERATOR_VERSION = "0.12.1";
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-DGWw3SH2.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-DGWw3SH2.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 {
@@ -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.11.0";
551
+ declare const GENERATOR_VERSION = "0.12.1";
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-NJ75RVHO.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-H4FSGTEW.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.11.0";
2525
+ var GENERATOR_VERSION = "0.12.1";
2455
2526
  var SCHEMA_VERSION = "3.0.0";
2456
2527
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2457
2528
  function isOurGeneratorName(name) {
@@ -3410,6 +3481,8 @@ function normalizeResolvedConfig(config) {
3410
3481
  // is re-validated because the number reaches a rendered artifact.
3411
3482
  attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3412
3483
  maxParts: resolveMaxParts(config.maxParts),
3484
+ promptTask: resolvePromptTask(config.promptTask),
3485
+ ...config.brief === void 0 ? {} : { brief: config.brief },
3413
3486
  includeMonolith: artifacts.monolith,
3414
3487
  secretRules: compileSecretRules(config.secretRules),
3415
3488
  artifacts,
@@ -3480,6 +3553,7 @@ var CONFIG_KEY_NAMES = [
3480
3553
  "artifacts",
3481
3554
  "attachmentSlots",
3482
3555
  "branch",
3556
+ "brief",
3483
3557
  "budgets",
3484
3558
  "changedSince",
3485
3559
  "cwd",
@@ -3501,6 +3575,7 @@ var CONFIG_KEY_NAMES = [
3501
3575
  "outDir",
3502
3576
  "preset",
3503
3577
  "previewHeadLines",
3578
+ "promptTask",
3504
3579
  "staged",
3505
3580
  "previewTailLines",
3506
3581
  "secretRules",
@@ -3785,6 +3860,38 @@ function resolveMaxParts(value) {
3785
3860
  }
3786
3861
  return value;
3787
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
+ }
3788
3895
  function strictPositiveInteger(value, fallback, label) {
3789
3896
  if (value === void 0) return fallback;
3790
3897
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -4144,6 +4251,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4144
4251
  configuredSensitiveFiles,
4145
4252
  "`includeSensitiveFiles`"
4146
4253
  );
4254
+ const configuredBrief = readConfiguredBrief(
4255
+ cwd,
4256
+ cliOptions?.brief ?? userConfig?.brief
4257
+ );
4147
4258
  const presetExclude = [
4148
4259
  .../* @__PURE__ */ new Set([...preset.exclude, ...outputExcludePatterns(cwd, outDir, tmpDir)])
4149
4260
  ];
@@ -4167,6 +4278,8 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4167
4278
  cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4168
4279
  ),
4169
4280
  maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4281
+ promptTask: resolvePromptTask(cliOptions?.promptTask ?? userConfig?.promptTask),
4282
+ ...configuredBrief === void 0 ? {} : { brief: configuredBrief },
4170
4283
  ...changedSince === void 0 ? {} : { changedSince },
4171
4284
  ...staged ? { staged } : {},
4172
4285
  ...withDependents ? { withDependents } : {},
@@ -4252,6 +4365,12 @@ function configDigest(config) {
4252
4365
  // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4253
4366
  // material would change the digest of every snapshot taken before the setting existed.
4254
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 },
4255
4374
  artifacts: config.artifacts,
4256
4375
  include: config.include,
4257
4376
  excludePatterns: config.excludePatterns,
@@ -8731,6 +8850,8 @@ var VALIDATE_OPTIONS = [
8731
8850
  "large-file-bytes",
8732
8851
  "max-monolith-bytes",
8733
8852
  "max-parts",
8853
+ "brief",
8854
+ "prompt-task",
8734
8855
  "include-monolith",
8735
8856
  "include-sensitive-files",
8736
8857
  "skip-artifacts",
@@ -8758,6 +8879,8 @@ var COMMAND_OPTION_SCOPE = {
8758
8879
  "max-monolith-bytes",
8759
8880
  "attachment-slots",
8760
8881
  "max-parts",
8882
+ "brief",
8883
+ "prompt-task",
8761
8884
  "include-monolith",
8762
8885
  "include-sensitive-files",
8763
8886
  "skip-artifacts",
@@ -9131,6 +9254,20 @@ function buildAgentContract() {
9131
9254
  appliesTo: optionAppliesTo("attachment-slots"),
9132
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."
9133
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
+ },
9134
9271
  {
9135
9272
  flag: "--max-parts",
9136
9273
  type: "number",
@@ -9351,6 +9488,8 @@ function buildAgentContract() {
9351
9488
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
9352
9489
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
9353
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." },
9354
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." },
9355
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." },
9356
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." },
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-5ZOXHBTW.js';
2
- export { generateInWorker } from './chunk-NJ75RVHO.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-BXWV2OXE.js';
2
+ export { generateInWorker } from './chunk-H4FSGTEW.js';
@@ -385,6 +385,13 @@ interface ManifestConfigSnapshot {
385
385
  attachmentSlots?: number;
386
386
  /** The part-count ceiling the run enforced, `null` when the experimental mode was off. */
387
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
+ };
388
395
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
389
396
  discovery?: DiscoveryMode;
390
397
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -522,6 +529,32 @@ interface LayerRule {
522
529
  * is the one exception, because it duplicates the entire payload: it follows
523
530
  * `includeMonolith` (off by default) unless set here explicitly.
524
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
+ }
525
558
  interface ArtifactSelection {
526
559
  /** `README.md` — the orientation page for humans and models. */
527
560
  readme?: boolean;
@@ -604,6 +637,15 @@ interface SnapshotConfig {
604
637
  * so, because a larger part is more tokens for the destination to swallow at once.
605
638
  */
606
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;
607
649
  /**
608
650
  * How files are discovered; `auto` picks git when it can list files and walks the tree
609
651
  * otherwise.
@@ -680,6 +722,10 @@ interface ResolvedSnapshotConfig {
680
722
  attachmentSlots: number;
681
723
  /** The part-count ceiling, or `null` when the experimental mode is off. */
682
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;
683
729
  /**
684
730
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
685
731
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -729,6 +775,10 @@ interface CliOptions {
729
775
  attachmentSlots?: number;
730
776
  /** `--max-parts`: the experimental part-count ceiling. */
731
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;
732
782
  maxPartBytes?: number;
733
783
  maxPartTokens?: ByteSize | null;
734
784
  largeFileBytes?: number;
@@ -778,4 +828,4 @@ interface ValidationResult {
778
828
  warnings: string[];
779
829
  }
780
830
 
781
- 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 };
@@ -385,6 +385,13 @@ interface ManifestConfigSnapshot {
385
385
  attachmentSlots?: number;
386
386
  /** The part-count ceiling the run enforced, `null` when the experimental mode was off. */
387
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
+ };
388
395
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
389
396
  discovery?: DiscoveryMode;
390
397
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -522,6 +529,32 @@ interface LayerRule {
522
529
  * is the one exception, because it duplicates the entire payload: it follows
523
530
  * `includeMonolith` (off by default) unless set here explicitly.
524
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
+ }
525
558
  interface ArtifactSelection {
526
559
  /** `README.md` — the orientation page for humans and models. */
527
560
  readme?: boolean;
@@ -604,6 +637,15 @@ interface SnapshotConfig {
604
637
  * so, because a larger part is more tokens for the destination to swallow at once.
605
638
  */
606
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;
607
649
  /**
608
650
  * How files are discovered; `auto` picks git when it can list files and walks the tree
609
651
  * otherwise.
@@ -680,6 +722,10 @@ interface ResolvedSnapshotConfig {
680
722
  attachmentSlots: number;
681
723
  /** The part-count ceiling, or `null` when the experimental mode is off. */
682
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;
683
729
  /**
684
730
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
685
731
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -729,6 +775,10 @@ interface CliOptions {
729
775
  attachmentSlots?: number;
730
776
  /** `--max-parts`: the experimental part-count ceiling. */
731
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;
732
782
  maxPartBytes?: number;
733
783
  maxPartTokens?: ByteSize | null;
734
784
  largeFileBytes?: number;
@@ -778,4 +828,4 @@ interface ValidationResult {
778
828
  warnings: string[];
779
829
  }
780
830
 
781
- 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 };
package/docs/cli.md CHANGED
@@ -97,7 +97,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
97
97
 
98
98
  ```
99
99
  📸 Generating snapshot for: /path/to/repo
100
- Branch: main | Part budget: 300 KB | Generator: 0.11.0 (project dependency ^0.11.0)
100
+ Branch: main | Part budget: 300 KB | Generator: 0.12.1 (project dependency ^0.12.1)
101
101
 
102
102
  ✅ Snapshot generated in 0.14s:
103
103
  - Tracked files: 121 included of 128 paths found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
@@ -192,7 +192,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
192
192
  🚀 Setup for: /path/to/repo
193
193
  ✅ Created snapshot.config.ts (preset: nextjs)
194
194
  Added npm scripts: snapshot, snapshot:validate
195
- Added devDependency: codebase-snapshot ^0.11.0
195
+ Added devDependency: codebase-snapshot ^0.12.1
196
196
  Added to .gitignore: /snapshot/, /snapshot.tmp/
197
197
  ⏳ Installing dependencies…
198
198
  ✅ Installed dependencies (npm install, 2.1s)
@@ -244,7 +244,7 @@ It also has three side effects on files you own, and it says so when it does the
244
244
  ```
245
245
  ✅ Created snapshot.config.ts (preset: node-lib)
246
246
  Added npm scripts: snapshot, snapshot:validate
247
- Added devDependency: codebase-snapshot ^0.11.0
247
+ Added devDependency: codebase-snapshot ^0.12.1
248
248
  Added to .gitignore: /snapshot/, /snapshot.tmp/
249
249
  ```
250
250
 
@@ -450,6 +450,8 @@ for the two install flags, and the init-and-setup flags list both commands.
450
450
  | `--max-part-tokens <n>` | size | unset | generate, validate, setup | A per-part ceiling in **tokens**, for a context window rather than a disk. Narrows `--max-part-bytes` to the equivalent byte count (`tokens × 4`); the smaller of the two ceilings always wins, and both are recorded in the manifest. Accepts `32k`. Minimum 1024 — below that it is a usage error, not a value quietly raised to the floor. The byte ceiling is what is enforced: `estimatedTokens` is an estimate, and a part whose estimate exceeds the token ceiling is named in a warning rather than silently accepted. |
451
451
  | `--large-file-bytes <n>` | size | the part budget (307200) | generate, validate, explain, setup | Above this, a file becomes a head/tail preview. It may not exceed `--max-part-bytes`: a file between the two could not fit a part. |
452
452
  | `--max-monolith-bytes <n>` | size | unset | generate, validate, setup | Skip the single-file monolith when it would exceed this. |
453
+ | `--brief <path>` | path | unset | generate, validate | The owner-written half of `PROMPT.md`: `Stakes`, `The system`, `What came before`, `The bar`, `Calibration`. Unknown headings are kept as Owner notes; measured headings cannot be redefined; the file is digested, so editing it is drift. |
454
+ | `--prompt-task <task>` | string | `audit` | generate, validate | `audit`, `review` or `explain` — which job the brief is written for. Changes the opening section, not the standard. |
453
455
  | `--max-parts <n>` | count | unset | generate, validate | **Experimental.** Grow the per-part budget until the snapshot has at most `n` parts, so the file count stays fixed as the code grows. The budget it settles on is recorded in `manifest.budgets.maxPartBytes` and may exceed `--max-part-bytes`; a warning says so. `0` is a usage error. |
454
456
  | `--attachment-slots <n>` | count | `10` | generate | Files the destination accepts in one message; `0` means no limit. `PROMPT.md` plans the delivery against it — which parts to attach, what to leave behind, and the `--max-part-bytes` value that would merge them. It changes no part and no file, so it is recorded in the manifest but is not part of the config digest. |
455
457
  | `--include-monolith` | flag | off | generate, validate, setup | Also write `full-codebase.json` and `full-codebase.md`. |
@@ -295,6 +295,61 @@ eleven parts next month.
295
295
  Treat it as experimental: `maxPartBytes` stays the honest control, and this is the knob for the
296
296
  case where the file count, not the byte count, is the binding constraint.
297
297
 
298
+ ## The brief: what only you can write
299
+
300
+ `PROMPT.md` is generated, and half of it cannot be: what the software is *for*, what has already
301
+ gone wrong, and which failures you would recognise. That is judgement, so it is supplied as a
302
+ file and merged at fixed slots.
303
+
304
+ ```js
305
+ export default {
306
+ brief: "docs/brief.md", // relative to cwd; a missing file is an error
307
+ promptTask: "audit", // audit | review | explain
308
+ };
309
+ ```
310
+
311
+ The file is plain markdown with five recognised headings:
312
+
313
+ | Heading | What happens |
314
+ | :--- | :--- |
315
+ | `## Stakes` | rendered as its own section, right after the job |
316
+ | `## The system` | replaces the generated narrative, and the index facts follow under "What the index records" |
317
+ | `## What came before` | rendered above the generated commit ledger |
318
+ | `## The bar` | replaces the standard |
319
+ | `## Calibration` | replaces the example failures |
320
+
321
+ ```markdown
322
+ <!-- docs/brief.md -->
323
+ ## Stakes
324
+ Runs live production for one owner. A wrong cleanup deletes their data.
325
+
326
+ ## What came before
327
+ Four rounds, 23 defects. The recurring shapes are a guard at the route but not the timer, and
328
+ an ok flag that means the call returned.
329
+
330
+ ## Calibration
331
+ - a grant signed for one recipe executing another recipe's deletions
332
+ - a recipe that never worked, because its test supplied a number where the daemon sends a string
333
+ ```
334
+
335
+ Any other `##` heading is kept, verbatim, under **Owner notes** — nothing is dropped because the
336
+ merge did not recognise it. Every owner section is marked in the output as written by the project
337
+ owner, so a reader can tell an assertion from a measurement.
338
+
339
+ Three things are refused because they would make the document lie:
340
+
341
+ - a heading that redefines a **measured** section (`Coverage`, `This snapshot`, `Attaching this`,
342
+ `The job`, `What you have`, `What a useful answer contains`, `Your task`) is a configuration
343
+ error, not an override;
344
+ - a `brief` path that cannot be read is an error — a snapshot must not silently ship without the
345
+ half you wrote;
346
+ - and the file is digested into the config digest, so editing the brief after generating makes
347
+ `validate` report drift. A stale brief is the same failure as a stale snapshot.
348
+
349
+ `promptTask` changes only the opening section: `audit` (the default) asks for what is wrong or
350
+ will break, `review` for what a change breaks, `explain` for how a subsystem works. The standard
351
+ and the coverage duty are the same in all three.
352
+
298
353
  See [Snapshot output](output.md) for the layout and the manifest schema.
299
354
 
300
355
  ## Secrets: redaction
package/docs/mcp.md CHANGED
@@ -10,7 +10,7 @@ walk — that the client sees.
10
10
  ## Start it
11
11
 
12
12
  ```bash
13
- npx -y codebase-snapshot@0.11.0 mcp
13
+ npx -y codebase-snapshot@0.12.1 mcp
14
14
  ```
15
15
 
16
16
  The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
25
25
  "mcpServers": {
26
26
  "codebase-snapshot": {
27
27
  "command": "npx",
28
- "args": ["-y", "codebase-snapshot@0.11.0", "mcp", "--cwd", "/absolute/path/to/repo"]
28
+ "args": ["-y", "codebase-snapshot@0.12.1", "mcp", "--cwd", "/absolute/path/to/repo"]
29
29
  }
30
30
  }
31
31
  }
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
34
34
  Claude Code registers the same thing from a shell:
35
35
 
36
36
  ```bash
37
- claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.11.0 mcp --cwd /absolute/path/to/repo
37
+ claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.12.1 mcp --cwd /absolute/path/to/repo
38
38
  ```
39
39
 
40
40
  On Windows, wrap the command as `cmd /c npx` with the same arguments — `npx` is a `.cmd` shim
package/docs/output.md CHANGED
@@ -68,6 +68,12 @@ rather than an index. Paste it with the payload. It has two halves:
68
68
  - **Calibration**: the classes of defect that do not crash — a guard at one call site and not its
69
69
  twin, a budget shorter than the work it guards, a success flag that means the call returned.
70
70
 
71
+ **The owner half** — when `brief` is configured (see [configuration](configuration.md#the-brief-what-only-you-can-write)),
72
+ the five judgement sections come from that file instead of the generic prose: what is at stake, the
73
+ system in the owner`s words (with the measured facts still following under "What the index
74
+ records"), the history the owner has lived through, the bar this team applies, and the calibration
75
+ examples from its own incidents. Each is marked as written by the project owner.
76
+
71
77
  **The apparatus** — this run only:
72
78
 
73
79
  - the fingerprint to quote back, the timestamp, the commit, whether the tree was dirty, and the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-snapshot",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
5
5
  "keywords": [
6
6
  "codebase-snapshot",