codebase-snapshot 0.10.1 → 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/CHANGELOG.md +130 -0
- package/README.md +9 -1
- package/SECURITY.md +2 -2
- package/dist/bin.js +1247 -413
- package/dist/{chunk-WDJ3O3R4.js → chunk-5ZOXHBTW.js} +53 -30
- package/dist/{chunk-7DAW2LFZ.js → chunk-NJ75RVHO.js} +939 -180
- package/dist/cli.cjs +1246 -411
- package/dist/cli.d.cts +36 -11
- package/dist/cli.d.ts +36 -11
- package/dist/cli.js +60 -8
- package/dist/{generate-worker-D_mUjgXw.d.cts → generate-worker-BK4uJx7Z.d.cts} +17 -8
- package/dist/{generate-worker-D_mUjgXw.d.ts → generate-worker-BK4uJx7Z.d.ts} +17 -8
- package/dist/index.cjs +915 -173
- package/dist/index.d.cts +69 -24
- package/dist/index.d.ts +69 -24
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +745 -2923
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{types-Z471HW65.d.cts → types-DGWw3SH2.d.cts} +75 -4
- package/dist/{types-Z471HW65.d.ts → types-DGWw3SH2.d.ts} +75 -4
- package/docs/cli.md +32 -8
- package/docs/codebase-token-budget.md +12 -9
- package/docs/configuration.md +71 -2
- package/docs/how-to-context-budget.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +40 -9
- package/docs/mcp.md +3 -3
- package/docs/output.md +60 -7
- package/docs/stale-context-is-your-bug.md +8 -4
- package/docs/vs-code2prompt.md +1 -1
- package/docs/vs-gitingest.md +1 -1
- package/docs/vs-repomix.md +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS,
|
|
1
|
+
import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-NJ75RVHO.js';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
|
|
@@ -736,45 +736,38 @@ var planTool = {
|
|
|
736
736
|
const prepared = await prepare(args, context, workspaceOverrides(args));
|
|
737
737
|
if (!prepared.ok) return prepared.outcome;
|
|
738
738
|
const workspace = prepared.workspace;
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
return failure(error instanceof Error ? error.message : String(error));
|
|
744
|
-
}
|
|
745
|
-
const reasons = /* @__PURE__ */ new Map();
|
|
746
|
-
for (const record of manifest.skipped) {
|
|
747
|
-
reasons.set(record.reason, (reasons.get(record.reason) ?? 0) + 1);
|
|
748
|
-
}
|
|
749
|
-
const topReasons = [...reasons.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 8).map(([reason, count]) => ({ reason, count }));
|
|
739
|
+
const result = await generateInWorker(workspace.root, workspace.cliOptions, { dryRun: true });
|
|
740
|
+
if (!result.ok) return failure(result.message);
|
|
741
|
+
const summary = result.summary;
|
|
742
|
+
const topReasons = summary.skipReasons;
|
|
750
743
|
const lines = [
|
|
751
744
|
"Dry run \u2014 nothing was written.",
|
|
752
|
-
`Preset: ${
|
|
753
|
-
`Would include ${plural(
|
|
754
|
-
`Would skip ${plural(
|
|
745
|
+
`Preset: ${summary.preset}`,
|
|
746
|
+
`Would include ${plural(summary.totalFiles, "file")} in ${plural(summary.partsCount, "part")} (${formatBytes(summary.totalSizeBytes)} of source, ${formatBytes(summary.totalContentBytes)} emitted).`,
|
|
747
|
+
`Would skip ${plural(summary.skippedCount, "file")}.`
|
|
755
748
|
];
|
|
756
749
|
if (topReasons.length > 0) {
|
|
757
750
|
lines.push("Top skip reasons:");
|
|
758
751
|
for (const entry of topReasons) lines.push(` - ${entry.reason} (${entry.count})`);
|
|
759
752
|
}
|
|
760
|
-
if (
|
|
761
|
-
lines.push(`Warnings (${
|
|
762
|
-
for (const warning of
|
|
753
|
+
if (summary.warnings.length > 0) {
|
|
754
|
+
lines.push(`Warnings (${summary.warnings.length}):`);
|
|
755
|
+
for (const warning of summary.warnings.slice(0, 5)) lines.push(` - ${warning}`);
|
|
763
756
|
}
|
|
764
757
|
return {
|
|
765
758
|
text: lines.join("\n"),
|
|
766
759
|
structured: {
|
|
767
|
-
files:
|
|
768
|
-
skipped:
|
|
769
|
-
parts:
|
|
770
|
-
sourceBytes:
|
|
771
|
-
emittedBytes:
|
|
772
|
-
preset:
|
|
773
|
-
maxPartBytes:
|
|
774
|
-
layers:
|
|
760
|
+
files: summary.totalFiles,
|
|
761
|
+
skipped: summary.skippedCount,
|
|
762
|
+
parts: summary.partsCount,
|
|
763
|
+
sourceBytes: summary.totalSizeBytes,
|
|
764
|
+
emittedBytes: summary.totalContentBytes,
|
|
765
|
+
preset: summary.preset,
|
|
766
|
+
maxPartBytes: workspace.config.maxPartBytes,
|
|
767
|
+
layers: summary.layers,
|
|
775
768
|
skipReasons: topReasons,
|
|
776
|
-
warnings:
|
|
777
|
-
warningCount:
|
|
769
|
+
warnings: summary.warnings.slice(0, 5),
|
|
770
|
+
warningCount: summary.warnings.length
|
|
778
771
|
}
|
|
779
772
|
};
|
|
780
773
|
}
|
|
@@ -1447,6 +1440,7 @@ var VALIDATE_OPTIONS = [
|
|
|
1447
1440
|
"max-part-tokens",
|
|
1448
1441
|
"large-file-bytes",
|
|
1449
1442
|
"max-monolith-bytes",
|
|
1443
|
+
"max-parts",
|
|
1450
1444
|
"include-monolith",
|
|
1451
1445
|
"include-sensitive-files",
|
|
1452
1446
|
"skip-artifacts",
|
|
@@ -1472,6 +1466,8 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
1472
1466
|
"max-part-tokens",
|
|
1473
1467
|
"large-file-bytes",
|
|
1474
1468
|
"max-monolith-bytes",
|
|
1469
|
+
"attachment-slots",
|
|
1470
|
+
"max-parts",
|
|
1475
1471
|
"include-monolith",
|
|
1476
1472
|
"include-sensitive-files",
|
|
1477
1473
|
"skip-artifacts",
|
|
@@ -1617,6 +1613,7 @@ var PACKAGE_NAME = "codebase-snapshot";
|
|
|
1617
1613
|
var MAJOR_VERSION = GENERATOR_VERSION.split(".")[0];
|
|
1618
1614
|
var ARTIFACT_SUMMARY = {
|
|
1619
1615
|
readme: "README.md describing the snapshot at the output root.",
|
|
1616
|
+
prompt: "PROMPT.md: the instruction sheet to paste with the snapshot, rendered from its manifest.",
|
|
1620
1617
|
manifest: "manifest.json: machine-readable index of every file, part, hash and config.",
|
|
1621
1618
|
parts: "parts/*.md: the packed, budget-limited markdown parts that carry the code.",
|
|
1622
1619
|
navigation: "reports/navigation.md: links between parts and layers.",
|
|
@@ -1626,6 +1623,7 @@ var ARTIFACT_SUMMARY = {
|
|
|
1626
1623
|
};
|
|
1627
1624
|
var ARTIFACT_DEFAULTS = {
|
|
1628
1625
|
readme: true,
|
|
1626
|
+
prompt: true,
|
|
1629
1627
|
manifest: true,
|
|
1630
1628
|
parts: true,
|
|
1631
1629
|
navigation: true,
|
|
@@ -1766,9 +1764,9 @@ function buildAgentContract() {
|
|
|
1766
1764
|
{
|
|
1767
1765
|
step: 6,
|
|
1768
1766
|
id: "consume",
|
|
1769
|
-
run: "read ./snapshot/
|
|
1767
|
+
run: "read ./snapshot/PROMPT.md first, then ./snapshot/parts/*.md, ./snapshot/manifest.json and ./snapshot/reports/audit.md",
|
|
1770
1768
|
expect: "the code, the index of what was included, and the risk findings",
|
|
1771
|
-
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."
|
|
1769
|
+
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."
|
|
1772
1770
|
}
|
|
1773
1771
|
],
|
|
1774
1772
|
commands: [
|
|
@@ -1905,6 +1903,20 @@ function buildAgentContract() {
|
|
|
1905
1903
|
appliesTo: optionAppliesTo("discovery"),
|
|
1906
1904
|
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)."
|
|
1907
1905
|
},
|
|
1906
|
+
{
|
|
1907
|
+
flag: "--attachment-slots",
|
|
1908
|
+
type: "number",
|
|
1909
|
+
default: "10",
|
|
1910
|
+
appliesTo: optionAppliesTo("attachment-slots"),
|
|
1911
|
+
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."
|
|
1912
|
+
},
|
|
1913
|
+
{
|
|
1914
|
+
flag: "--max-parts",
|
|
1915
|
+
type: "number",
|
|
1916
|
+
default: "unset",
|
|
1917
|
+
appliesTo: optionAppliesTo("max-parts"),
|
|
1918
|
+
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."
|
|
1919
|
+
},
|
|
1908
1920
|
{
|
|
1909
1921
|
flag: "--skip-artifacts",
|
|
1910
1922
|
type: "string",
|
|
@@ -2118,6 +2130,8 @@ function buildAgentContract() {
|
|
|
2118
2130
|
{ key: "includeSensitiveFiles", type: "boolean", default: false, summary: "Emit .env / *.pem / credential files." },
|
|
2119
2131
|
{ key: "include", type: "string[]", default: "[]", summary: "Allow-list of globs; empty means everything." },
|
|
2120
2132
|
{ key: "excludePatterns", type: "string[]", default: "[]", summary: "Extra exclude globs." },
|
|
2133
|
+
{ 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." },
|
|
2134
|
+
{ 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." },
|
|
2121
2135
|
{ 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." },
|
|
2122
2136
|
{ key: "artifacts", type: "object", default: "all on except monolith", summary: "Per-artifact opt-out." },
|
|
2123
2137
|
{ key: "budgets", type: "object", default: "{ default, byLayer }", summary: "Per-layer byte budgets." },
|
|
@@ -2125,12 +2139,14 @@ function buildAgentContract() {
|
|
|
2125
2139
|
{ key: "layers", type: "array", default: "preset layers", summary: "Custom layer rules (glob or RegExp)." },
|
|
2126
2140
|
{ key: "kinds", type: "array", default: "preset kinds", summary: "Custom kind rules." },
|
|
2127
2141
|
{ key: "secrets", type: "object", default: "{}", summary: "Custom secret patterns, or disable the defaults." },
|
|
2142
|
+
{ key: "secretRules", type: "array", default: "[]", summary: "Full secret-rule list: the library spelling of secrets.customPatterns. The built-ins are prepended unless secrets.disableDefaultPatterns is set." },
|
|
2128
2143
|
{ key: "hooks", type: "object", default: "{}", summary: "afterGenerate(manifest) runs after a successful generate." }
|
|
2129
2144
|
]
|
|
2130
2145
|
},
|
|
2131
2146
|
output: {
|
|
2132
2147
|
layout: [
|
|
2133
2148
|
"<outDir>/README.md",
|
|
2149
|
+
"<outDir>/PROMPT.md",
|
|
2134
2150
|
"<outDir>/manifest.json",
|
|
2135
2151
|
"<outDir>/parts/part-NNN.md",
|
|
2136
2152
|
"<outDir>/reports/project-tree.md",
|
|
@@ -2141,7 +2157,10 @@ function buildAgentContract() {
|
|
|
2141
2157
|
notes: [
|
|
2142
2158
|
"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.",
|
|
2143
2159
|
"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.",
|
|
2160
|
+
"indexes.imports.byFile includes previewed files (their import specifiers are still extracted); such an entry carries `exportsOmitted: true` instead of pretending it exports nothing.",
|
|
2161
|
+
"validate re-checks manifest.incomplete[] against files[] and refuses a manifest whose two statements of what is missing disagree.",
|
|
2144
2162
|
"manifest.skipped[] carries the path and the exact reason it was excluded.",
|
|
2163
|
+
"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.",
|
|
2145
2164
|
`The output directory is replaced atomically; ${MIN_MAX_PART_BYTES} bytes is the smallest legal budget.`
|
|
2146
2165
|
]
|
|
2147
2166
|
},
|
|
@@ -2312,6 +2331,10 @@ do not assume the repository is broken.
|
|
|
2312
2331
|
- \`snapshot/reports/audit.md\` \u2014 secrets found, large files, parse diagnostics, git
|
|
2313
2332
|
state. Read this before you quote code back to a user.
|
|
2314
2333
|
- \`snapshot/reports/project-tree.md\` and \`navigation.md\` \u2014 structure and cross-links.
|
|
2334
|
+
- \`snapshot/PROMPT.md\` \u2014 the instruction sheet to hand to the model that receives the
|
|
2335
|
+
snapshot: paste it with the parts. It is rendered from this run's manifest and names the
|
|
2336
|
+
parts, the partial files and the fingerprint, so do not rewrite it by hand \u2014 \`validate\`
|
|
2337
|
+
fails when it was edited.
|
|
2315
2338
|
|
|
2316
2339
|
## Project types
|
|
2317
2340
|
|