codebase-snapshot 0.15.0 → 0.17.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 +166 -0
- package/README.md +3 -3
- package/SECURITY.md +2 -2
- package/dist/bin.js +258 -3
- package/dist/{chunk-KHHUC6UT.js → chunk-PDLN24ZZ.js} +249 -3
- package/dist/{chunk-4OHQULCV.js → chunk-VI3JLKPX.js} +1 -1
- package/dist/cli.cjs +258 -3
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +12 -3
- package/dist/index.cjs +249 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +171 -2
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{types-5G2Q6tWP.d.cts → types-Cr5H2Y3t.d.cts} +9 -0
- package/dist/{types-5G2Q6tWP.d.ts → types-Cr5H2Y3t.d.ts} +9 -0
- package/docs/answer.md +51 -0
- package/docs/cli.md +4 -4
- package/docs/deploy.md +2 -2
- package/docs/mcp.md +7 -5
- package/docs/migration.md +19 -0
- package/docs/security-review.md +20 -0
- package/docs/slice.md +8 -0
- package/docs/tools.md +13 -1
- package/docs/vs-repomix.md +1 -1
- package/package.json +1 -1
|
@@ -3994,7 +3994,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
3994
3994
|
|
|
3995
3995
|
// src/version.ts
|
|
3996
3996
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
3997
|
-
var GENERATOR_VERSION = "0.
|
|
3997
|
+
var GENERATOR_VERSION = "0.17.0";
|
|
3998
3998
|
var SCHEMA_VERSION = "3.0.0";
|
|
3999
3999
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
4000
4000
|
function isOurGeneratorName(name) {
|
|
@@ -6974,6 +6974,51 @@ function generateNavigation(manifest) {
|
|
|
6974
6974
|
return lines.join("\n");
|
|
6975
6975
|
}
|
|
6976
6976
|
|
|
6977
|
+
// src/generator/selection.ts
|
|
6978
|
+
function generateSelectionReport(manifest, selection) {
|
|
6979
|
+
const lines = [];
|
|
6980
|
+
lines.push("# Selection");
|
|
6981
|
+
lines.push("");
|
|
6982
|
+
lines.push("**Kind:** `" + selection.kind + "` ");
|
|
6983
|
+
for (const detailLine of selection.detail.split("\n")) {
|
|
6984
|
+
lines.push("**" + detailLine.slice(0, detailLine.indexOf(":")) + ":**" + detailLine.slice(detailLine.indexOf(":") + 1) + " ");
|
|
6985
|
+
}
|
|
6986
|
+
lines.push("**Selected files:** " + selection.files.length + " ");
|
|
6987
|
+
const spent = manifest.budget?.usedTokens ?? manifest.slice?.usedTokens ?? 0;
|
|
6988
|
+
lines.push("**Tokens spent:** " + spent.toLocaleString("en-US"));
|
|
6989
|
+
lines.push("");
|
|
6990
|
+
lines.push("## Why each file is here");
|
|
6991
|
+
lines.push("");
|
|
6992
|
+
lines.push("| File | Tokens | Reason |");
|
|
6993
|
+
lines.push("| :-- | --: | :-- |");
|
|
6994
|
+
for (const file of selection.files) {
|
|
6995
|
+
lines.push("| `" + file.path + "` | " + file.tokens.toLocaleString("en-US") + " | " + file.why + " |");
|
|
6996
|
+
}
|
|
6997
|
+
lines.push("");
|
|
6998
|
+
const dropped = selection.kind === "slice" ? manifest.slice?.dropped : manifest.budget?.dropped;
|
|
6999
|
+
if (typeof dropped === "number") {
|
|
7000
|
+
lines.push("## What was left out");
|
|
7001
|
+
lines.push("");
|
|
7002
|
+
lines.push(dropped + " file(s) were not selected. They are recorded in `manifest.json` as `skipped`");
|
|
7003
|
+
lines.push("with the reason `not-selected`, so nothing left the snapshot without a reason.");
|
|
7004
|
+
lines.push("");
|
|
7005
|
+
}
|
|
7006
|
+
const next = manifest.budget?.nextInLine ?? [];
|
|
7007
|
+
if (next.length > 0) {
|
|
7008
|
+
lines.push("## What a larger budget would buy");
|
|
7009
|
+
lines.push("");
|
|
7010
|
+
lines.push("Headroom: " + (manifest.budget?.headroomTokens ?? 0).toLocaleString("en-US") + " tokens.");
|
|
7011
|
+
lines.push("");
|
|
7012
|
+
lines.push("| File | Tokens |");
|
|
7013
|
+
lines.push("| :-- | --: |");
|
|
7014
|
+
for (const item of next) {
|
|
7015
|
+
lines.push("| `" + item.path + "` | " + item.tokens.toLocaleString("en-US") + " |");
|
|
7016
|
+
}
|
|
7017
|
+
lines.push("");
|
|
7018
|
+
}
|
|
7019
|
+
return lines.join("\n");
|
|
7020
|
+
}
|
|
7021
|
+
|
|
6977
7022
|
// src/mcp/retrieval.ts
|
|
6978
7023
|
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
6979
7024
|
"the",
|
|
@@ -9493,6 +9538,7 @@ function validateSnapshot(configInput) {
|
|
|
9493
9538
|
["reports/diff.md", manifest.artifacts?.diff],
|
|
9494
9539
|
["reports/log.md", manifest.artifacts?.log],
|
|
9495
9540
|
["reports/tokens.md", manifest.artifacts?.tokenTree],
|
|
9541
|
+
["reports/selection.md", manifest.artifacts?.selection],
|
|
9496
9542
|
["full-codebase.json", manifest.artifacts?.fullJson],
|
|
9497
9543
|
["full-codebase.md", manifest.artifacts?.fullMarkdown],
|
|
9498
9544
|
["full-codebase.xml", manifest.artifacts?.fullXml]
|
|
@@ -10143,6 +10189,7 @@ var ARTIFACT_FILES = {
|
|
|
10143
10189
|
diff: "reports/diff.md",
|
|
10144
10190
|
log: "reports/log.md",
|
|
10145
10191
|
tokenTree: "reports/tokens.md",
|
|
10192
|
+
selection: "reports/selection.md",
|
|
10146
10193
|
fullJson: "full-codebase.json",
|
|
10147
10194
|
fullMarkdown: "full-codebase.md",
|
|
10148
10195
|
fullXml: "full-codebase.xml",
|
|
@@ -11584,6 +11631,65 @@ var historyTool = {
|
|
|
11584
11631
|
};
|
|
11585
11632
|
}
|
|
11586
11633
|
};
|
|
11634
|
+
var budgetTool = {
|
|
11635
|
+
name: "snapshot_budget",
|
|
11636
|
+
title: "What a larger budget would buy",
|
|
11637
|
+
description: 'Run the planner at several token budgets and report what each one adds: files, tokens used, entry points kept and the files gained over the previous budget. Answers "should I raise the budget, and what would I get?" without writing a snapshot. Read-only.',
|
|
11638
|
+
inputSchema: {
|
|
11639
|
+
type: "object",
|
|
11640
|
+
properties: {
|
|
11641
|
+
budgets: {
|
|
11642
|
+
type: "array",
|
|
11643
|
+
items: { type: "integer", minimum: 500 },
|
|
11644
|
+
description: "Token budgets to compare, ascending (default 10000, 30000, 60000)."
|
|
11645
|
+
},
|
|
11646
|
+
question: { type: "string", description: "Optional question to plan for; absent plans for the repository as a whole." },
|
|
11647
|
+
includeTests: { type: "boolean", description: "Include test files (default false)." },
|
|
11648
|
+
root: ROOT_PROPERTY,
|
|
11649
|
+
outDir: OUT_DIR_PROPERTY
|
|
11650
|
+
},
|
|
11651
|
+
additionalProperties: false
|
|
11652
|
+
},
|
|
11653
|
+
outputSchema: {
|
|
11654
|
+
type: "object",
|
|
11655
|
+
properties: { budgets: { type: "array", items: { type: "object" } } }
|
|
11656
|
+
},
|
|
11657
|
+
annotations: READ_ONLY,
|
|
11658
|
+
async handler(args, context) {
|
|
11659
|
+
const prepared = await prepare(args, context, outDirOverride(args));
|
|
11660
|
+
if (!prepared.ok) return prepared.outcome;
|
|
11661
|
+
const read = readManifest3(prepared.workspace);
|
|
11662
|
+
if (!read.ok) return { text: read.message + " Call snapshot_generate first.", isError: true };
|
|
11663
|
+
const requested = Array.isArray(args.budgets) ? args.budgets.filter((value) => typeof value === "number").map((value) => Math.max(500, value)) : [1e4, 3e4, 6e4];
|
|
11664
|
+
const budgets = [...new Set(requested)].sort((left, right) => left - right);
|
|
11665
|
+
if (budgets.length === 0) return { text: "budgets must hold at least one number", isError: true };
|
|
11666
|
+
const question = typeof args.question === "string" ? args.question : "";
|
|
11667
|
+
const rows = [];
|
|
11668
|
+
let previous = /* @__PURE__ */ new Set();
|
|
11669
|
+
for (const budget of budgets) {
|
|
11670
|
+
const plan = planForQuestion(read.manifest, question, {
|
|
11671
|
+
maxTokens: budget,
|
|
11672
|
+
...args.includeTests === true ? { includeTests: true } : {}
|
|
11673
|
+
});
|
|
11674
|
+
const paths = new Set(plan.files.map((file) => file.path));
|
|
11675
|
+
const gained = [...paths].filter((path26) => !previous.has(path26)).sort();
|
|
11676
|
+
previous = paths;
|
|
11677
|
+
rows.push({
|
|
11678
|
+
budget,
|
|
11679
|
+
files: plan.files.length,
|
|
11680
|
+
usedTokens: plan.usedTokens,
|
|
11681
|
+
gained
|
|
11682
|
+
});
|
|
11683
|
+
}
|
|
11684
|
+
const lines = [question === "" ? "No question: planning for the repository as a whole." : "Question: " + question];
|
|
11685
|
+
for (const row of rows) {
|
|
11686
|
+
lines.push(
|
|
11687
|
+
row.budget.toLocaleString("en-US") + " tokens: " + row.files + " file(s), " + row.usedTokens.toLocaleString("en-US") + " used" + (row.gained.length === 0 ? "" : ", " + row.gained.length + " gained (" + row.gained.slice(0, 4).join(", ") + (row.gained.length > 4 ? ", \u2026" : "") + ")")
|
|
11688
|
+
);
|
|
11689
|
+
}
|
|
11690
|
+
return { text: lines.join("\n"), structured: { budgets: rows } };
|
|
11691
|
+
}
|
|
11692
|
+
};
|
|
11587
11693
|
var testsTool = {
|
|
11588
11694
|
name: "snapshot_tests",
|
|
11589
11695
|
title: "Tests that cover a file, and files a test covers",
|
|
@@ -12610,6 +12716,110 @@ var planForTool = {
|
|
|
12610
12716
|
return { text: lines.join("\n"), structured: plan };
|
|
12611
12717
|
}
|
|
12612
12718
|
};
|
|
12719
|
+
var answerTool = {
|
|
12720
|
+
name: "snapshot_answer",
|
|
12721
|
+
title: "Question in, budgeted context out",
|
|
12722
|
+
description: "The one-call version of plan-then-read: plan a question, then return each chosen file as a head window with line numbers within the token budget. Every included file says why it is there; every planned file that did not fit says so. Read-only.",
|
|
12723
|
+
inputSchema: {
|
|
12724
|
+
type: "object",
|
|
12725
|
+
properties: {
|
|
12726
|
+
question: { type: "string", description: "What you need to answer." },
|
|
12727
|
+
maxTokens: { type: "integer", description: "Budget for the whole block (default 20000).", minimum: 500 },
|
|
12728
|
+
linesPerFile: { type: "integer", description: "Head lines per file (default 60).", minimum: 10 },
|
|
12729
|
+
includeTests: { type: "boolean", description: "Include test files (default false)." },
|
|
12730
|
+
root: ROOT_PROPERTY,
|
|
12731
|
+
outDir: OUT_DIR_PROPERTY
|
|
12732
|
+
},
|
|
12733
|
+
required: ["question"],
|
|
12734
|
+
additionalProperties: false
|
|
12735
|
+
},
|
|
12736
|
+
outputSchema: {
|
|
12737
|
+
type: "object",
|
|
12738
|
+
properties: {
|
|
12739
|
+
question: { type: "string" },
|
|
12740
|
+
budgetTokens: { type: "integer" },
|
|
12741
|
+
usedTokens: { type: "integer" },
|
|
12742
|
+
files: { type: "array", items: { type: "object" } },
|
|
12743
|
+
omitted: { type: "array", items: { type: "object" } }
|
|
12744
|
+
}
|
|
12745
|
+
},
|
|
12746
|
+
annotations: READ_ONLY,
|
|
12747
|
+
async handler(args, context) {
|
|
12748
|
+
const question = typeof args.question === "string" ? args.question.trim() : "";
|
|
12749
|
+
if (question.length === 0) return { text: "question must be a non-empty string", isError: true };
|
|
12750
|
+
const prepared = await prepare(args, context, outDirOverride(args));
|
|
12751
|
+
if (!prepared.ok) return prepared.outcome;
|
|
12752
|
+
const read = readManifest3(prepared.workspace);
|
|
12753
|
+
if (!read.ok) return { text: read.message + " Call snapshot_generate first.", isError: true };
|
|
12754
|
+
const maxTokens = Math.max(500, typeof args.maxTokens === "number" ? args.maxTokens : 2e4);
|
|
12755
|
+
const linesPerFile = Math.max(10, typeof args.linesPerFile === "number" ? args.linesPerFile : 60);
|
|
12756
|
+
const plan = planForQuestion(read.manifest, question, {
|
|
12757
|
+
maxTokens,
|
|
12758
|
+
...args.includeTests === true ? { includeTests: true } : {}
|
|
12759
|
+
});
|
|
12760
|
+
const blocks = [];
|
|
12761
|
+
const omitted = [];
|
|
12762
|
+
let used = 0;
|
|
12763
|
+
const parts = /* @__PURE__ */ new Map();
|
|
12764
|
+
for (const planned of plan.files) {
|
|
12765
|
+
if (used >= maxTokens) {
|
|
12766
|
+
omitted.push({ path: planned.path, reason: "the budget was spent on earlier files" });
|
|
12767
|
+
continue;
|
|
12768
|
+
}
|
|
12769
|
+
const partPath = partPathFor(prepared.workspace, planned.part);
|
|
12770
|
+
if (partPath === null) {
|
|
12771
|
+
omitted.push({ path: planned.path, reason: "its part is not in the snapshot" });
|
|
12772
|
+
continue;
|
|
12773
|
+
}
|
|
12774
|
+
let partText = parts.get(partPath);
|
|
12775
|
+
if (partText === void 0) {
|
|
12776
|
+
try {
|
|
12777
|
+
partText = fs24.readFileSync(partPath, "utf8");
|
|
12778
|
+
} catch {
|
|
12779
|
+
omitted.push({ path: planned.path, reason: "its part could not be read" });
|
|
12780
|
+
continue;
|
|
12781
|
+
}
|
|
12782
|
+
parts.set(partPath, partText);
|
|
12783
|
+
}
|
|
12784
|
+
const section = findSection(parsePartSections(partText), planned.path);
|
|
12785
|
+
if (section === null) {
|
|
12786
|
+
omitted.push({ path: planned.path, reason: "no section in its part" });
|
|
12787
|
+
continue;
|
|
12788
|
+
}
|
|
12789
|
+
const window = windowText(section.body, 1, linesPerFile);
|
|
12790
|
+
const text2 = window.text;
|
|
12791
|
+
const tokens = estimateTokens(text2);
|
|
12792
|
+
if (used + tokens > maxTokens && blocks.length > 0) {
|
|
12793
|
+
omitted.push({ path: planned.path, reason: "did not fit the remaining budget" });
|
|
12794
|
+
continue;
|
|
12795
|
+
}
|
|
12796
|
+
const numbered = text2.split("\n").map((line, index) => String(index + 1).padStart(5, " ") + " " + line).join("\n");
|
|
12797
|
+
blocks.push({ path: planned.path, why: planned.why, tokens, text: numbered, truncated: window.truncated, totalLines: window.totalLines });
|
|
12798
|
+
used += tokens;
|
|
12799
|
+
}
|
|
12800
|
+
const lines = [
|
|
12801
|
+
"# Answer context: " + question,
|
|
12802
|
+
"Budget: " + used + " of " + maxTokens + " tokens; " + blocks.length + " file(s)."
|
|
12803
|
+
];
|
|
12804
|
+
for (const block of blocks) {
|
|
12805
|
+
lines.push("");
|
|
12806
|
+
lines.push("## " + block.path + " (" + block.tokens + " tokens, " + (block.truncated ? "first lines of " + block.totalLines : "whole file") + ")");
|
|
12807
|
+
lines.push("Why: " + block.why);
|
|
12808
|
+
lines.push("```");
|
|
12809
|
+
lines.push(block.text);
|
|
12810
|
+
lines.push("```");
|
|
12811
|
+
}
|
|
12812
|
+
if (omitted.length > 0) {
|
|
12813
|
+
lines.push("");
|
|
12814
|
+
lines.push("Not included:");
|
|
12815
|
+
for (const entry of omitted) lines.push("- " + entry.path + " - " + entry.reason);
|
|
12816
|
+
}
|
|
12817
|
+
return {
|
|
12818
|
+
text: lines.join("\n"),
|
|
12819
|
+
structured: { question, budgetTokens: maxTokens, usedTokens: used, files: blocks, omitted }
|
|
12820
|
+
};
|
|
12821
|
+
}
|
|
12822
|
+
};
|
|
12613
12823
|
var healthTool = {
|
|
12614
12824
|
name: "snapshot_health",
|
|
12615
12825
|
title: "Snapshot health audit",
|
|
@@ -13460,6 +13670,7 @@ var explainTool = {
|
|
|
13460
13670
|
var TOOL_COSTS = {
|
|
13461
13671
|
snapshot_status: "cheap",
|
|
13462
13672
|
snapshot_health: "expensive",
|
|
13673
|
+
snapshot_budget: "medium",
|
|
13463
13674
|
snapshot_history: "cheap",
|
|
13464
13675
|
snapshot_tests: "cheap",
|
|
13465
13676
|
snapshot_workspace: "cheap",
|
|
@@ -13475,6 +13686,7 @@ var TOOL_COSTS = {
|
|
|
13475
13686
|
snapshot_context: "medium",
|
|
13476
13687
|
snapshot_query: "cheap",
|
|
13477
13688
|
snapshot_plan_for: "cheap",
|
|
13689
|
+
snapshot_answer: "medium",
|
|
13478
13690
|
snapshot_plan: "expensive",
|
|
13479
13691
|
snapshot_generate: "expensive",
|
|
13480
13692
|
snapshot_validate: "medium",
|
|
@@ -13487,6 +13699,7 @@ function buildTools() {
|
|
|
13487
13699
|
return [
|
|
13488
13700
|
statusTool,
|
|
13489
13701
|
healthTool,
|
|
13702
|
+
budgetTool,
|
|
13490
13703
|
historyTool,
|
|
13491
13704
|
testsTool,
|
|
13492
13705
|
workspaceTool,
|
|
@@ -13502,6 +13715,7 @@ function buildTools() {
|
|
|
13502
13715
|
contextTool,
|
|
13503
13716
|
queryTool,
|
|
13504
13717
|
planForTool,
|
|
13718
|
+
answerTool,
|
|
13505
13719
|
planTool,
|
|
13506
13720
|
generateTool,
|
|
13507
13721
|
validateTool,
|
|
@@ -14894,7 +15108,7 @@ diff, and the commit, are then yours.
|
|
|
14894
15108
|
## When the client speaks MCP
|
|
14895
15109
|
|
|
14896
15110
|
If the agent runs inside an MCP client, \`npx ${PACKAGE_NAME2}@latest mcp\` serves this repository
|
|
14897
|
-
as
|
|
15111
|
+
as 26 tools over stdio instead of shelling out. Its reads come from the snapshot rather than
|
|
14898
15112
|
the working tree, so excluded files and redacted values never reach the context. Use
|
|
14899
15113
|
\`snapshot_locate\` before \`snapshot_read\`, and \`snapshot_validate\` before trusting a snapshot
|
|
14900
15114
|
from an earlier session.
|
|
@@ -19799,6 +20013,7 @@ function generateSnapshot(configInput, options) {
|
|
|
19799
20013
|
}
|
|
19800
20014
|
}
|
|
19801
20015
|
let sliceBlock;
|
|
20016
|
+
let selectionReport = null;
|
|
19802
20017
|
if (options?.slice !== void 0) {
|
|
19803
20018
|
const byFile = files.filter((file) => isSourceSummary(file.summary)).map((file) => ({
|
|
19804
20019
|
path: file.relativePath,
|
|
@@ -19822,6 +20037,11 @@ function generateSnapshot(configInput, options) {
|
|
|
19822
20037
|
files: plan.files.map((file) => file.path),
|
|
19823
20038
|
dropped: scanned - plan.files.length
|
|
19824
20039
|
};
|
|
20040
|
+
selectionReport = {
|
|
20041
|
+
kind: "slice",
|
|
20042
|
+
detail: "Question: " + options.slice.question + "\nBudget: " + plan.budgetTokens.toLocaleString("en-US") + " tokens",
|
|
20043
|
+
files: plan.files.map((file) => ({ path: file.path, tokens: file.tokens, why: file.why }))
|
|
20044
|
+
};
|
|
19825
20045
|
}
|
|
19826
20046
|
let budgetBlock;
|
|
19827
20047
|
if (options?.budgetTokens !== void 0) {
|
|
@@ -19847,12 +20067,26 @@ function generateSnapshot(configInput, options) {
|
|
|
19847
20067
|
const keep = /* @__PURE__ */ new Set();
|
|
19848
20068
|
let used = 0;
|
|
19849
20069
|
const selected = [];
|
|
20070
|
+
const chosen = [];
|
|
19850
20071
|
for (const item of ranked) {
|
|
19851
20072
|
if (used + item.tokens > budget) continue;
|
|
19852
20073
|
keep.add(item.file.relativePath);
|
|
19853
20074
|
selected.push(item.file.relativePath);
|
|
20075
|
+
chosen.push({
|
|
20076
|
+
path: item.file.relativePath,
|
|
20077
|
+
tokens: item.tokens,
|
|
20078
|
+
why: (entry(item.file.relativePath) ? "entry point" : "not an entry point") + "; " + (importers.get(item.file.relativePath) ?? 0) + " importer(s); layer " + item.file.layer
|
|
20079
|
+
});
|
|
19854
20080
|
used += item.tokens;
|
|
19855
20081
|
}
|
|
20082
|
+
const nextInLine = [];
|
|
20083
|
+
let headroom = budget - used;
|
|
20084
|
+
for (const item of ranked) {
|
|
20085
|
+
if (keep.has(item.file.relativePath)) continue;
|
|
20086
|
+
if (nextInLine.length >= 10) break;
|
|
20087
|
+
nextInLine.push({ path: item.file.relativePath, tokens: item.tokens });
|
|
20088
|
+
headroom = Math.max(headroom, item.tokens);
|
|
20089
|
+
}
|
|
19856
20090
|
const scanned = files.length;
|
|
19857
20091
|
const byLayer = {};
|
|
19858
20092
|
let entryKept = 0;
|
|
@@ -19881,7 +20115,14 @@ function generateSnapshot(configInput, options) {
|
|
|
19881
20115
|
usedTokens: used,
|
|
19882
20116
|
files: selected,
|
|
19883
20117
|
dropped: scanned - selected.length,
|
|
19884
|
-
coverage: { byLayer, entryPoints: { kept: entryKept, total: entryTotal }, symbols: { kept: symbolsKept, total: symbolsTotal } }
|
|
20118
|
+
coverage: { byLayer, entryPoints: { kept: entryKept, total: entryTotal }, symbols: { kept: symbolsKept, total: symbolsTotal } },
|
|
20119
|
+
headroomTokens: Math.max(0, budget - used),
|
|
20120
|
+
nextInLine
|
|
20121
|
+
};
|
|
20122
|
+
selectionReport = {
|
|
20123
|
+
kind: "budget",
|
|
20124
|
+
detail: "Budget: " + budget.toLocaleString("en-US") + " tokens",
|
|
20125
|
+
files: chosen
|
|
19885
20126
|
};
|
|
19886
20127
|
if (entryTotal > 0 && entryKept < entryTotal) {
|
|
19887
20128
|
warnings.push(
|
|
@@ -20190,6 +20431,8 @@ function generateSnapshot(configInput, options) {
|
|
|
20190
20431
|
}) : null;
|
|
20191
20432
|
if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
|
|
20192
20433
|
if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
|
|
20434
|
+
const selectionText = selectionReport === null ? null : generateSelectionReport(manifest, selectionReport);
|
|
20435
|
+
if (selectionText !== null) manifest.artifacts.selection = artifactRecord(selectionText);
|
|
20193
20436
|
let monolithJson = null;
|
|
20194
20437
|
let monolithMarkdown = null;
|
|
20195
20438
|
let monolithXml = null;
|
|
@@ -20346,6 +20589,9 @@ function generateSnapshot(configInput, options) {
|
|
|
20346
20589
|
if (tokenTree !== null) {
|
|
20347
20590
|
writeArtifact(reportsDir, "tokens.md", tokenTree.text);
|
|
20348
20591
|
}
|
|
20592
|
+
if (selectionText !== null) {
|
|
20593
|
+
writeArtifact(reportsDir, "selection.md", selectionText);
|
|
20594
|
+
}
|
|
20349
20595
|
if (sarifText !== null) {
|
|
20350
20596
|
writeArtifact(reportsDir, "audit.sarif", sarifText);
|
|
20351
20597
|
}
|