codebase-snapshot 0.9.18 → 0.10.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-KbJvBjmV.cjs';
2
- export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as SummaryQuality, r as ValidationDrift } from './types-KbJvBjmV.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-Z471HW65.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-Z471HW65.cjs';
3
3
  export { w as workerEntry } from './generate-worker-D_mUjgXw.cjs';
4
4
 
5
5
  interface GitInfo {
@@ -337,6 +337,14 @@ interface PreviewResult {
337
337
  isTruncated: boolean;
338
338
  originalLines: number;
339
339
  includedLines: number;
340
+ /**
341
+ * 1-based, inclusive source line ranges the preview does not contain.
342
+ *
343
+ * Empty when nothing was dropped. A head/tail preview drops exactly one contiguous run, so a
344
+ * reader can say which lines are missing instead of inferring it from a sentence in the middle
345
+ * of a part.
346
+ */
347
+ omittedRanges: Array<[number, number]>;
340
348
  }
341
349
  /**
342
350
  * Line count with one consistent convention: a trailing newline does not start
@@ -520,7 +528,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
520
528
  * `package.json` carries the same version; `npm run verify` compares the two.
521
529
  */
522
530
  declare const GENERATOR_NAME = "codebase-snapshot";
523
- declare const GENERATOR_VERSION = "0.9.18";
531
+ declare const GENERATOR_VERSION = "0.10.0";
524
532
  /**
525
533
  * The manifest and ownership-marker schema this build writes and understands.
526
534
  *
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-KbJvBjmV.js';
2
- export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as SummaryQuality, r as ValidationDrift } from './types-KbJvBjmV.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-Z471HW65.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-Z471HW65.js';
3
3
  export { w as workerEntry } from './generate-worker-D_mUjgXw.js';
4
4
 
5
5
  interface GitInfo {
@@ -337,6 +337,14 @@ interface PreviewResult {
337
337
  isTruncated: boolean;
338
338
  originalLines: number;
339
339
  includedLines: number;
340
+ /**
341
+ * 1-based, inclusive source line ranges the preview does not contain.
342
+ *
343
+ * Empty when nothing was dropped. A head/tail preview drops exactly one contiguous run, so a
344
+ * reader can say which lines are missing instead of inferring it from a sentence in the middle
345
+ * of a part.
346
+ */
347
+ omittedRanges: Array<[number, number]>;
340
348
  }
341
349
  /**
342
350
  * Line count with one consistent convention: a trailing newline does not start
@@ -520,7 +528,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
520
528
  * `package.json` carries the same version; `npm run verify` compares the two.
521
529
  */
522
530
  declare const GENERATOR_NAME = "codebase-snapshot";
523
- declare const GENERATOR_VERSION = "0.9.18";
531
+ declare const GENERATOR_VERSION = "0.10.0";
524
532
  /**
525
533
  * The manifest and ownership-marker schema this build writes and understands.
526
534
  *
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, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-ZXWAVHSZ.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, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-EP7OCPUM.js';
package/dist/mcp.cjs CHANGED
@@ -716,7 +716,7 @@ var JS_PRESETS = [
716
716
  ...commonKinds()
717
717
  ],
718
718
  exclude: [".nuxt", ".output"],
719
- recommendedBudget: "200k"
719
+ recommendedBudget: "300k"
720
720
  },
721
721
  {
722
722
  name: "sveltekit",
@@ -737,7 +737,7 @@ var JS_PRESETS = [
737
737
  ...commonKinds()
738
738
  ],
739
739
  exclude: [".svelte-kit", ".vercel"],
740
- recommendedBudget: "200k"
740
+ recommendedBudget: "300k"
741
741
  },
742
742
  {
743
743
  name: "remix",
@@ -751,7 +751,7 @@ var JS_PRESETS = [
751
751
  ],
752
752
  kinds: [kindOf("route", "routes/"), ...commonKinds()],
753
753
  exclude: [".cache", "public/build"],
754
- recommendedBudget: "200k"
754
+ recommendedBudget: "300k"
755
755
  },
756
756
  {
757
757
  name: "astro",
@@ -766,7 +766,7 @@ var JS_PRESETS = [
766
766
  ],
767
767
  kinds: [suffixKind("page", ".astro"), kindOf("layout", "layouts/"), ...commonKinds()],
768
768
  exclude: [".astro", "dist"],
769
- recommendedBudget: "150k"
769
+ recommendedBudget: "300k"
770
770
  },
771
771
  {
772
772
  name: "angular",
@@ -790,7 +790,7 @@ var JS_PRESETS = [
790
790
  ...commonKinds()
791
791
  ],
792
792
  exclude: [".angular", "dist"],
793
- recommendedBudget: "200k"
793
+ recommendedBudget: "300k"
794
794
  },
795
795
  {
796
796
  name: "solid",
@@ -803,7 +803,7 @@ var JS_PRESETS = [
803
803
  ],
804
804
  kinds: [kindOf("route", "routes/"), ...commonKinds()],
805
805
  exclude: [".solid", "dist"],
806
- recommendedBudget: "120k"
806
+ recommendedBudget: "300k"
807
807
  },
808
808
  {
809
809
  name: "vue-vite",
@@ -836,7 +836,7 @@ var JS_PRESETS = [
836
836
  ...commonKinds()
837
837
  ],
838
838
  exclude: [".vite", "dist"],
839
- recommendedBudget: "120k"
839
+ recommendedBudget: "300k"
840
840
  },
841
841
  {
842
842
  name: "react-vite",
@@ -850,7 +850,7 @@ var JS_PRESETS = [
850
850
  layers: VITE_LAYERS,
851
851
  kinds: VITE_KINDS,
852
852
  exclude: [".vite", "dist"],
853
- recommendedBudget: "120k"
853
+ recommendedBudget: "300k"
854
854
  },
855
855
  {
856
856
  name: "nest",
@@ -876,7 +876,7 @@ var JS_PRESETS = [
876
876
  ...commonKinds()
877
877
  ],
878
878
  exclude: ["dist", "node_modules"],
879
- recommendedBudget: "200k"
879
+ recommendedBudget: "300k"
880
880
  },
881
881
  {
882
882
  name: "node-express",
@@ -885,7 +885,7 @@ var JS_PRESETS = [
885
885
  layers: NODE_LAYERS,
886
886
  kinds: NODE_KINDS,
887
887
  exclude: ["dist"],
888
- recommendedBudget: "200k"
888
+ recommendedBudget: "300k"
889
889
  },
890
890
  {
891
891
  name: "node-lib",
@@ -901,7 +901,7 @@ var JS_PRESETS = [
901
901
  ],
902
902
  kinds: [suffixKind("type", ".d.ts"), ...commonKinds()],
903
903
  exclude: ["dist"],
904
- recommendedBudget: "120k"
904
+ recommendedBudget: "300k"
905
905
  }
906
906
  ];
907
907
 
@@ -932,7 +932,7 @@ var LANGUAGE_PRESETS = [
932
932
  ...commonKinds()
933
933
  ],
934
934
  exclude: ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache", ".tox", ".eggs", "staticfiles", "media"],
935
- recommendedBudget: "150k"
935
+ recommendedBudget: "300k"
936
936
  },
937
937
  {
938
938
  name: "python-fastapi",
@@ -955,7 +955,7 @@ var LANGUAGE_PRESETS = [
955
955
  ...commonKinds()
956
956
  ],
957
957
  exclude: ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache", ".tox", ".eggs"],
958
- recommendedBudget: "150k"
958
+ recommendedBudget: "300k"
959
959
  },
960
960
  {
961
961
  name: "python-lib",
@@ -969,7 +969,7 @@ var LANGUAGE_PRESETS = [
969
969
  ],
970
970
  kinds: [suffixKind("module", ".py"), ...commonKinds()],
971
971
  exclude: ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache", ".tox", ".eggs"],
972
- recommendedBudget: "120k"
972
+ recommendedBudget: "300k"
973
973
  },
974
974
  {
975
975
  name: "go",
@@ -993,7 +993,7 @@ var LANGUAGE_PRESETS = [
993
993
  ...commonKinds()
994
994
  ],
995
995
  exclude: ["vendor", "testdata"],
996
- recommendedBudget: "200k"
996
+ recommendedBudget: "300k"
997
997
  },
998
998
  {
999
999
  name: "rust",
@@ -1009,7 +1009,7 @@ var LANGUAGE_PRESETS = [
1009
1009
  ],
1010
1010
  kinds: [suffixKind("module", ".rs"), suffixKind("test", "_test.rs"), ...commonKinds()],
1011
1011
  exclude: ["target"],
1012
- recommendedBudget: "200k"
1012
+ recommendedBudget: "300k"
1013
1013
  },
1014
1014
  {
1015
1015
  name: "java-spring",
@@ -1032,7 +1032,7 @@ var LANGUAGE_PRESETS = [
1032
1032
  ...commonKinds()
1033
1033
  ],
1034
1034
  exclude: [".gradle", "out", "target"],
1035
- recommendedBudget: "200k"
1035
+ recommendedBudget: "300k"
1036
1036
  },
1037
1037
  {
1038
1038
  name: "dotnet",
@@ -1055,7 +1055,7 @@ var LANGUAGE_PRESETS = [
1055
1055
  ...commonKinds()
1056
1056
  ],
1057
1057
  exclude: ["bin", "obj", ".vs"],
1058
- recommendedBudget: "200k"
1058
+ recommendedBudget: "300k"
1059
1059
  },
1060
1060
  {
1061
1061
  name: "php-laravel",
@@ -1081,7 +1081,7 @@ var LANGUAGE_PRESETS = [
1081
1081
  ...commonKinds()
1082
1082
  ],
1083
1083
  exclude: ["vendor", "storage", "bootstrap/cache", "public/build"],
1084
- recommendedBudget: "150k"
1084
+ recommendedBudget: "300k"
1085
1085
  },
1086
1086
  {
1087
1087
  name: "ruby-rails",
@@ -1106,7 +1106,7 @@ var LANGUAGE_PRESETS = [
1106
1106
  ...commonKinds()
1107
1107
  ],
1108
1108
  exclude: [".bundle", "log", "tmp", "vendor/bundle", "public/assets"],
1109
- recommendedBudget: "150k"
1109
+ recommendedBudget: "300k"
1110
1110
  }
1111
1111
  ];
1112
1112
 
@@ -1168,7 +1168,7 @@ var SHAPE_PRESETS = [
1168
1168
  ],
1169
1169
  kinds: commonKinds(),
1170
1170
  exclude: [".turbo", ".nx"],
1171
- recommendedBudget: "200k"
1171
+ recommendedBudget: "300k"
1172
1172
  },
1173
1173
  {
1174
1174
  name: "infra",
@@ -1186,7 +1186,7 @@ var SHAPE_PRESETS = [
1186
1186
  ...commonKinds()
1187
1187
  ],
1188
1188
  exclude: [".terraform", ".terragrunt-cache"],
1189
- recommendedBudget: "100k"
1189
+ recommendedBudget: "300k"
1190
1190
  },
1191
1191
  {
1192
1192
  name: "docs",
@@ -1203,7 +1203,7 @@ var SHAPE_PRESETS = [
1203
1203
  ],
1204
1204
  kinds: commonKinds(),
1205
1205
  exclude: [".docusaurus", ".vitepress/dist", "site"],
1206
- recommendedBudget: "100k"
1206
+ recommendedBudget: "300k"
1207
1207
  },
1208
1208
  {
1209
1209
  name: "generic",
@@ -1215,7 +1215,7 @@ var SHAPE_PRESETS = [
1215
1215
  layers: DEFAULT_LAYERS,
1216
1216
  kinds: DEFAULT_KINDS,
1217
1217
  exclude: [],
1218
- recommendedBudget: "120k"
1218
+ recommendedBudget: "300k"
1219
1219
  }
1220
1220
  ];
1221
1221
 
@@ -2341,7 +2341,7 @@ function applySpans(line, spans) {
2341
2341
 
2342
2342
  // src/version.ts
2343
2343
  var GENERATOR_NAME = "codebase-snapshot";
2344
- var GENERATOR_VERSION = "0.9.18";
2344
+ var GENERATOR_VERSION = "0.10.0";
2345
2345
  var SCHEMA_VERSION = "3.0.0";
2346
2346
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2347
2347
  function isOurGeneratorName(name) {
@@ -3645,6 +3645,16 @@ async function loadConfigFileDetailed(cwd, options = {}) {
3645
3645
  }
3646
3646
  return { config: null, file: null, warnings, errors };
3647
3647
  }
3648
+ function largeFileBytesFor(maxPartBytes, cliOptions, userConfig) {
3649
+ const requested = cliOptions?.largeFileBytes ?? userConfig?.largeFileBytes;
3650
+ const value = boundedBytes(requested, maxPartBytes, 1, "largeFileBytes");
3651
+ if (value > maxPartBytes) {
3652
+ throw new Error(
3653
+ `largeFileBytes (${describeBytes(value)}) is larger than maxPartBytes (${describeBytes(maxPartBytes)}). A file between the two cannot fit a part, so it would be cut to fit while the manifest called it complete. Raise maxPartBytes to at least largeFileBytes, or lower largeFileBytes.`
3654
+ );
3655
+ }
3656
+ return value;
3657
+ }
3648
3658
  var MIN_MAX_PART_BYTES = 4096;
3649
3659
  var MIN_MAX_PART_TOKENS = MIN_MAX_PART_BYTES / 4;
3650
3660
  var ARTIFACT_NAMES = [
@@ -4087,7 +4097,7 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
4087
4097
  tmpDir,
4088
4098
  maxPartBytes: resolvedMaxPartBytes,
4089
4099
  ...maxPartTokens === void 0 ? {} : { maxPartTokens },
4090
- largeFileBytes: boundedBytes(cliOptions?.largeFileBytes ?? userConfig?.largeFileBytes, 200 * 1024, 1, "largeFileBytes"),
4100
+ largeFileBytes: largeFileBytesFor(resolvedMaxPartBytes, cliOptions, userConfig),
4091
4101
  previewHeadLines: strictPositiveInteger(userConfig?.previewHeadLines, 80, "`previewHeadLines`"),
4092
4102
  previewTailLines: strictPositiveInteger(userConfig?.previewTailLines, 40, "`previewTailLines`"),
4093
4103
  includeMonolith: artifacts.monolith,
@@ -5998,7 +6008,7 @@ function generateAuditReport(manifest, secretFindings, secretRules) {
5998
6008
  );
5999
6009
  for (const file of affected) {
6000
6010
  const status = file.isPreviewTruncated ? "Truncated" : "Full";
6001
- const cutBy = file.isLarge ? "largeFileBytes" : "maxPartBytes";
6011
+ const cutBy = file.truncationReason === "part-budget" ? "maxPartBytes" : "largeFileBytes";
6002
6012
  lines.push(
6003
6013
  `| ${code(file.relativePath)} | ${file.sizeBytes} | ${file.lines} | ${file.includedBytes} | ${file.includedLines} | ${status} | ${cutBy} |`
6004
6014
  );
@@ -6177,7 +6187,8 @@ function truncatePreview(content, headLines, tailLines) {
6177
6187
  content: normalised,
6178
6188
  isTruncated: false,
6179
6189
  originalLines: total,
6180
- includedLines: total
6190
+ includedLines: total,
6191
+ omittedRanges: []
6181
6192
  };
6182
6193
  }
6183
6194
  const window = normalised.endsWith("\n") ? lines.slice(0, -1) : lines;
@@ -6189,13 +6200,16 @@ function truncatePreview(content, headLines, tailLines) {
6189
6200
  `... [${omitted} lines omitted: file exceeds large file size budget] ...`,
6190
6201
  ...tail
6191
6202
  ].join("\n");
6203
+ const firstOmitted = head.length + 1;
6204
+ const lastOmitted = total - tail.length;
6192
6205
  return {
6193
6206
  content: result,
6194
6207
  isTruncated: true,
6195
6208
  originalLines: total,
6196
6209
  // Head + notice + tail is exactly what is emitted; counting the slice is
6197
6210
  // wrong when the source ended with a newline (the trailing "" issue above).
6198
- includedLines: head.length + tail.length + 1
6211
+ includedLines: head.length + tail.length + 1,
6212
+ omittedRanges: lastOmitted >= firstOmitted ? [[firstOmitted, lastOmitted]] : []
6199
6213
  };
6200
6214
  }
6201
6215
 
@@ -6295,7 +6309,7 @@ function partitionFilesForBuckets(buckets, contentFingerprint) {
6295
6309
  section.file.originalLines
6296
6310
  );
6297
6311
  if (shrunk.isTruncated) {
6298
- applyTruncatedContent(section.file, shrunk.content);
6312
+ applyTruncatedContent(section.file, shrunk.content, "part-budget");
6299
6313
  section.text = renderFileSection(section.file);
6300
6314
  section.byteSize = Buffer.byteLength(section.text, "utf8");
6301
6315
  assemblies.delete(group);
@@ -6369,7 +6383,7 @@ function prepareSection(file, sectionBudget, partBudget) {
6369
6383
  file.originalLines
6370
6384
  );
6371
6385
  if (!truncated.isTruncated) return;
6372
- applyTruncatedContent(file, truncated.content);
6386
+ applyTruncatedContent(file, truncated.content, "part-budget");
6373
6387
  text = renderFileSection(file);
6374
6388
  byteSize = Buffer.byteLength(text, "utf8");
6375
6389
  };
@@ -6377,14 +6391,16 @@ function prepareSection(file, sectionBudget, partBudget) {
6377
6391
  if (byteSize > sectionBudget && file.summary) {
6378
6392
  file.summary = void 0;
6379
6393
  file.summaryOmitted = true;
6394
+ file.summaryOmittedReason = "part-budget";
6380
6395
  text = renderFileSection(file);
6381
6396
  byteSize = Buffer.byteLength(text, "utf8");
6382
6397
  shrinkBody();
6383
6398
  }
6384
6399
  if (byteSize > sectionBudget) {
6385
- applyTruncatedContent(file, SECTION_TRUNCATION_NOTICE);
6400
+ applyTruncatedContent(file, SECTION_TRUNCATION_NOTICE, "section-metadata");
6386
6401
  file.summary = void 0;
6387
6402
  file.summaryOmitted = true;
6403
+ file.summaryOmittedReason = "part-budget";
6388
6404
  text = renderFileSection(file);
6389
6405
  byteSize = Buffer.byteLength(text, "utf8");
6390
6406
  if (byteSize > sectionBudget) {
@@ -6433,10 +6449,14 @@ function fenceIsOpen(text, fence) {
6433
6449
  }
6434
6450
  return open;
6435
6451
  }
6436
- function applyTruncatedContent(file, content) {
6452
+ var OMISSION_NOTICE_LINE = /^\.\.\. \[\d+ lines omitted: [^\]]*\] \.\.\.$/;
6453
+ function applyTruncatedContent(file, content, reason) {
6454
+ const keptLines = content.split("\n").filter((line) => !OMISSION_NOTICE_LINE.test(line)).length;
6437
6455
  file.content = content;
6438
6456
  file.isPreviewTruncated = true;
6439
6457
  file.inclusionMode = "preview";
6458
+ file.truncationReason = reason;
6459
+ file.omittedRanges = keptLines >= file.originalLines ? file.originalLines > 0 ? [[file.originalLines, file.originalLines]] : [] : [[keptLines + 1, file.originalLines]];
6440
6460
  file.includedBytes = Buffer.byteLength(content, "utf8");
6441
6461
  file.includedLines = countLines(content);
6442
6462
  }
@@ -6583,7 +6603,9 @@ function renderFileSection(file) {
6583
6603
  compactMetadata(file),
6584
6604
  ...file.summaryQuality ? [`- Summary Quality: ${file.summaryQuality}`] : [],
6585
6605
  ...renderSummary(file.summary, file.inclusionMode),
6586
- ...file.summaryOmitted ? ["- Summary: (omitted: exceeds the part budget)"] : [],
6606
+ ...file.summaryOmitted ? [
6607
+ file.summaryOmittedReason === "preview" ? "- Summary: (omitted: the file is a head/tail preview)" : file.summaryOmittedReason === "oversize" ? "- Summary: (omitted: the file is too large to parse)" : "- Summary: (omitted: exceeds the part budget)"
6608
+ ] : [],
6587
6609
  "",
6588
6610
  file.inclusionMode === "preview" ? "#### Bounded Preview" : "#### Content",
6589
6611
  "",
@@ -8431,6 +8453,8 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
8431
8453
  const oversizeForSummary = Buffer.byteLength(rawContent, "utf8") > SUMMARY_MAX_SOURCE_BYTES2;
8432
8454
  let finalContent = redacted;
8433
8455
  let isPreviewTruncated = false;
8456
+ let truncationReason;
8457
+ let omittedRanges = [];
8434
8458
  let includedLines = lineCount;
8435
8459
  let inclusionMode = "full";
8436
8460
  if (config.skeleton === true && isSkeletonizable(relativePath) && !oversizeForSummary) {
@@ -8447,6 +8471,10 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
8447
8471
  isPreviewTruncated = preview.isTruncated;
8448
8472
  includedLines = preview.includedLines;
8449
8473
  inclusionMode = isPreviewTruncated ? "preview" : "full";
8474
+ if (isPreviewTruncated) {
8475
+ truncationReason = "large-file-budget";
8476
+ omittedRanges = preview.omittedRanges;
8477
+ }
8450
8478
  }
8451
8479
  let summary;
8452
8480
  let summaryQuality;
@@ -8481,6 +8509,8 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
8481
8509
  finalContent,
8482
8510
  inclusionMode,
8483
8511
  isPreviewTruncated,
8512
+ truncationReason,
8513
+ omittedRanges,
8484
8514
  includedLines,
8485
8515
  isLarge,
8486
8516
  summary,
@@ -8590,8 +8620,30 @@ function buildIndexes(files, tsconfigPaths) {
8590
8620
  }))
8591
8621
  };
8592
8622
  }
8593
- function verifyInMemory(files, parts) {
8623
+ function verifyInMemory(files, parts, unaccounted) {
8594
8624
  const errors = [];
8625
+ if (unaccounted.length > 0) {
8626
+ const shown = unaccounted.slice(0, 5).join(", ");
8627
+ errors.push(
8628
+ `${unaccounted.length} scanned file(s) appear in neither files[] nor skipped[]${unaccounted.length > 5 ? ` (first five: ${shown})` : `: ${shown}`}.`
8629
+ );
8630
+ }
8631
+ for (const file of files) {
8632
+ if (file.isPreviewTruncated && file.truncationReason === void 0) {
8633
+ errors.push(`${file.relativePath} is truncated but records no truncationReason.`);
8634
+ }
8635
+ const ranges = file.omittedRanges ?? [];
8636
+ if (file.truncationReason !== void 0 && ranges.length === 0) {
8637
+ errors.push(`${file.relativePath} is truncated but records no omittedRanges.`);
8638
+ }
8639
+ for (const [from, to] of ranges) {
8640
+ if (from < 1 || to < from || to > file.lines) {
8641
+ errors.push(
8642
+ `${file.relativePath} records omitted range ${from}-${to}, outside 1-${file.lines}.`
8643
+ );
8644
+ }
8645
+ }
8646
+ }
8595
8647
  const partNames = new Set(parts.map((part) => part.filename));
8596
8648
  for (const file of files) {
8597
8649
  if (!file.part || !partNames.has(file.part)) {
@@ -9090,10 +9142,6 @@ function generateSnapshot(configInput, options) {
9090
9142
  const skipped = maskSkipRecords([...collection.skipped], config.secretRules);
9091
9143
  const secretFindings = [];
9092
9144
  const warnings = [];
9093
- const budgetOrderCutsFiles = () => {
9094
- if (config.maxPartBytes >= config.largeFileBytes) return false;
9095
- return files.some((file) => file.isPreviewTruncated && !file.isLarge);
9096
- };
9097
9145
  const encodingNotes = [];
9098
9146
  const fileWarnings = [];
9099
9147
  const oversizeSummaryPaths = [];
@@ -9255,11 +9303,16 @@ function generateSnapshot(configInput, options) {
9255
9303
  inclusionMode: derivation.inclusionMode,
9256
9304
  isLarge: derivation.isLarge,
9257
9305
  isPreviewTruncated: derivation.isPreviewTruncated,
9306
+ ...derivation.truncationReason === void 0 ? {} : { truncationReason: derivation.truncationReason },
9307
+ ...derivation.omittedRanges.length === 0 ? {} : { omittedRanges: derivation.omittedRanges },
9258
9308
  originalLines: lineCount,
9259
9309
  includedLines: derivation.includedLines,
9260
9310
  includedBytes: Buffer.byteLength(derivation.finalContent, "utf8"),
9261
9311
  summary: derivation.summary,
9262
9312
  summaryQuality: derivation.summaryQuality,
9313
+ // A summary skipped for size is not an absent summary: record it the same way the
9314
+ // partitioner records one it had to drop, so a reader can tell the two apart.
9315
+ ...derivation.summarySkip === null ? {} : { summaryOmitted: true, summaryOmittedReason: derivation.summarySkip },
9263
9316
  ...decoded.encoding === "utf-8" ? {} : { encoding: decoded.encoding },
9264
9317
  content: derivation.finalContent
9265
9318
  });
@@ -9379,7 +9432,28 @@ function generateSnapshot(configInput, options) {
9379
9432
  }
9380
9433
  const parts = partitionByBudget(files, config, fingerprint);
9381
9434
  const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
9382
- const validationErrors = verifyInMemory(files, parts);
9435
+ const incomplete = files.flatMap((file) => {
9436
+ if (file.truncationReason === void 0) return [];
9437
+ const ranges = file.omittedRanges ?? [];
9438
+ const omittedLines = ranges.reduce((total, [from, to]) => total + (to - from + 1), 0);
9439
+ return [
9440
+ {
9441
+ relativePath: file.relativePath,
9442
+ part: file.part,
9443
+ reason: file.truncationReason,
9444
+ omittedRanges: ranges,
9445
+ omittedLines,
9446
+ includedLines: file.includedLines,
9447
+ lines: file.lines
9448
+ }
9449
+ ];
9450
+ });
9451
+ const accounted = /* @__PURE__ */ new Set([
9452
+ ...files.map((file) => maskPathText(file.relativePath, config.secretRules)),
9453
+ ...skipped.map((record) => record.path)
9454
+ ]);
9455
+ const unaccounted = candidateFiles.map((candidate) => maskPathText(candidate, config.secretRules)).filter((candidate) => !accounted.has(candidate));
9456
+ const validationErrors = verifyInMemory(files, parts, unaccounted);
9383
9457
  const totalContentBytes = files.reduce((total, file) => total + file.includedBytes, 0);
9384
9458
  const maskName = (value) => maskPathText(value, config.secretRules);
9385
9459
  const manifest = {
@@ -9440,7 +9514,8 @@ function generateSnapshot(configInput, options) {
9440
9514
  partsCount: parts.length,
9441
9515
  skippedCount: skipped.length,
9442
9516
  largeFileCount,
9443
- truncatedPreviewCount
9517
+ truncatedPreviewCount,
9518
+ incompleteCount: incomplete.length
9444
9519
  },
9445
9520
  totals: {
9446
9521
  candidateFiles: files.length + skipped.length,
@@ -9477,19 +9552,14 @@ function generateSnapshot(configInput, options) {
9477
9552
  return rest;
9478
9553
  }),
9479
9554
  skipped: maskSkipRecords(skipped, config.secretRules),
9555
+ incomplete,
9480
9556
  warnings
9481
9557
  };
9482
9558
  manifest.totals.redactedLines = secretFindings.length;
9483
9559
  manifest.totals.warningCount = manifest.warnings.length;
9484
- if (budgetOrderCutsFiles()) {
9485
- manifest.warnings.push(
9486
- `maxPartBytes (${config.maxPartBytes} B) is below largeFileBytes (${config.largeFileBytes} B), so files cut by the part budget are not marked as large previews. Increase maxPartBytes or lower largeFileBytes.`
9487
- );
9488
- manifest.totals.warningCount = manifest.warnings.length;
9489
- }
9490
- if (files.some((file) => file.isPreviewTruncated) && config.largeFileBytes <= config.maxPartBytes) {
9560
+ if (files.some((file) => file.isPreviewTruncated) && config.largeFileBytes < config.maxPartBytes) {
9491
9561
  manifest.warnings.push(
9492
- `${files.filter((file) => file.isPreviewTruncated).length} file(s) were previewed because largeFileBytes (${config.largeFileBytes} B) is not above maxPartBytes (${config.maxPartBytes} B). Raise largeFileBytes if a whole file is wanted.`
9562
+ `${files.filter((file) => file.isPreviewTruncated).length} file(s) were previewed because largeFileBytes (${config.largeFileBytes} B) is below maxPartBytes (${config.maxPartBytes} B). Raise largeFileBytes if a whole file is wanted.`
9493
9563
  );
9494
9564
  manifest.totals.warningCount = manifest.warnings.length;
9495
9565
  }
@@ -10698,6 +10768,9 @@ var readTool = {
10698
10768
  structured: {
10699
10769
  path: entry.relativePath,
10700
10770
  part: entry.part,
10771
+ // The window itself: a caller that wants to measure or re-send what it received should
10772
+ // not have to strip the header and the paging note back off `text`.
10773
+ body,
10701
10774
  layer: entry.layer,
10702
10775
  kind: entry.kind,
10703
10776
  language: entry.language,
@@ -11222,9 +11295,9 @@ function buildAgentContract() {
11222
11295
  {
11223
11296
  flag: "--large-file-bytes",
11224
11297
  type: "string",
11225
- default: 204800,
11298
+ default: 307200,
11226
11299
  appliesTo: optionAppliesTo("large-file-bytes"),
11227
- summary: "Above this size a file gets a head/tail preview instead of the full body."
11300
+ summary: "Above this size a file gets a head/tail preview instead of the full body. It defaults to maxPartBytes and may not exceed it: a file between the two could not fit a part."
11228
11301
  },
11229
11302
  {
11230
11303
  flag: "--max-monolith-bytes",
@@ -11459,7 +11532,7 @@ function buildAgentContract() {
11459
11532
  { key: "changedSince", type: "string | null", default: null, summary: "Snapshot only files that differ from this git ref." },
11460
11533
  { key: "staged", type: "boolean", default: false, summary: "Snapshot only files staged in the index." },
11461
11534
  { key: "withDependents", type: "boolean", default: false, summary: "With a changed-files scope, also include one hop of importers." },
11462
- { key: "largeFileBytes", type: "number | string", default: 204800, summary: "Preview threshold for large files." },
11535
+ { key: "largeFileBytes", type: "number | string", default: 307200, summary: "Preview threshold for large files; defaults to maxPartBytes and may not exceed it." },
11463
11536
  { key: "previewHeadLines", type: "number", default: 80, summary: "Lines kept from the head of a large file." },
11464
11537
  { key: "previewTailLines", type: "number", default: 40, summary: "Lines kept from the tail of a large file." },
11465
11538
  { key: "includeMonolith", type: "boolean", default: false, summary: "Also write the single-file monolith." },
@@ -11488,8 +11561,8 @@ function buildAgentContract() {
11488
11561
  "<outDir>/.codebase-snapshot (ownership marker, always written)"
11489
11562
  ],
11490
11563
  notes: [
11491
- "Parts are ordered and budget-limited; a single file larger than the budget becomes a head/tail preview.",
11492
- "manifest.json.files[] carries relativePath, layer, kind, language, part, inclusionMode and hash; `summary` is conditional \u2014 it is absent for languages with no structural summary, and `summaryOmitted: true` marks a summary dropped to fit the part budget; encoding appears when the file was not plain UTF-8.",
11564
+ "Parts are ordered and budget-limited; a file that cannot fit one part is emitted as a head/tail preview, and every file not present in full is listed in manifest.json incomplete[] with the missing line ranges.",
11565
+ "manifest.json.files[] carries relativePath, layer, kind, language, part, inclusionMode, truncationReason, omittedRanges and hash; manifest.json.incomplete[] lists every file not present in full; `summary` is conditional \u2014 it is absent for languages with no structural summary, and `summaryOmitted: true` marks a summary dropped to fit the part budget; encoding appears when the file was not plain UTF-8.",
11493
11566
  "manifest.skipped[] carries the path and the exact reason it was excluded.",
11494
11567
  `The output directory is replaced atomically; ${MIN_MAX_PART_BYTES} bytes is the smallest legal budget.`
11495
11568
  ]
@@ -11651,10 +11724,12 @@ do not assume the repository is broken.
11651
11724
  \`kind\`, \`language\`, \`part\`, \`inclusionMode\`, \`hashSha256\` and the structural
11652
11725
  \`summary\`, plus \`encoding\` when the file was not plain UTF-8. \`summary\` is
11653
11726
  **optional**: it is absent for languages with no structural summary, and
11654
- \`summaryOmitted: true\` marks one dropped to fit the part budget \u2014 never assume it
11727
+ \`summaryOmitted: true\` marks one dropped for size, and the reason in \`summaryOmittedReason\` says which rule \u2014 never assume it
11655
11728
  exists. The per-file \`hashSha256\` is only here and in the manifest; it is not printed
11656
11729
  into the parts.
11657
- \`skipped[]\` records every excluded file **and why**. Prefer querying this over
11730
+ \`skipped[]\` records every excluded file **and why**. The top-level \`incomplete[]\` records every included
11731
+ file whose body is not the whole file, with its reason and omittedRanges: ask that list,
11732
+ not the footer of a part, when the question is whether anything was lost. Prefer querying this over
11658
11733
  re-reading the parts.
11659
11734
  - \`snapshot/reports/audit.md\` \u2014 secrets found, large files, parse diagnostics, git
11660
11735
  state. Read this before you quote code back to a user.
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-XAW5GY6X.js';
2
- export { generateInWorker } from './chunk-ZXWAVHSZ.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-4H7MSW64.js';
2
+ export { generateInWorker } from './chunk-EP7OCPUM.js';