codebase-snapshot 0.10.2 → 0.11.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, 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';
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.11.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, 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';
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.11.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-NJ75RVHO.js';
package/dist/mcp.cjs CHANGED
@@ -2451,7 +2451,7 @@ function applySpansKeepingQuotes(line, spans) {
2451
2451
 
2452
2452
  // src/version.ts
2453
2453
  var GENERATOR_NAME = "codebase-snapshot";
2454
- var GENERATOR_VERSION = "0.10.2";
2454
+ var GENERATOR_VERSION = "0.11.0";
2455
2455
  var SCHEMA_VERSION = "3.0.0";
2456
2456
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2457
2457
  function isOurGeneratorName(name) {
@@ -3406,6 +3406,10 @@ function normalizeResolvedConfig(config) {
3406
3406
  return markResolvedConfig({
3407
3407
  ...config,
3408
3408
  discovery,
3409
+ // A spread copy built before the field existed carries no value; the default applies, and it
3410
+ // is re-validated because the number reaches a rendered artifact.
3411
+ attachmentSlots: resolveAttachmentSlots(config.attachmentSlots),
3412
+ maxParts: resolveMaxParts(config.maxParts),
3409
3413
  includeMonolith: artifacts.monolith,
3410
3414
  secretRules: compileSecretRules(config.secretRules),
3411
3415
  artifacts,
@@ -3474,6 +3478,7 @@ function describeValue2(value) {
3474
3478
  var isThenable = (value) => typeof value.then === "function";
3475
3479
  var CONFIG_KEY_NAMES = [
3476
3480
  "artifacts",
3481
+ "attachmentSlots",
3477
3482
  "branch",
3478
3483
  "budgets",
3479
3484
  "changedSince",
@@ -3491,6 +3496,7 @@ var CONFIG_KEY_NAMES = [
3491
3496
  "layersMode",
3492
3497
  "maxMonolithBytes",
3493
3498
  "maxPartBytes",
3499
+ "maxParts",
3494
3500
  "maxPartTokens",
3495
3501
  "outDir",
3496
3502
  "preset",
@@ -3689,6 +3695,7 @@ var MIN_MAX_PART_BYTES = 4096;
3689
3695
  var MIN_MAX_PART_TOKENS = MIN_MAX_PART_BYTES / 4;
3690
3696
  var ARTIFACT_NAMES = [
3691
3697
  "readme",
3698
+ "prompt",
3692
3699
  "manifest",
3693
3700
  "parts",
3694
3701
  "navigation",
@@ -3698,6 +3705,7 @@ var ARTIFACT_NAMES = [
3698
3705
  ];
3699
3706
  var DEFAULT_ARTIFACTS = {
3700
3707
  readme: true,
3708
+ prompt: true,
3701
3709
  manifest: true,
3702
3710
  parts: true,
3703
3711
  navigation: true,
@@ -3758,6 +3766,25 @@ function resolveArtifacts(requested, skipped, includeMonolith, monolithOverride,
3758
3766
  }
3759
3767
  return artifacts;
3760
3768
  }
3769
+ var DEFAULT_ATTACHMENT_SLOTS = 10;
3770
+ function resolveAttachmentSlots(value) {
3771
+ if (value === void 0 || value === null) return DEFAULT_ATTACHMENT_SLOTS;
3772
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
3773
+ throw new Error(
3774
+ "attachmentSlots must be a whole number, with 0 meaning no limit (received " + describeValue2(value) + ")."
3775
+ );
3776
+ }
3777
+ return value;
3778
+ }
3779
+ function resolveMaxParts(value) {
3780
+ if (value === void 0 || value === null) return null;
3781
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 1) {
3782
+ throw new Error(
3783
+ "maxParts must be a whole number of parts, or null to disable it (received " + describeValue2(value) + ")."
3784
+ );
3785
+ }
3786
+ return value;
3787
+ }
3761
3788
  function strictPositiveInteger(value, fallback, label) {
3762
3789
  if (value === void 0) return fallback;
3763
3790
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
@@ -4136,6 +4163,10 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4136
4163
  "maxMonolithBytes"
4137
4164
  ),
4138
4165
  includeSensitiveFiles,
4166
+ attachmentSlots: resolveAttachmentSlots(
4167
+ cliOptions?.attachmentSlots ?? userConfig?.attachmentSlots
4168
+ ),
4169
+ maxParts: resolveMaxParts(cliOptions?.maxParts ?? userConfig?.maxParts),
4139
4170
  ...changedSince === void 0 ? {} : { changedSince },
4140
4171
  ...staged ? { staged } : {},
4141
4172
  ...withDependents ? { withDependents } : {},
@@ -4218,6 +4249,9 @@ function configDigest(config) {
4218
4249
  includeMonolith: config.includeMonolith,
4219
4250
  maxMonolithBytes: config.maxMonolithBytes ?? null,
4220
4251
  includeSensitiveFiles: config.includeSensitiveFiles,
4252
+ // Only when the experimental mode is on: `null` is the off switch, and writing it into the
4253
+ // material would change the digest of every snapshot taken before the setting existed.
4254
+ ...config.maxParts === null ? {} : { maxParts: config.maxParts },
4221
4255
  artifacts: config.artifacts,
4222
4256
  include: config.include,
4223
4257
  excludePatterns: config.excludePatterns,
@@ -6964,7 +6998,8 @@ function validateSnapshot(configInput) {
6964
6998
  );
6965
6999
  }
6966
7000
  }
6967
- if (manifest.budgets && manifest.budgets.maxPartBytes !== config.maxPartBytes) {
7001
+ const ceilingDerivedByMaxParts = (manifest.config?.maxParts ?? null) !== null;
7002
+ if (!ceilingDerivedByMaxParts && manifest.budgets && manifest.budgets.maxPartBytes !== config.maxPartBytes) {
6968
7003
  totalsMismatches.push(
6969
7004
  `budgets.maxPartBytes: manifest ${manifest.budgets.maxPartBytes} vs current ${config.maxPartBytes}`
6970
7005
  );
@@ -6993,6 +7028,7 @@ function validateSnapshot(configInput) {
6993
7028
  }
6994
7029
  const declaredArtifacts = [
6995
7030
  ["README.md", manifest.artifacts?.readme],
7031
+ ["PROMPT.md", manifest.artifacts?.prompt],
6996
7032
  ["reports/navigation.md", manifest.artifacts?.navigation],
6997
7033
  ["reports/project-tree.md", manifest.artifacts?.projectTree],
6998
7034
  ["reports/audit.md", manifest.artifacts?.audit],
@@ -8694,6 +8730,7 @@ var VALIDATE_OPTIONS = [
8694
8730
  "max-part-tokens",
8695
8731
  "large-file-bytes",
8696
8732
  "max-monolith-bytes",
8733
+ "max-parts",
8697
8734
  "include-monolith",
8698
8735
  "include-sensitive-files",
8699
8736
  "skip-artifacts",
@@ -8719,6 +8756,8 @@ var COMMAND_OPTION_SCOPE = {
8719
8756
  "max-part-tokens",
8720
8757
  "large-file-bytes",
8721
8758
  "max-monolith-bytes",
8759
+ "attachment-slots",
8760
+ "max-parts",
8722
8761
  "include-monolith",
8723
8762
  "include-sensitive-files",
8724
8763
  "skip-artifacts",
@@ -8864,6 +8903,7 @@ var PACKAGE_NAME = "codebase-snapshot";
8864
8903
  var MAJOR_VERSION = GENERATOR_VERSION.split(".")[0];
8865
8904
  var ARTIFACT_SUMMARY = {
8866
8905
  readme: "README.md describing the snapshot at the output root.",
8906
+ prompt: "PROMPT.md: the instruction sheet to paste with the snapshot, rendered from its manifest.",
8867
8907
  manifest: "manifest.json: machine-readable index of every file, part, hash and config.",
8868
8908
  parts: "parts/*.md: the packed, budget-limited markdown parts that carry the code.",
8869
8909
  navigation: "reports/navigation.md: links between parts and layers.",
@@ -8873,6 +8913,7 @@ var ARTIFACT_SUMMARY = {
8873
8913
  };
8874
8914
  var ARTIFACT_DEFAULTS = {
8875
8915
  readme: true,
8916
+ prompt: true,
8876
8917
  manifest: true,
8877
8918
  parts: true,
8878
8919
  navigation: true,
@@ -8944,9 +8985,9 @@ function buildAgentContract() {
8944
8985
  {
8945
8986
  step: 6,
8946
8987
  id: "consume",
8947
- run: "read ./snapshot/parts/*.md, then ./snapshot/manifest.json, then ./snapshot/reports/audit.md",
8988
+ run: "read ./snapshot/PROMPT.md first, then ./snapshot/parts/*.md, ./snapshot/manifest.json and ./snapshot/reports/audit.md",
8948
8989
  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."
8990
+ 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
8991
  }
8951
8992
  ],
8952
8993
  commands: [
@@ -9083,6 +9124,20 @@ function buildAgentContract() {
9083
9124
  appliesTo: optionAppliesTo("discovery"),
9084
9125
  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
9126
  },
9127
+ {
9128
+ flag: "--attachment-slots",
9129
+ type: "number",
9130
+ default: "10",
9131
+ appliesTo: optionAppliesTo("attachment-slots"),
9132
+ 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
+ },
9134
+ {
9135
+ flag: "--max-parts",
9136
+ type: "number",
9137
+ default: "unset",
9138
+ appliesTo: optionAppliesTo("max-parts"),
9139
+ 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."
9140
+ },
9086
9141
  {
9087
9142
  flag: "--skip-artifacts",
9088
9143
  type: "string",
@@ -9296,6 +9351,8 @@ function buildAgentContract() {
9296
9351
  { key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
9297
9352
  { key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
9298
9353
  { key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
9354
+ { 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
+ { 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
9356
  { 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
9357
  { key: "artifacts", type: "object", default: "all on except monolith", summary: "Per-artifact opt-out." },
9301
9358
  { key: "budgets", type: "object", default: "{ default, byLayer }", summary: "Per-layer byte budgets." },
@@ -9310,6 +9367,7 @@ function buildAgentContract() {
9310
9367
  output: {
9311
9368
  layout: [
9312
9369
  "<outDir>/README.md",
9370
+ "<outDir>/PROMPT.md",
9313
9371
  "<outDir>/manifest.json",
9314
9372
  "<outDir>/parts/part-NNN.md",
9315
9373
  "<outDir>/reports/project-tree.md",
@@ -9323,6 +9381,7 @@ function buildAgentContract() {
9323
9381
  "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
9382
  "validate re-checks manifest.incomplete[] against files[] and refuses a manifest whose two statements of what is missing disagree.",
9325
9383
  "manifest.skipped[] carries the path and the exact reason it was excluded.",
9384
+ "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
9385
  `The output directory is replaced atomically; ${MIN_MAX_PART_BYTES} bytes is the smallest legal budget.`
9327
9386
  ]
9328
9387
  },
@@ -9493,6 +9552,10 @@ do not assume the repository is broken.
9493
9552
  - \`snapshot/reports/audit.md\` \u2014 secrets found, large files, parse diagnostics, git
9494
9553
  state. Read this before you quote code back to a user.
9495
9554
  - \`snapshot/reports/project-tree.md\` and \`navigation.md\` \u2014 structure and cross-links.
9555
+ - \`snapshot/PROMPT.md\` \u2014 the instruction sheet to hand to the model that receives the
9556
+ snapshot: paste it with the parts. It is rendered from this run's manifest and names the
9557
+ parts, the partial files and the fingerprint, so do not rewrite it by hand \u2014 \`validate\`
9558
+ fails when it was edited.
9496
9559
 
9497
9560
  ## Project types
9498
9561
 
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-5ZOXHBTW.js';
2
+ export { generateInWorker } from './chunk-NJ75RVHO.js';
@@ -374,6 +374,17 @@ 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;
377
388
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
378
389
  discovery?: DiscoveryMode;
379
390
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -467,6 +478,7 @@ interface Manifest {
467
478
  * recorded has no key; a current manifest records every artifact it wrote.
468
479
  */
469
480
  readme?: ManifestArtifact;
481
+ prompt?: ManifestArtifact;
470
482
  navigation?: ManifestArtifact;
471
483
  projectTree?: ManifestArtifact;
472
484
  audit?: ManifestArtifact;
@@ -513,6 +525,8 @@ interface LayerRule {
513
525
  interface ArtifactSelection {
514
526
  /** `README.md` — the orientation page for humans and models. */
515
527
  readme?: boolean;
528
+ /** `PROMPT.md` — the instruction sheet a snapshot is pasted with. */
529
+ prompt?: boolean;
516
530
  /** `manifest.json` — the registry `validate` and `report` read. */
517
531
  manifest?: boolean;
518
532
  /** `parts/part-XXX.md` — the partitioned code payload. */
@@ -572,6 +586,24 @@ interface SnapshotConfig {
572
586
  maxMonolithBytes?: ByteSize | null;
573
587
  /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
574
588
  includeSensitiveFiles?: boolean;
589
+ /**
590
+ * Files the destination accepts in one message; 10 by default, `0` for no limit.
591
+ *
592
+ * `PROMPT.md` plans the delivery to fit: which parts to attach, what to leave behind, and the
593
+ * part budget that would merge them. The payload is unchanged by this setting — only the
594
+ * instructions and the plan that ships with it.
595
+ */
596
+ attachmentSlots?: number;
597
+ /**
598
+ * Experimental: the most parts a snapshot may have.
599
+ *
600
+ * Off by default. When set, the partitioner grows the per-part budget until the run fits this
601
+ * many parts, which is how a repository that keeps growing keeps its shape instead of adding a
602
+ * twelfth file to a chat that takes ten. The budget it settles on is recorded in
603
+ * `manifest.budgets.maxPartBytes` and may exceed the configured `maxPartBytes`; a warning says
604
+ * so, because a larger part is more tokens for the destination to swallow at once.
605
+ */
606
+ maxParts?: number | null;
575
607
  /**
576
608
  * How files are discovered; `auto` picks git when it can list files and walks the tree
577
609
  * otherwise.
@@ -644,6 +676,10 @@ interface ResolvedSnapshotConfig {
644
676
  includeMonolith: boolean;
645
677
  maxMonolithBytes: number | null;
646
678
  includeSensitiveFiles: boolean;
679
+ /** Files the destination accepts in one message; `0` means no limit. */
680
+ attachmentSlots: number;
681
+ /** The part-count ceiling, or `null` when the experimental mode is off. */
682
+ maxParts: number | null;
647
683
  /**
648
684
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
649
685
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -689,6 +725,10 @@ interface CliOptions {
689
725
  includeMonolith?: boolean;
690
726
  includeSensitiveFiles?: boolean;
691
727
  maxMonolithBytes?: number | null;
728
+ /** `--attachment-slots`: how many files the destination accepts. */
729
+ attachmentSlots?: number;
730
+ /** `--max-parts`: the experimental part-count ceiling. */
731
+ maxParts?: number | null;
692
732
  maxPartBytes?: number;
693
733
  maxPartTokens?: ByteSize | null;
694
734
  largeFileBytes?: number;
@@ -374,6 +374,17 @@ 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;
377
388
  /** How files were discovered; `undefined` on manifests written before this was recorded. */
378
389
  discovery?: DiscoveryMode;
379
390
  /** The changed-files scope the snapshot was taken over, when one was used. */
@@ -467,6 +478,7 @@ interface Manifest {
467
478
  * recorded has no key; a current manifest records every artifact it wrote.
468
479
  */
469
480
  readme?: ManifestArtifact;
481
+ prompt?: ManifestArtifact;
470
482
  navigation?: ManifestArtifact;
471
483
  projectTree?: ManifestArtifact;
472
484
  audit?: ManifestArtifact;
@@ -513,6 +525,8 @@ interface LayerRule {
513
525
  interface ArtifactSelection {
514
526
  /** `README.md` — the orientation page for humans and models. */
515
527
  readme?: boolean;
528
+ /** `PROMPT.md` — the instruction sheet a snapshot is pasted with. */
529
+ prompt?: boolean;
516
530
  /** `manifest.json` — the registry `validate` and `report` read. */
517
531
  manifest?: boolean;
518
532
  /** `parts/part-XXX.md` — the partitioned code payload. */
@@ -572,6 +586,24 @@ interface SnapshotConfig {
572
586
  maxMonolithBytes?: ByteSize | null;
573
587
  /** Opt in to emitting `.env`/`*.pem`/`.npmrc`/`credential files. Default false. */
574
588
  includeSensitiveFiles?: boolean;
589
+ /**
590
+ * Files the destination accepts in one message; 10 by default, `0` for no limit.
591
+ *
592
+ * `PROMPT.md` plans the delivery to fit: which parts to attach, what to leave behind, and the
593
+ * part budget that would merge them. The payload is unchanged by this setting — only the
594
+ * instructions and the plan that ships with it.
595
+ */
596
+ attachmentSlots?: number;
597
+ /**
598
+ * Experimental: the most parts a snapshot may have.
599
+ *
600
+ * Off by default. When set, the partitioner grows the per-part budget until the run fits this
601
+ * many parts, which is how a repository that keeps growing keeps its shape instead of adding a
602
+ * twelfth file to a chat that takes ten. The budget it settles on is recorded in
603
+ * `manifest.budgets.maxPartBytes` and may exceed the configured `maxPartBytes`; a warning says
604
+ * so, because a larger part is more tokens for the destination to swallow at once.
605
+ */
606
+ maxParts?: number | null;
575
607
  /**
576
608
  * How files are discovered; `auto` picks git when it can list files and walks the tree
577
609
  * otherwise.
@@ -644,6 +676,10 @@ interface ResolvedSnapshotConfig {
644
676
  includeMonolith: boolean;
645
677
  maxMonolithBytes: number | null;
646
678
  includeSensitiveFiles: boolean;
679
+ /** Files the destination accepts in one message; `0` means no limit. */
680
+ attachmentSlots: number;
681
+ /** The part-count ceiling, or `null` when the experimental mode is off. */
682
+ maxParts: number | null;
647
683
  /**
648
684
  * How files are discovered; `auto` picks git when it can list files and walks the tree otherwise.
649
685
  * Optional because a resolved config can arrive from an older caller that never named it — every
@@ -689,6 +725,10 @@ interface CliOptions {
689
725
  includeMonolith?: boolean;
690
726
  includeSensitiveFiles?: boolean;
691
727
  maxMonolithBytes?: number | null;
728
+ /** `--attachment-slots`: how many files the destination accepts. */
729
+ attachmentSlots?: number;
730
+ /** `--max-parts`: the experimental part-count ceiling. */
731
+ maxParts?: number | null;
692
732
  maxPartBytes?: number;
693
733
  maxPartTokens?: ByteSize | null;
694
734
  largeFileBytes?: number;
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.10.2 (project dependency ^0.10.2)
100
+ Branch: main | Part budget: 300 KB | Generator: 0.11.0 (project dependency ^0.11.0)
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
@@ -106,6 +106,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
106
106
  - Parts written: 3 under snapshot/parts/
107
107
  - Reports: snapshot/reports/ (project-tree, navigation, audit)
108
108
  - Manifest: snapshot/manifest.json
109
+ - Orientation: snapshot/README.md, snapshot/PROMPT.md
109
110
  - Fingerprint: e4607b570268c8def0911babbace97e4a0196d9eaf2cac22c8847500883d70aa
110
111
  - Integrity: passed
111
112
  - Redacted: 2 line(s) — values masked; see snapshot/reports/audit.md
@@ -191,7 +192,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
191
192
  🚀 Setup for: /path/to/repo
192
193
  ✅ Created snapshot.config.ts (preset: nextjs)
193
194
  Added npm scripts: snapshot, snapshot:validate
194
- Added devDependency: codebase-snapshot ^0.10.2
195
+ Added devDependency: codebase-snapshot ^0.11.0
195
196
  Added to .gitignore: /snapshot/, /snapshot.tmp/
196
197
  ⏳ Installing dependencies…
197
198
  ✅ Installed dependencies (npm install, 2.1s)
@@ -243,7 +244,7 @@ It also has three side effects on files you own, and it says so when it does the
243
244
  ```
244
245
  ✅ Created snapshot.config.ts (preset: node-lib)
245
246
  Added npm scripts: snapshot, snapshot:validate
246
- Added devDependency: codebase-snapshot ^0.10.2
247
+ Added devDependency: codebase-snapshot ^0.11.0
247
248
  Added to .gitignore: /snapshot/, /snapshot.tmp/
248
249
  ```
249
250
 
@@ -449,6 +450,8 @@ for the two install flags, and the init-and-setup flags list both commands.
449
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. |
450
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. |
451
452
  | `--max-monolith-bytes <n>` | size | unset | generate, validate, setup | Skip the single-file monolith when it would exceed this. |
453
+ | `--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
+ | `--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. |
452
455
  | `--include-monolith` | flag | off | generate, validate, setup | Also write `full-codebase.json` and `full-codebase.md`. |
453
456
  | `--include-sensitive-files` | flag | off | generate, validate, explain, init, setup | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
454
457
  | `--skip-artifacts <names>` | list | unset | generate, validate, init, setup | Comma-separated artifacts to omit. |
@@ -225,6 +225,7 @@ the manifest called it a preview by policy. That combination is a config error.
225
225
  export default {
226
226
  artifacts: {
227
227
  readme: true, // snapshot/README.md
228
+ prompt: true, // snapshot/PROMPT.md — the instruction sheet a model is given
228
229
  manifest: true, // snapshot/manifest.json
229
230
  parts: true, // snapshot/parts/*.md
230
231
  navigation: true, // snapshot/reports/navigation.md
@@ -246,6 +247,54 @@ on leaves links pointing at files that were never written. Both are allowed.
246
247
 
247
248
  The `.codebase-snapshot` ownership marker is always written, whatever the selection.
248
249
 
250
+ ## Delivering it: how many files the destination takes
251
+
252
+ ```js
253
+ export default {
254
+ attachmentSlots: 10, // files your chat accepts per message; 0 = no limit
255
+ };
256
+ ```
257
+
258
+ Hosted assistants take a fixed number of files per message — 10 is the common cap — and every part
259
+ is one of them. `PROMPT.md` plans the delivery against this number: which parts to attach, what to
260
+ leave behind when they do not all fit, and the `--max-part-bytes` value that would merge them.
261
+
262
+ - Default `10`; `0` means the destination imposes no limit and the plan says to attach everything.
263
+ - It changes **no part and no file**: the payload is byte-identical either way. Only the delivery
264
+ section of `PROMPT.md` moves, which is why it is recorded in `manifest.config` but is not part of
265
+ the config digest — a new delivery preference must not make an existing snapshot fail `validate`.
266
+ - Instructions are pasted as text and cost no slot, so the budget is always spent on files.
267
+
268
+ The one thing it cannot do is make a snapshot fit: a 12-part snapshot does not go into a 10-file
269
+ message at any setting. Raise `maxPartBytes` to merge the parts, or narrow the scope — the plan in
270
+ `PROMPT.md` names the number.
271
+
272
+ ### Experimental: a fixed number of parts
273
+
274
+ ```js
275
+ export default {
276
+ maxParts: 10, // grow the parts until the snapshot has at most ten; off by default
277
+ };
278
+ ```
279
+
280
+ The opposite trade to everything above: the **count** is fixed and the **size** gives way. As the
281
+ repository grows, `maxParts` grows the per-part budget instead of adding a part, which is what a
282
+ destination with a hard file limit wants — the snapshot keeps its shape instead of turning into
283
+ eleven parts next month.
284
+
285
+ - Off by default (`null`). Opt in per run with `--max-parts <n>`, or in the config.
286
+ - The budget it settles on is recorded in `manifest.budgets.maxPartBytes` — the number the parts
287
+ actually honour — while `manifest.config.maxPartBytes` keeps the configured value, so
288
+ `validate` still compares like with like.
289
+ - It may exceed `maxPartBytes`, and that is the point: a part bigger than the configured ceiling is
290
+ more tokens at once, and some destinations cap a single file. Both facts land in
291
+ `manifest.warnings`, so the run says what it did rather than quietly changing the shape.
292
+ - If it cannot converge, generation fails with the counts it tried rather than writing something
293
+ the setting did not ask for.
294
+
295
+ Treat it as experimental: `maxPartBytes` stays the honest control, and this is the knob for the
296
+ case where the file count, not the byte count, is the binding constraint.
297
+
249
298
  See [Snapshot output](output.md) for the layout and the manifest schema.
250
299
 
251
300
  ## Secrets: redaction
@@ -464,6 +513,9 @@ const config = {
464
513
  excludePatterns: [],
465
514
  discovery: "auto", // "auto" | "git" | "walk"
466
515
 
516
+ // ── Delivery ─────────────────────────────────────────────
517
+ attachmentSlots: 10, // files your destination takes per message; 0 = no limit
518
+
467
519
  // ── Classification ───────────────────────────────────────
468
520
  layersMode: "merge",
469
521
  layers: [],
@@ -476,6 +528,7 @@ const config = {
476
528
  // ── Artifacts ────────────────────────────────────────────
477
529
  artifacts: {
478
530
  readme: true,
531
+ prompt: true,
479
532
  manifest: true,
480
533
  parts: true,
481
534
  navigation: true,
@@ -70,17 +70,36 @@ A file is never cut down to make a part fit. A file above `largeFileBytes` — w
70
70
  budget — becomes a head/tail excerpt with an explicit marker, and `manifest.json` lists it in
71
71
  `incomplete[]` with the line ranges it lost.
72
72
 
73
+ ### 2b. Count the attachment slots, not just the bytes
74
+
75
+ Hosted chats take a fixed number of files per message — 10 is the common cap — and every part is
76
+ one file. A 12-part snapshot cannot be delivered to a 10-file chat at all, and no amount of
77
+ compression changes that: the payload is twelve files.
78
+
79
+ Three things follow:
80
+
81
+ - **Instructions are text, not a file.** Paste `PROMPT.md` into the message and attach only code.
82
+ A prompt that costs a slot is a part you do not get.
83
+ - **Parts before reports.** When the parts leave no room, skip `manifest.json` and `reports/`:
84
+ `PROMPT.md` already names the parts, the counts and the omissions.
85
+ - **Fewer parts, or fewer files.** Raise `maxPartBytes` to merge the parts into fewer, larger
86
+ files, or narrow the scope with `--include` and `excludePatterns` so the code that matters fits.
87
+
88
+ `PROMPT.md` does this arithmetic for the snapshot you have: how many parts fit, which to leave out
89
+ when they do not, and the `--max-part-bytes` value that would fit the whole repository.
90
+
73
91
  ### 3. Tell the model what it is looking at
74
92
 
75
- The snapshot is self-describing, and saying so up front measurably improves answers:
93
+ `generate` writes `snapshot/PROMPT.md` for exactly this. Paste it before the parts.
76
94
 
77
- > The context below is a generated snapshot of a repository. `manifest.json` lists every included
78
- > file with its language, part and hash, and every excluded file with the reason. Reads start with
79
- > `parts/part-001.md`. If something you need is missing, ask me to check `explain <path>` rather than
80
- > assuming it does not exist.
95
+ It is rendered from the manifest rather than written once, so it is about *this* snapshot: the
96
+ parts by name, every file that is only partly present with the line ranges it lost, the skip
97
+ reasons with counts, the fingerprint to quote back, and the commit it was taken from. Regenerate
98
+ the snapshot and those numbers move with the code.
81
99
 
82
- That last sentence matters more than it looks: models fill gaps by invention, and telling them the
83
- gap is documented turns a hallucination into a question.
100
+ The sentence it exists to say is the one models otherwise fill by invention — *a file may be
101
+ missing, and the reason is recorded, so ask instead of assuming*. That is what turns a
102
+ hallucination into a question you can answer with `explain <path>`.
84
103
 
85
104
  ### 4. Include the index, always
86
105
 
@@ -98,10 +117,22 @@ npm run snapshot:validate || npm run snapshot
98
117
  changed budget, layer rule or secret pattern is drift, not silence — so the check catches both code
99
118
  changes and configuration changes.
100
119
 
101
- ## The prompt, ready to paste
120
+ ## The prompt
102
121
 
103
122
  Everything above is about producing the snapshot. This is the other half: what to say to the model
104
- that receives it. Put this before the artefacts and replace the task section with your question.
123
+ that receives it.
124
+
125
+ You do not have to write it. `snapshot/PROMPT.md` is the prompt, and being generated is what makes
126
+ it worth pasting: it describes the snapshot you are actually sending. It is a brief, not a packing
127
+ slip — the job, the system map the manifest can prove (layers, the modules with the most
128
+ importers, entry points, which surfaces were indexed), the last ten commit subjects as claims to
129
+ verify rather than rediscover, the evidence bar, the coverage owed, and calibration examples of
130
+ the defects that do not crash. Then the per-run apparatus: fingerprint, part inventory, partial
131
+ files, skip tallies and the attachment arithmetic.
132
+
133
+ If you are assembling the message by hand instead — a chat window that takes one file at a time, a
134
+ wrapper that cannot include a directory — this is the minimum that keeps the properties. Replace
135
+ the task section with your question.
105
136
 
106
137
  ```text
107
138
  You are working on a codebase you cannot clone, run or grep. What you have is a generated snapshot of