codebase-snapshot 0.9.17 → 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/CHANGELOG.md +148 -0
- package/README.md +7 -7
- package/SECURITY.md +2 -2
- package/dist/bin.js +210 -65
- package/dist/{chunk-S4367K5X.js → chunk-4H7MSW64.js} +14 -9
- package/dist/{chunk-IIP43I7C.js → chunk-EP7OCPUM.js} +160 -55
- package/dist/cli.cjs +210 -65
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +41 -6
- package/dist/index.cjs +160 -54
- package/dist/index.d.cts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +132 -57
- package/dist/mcp.js +2 -2
- package/dist/{types-KbJvBjmV.d.cts → types-Z471HW65.d.cts} +48 -2
- package/dist/{types-KbJvBjmV.d.ts → types-Z471HW65.d.ts} +48 -2
- package/docs/agent.md +3 -1
- package/docs/cli.md +15 -10
- package/docs/configuration.md +36 -27
- package/docs/how-to-context-budget.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +6 -4
- package/docs/mcp.md +3 -3
- package/docs/output.md +40 -24
- package/docs/troubleshooting.md +25 -0
- package/docs/vs-repomix.md +9 -5
- package/package.json +14 -17
package/dist/cli.cjs
CHANGED
|
@@ -554,7 +554,7 @@ var JS_PRESETS = [
|
|
|
554
554
|
...commonKinds()
|
|
555
555
|
],
|
|
556
556
|
exclude: [".nuxt", ".output"],
|
|
557
|
-
recommendedBudget: "
|
|
557
|
+
recommendedBudget: "300k"
|
|
558
558
|
},
|
|
559
559
|
{
|
|
560
560
|
name: "sveltekit",
|
|
@@ -575,7 +575,7 @@ var JS_PRESETS = [
|
|
|
575
575
|
...commonKinds()
|
|
576
576
|
],
|
|
577
577
|
exclude: [".svelte-kit", ".vercel"],
|
|
578
|
-
recommendedBudget: "
|
|
578
|
+
recommendedBudget: "300k"
|
|
579
579
|
},
|
|
580
580
|
{
|
|
581
581
|
name: "remix",
|
|
@@ -589,7 +589,7 @@ var JS_PRESETS = [
|
|
|
589
589
|
],
|
|
590
590
|
kinds: [kindOf("route", "routes/"), ...commonKinds()],
|
|
591
591
|
exclude: [".cache", "public/build"],
|
|
592
|
-
recommendedBudget: "
|
|
592
|
+
recommendedBudget: "300k"
|
|
593
593
|
},
|
|
594
594
|
{
|
|
595
595
|
name: "astro",
|
|
@@ -604,7 +604,7 @@ var JS_PRESETS = [
|
|
|
604
604
|
],
|
|
605
605
|
kinds: [suffixKind("page", ".astro"), kindOf("layout", "layouts/"), ...commonKinds()],
|
|
606
606
|
exclude: [".astro", "dist"],
|
|
607
|
-
recommendedBudget: "
|
|
607
|
+
recommendedBudget: "300k"
|
|
608
608
|
},
|
|
609
609
|
{
|
|
610
610
|
name: "angular",
|
|
@@ -628,7 +628,7 @@ var JS_PRESETS = [
|
|
|
628
628
|
...commonKinds()
|
|
629
629
|
],
|
|
630
630
|
exclude: [".angular", "dist"],
|
|
631
|
-
recommendedBudget: "
|
|
631
|
+
recommendedBudget: "300k"
|
|
632
632
|
},
|
|
633
633
|
{
|
|
634
634
|
name: "solid",
|
|
@@ -641,7 +641,7 @@ var JS_PRESETS = [
|
|
|
641
641
|
],
|
|
642
642
|
kinds: [kindOf("route", "routes/"), ...commonKinds()],
|
|
643
643
|
exclude: [".solid", "dist"],
|
|
644
|
-
recommendedBudget: "
|
|
644
|
+
recommendedBudget: "300k"
|
|
645
645
|
},
|
|
646
646
|
{
|
|
647
647
|
name: "vue-vite",
|
|
@@ -674,7 +674,7 @@ var JS_PRESETS = [
|
|
|
674
674
|
...commonKinds()
|
|
675
675
|
],
|
|
676
676
|
exclude: [".vite", "dist"],
|
|
677
|
-
recommendedBudget: "
|
|
677
|
+
recommendedBudget: "300k"
|
|
678
678
|
},
|
|
679
679
|
{
|
|
680
680
|
name: "react-vite",
|
|
@@ -688,7 +688,7 @@ var JS_PRESETS = [
|
|
|
688
688
|
layers: VITE_LAYERS,
|
|
689
689
|
kinds: VITE_KINDS,
|
|
690
690
|
exclude: [".vite", "dist"],
|
|
691
|
-
recommendedBudget: "
|
|
691
|
+
recommendedBudget: "300k"
|
|
692
692
|
},
|
|
693
693
|
{
|
|
694
694
|
name: "nest",
|
|
@@ -714,7 +714,7 @@ var JS_PRESETS = [
|
|
|
714
714
|
...commonKinds()
|
|
715
715
|
],
|
|
716
716
|
exclude: ["dist", "node_modules"],
|
|
717
|
-
recommendedBudget: "
|
|
717
|
+
recommendedBudget: "300k"
|
|
718
718
|
},
|
|
719
719
|
{
|
|
720
720
|
name: "node-express",
|
|
@@ -723,7 +723,7 @@ var JS_PRESETS = [
|
|
|
723
723
|
layers: NODE_LAYERS,
|
|
724
724
|
kinds: NODE_KINDS,
|
|
725
725
|
exclude: ["dist"],
|
|
726
|
-
recommendedBudget: "
|
|
726
|
+
recommendedBudget: "300k"
|
|
727
727
|
},
|
|
728
728
|
{
|
|
729
729
|
name: "node-lib",
|
|
@@ -739,7 +739,7 @@ var JS_PRESETS = [
|
|
|
739
739
|
],
|
|
740
740
|
kinds: [suffixKind("type", ".d.ts"), ...commonKinds()],
|
|
741
741
|
exclude: ["dist"],
|
|
742
|
-
recommendedBudget: "
|
|
742
|
+
recommendedBudget: "300k"
|
|
743
743
|
}
|
|
744
744
|
];
|
|
745
745
|
|
|
@@ -770,7 +770,7 @@ var LANGUAGE_PRESETS = [
|
|
|
770
770
|
...commonKinds()
|
|
771
771
|
],
|
|
772
772
|
exclude: ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache", ".tox", ".eggs", "staticfiles", "media"],
|
|
773
|
-
recommendedBudget: "
|
|
773
|
+
recommendedBudget: "300k"
|
|
774
774
|
},
|
|
775
775
|
{
|
|
776
776
|
name: "python-fastapi",
|
|
@@ -793,7 +793,7 @@ var LANGUAGE_PRESETS = [
|
|
|
793
793
|
...commonKinds()
|
|
794
794
|
],
|
|
795
795
|
exclude: ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache", ".tox", ".eggs"],
|
|
796
|
-
recommendedBudget: "
|
|
796
|
+
recommendedBudget: "300k"
|
|
797
797
|
},
|
|
798
798
|
{
|
|
799
799
|
name: "python-lib",
|
|
@@ -807,7 +807,7 @@ var LANGUAGE_PRESETS = [
|
|
|
807
807
|
],
|
|
808
808
|
kinds: [suffixKind("module", ".py"), ...commonKinds()],
|
|
809
809
|
exclude: ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache", ".tox", ".eggs"],
|
|
810
|
-
recommendedBudget: "
|
|
810
|
+
recommendedBudget: "300k"
|
|
811
811
|
},
|
|
812
812
|
{
|
|
813
813
|
name: "go",
|
|
@@ -831,7 +831,7 @@ var LANGUAGE_PRESETS = [
|
|
|
831
831
|
...commonKinds()
|
|
832
832
|
],
|
|
833
833
|
exclude: ["vendor", "testdata"],
|
|
834
|
-
recommendedBudget: "
|
|
834
|
+
recommendedBudget: "300k"
|
|
835
835
|
},
|
|
836
836
|
{
|
|
837
837
|
name: "rust",
|
|
@@ -847,7 +847,7 @@ var LANGUAGE_PRESETS = [
|
|
|
847
847
|
],
|
|
848
848
|
kinds: [suffixKind("module", ".rs"), suffixKind("test", "_test.rs"), ...commonKinds()],
|
|
849
849
|
exclude: ["target"],
|
|
850
|
-
recommendedBudget: "
|
|
850
|
+
recommendedBudget: "300k"
|
|
851
851
|
},
|
|
852
852
|
{
|
|
853
853
|
name: "java-spring",
|
|
@@ -870,7 +870,7 @@ var LANGUAGE_PRESETS = [
|
|
|
870
870
|
...commonKinds()
|
|
871
871
|
],
|
|
872
872
|
exclude: [".gradle", "out", "target"],
|
|
873
|
-
recommendedBudget: "
|
|
873
|
+
recommendedBudget: "300k"
|
|
874
874
|
},
|
|
875
875
|
{
|
|
876
876
|
name: "dotnet",
|
|
@@ -893,7 +893,7 @@ var LANGUAGE_PRESETS = [
|
|
|
893
893
|
...commonKinds()
|
|
894
894
|
],
|
|
895
895
|
exclude: ["bin", "obj", ".vs"],
|
|
896
|
-
recommendedBudget: "
|
|
896
|
+
recommendedBudget: "300k"
|
|
897
897
|
},
|
|
898
898
|
{
|
|
899
899
|
name: "php-laravel",
|
|
@@ -919,7 +919,7 @@ var LANGUAGE_PRESETS = [
|
|
|
919
919
|
...commonKinds()
|
|
920
920
|
],
|
|
921
921
|
exclude: ["vendor", "storage", "bootstrap/cache", "public/build"],
|
|
922
|
-
recommendedBudget: "
|
|
922
|
+
recommendedBudget: "300k"
|
|
923
923
|
},
|
|
924
924
|
{
|
|
925
925
|
name: "ruby-rails",
|
|
@@ -944,7 +944,7 @@ var LANGUAGE_PRESETS = [
|
|
|
944
944
|
...commonKinds()
|
|
945
945
|
],
|
|
946
946
|
exclude: [".bundle", "log", "tmp", "vendor/bundle", "public/assets"],
|
|
947
|
-
recommendedBudget: "
|
|
947
|
+
recommendedBudget: "300k"
|
|
948
948
|
}
|
|
949
949
|
];
|
|
950
950
|
|
|
@@ -1006,7 +1006,7 @@ var SHAPE_PRESETS = [
|
|
|
1006
1006
|
],
|
|
1007
1007
|
kinds: commonKinds(),
|
|
1008
1008
|
exclude: [".turbo", ".nx"],
|
|
1009
|
-
recommendedBudget: "
|
|
1009
|
+
recommendedBudget: "300k"
|
|
1010
1010
|
},
|
|
1011
1011
|
{
|
|
1012
1012
|
name: "infra",
|
|
@@ -1024,7 +1024,7 @@ var SHAPE_PRESETS = [
|
|
|
1024
1024
|
...commonKinds()
|
|
1025
1025
|
],
|
|
1026
1026
|
exclude: [".terraform", ".terragrunt-cache"],
|
|
1027
|
-
recommendedBudget: "
|
|
1027
|
+
recommendedBudget: "300k"
|
|
1028
1028
|
},
|
|
1029
1029
|
{
|
|
1030
1030
|
name: "docs",
|
|
@@ -1041,7 +1041,7 @@ var SHAPE_PRESETS = [
|
|
|
1041
1041
|
],
|
|
1042
1042
|
kinds: commonKinds(),
|
|
1043
1043
|
exclude: [".docusaurus", ".vitepress/dist", "site"],
|
|
1044
|
-
recommendedBudget: "
|
|
1044
|
+
recommendedBudget: "300k"
|
|
1045
1045
|
},
|
|
1046
1046
|
{
|
|
1047
1047
|
name: "generic",
|
|
@@ -1053,7 +1053,7 @@ var SHAPE_PRESETS = [
|
|
|
1053
1053
|
layers: DEFAULT_LAYERS,
|
|
1054
1054
|
kinds: DEFAULT_KINDS,
|
|
1055
1055
|
exclude: [],
|
|
1056
|
-
recommendedBudget: "
|
|
1056
|
+
recommendedBudget: "300k"
|
|
1057
1057
|
}
|
|
1058
1058
|
];
|
|
1059
1059
|
|
|
@@ -2179,7 +2179,7 @@ function applySpans(line, spans) {
|
|
|
2179
2179
|
|
|
2180
2180
|
// src/version.ts
|
|
2181
2181
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2182
|
-
var GENERATOR_VERSION = "0.
|
|
2182
|
+
var GENERATOR_VERSION = "0.10.0";
|
|
2183
2183
|
var SCHEMA_VERSION = "3.0.0";
|
|
2184
2184
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2185
2185
|
function isOurGeneratorName(name) {
|
|
@@ -3505,6 +3505,16 @@ async function loadConfigFileDetailed(cwd, options = {}) {
|
|
|
3505
3505
|
}
|
|
3506
3506
|
return { config: null, file: null, warnings, errors };
|
|
3507
3507
|
}
|
|
3508
|
+
function largeFileBytesFor(maxPartBytes, cliOptions, userConfig) {
|
|
3509
|
+
const requested = cliOptions?.largeFileBytes ?? userConfig?.largeFileBytes;
|
|
3510
|
+
const value = boundedBytes(requested, maxPartBytes, 1, "largeFileBytes");
|
|
3511
|
+
if (value > maxPartBytes) {
|
|
3512
|
+
throw new Error(
|
|
3513
|
+
`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.`
|
|
3514
|
+
);
|
|
3515
|
+
}
|
|
3516
|
+
return value;
|
|
3517
|
+
}
|
|
3508
3518
|
var MIN_MAX_PART_BYTES = 4096;
|
|
3509
3519
|
var MIN_MAX_PART_TOKENS = MIN_MAX_PART_BYTES / 4;
|
|
3510
3520
|
var ARTIFACT_NAMES = [
|
|
@@ -3947,7 +3957,7 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
3947
3957
|
tmpDir,
|
|
3948
3958
|
maxPartBytes: resolvedMaxPartBytes,
|
|
3949
3959
|
...maxPartTokens === void 0 ? {} : { maxPartTokens },
|
|
3950
|
-
largeFileBytes:
|
|
3960
|
+
largeFileBytes: largeFileBytesFor(resolvedMaxPartBytes, cliOptions, userConfig),
|
|
3951
3961
|
previewHeadLines: strictPositiveInteger(userConfig?.previewHeadLines, 80, "`previewHeadLines`"),
|
|
3952
3962
|
previewTailLines: strictPositiveInteger(userConfig?.previewTailLines, 40, "`previewTailLines`"),
|
|
3953
3963
|
includeMonolith: artifacts.monolith,
|
|
@@ -7000,7 +7010,8 @@ function truncatePreview(content, headLines, tailLines) {
|
|
|
7000
7010
|
content: normalised,
|
|
7001
7011
|
isTruncated: false,
|
|
7002
7012
|
originalLines: total,
|
|
7003
|
-
includedLines: total
|
|
7013
|
+
includedLines: total,
|
|
7014
|
+
omittedRanges: []
|
|
7004
7015
|
};
|
|
7005
7016
|
}
|
|
7006
7017
|
const window = normalised.endsWith("\n") ? lines.slice(0, -1) : lines;
|
|
@@ -7012,13 +7023,16 @@ function truncatePreview(content, headLines, tailLines) {
|
|
|
7012
7023
|
`... [${omitted} lines omitted: file exceeds large file size budget] ...`,
|
|
7013
7024
|
...tail
|
|
7014
7025
|
].join("\n");
|
|
7026
|
+
const firstOmitted = head.length + 1;
|
|
7027
|
+
const lastOmitted = total - tail.length;
|
|
7015
7028
|
return {
|
|
7016
7029
|
content: result,
|
|
7017
7030
|
isTruncated: true,
|
|
7018
7031
|
originalLines: total,
|
|
7019
7032
|
// Head + notice + tail is exactly what is emitted; counting the slice is
|
|
7020
7033
|
// wrong when the source ended with a newline (the trailing "" issue above).
|
|
7021
|
-
includedLines: head.length + tail.length + 1
|
|
7034
|
+
includedLines: head.length + tail.length + 1,
|
|
7035
|
+
omittedRanges: lastOmitted >= firstOmitted ? [[firstOmitted, lastOmitted]] : []
|
|
7022
7036
|
};
|
|
7023
7037
|
}
|
|
7024
7038
|
var LANGUAGE_BY_EXTENSION = {
|
|
@@ -7666,7 +7680,9 @@ function renderConfig(answers) {
|
|
|
7666
7680
|
// The same ceiling expressed in tokens; it narrows maxPartBytes rather than
|
|
7667
7681
|
// replacing it. null = not set. Minimum 1024.
|
|
7668
7682
|
maxPartTokens: ${answers.maxPartTokens === null ? "null" : String(answers.maxPartTokens)},
|
|
7669
|
-
// Files above this size get a head/tail preview instead of the full body.
|
|
7683
|
+
// Files above this size get a head/tail preview instead of the full body. It may not
|
|
7684
|
+
// exceed maxPartBytes: a file between the two could not fit a part, and cutting it to fit
|
|
7685
|
+
// while the manifest called it a preview is exactly what this ceiling pair must prevent.
|
|
7670
7686
|
largeFileBytes: ${size(answers.largeFileBytes)},
|
|
7671
7687
|
previewHeadLines: 80,
|
|
7672
7688
|
previewTailLines: 40,
|
|
@@ -8351,6 +8367,9 @@ async function runInit(options) {
|
|
|
8351
8367
|
let reason = detected.reason;
|
|
8352
8368
|
let fallback = detected.fallback;
|
|
8353
8369
|
const notes = [];
|
|
8370
|
+
const budgetBytes = parseByteSize(options.maxPartBytes ?? detected.recommendedBudget ?? DEFAULT_ANSWERS.maxPartBytes) ?? 307200;
|
|
8371
|
+
const tokenBudgetBytes = options.maxPartTokens === void 0 || options.maxPartTokens === null ? void 0 : options.maxPartTokens * 4;
|
|
8372
|
+
const effectiveBudgetBytes = tokenBudgetBytes === void 0 ? budgetBytes : Math.min(budgetBytes, tokenBudgetBytes);
|
|
8354
8373
|
const answers = {
|
|
8355
8374
|
preset: detected.presetName,
|
|
8356
8375
|
// The repository's own branch, read the same way the generator reads it.
|
|
@@ -8364,7 +8383,13 @@ async function runInit(options) {
|
|
|
8364
8383
|
// what the run used is drift the next `validate` reports, and `setup` is the one command
|
|
8365
8384
|
// that is supposed to leave a project in a consistent state.
|
|
8366
8385
|
maxPartTokens: options.maxPartTokens ?? DEFAULT_ANSWERS.maxPartTokens,
|
|
8367
|
-
largeFileBytes: options.largeFileBytes ??
|
|
8386
|
+
largeFileBytes: options.largeFileBytes ?? // A threshold above the part budget is a configuration error (a file between the two
|
|
8387
|
+
// cannot fit, so it is cut while the manifest calls it a preview). Writing the old fixed
|
|
8388
|
+
// 200 KB beside `--max-part-tokens 32k` made the setup's own output fail its own validate.
|
|
8389
|
+
Math.min(
|
|
8390
|
+
parseByteSize(DEFAULT_ANSWERS.largeFileBytes) ?? effectiveBudgetBytes,
|
|
8391
|
+
effectiveBudgetBytes
|
|
8392
|
+
),
|
|
8368
8393
|
maxMonolithBytes: options.maxMonolithBytes ?? DEFAULT_ANSWERS.maxMonolithBytes,
|
|
8369
8394
|
discovery: options.discovery ?? DEFAULT_ANSWERS.discovery,
|
|
8370
8395
|
skeleton: options.skeleton ?? DEFAULT_ANSWERS.skeleton,
|
|
@@ -8839,7 +8864,7 @@ function generateAuditReport(manifest, secretFindings, secretRules) {
|
|
|
8839
8864
|
);
|
|
8840
8865
|
for (const file of affected) {
|
|
8841
8866
|
const status = file.isPreviewTruncated ? "Truncated" : "Full";
|
|
8842
|
-
const cutBy = file.
|
|
8867
|
+
const cutBy = file.truncationReason === "part-budget" ? "maxPartBytes" : "largeFileBytes";
|
|
8843
8868
|
lines.push(
|
|
8844
8869
|
`| ${code(file.relativePath)} | ${file.sizeBytes} | ${file.lines} | ${file.includedBytes} | ${file.includedLines} | ${status} | ${cutBy} |`
|
|
8845
8870
|
);
|
|
@@ -9078,7 +9103,7 @@ function partitionFilesForBuckets(buckets, contentFingerprint) {
|
|
|
9078
9103
|
section.file.originalLines
|
|
9079
9104
|
);
|
|
9080
9105
|
if (shrunk.isTruncated) {
|
|
9081
|
-
applyTruncatedContent(section.file, shrunk.content);
|
|
9106
|
+
applyTruncatedContent(section.file, shrunk.content, "part-budget");
|
|
9082
9107
|
section.text = renderFileSection(section.file);
|
|
9083
9108
|
section.byteSize = Buffer.byteLength(section.text, "utf8");
|
|
9084
9109
|
assemblies.delete(group);
|
|
@@ -9152,7 +9177,7 @@ function prepareSection(file, sectionBudget, partBudget) {
|
|
|
9152
9177
|
file.originalLines
|
|
9153
9178
|
);
|
|
9154
9179
|
if (!truncated.isTruncated) return;
|
|
9155
|
-
applyTruncatedContent(file, truncated.content);
|
|
9180
|
+
applyTruncatedContent(file, truncated.content, "part-budget");
|
|
9156
9181
|
text2 = renderFileSection(file);
|
|
9157
9182
|
byteSize = Buffer.byteLength(text2, "utf8");
|
|
9158
9183
|
};
|
|
@@ -9160,14 +9185,16 @@ function prepareSection(file, sectionBudget, partBudget) {
|
|
|
9160
9185
|
if (byteSize > sectionBudget && file.summary) {
|
|
9161
9186
|
file.summary = void 0;
|
|
9162
9187
|
file.summaryOmitted = true;
|
|
9188
|
+
file.summaryOmittedReason = "part-budget";
|
|
9163
9189
|
text2 = renderFileSection(file);
|
|
9164
9190
|
byteSize = Buffer.byteLength(text2, "utf8");
|
|
9165
9191
|
shrinkBody();
|
|
9166
9192
|
}
|
|
9167
9193
|
if (byteSize > sectionBudget) {
|
|
9168
|
-
applyTruncatedContent(file, SECTION_TRUNCATION_NOTICE);
|
|
9194
|
+
applyTruncatedContent(file, SECTION_TRUNCATION_NOTICE, "section-metadata");
|
|
9169
9195
|
file.summary = void 0;
|
|
9170
9196
|
file.summaryOmitted = true;
|
|
9197
|
+
file.summaryOmittedReason = "part-budget";
|
|
9171
9198
|
text2 = renderFileSection(file);
|
|
9172
9199
|
byteSize = Buffer.byteLength(text2, "utf8");
|
|
9173
9200
|
if (byteSize > sectionBudget) {
|
|
@@ -9216,10 +9243,14 @@ function fenceIsOpen(text2, fence) {
|
|
|
9216
9243
|
}
|
|
9217
9244
|
return open;
|
|
9218
9245
|
}
|
|
9219
|
-
|
|
9246
|
+
var OMISSION_NOTICE_LINE = /^\.\.\. \[\d+ lines omitted: [^\]]*\] \.\.\.$/;
|
|
9247
|
+
function applyTruncatedContent(file, content, reason) {
|
|
9248
|
+
const keptLines = content.split("\n").filter((line) => !OMISSION_NOTICE_LINE.test(line)).length;
|
|
9220
9249
|
file.content = content;
|
|
9221
9250
|
file.isPreviewTruncated = true;
|
|
9222
9251
|
file.inclusionMode = "preview";
|
|
9252
|
+
file.truncationReason = reason;
|
|
9253
|
+
file.omittedRanges = keptLines >= file.originalLines ? file.originalLines > 0 ? [[file.originalLines, file.originalLines]] : [] : [[keptLines + 1, file.originalLines]];
|
|
9223
9254
|
file.includedBytes = Buffer.byteLength(content, "utf8");
|
|
9224
9255
|
file.includedLines = countLines(content);
|
|
9225
9256
|
}
|
|
@@ -9366,7 +9397,9 @@ function renderFileSection(file) {
|
|
|
9366
9397
|
compactMetadata(file),
|
|
9367
9398
|
...file.summaryQuality ? [`- Summary Quality: ${file.summaryQuality}`] : [],
|
|
9368
9399
|
...renderSummary(file.summary, file.inclusionMode),
|
|
9369
|
-
...file.summaryOmitted ? [
|
|
9400
|
+
...file.summaryOmitted ? [
|
|
9401
|
+
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)"
|
|
9402
|
+
] : [],
|
|
9370
9403
|
"",
|
|
9371
9404
|
file.inclusionMode === "preview" ? "#### Bounded Preview" : "#### Content",
|
|
9372
9405
|
"",
|
|
@@ -9649,6 +9682,7 @@ function generateProjectTree(filePaths) {
|
|
|
9649
9682
|
}
|
|
9650
9683
|
var PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
|
|
9651
9684
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
9685
|
+
var UP_TO_DATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
9652
9686
|
var FAILURE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
9653
9687
|
var REQUEST_TIMEOUT_MS = 1200;
|
|
9654
9688
|
function installKind(scriptPath = process.argv[1] ?? "", cwd = process.cwd()) {
|
|
@@ -9823,7 +9857,8 @@ async function checkForUpdate(options) {
|
|
|
9823
9857
|
needsFetch = age >= FAILURE_INTERVAL_MS;
|
|
9824
9858
|
} else {
|
|
9825
9859
|
latest = cached.latest;
|
|
9826
|
-
|
|
9860
|
+
const interval = isNewer(cached.latest, options.current) ? CHECK_INTERVAL_MS : UP_TO_DATE_INTERVAL_MS;
|
|
9861
|
+
needsFetch = age >= interval;
|
|
9827
9862
|
}
|
|
9828
9863
|
}
|
|
9829
9864
|
if (needsFetch) {
|
|
@@ -10127,6 +10162,8 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
|
|
|
10127
10162
|
const oversizeForSummary = Buffer.byteLength(rawContent, "utf8") > SUMMARY_MAX_SOURCE_BYTES2;
|
|
10128
10163
|
let finalContent = redacted;
|
|
10129
10164
|
let isPreviewTruncated = false;
|
|
10165
|
+
let truncationReason;
|
|
10166
|
+
let omittedRanges = [];
|
|
10130
10167
|
let includedLines = lineCount;
|
|
10131
10168
|
let inclusionMode = "full";
|
|
10132
10169
|
if (config.skeleton === true && isSkeletonizable(relativePath) && !oversizeForSummary) {
|
|
@@ -10143,6 +10180,10 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
|
|
|
10143
10180
|
isPreviewTruncated = preview.isTruncated;
|
|
10144
10181
|
includedLines = preview.includedLines;
|
|
10145
10182
|
inclusionMode = isPreviewTruncated ? "preview" : "full";
|
|
10183
|
+
if (isPreviewTruncated) {
|
|
10184
|
+
truncationReason = "large-file-budget";
|
|
10185
|
+
omittedRanges = preview.omittedRanges;
|
|
10186
|
+
}
|
|
10146
10187
|
}
|
|
10147
10188
|
let summary;
|
|
10148
10189
|
let summaryQuality;
|
|
@@ -10177,6 +10218,8 @@ function deriveFile(relativePath, rawContent, sizeBytes, config) {
|
|
|
10177
10218
|
finalContent,
|
|
10178
10219
|
inclusionMode,
|
|
10179
10220
|
isPreviewTruncated,
|
|
10221
|
+
truncationReason,
|
|
10222
|
+
omittedRanges,
|
|
10180
10223
|
includedLines,
|
|
10181
10224
|
isLarge,
|
|
10182
10225
|
summary,
|
|
@@ -10286,8 +10329,30 @@ function buildIndexes(files, tsconfigPaths) {
|
|
|
10286
10329
|
}))
|
|
10287
10330
|
};
|
|
10288
10331
|
}
|
|
10289
|
-
function verifyInMemory(files, parts) {
|
|
10332
|
+
function verifyInMemory(files, parts, unaccounted) {
|
|
10290
10333
|
const errors = [];
|
|
10334
|
+
if (unaccounted.length > 0) {
|
|
10335
|
+
const shown = unaccounted.slice(0, 5).join(", ");
|
|
10336
|
+
errors.push(
|
|
10337
|
+
`${unaccounted.length} scanned file(s) appear in neither files[] nor skipped[]${unaccounted.length > 5 ? ` (first five: ${shown})` : `: ${shown}`}.`
|
|
10338
|
+
);
|
|
10339
|
+
}
|
|
10340
|
+
for (const file of files) {
|
|
10341
|
+
if (file.isPreviewTruncated && file.truncationReason === void 0) {
|
|
10342
|
+
errors.push(`${file.relativePath} is truncated but records no truncationReason.`);
|
|
10343
|
+
}
|
|
10344
|
+
const ranges = file.omittedRanges ?? [];
|
|
10345
|
+
if (file.truncationReason !== void 0 && ranges.length === 0) {
|
|
10346
|
+
errors.push(`${file.relativePath} is truncated but records no omittedRanges.`);
|
|
10347
|
+
}
|
|
10348
|
+
for (const [from, to] of ranges) {
|
|
10349
|
+
if (from < 1 || to < from || to > file.lines) {
|
|
10350
|
+
errors.push(
|
|
10351
|
+
`${file.relativePath} records omitted range ${from}-${to}, outside 1-${file.lines}.`
|
|
10352
|
+
);
|
|
10353
|
+
}
|
|
10354
|
+
}
|
|
10355
|
+
}
|
|
10291
10356
|
const partNames = new Set(parts.map((part) => part.filename));
|
|
10292
10357
|
for (const file of files) {
|
|
10293
10358
|
if (!file.part || !partNames.has(file.part)) {
|
|
@@ -11038,7 +11103,20 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
|
|
|
11038
11103
|
const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
|
|
11039
11104
|
const hadPrevious = fs15__namespace.existsSync(outDir);
|
|
11040
11105
|
if (hadPrevious) beforeSwap?.();
|
|
11041
|
-
|
|
11106
|
+
let movedAside = false;
|
|
11107
|
+
if (hadPrevious) {
|
|
11108
|
+
try {
|
|
11109
|
+
fs15__namespace.renameSync(outDir, backupDir);
|
|
11110
|
+
movedAside = true;
|
|
11111
|
+
} catch (err) {
|
|
11112
|
+
if (!isLockError(err)) throw err;
|
|
11113
|
+
fs15__namespace.rmSync(outDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
11114
|
+
process.stderr.write(
|
|
11115
|
+
`\u26A0 ${outDir} could not be moved aside (${err.message}), so it was replaced in place. Close anything holding the old snapshot open to avoid this next time.
|
|
11116
|
+
`
|
|
11117
|
+
);
|
|
11118
|
+
}
|
|
11119
|
+
}
|
|
11042
11120
|
try {
|
|
11043
11121
|
try {
|
|
11044
11122
|
fs15__namespace.renameSync(stagingDir, outDir);
|
|
@@ -11058,9 +11136,14 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
|
|
|
11058
11136
|
}
|
|
11059
11137
|
}
|
|
11060
11138
|
} catch (err) {
|
|
11061
|
-
if (hadPrevious && fs15__namespace.existsSync(backupDir)) {
|
|
11139
|
+
if (hadPrevious && movedAside && fs15__namespace.existsSync(backupDir)) {
|
|
11062
11140
|
if (fs15__namespace.existsSync(outDir)) fs15__namespace.rmSync(outDir, { recursive: true, force: true });
|
|
11063
11141
|
fs15__namespace.renameSync(backupDir, outDir);
|
|
11142
|
+
} else if (hadPrevious && !movedAside) {
|
|
11143
|
+
process.stderr.write(
|
|
11144
|
+
`\u26A0 The previous snapshot at ${outDir} was removed and the new one could not be moved into place. It is complete at ${stagingDir}.
|
|
11145
|
+
`
|
|
11146
|
+
);
|
|
11064
11147
|
}
|
|
11065
11148
|
throw err;
|
|
11066
11149
|
}
|
|
@@ -11075,6 +11158,10 @@ function swapOnce(stagingDir, outDir, beforeSwap) {
|
|
|
11075
11158
|
}
|
|
11076
11159
|
}
|
|
11077
11160
|
}
|
|
11161
|
+
function isLockError(err) {
|
|
11162
|
+
const code = err.code;
|
|
11163
|
+
return code === "EPERM" || code === "EBUSY" || code === "EACCES";
|
|
11164
|
+
}
|
|
11078
11165
|
function sleepSync(milliseconds) {
|
|
11079
11166
|
const buffer = new Int32Array(new SharedArrayBuffer(4));
|
|
11080
11167
|
Atomics.wait(buffer, 0, 0, milliseconds);
|
|
@@ -11178,10 +11265,6 @@ function generateSnapshot(configInput, options) {
|
|
|
11178
11265
|
const skipped = maskSkipRecords([...collection.skipped], config.secretRules);
|
|
11179
11266
|
const secretFindings = [];
|
|
11180
11267
|
const warnings = [];
|
|
11181
|
-
const budgetOrderCutsFiles = () => {
|
|
11182
|
-
if (config.maxPartBytes >= config.largeFileBytes) return false;
|
|
11183
|
-
return files.some((file) => file.isPreviewTruncated && !file.isLarge);
|
|
11184
|
-
};
|
|
11185
11268
|
const encodingNotes = [];
|
|
11186
11269
|
const fileWarnings = [];
|
|
11187
11270
|
const oversizeSummaryPaths = [];
|
|
@@ -11343,11 +11426,16 @@ function generateSnapshot(configInput, options) {
|
|
|
11343
11426
|
inclusionMode: derivation.inclusionMode,
|
|
11344
11427
|
isLarge: derivation.isLarge,
|
|
11345
11428
|
isPreviewTruncated: derivation.isPreviewTruncated,
|
|
11429
|
+
...derivation.truncationReason === void 0 ? {} : { truncationReason: derivation.truncationReason },
|
|
11430
|
+
...derivation.omittedRanges.length === 0 ? {} : { omittedRanges: derivation.omittedRanges },
|
|
11346
11431
|
originalLines: lineCount,
|
|
11347
11432
|
includedLines: derivation.includedLines,
|
|
11348
11433
|
includedBytes: Buffer.byteLength(derivation.finalContent, "utf8"),
|
|
11349
11434
|
summary: derivation.summary,
|
|
11350
11435
|
summaryQuality: derivation.summaryQuality,
|
|
11436
|
+
// A summary skipped for size is not an absent summary: record it the same way the
|
|
11437
|
+
// partitioner records one it had to drop, so a reader can tell the two apart.
|
|
11438
|
+
...derivation.summarySkip === null ? {} : { summaryOmitted: true, summaryOmittedReason: derivation.summarySkip },
|
|
11351
11439
|
...decoded.encoding === "utf-8" ? {} : { encoding: decoded.encoding },
|
|
11352
11440
|
content: derivation.finalContent
|
|
11353
11441
|
});
|
|
@@ -11467,7 +11555,28 @@ function generateSnapshot(configInput, options) {
|
|
|
11467
11555
|
}
|
|
11468
11556
|
const parts = partitionByBudget(files, config, fingerprint);
|
|
11469
11557
|
const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
|
|
11470
|
-
const
|
|
11558
|
+
const incomplete = files.flatMap((file) => {
|
|
11559
|
+
if (file.truncationReason === void 0) return [];
|
|
11560
|
+
const ranges = file.omittedRanges ?? [];
|
|
11561
|
+
const omittedLines = ranges.reduce((total, [from, to]) => total + (to - from + 1), 0);
|
|
11562
|
+
return [
|
|
11563
|
+
{
|
|
11564
|
+
relativePath: file.relativePath,
|
|
11565
|
+
part: file.part,
|
|
11566
|
+
reason: file.truncationReason,
|
|
11567
|
+
omittedRanges: ranges,
|
|
11568
|
+
omittedLines,
|
|
11569
|
+
includedLines: file.includedLines,
|
|
11570
|
+
lines: file.lines
|
|
11571
|
+
}
|
|
11572
|
+
];
|
|
11573
|
+
});
|
|
11574
|
+
const accounted = /* @__PURE__ */ new Set([
|
|
11575
|
+
...files.map((file) => maskPathText(file.relativePath, config.secretRules)),
|
|
11576
|
+
...skipped.map((record) => record.path)
|
|
11577
|
+
]);
|
|
11578
|
+
const unaccounted = candidateFiles.map((candidate) => maskPathText(candidate, config.secretRules)).filter((candidate) => !accounted.has(candidate));
|
|
11579
|
+
const validationErrors = verifyInMemory(files, parts, unaccounted);
|
|
11471
11580
|
const totalContentBytes = files.reduce((total, file) => total + file.includedBytes, 0);
|
|
11472
11581
|
const maskName = (value) => maskPathText(value, config.secretRules);
|
|
11473
11582
|
const manifest = {
|
|
@@ -11528,7 +11637,8 @@ function generateSnapshot(configInput, options) {
|
|
|
11528
11637
|
partsCount: parts.length,
|
|
11529
11638
|
skippedCount: skipped.length,
|
|
11530
11639
|
largeFileCount,
|
|
11531
|
-
truncatedPreviewCount
|
|
11640
|
+
truncatedPreviewCount,
|
|
11641
|
+
incompleteCount: incomplete.length
|
|
11532
11642
|
},
|
|
11533
11643
|
totals: {
|
|
11534
11644
|
candidateFiles: files.length + skipped.length,
|
|
@@ -11565,19 +11675,14 @@ function generateSnapshot(configInput, options) {
|
|
|
11565
11675
|
return rest;
|
|
11566
11676
|
}),
|
|
11567
11677
|
skipped: maskSkipRecords(skipped, config.secretRules),
|
|
11678
|
+
incomplete,
|
|
11568
11679
|
warnings
|
|
11569
11680
|
};
|
|
11570
11681
|
manifest.totals.redactedLines = secretFindings.length;
|
|
11571
11682
|
manifest.totals.warningCount = manifest.warnings.length;
|
|
11572
|
-
if (
|
|
11683
|
+
if (files.some((file) => file.isPreviewTruncated) && config.largeFileBytes < config.maxPartBytes) {
|
|
11573
11684
|
manifest.warnings.push(
|
|
11574
|
-
|
|
11575
|
-
);
|
|
11576
|
-
manifest.totals.warningCount = manifest.warnings.length;
|
|
11577
|
-
}
|
|
11578
|
-
if (files.some((file) => file.isPreviewTruncated) && config.largeFileBytes <= config.maxPartBytes) {
|
|
11579
|
-
manifest.warnings.push(
|
|
11580
|
-
`${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.`
|
|
11685
|
+
`${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.`
|
|
11581
11686
|
);
|
|
11582
11687
|
manifest.totals.warningCount = manifest.warnings.length;
|
|
11583
11688
|
}
|
|
@@ -12945,6 +13050,9 @@ var readTool = {
|
|
|
12945
13050
|
structured: {
|
|
12946
13051
|
path: entry.relativePath,
|
|
12947
13052
|
part: entry.part,
|
|
13053
|
+
// The window itself: a caller that wants to measure or re-send what it received should
|
|
13054
|
+
// not have to strip the header and the paging note back off `text`.
|
|
13055
|
+
body,
|
|
12948
13056
|
layer: entry.layer,
|
|
12949
13057
|
kind: entry.kind,
|
|
12950
13058
|
language: entry.language,
|
|
@@ -13611,9 +13719,9 @@ function buildAgentContract() {
|
|
|
13611
13719
|
{
|
|
13612
13720
|
flag: "--large-file-bytes",
|
|
13613
13721
|
type: "string",
|
|
13614
|
-
default:
|
|
13722
|
+
default: 307200,
|
|
13615
13723
|
appliesTo: optionAppliesTo("large-file-bytes"),
|
|
13616
|
-
summary: "Above this size a file gets a head/tail preview instead of the full body."
|
|
13724
|
+
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."
|
|
13617
13725
|
},
|
|
13618
13726
|
{
|
|
13619
13727
|
flag: "--max-monolith-bytes",
|
|
@@ -13811,7 +13919,7 @@ function buildAgentContract() {
|
|
|
13811
13919
|
type: "boolean",
|
|
13812
13920
|
default: false,
|
|
13813
13921
|
appliesTo: optionAppliesTo("no-update-check"),
|
|
13814
|
-
summary: "Skip the
|
|
13922
|
+
summary: "Skip the check for a newer published version. The check is already skipped when stdout is not a terminal, in CI, in a JSON invocation, and in `mcp`, which makes no network requests."
|
|
13815
13923
|
}
|
|
13816
13924
|
],
|
|
13817
13925
|
presets: PRESETS.map((preset) => ({
|
|
@@ -13848,7 +13956,7 @@ function buildAgentContract() {
|
|
|
13848
13956
|
{ key: "changedSince", type: "string | null", default: null, summary: "Snapshot only files that differ from this git ref." },
|
|
13849
13957
|
{ key: "staged", type: "boolean", default: false, summary: "Snapshot only files staged in the index." },
|
|
13850
13958
|
{ key: "withDependents", type: "boolean", default: false, summary: "With a changed-files scope, also include one hop of importers." },
|
|
13851
|
-
{ key: "largeFileBytes", type: "number | string", default:
|
|
13959
|
+
{ key: "largeFileBytes", type: "number | string", default: 307200, summary: "Preview threshold for large files; defaults to maxPartBytes and may not exceed it." },
|
|
13852
13960
|
{ key: "previewHeadLines", type: "number", default: 80, summary: "Lines kept from the head of a large file." },
|
|
13853
13961
|
{ key: "previewTailLines", type: "number", default: 40, summary: "Lines kept from the tail of a large file." },
|
|
13854
13962
|
{ key: "includeMonolith", type: "boolean", default: false, summary: "Also write the single-file monolith." },
|
|
@@ -13877,8 +13985,8 @@ function buildAgentContract() {
|
|
|
13877
13985
|
"<outDir>/.codebase-snapshot (ownership marker, always written)"
|
|
13878
13986
|
],
|
|
13879
13987
|
notes: [
|
|
13880
|
-
"Parts are ordered and budget-limited; a
|
|
13881
|
-
"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.",
|
|
13988
|
+
"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.",
|
|
13989
|
+
"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.",
|
|
13882
13990
|
"manifest.skipped[] carries the path and the exact reason it was excluded.",
|
|
13883
13991
|
`The output directory is replaced atomically; ${MIN_MAX_PART_BYTES} bytes is the smallest legal budget.`
|
|
13884
13992
|
]
|
|
@@ -14040,10 +14148,12 @@ do not assume the repository is broken.
|
|
|
14040
14148
|
\`kind\`, \`language\`, \`part\`, \`inclusionMode\`, \`hashSha256\` and the structural
|
|
14041
14149
|
\`summary\`, plus \`encoding\` when the file was not plain UTF-8. \`summary\` is
|
|
14042
14150
|
**optional**: it is absent for languages with no structural summary, and
|
|
14043
|
-
\`summaryOmitted: true\` marks one dropped
|
|
14151
|
+
\`summaryOmitted: true\` marks one dropped for size, and the reason in \`summaryOmittedReason\` says which rule \u2014 never assume it
|
|
14044
14152
|
exists. The per-file \`hashSha256\` is only here and in the manifest; it is not printed
|
|
14045
14153
|
into the parts.
|
|
14046
|
-
\`skipped[]\` records every excluded file **and why**.
|
|
14154
|
+
\`skipped[]\` records every excluded file **and why**. The top-level \`incomplete[]\` records every included
|
|
14155
|
+
file whose body is not the whole file, with its reason and omittedRanges: ask that list,
|
|
14156
|
+
not the footer of a part, when the question is whether anything was lost. Prefer querying this over
|
|
14047
14157
|
re-reading the parts.
|
|
14048
14158
|
- \`snapshot/reports/audit.md\` \u2014 secrets found, large files, parse diagnostics, git
|
|
14049
14159
|
state. Read this before you quote code back to a user.
|
|
@@ -15219,7 +15329,7 @@ Options:
|
|
|
15219
15329
|
--install Write the skill into the repository instead of printing
|
|
15220
15330
|
--target <name> claude | cursor | all (default: all)
|
|
15221
15331
|
|
|
15222
|
-
--no-update-check Skip the
|
|
15332
|
+
--no-update-check Skip the check for a newer published version
|
|
15223
15333
|
|
|
15224
15334
|
-h, --help Display this help message
|
|
15225
15335
|
-v, --version Display version
|
|
@@ -15622,6 +15732,17 @@ async function runInitCommand(invocation) {
|
|
|
15622
15732
|
return fail(invocation.format, err.message);
|
|
15623
15733
|
}
|
|
15624
15734
|
}
|
|
15735
|
+
function generatorOrigin(cwd) {
|
|
15736
|
+
try {
|
|
15737
|
+
const pkg = JSON.parse(fs15__namespace.readFileSync(path16__namespace.join(cwd, "package.json"), "utf8"));
|
|
15738
|
+
const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
|
|
15739
|
+
if (typeof spec === "string") return `project dependency ${spec}`;
|
|
15740
|
+
} catch {
|
|
15741
|
+
}
|
|
15742
|
+
const entry = process.argv[1] ?? "";
|
|
15743
|
+
if (entry.includes("_npx") || entry.includes(`${path16__namespace.sep}npx${path16__namespace.sep}`)) return "via npx";
|
|
15744
|
+
return "global or direct install";
|
|
15745
|
+
}
|
|
15625
15746
|
function detectPackageManager(cwd) {
|
|
15626
15747
|
const has = (name) => fs15__namespace.existsSync(path16__namespace.join(cwd, name));
|
|
15627
15748
|
if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
|
|
@@ -15769,9 +15890,14 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
15769
15890
|
info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
|
|
15770
15891
|
}
|
|
15771
15892
|
}
|
|
15893
|
+
const hasManifest = fs15__namespace.existsSync(path16__namespace.join(invocation.cwd, "package.json"));
|
|
15772
15894
|
let install = null;
|
|
15773
15895
|
if (invocation.noInstall) {
|
|
15774
15896
|
if (invocation.format !== "json") info(" Skipped the install (--no-install)");
|
|
15897
|
+
} else if (!hasManifest) {
|
|
15898
|
+
if (invocation.format !== "json") {
|
|
15899
|
+
info(" Skipped the install: no package.json here, so there is no dependency to add.");
|
|
15900
|
+
}
|
|
15775
15901
|
} else {
|
|
15776
15902
|
if (invocation.format !== "json") info("\u23F3 Installing dependencies\u2026");
|
|
15777
15903
|
install = installDependencies(invocation.cwd);
|
|
@@ -16124,7 +16250,7 @@ ${USAGE}
|
|
|
16124
16250
|
const started = performance.now();
|
|
16125
16251
|
info(`\u{1F4F8} ${invocation.dryRun ? "Planning snapshot (dry run)" : "Generating snapshot"} for: ${resolved.cwd}`);
|
|
16126
16252
|
info(
|
|
16127
|
-
` Branch: ${resolved.branch} | Part budget: ${(resolved.maxPartBytes / 1024).toFixed(0)} KB`
|
|
16253
|
+
` Branch: ${resolved.branch} | Part budget: ${(resolved.maxPartBytes / 1024).toFixed(0)} KB | Generator: ${GENERATOR_VERSION} (${generatorOrigin(resolved.cwd)})`
|
|
16128
16254
|
);
|
|
16129
16255
|
try {
|
|
16130
16256
|
const manifest = generateSnapshot(resolved, { dryRun: invocation.dryRun });
|
|
@@ -16142,12 +16268,31 @@ ${USAGE}
|
|
|
16142
16268
|
` - Redacted: ${manifest.totals.redactedLines} line(s) \u2014 a real run lists them in ` + displayOutPath(resolved.cwd, resolved.outDir, "reports/audit.md")
|
|
16143
16269
|
);
|
|
16144
16270
|
}
|
|
16271
|
+
const incomplete = manifest.incomplete ?? [];
|
|
16272
|
+
if (incomplete.length > 0) {
|
|
16273
|
+
const byReason = /* @__PURE__ */ new Map();
|
|
16274
|
+
for (const record of incomplete) {
|
|
16275
|
+
byReason.set(record.reason, (byReason.get(record.reason) ?? 0) + 1);
|
|
16276
|
+
}
|
|
16277
|
+
const detail = [...byReason.entries()].map(([reason, count]) => `${count} ${reason}`).join(", ");
|
|
16278
|
+
info(` - Incomplete: ${incomplete.length} file(s) \u2014 ${detail}; see manifest.json incomplete[]`);
|
|
16279
|
+
}
|
|
16145
16280
|
info(` - Integrity: ${manifest.validation.status}`);
|
|
16146
16281
|
for (const error of manifest.validation.errors.slice(0, 10)) info(` - ${error}`);
|
|
16147
16282
|
} else {
|
|
16148
16283
|
info(`
|
|
16149
16284
|
\u2705 Snapshot generated in ${elapsed}s:`);
|
|
16150
|
-
|
|
16285
|
+
const skipCounts = /* @__PURE__ */ new Map();
|
|
16286
|
+
for (const record of manifest.skipped) {
|
|
16287
|
+
skipCounts.set(record.reason, (skipCounts.get(record.reason) ?? 0) + 1);
|
|
16288
|
+
}
|
|
16289
|
+
const skipBreakdown = [...skipCounts.entries()].sort((left, right) => right[1] - left[1]).map(([reason, count]) => `${reason} ${formatNumber(count)}`);
|
|
16290
|
+
const shownReasons = skipBreakdown.slice(0, 3);
|
|
16291
|
+
const reasons = skipBreakdown.length > shownReasons.length ? `${shownReasons.join(", ")}, +${skipBreakdown.length - shownReasons.length} more` : shownReasons.join(", ");
|
|
16292
|
+
const candidates = manifest.counts.totalFiles + manifest.counts.skippedCount;
|
|
16293
|
+
info(
|
|
16294
|
+
manifest.counts.skippedCount === 0 ? ` - Tracked files: ${formatNumber(manifest.counts.totalFiles)}` : ` - Tracked files: ${formatNumber(manifest.counts.totalFiles)} included of ${formatNumber(candidates)} found \u2014 ${formatNumber(manifest.counts.skippedCount)} skipped (${reasons}); every one is listed in ${displayOutPath(resolved.cwd, resolved.outDir, "reports/audit.md")}`
|
|
16295
|
+
);
|
|
16151
16296
|
info(` - Total lines: ${formatNumber(manifest.counts.totalLines)}`);
|
|
16152
16297
|
info(
|
|
16153
16298
|
` - Total size: ${(manifest.counts.totalSizeBytes / (1024 * 1024)).toFixed(2)} MB`
|