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
package/dist/cli.cjs
CHANGED
|
@@ -2221,7 +2221,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2221
2221
|
|
|
2222
2222
|
// src/version.ts
|
|
2223
2223
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2224
|
-
var GENERATOR_VERSION = "0.
|
|
2224
|
+
var GENERATOR_VERSION = "0.17.0";
|
|
2225
2225
|
var SCHEMA_VERSION = "3.0.0";
|
|
2226
2226
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2227
2227
|
function isOurGeneratorName(name) {
|
|
@@ -7142,6 +7142,7 @@ function validateSnapshot(configInput) {
|
|
|
7142
7142
|
["reports/diff.md", manifest.artifacts?.diff],
|
|
7143
7143
|
["reports/log.md", manifest.artifacts?.log],
|
|
7144
7144
|
["reports/tokens.md", manifest.artifacts?.tokenTree],
|
|
7145
|
+
["reports/selection.md", manifest.artifacts?.selection],
|
|
7145
7146
|
["full-codebase.json", manifest.artifacts?.fullJson],
|
|
7146
7147
|
["full-codebase.md", manifest.artifacts?.fullMarkdown],
|
|
7147
7148
|
["full-codebase.xml", manifest.artifacts?.fullXml]
|
|
@@ -10149,6 +10150,51 @@ function generateNavigation(manifest) {
|
|
|
10149
10150
|
return lines.join("\n");
|
|
10150
10151
|
}
|
|
10151
10152
|
|
|
10153
|
+
// src/generator/selection.ts
|
|
10154
|
+
function generateSelectionReport(manifest, selection) {
|
|
10155
|
+
const lines = [];
|
|
10156
|
+
lines.push("# Selection");
|
|
10157
|
+
lines.push("");
|
|
10158
|
+
lines.push("**Kind:** `" + selection.kind + "` ");
|
|
10159
|
+
for (const detailLine of selection.detail.split("\n")) {
|
|
10160
|
+
lines.push("**" + detailLine.slice(0, detailLine.indexOf(":")) + ":**" + detailLine.slice(detailLine.indexOf(":") + 1) + " ");
|
|
10161
|
+
}
|
|
10162
|
+
lines.push("**Selected files:** " + selection.files.length + " ");
|
|
10163
|
+
const spent = manifest.budget?.usedTokens ?? manifest.slice?.usedTokens ?? 0;
|
|
10164
|
+
lines.push("**Tokens spent:** " + spent.toLocaleString("en-US"));
|
|
10165
|
+
lines.push("");
|
|
10166
|
+
lines.push("## Why each file is here");
|
|
10167
|
+
lines.push("");
|
|
10168
|
+
lines.push("| File | Tokens | Reason |");
|
|
10169
|
+
lines.push("| :-- | --: | :-- |");
|
|
10170
|
+
for (const file of selection.files) {
|
|
10171
|
+
lines.push("| `" + file.path + "` | " + file.tokens.toLocaleString("en-US") + " | " + file.why + " |");
|
|
10172
|
+
}
|
|
10173
|
+
lines.push("");
|
|
10174
|
+
const dropped = selection.kind === "slice" ? manifest.slice?.dropped : manifest.budget?.dropped;
|
|
10175
|
+
if (typeof dropped === "number") {
|
|
10176
|
+
lines.push("## What was left out");
|
|
10177
|
+
lines.push("");
|
|
10178
|
+
lines.push(dropped + " file(s) were not selected. They are recorded in `manifest.json` as `skipped`");
|
|
10179
|
+
lines.push("with the reason `not-selected`, so nothing left the snapshot without a reason.");
|
|
10180
|
+
lines.push("");
|
|
10181
|
+
}
|
|
10182
|
+
const next = manifest.budget?.nextInLine ?? [];
|
|
10183
|
+
if (next.length > 0) {
|
|
10184
|
+
lines.push("## What a larger budget would buy");
|
|
10185
|
+
lines.push("");
|
|
10186
|
+
lines.push("Headroom: " + (manifest.budget?.headroomTokens ?? 0).toLocaleString("en-US") + " tokens.");
|
|
10187
|
+
lines.push("");
|
|
10188
|
+
lines.push("| File | Tokens |");
|
|
10189
|
+
lines.push("| :-- | --: |");
|
|
10190
|
+
for (const item of next) {
|
|
10191
|
+
lines.push("| `" + item.path + "` | " + item.tokens.toLocaleString("en-US") + " |");
|
|
10192
|
+
}
|
|
10193
|
+
lines.push("");
|
|
10194
|
+
}
|
|
10195
|
+
return lines.join("\n");
|
|
10196
|
+
}
|
|
10197
|
+
|
|
10152
10198
|
// src/mcp/retrieval.ts
|
|
10153
10199
|
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
10154
10200
|
"the",
|
|
@@ -11881,6 +11927,7 @@ var ARTIFACT_FILES = {
|
|
|
11881
11927
|
diff: "reports/diff.md",
|
|
11882
11928
|
log: "reports/log.md",
|
|
11883
11929
|
tokenTree: "reports/tokens.md",
|
|
11930
|
+
selection: "reports/selection.md",
|
|
11884
11931
|
fullJson: "full-codebase.json",
|
|
11885
11932
|
fullMarkdown: "full-codebase.md",
|
|
11886
11933
|
fullXml: "full-codebase.xml",
|
|
@@ -13084,6 +13131,65 @@ var historyTool = {
|
|
|
13084
13131
|
};
|
|
13085
13132
|
}
|
|
13086
13133
|
};
|
|
13134
|
+
var budgetTool = {
|
|
13135
|
+
name: "snapshot_budget",
|
|
13136
|
+
title: "What a larger budget would buy",
|
|
13137
|
+
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.',
|
|
13138
|
+
inputSchema: {
|
|
13139
|
+
type: "object",
|
|
13140
|
+
properties: {
|
|
13141
|
+
budgets: {
|
|
13142
|
+
type: "array",
|
|
13143
|
+
items: { type: "integer", minimum: 500 },
|
|
13144
|
+
description: "Token budgets to compare, ascending (default 10000, 30000, 60000)."
|
|
13145
|
+
},
|
|
13146
|
+
question: { type: "string", description: "Optional question to plan for; absent plans for the repository as a whole." },
|
|
13147
|
+
includeTests: { type: "boolean", description: "Include test files (default false)." },
|
|
13148
|
+
root: ROOT_PROPERTY,
|
|
13149
|
+
outDir: OUT_DIR_PROPERTY
|
|
13150
|
+
},
|
|
13151
|
+
additionalProperties: false
|
|
13152
|
+
},
|
|
13153
|
+
outputSchema: {
|
|
13154
|
+
type: "object",
|
|
13155
|
+
properties: { budgets: { type: "array", items: { type: "object" } } }
|
|
13156
|
+
},
|
|
13157
|
+
annotations: READ_ONLY,
|
|
13158
|
+
async handler(args, context) {
|
|
13159
|
+
const prepared = await prepare(args, context, outDirOverride(args));
|
|
13160
|
+
if (!prepared.ok) return prepared.outcome;
|
|
13161
|
+
const read = readManifest3(prepared.workspace);
|
|
13162
|
+
if (!read.ok) return { text: read.message + " Call snapshot_generate first.", isError: true };
|
|
13163
|
+
const requested = Array.isArray(args.budgets) ? args.budgets.filter((value) => typeof value === "number").map((value) => Math.max(500, value)) : [1e4, 3e4, 6e4];
|
|
13164
|
+
const budgets = [...new Set(requested)].sort((left, right) => left - right);
|
|
13165
|
+
if (budgets.length === 0) return { text: "budgets must hold at least one number", isError: true };
|
|
13166
|
+
const question = typeof args.question === "string" ? args.question : "";
|
|
13167
|
+
const rows = [];
|
|
13168
|
+
let previous = /* @__PURE__ */ new Set();
|
|
13169
|
+
for (const budget of budgets) {
|
|
13170
|
+
const plan = planForQuestion(read.manifest, question, {
|
|
13171
|
+
maxTokens: budget,
|
|
13172
|
+
...args.includeTests === true ? { includeTests: true } : {}
|
|
13173
|
+
});
|
|
13174
|
+
const paths = new Set(plan.files.map((file) => file.path));
|
|
13175
|
+
const gained = [...paths].filter((path28) => !previous.has(path28)).sort();
|
|
13176
|
+
previous = paths;
|
|
13177
|
+
rows.push({
|
|
13178
|
+
budget,
|
|
13179
|
+
files: plan.files.length,
|
|
13180
|
+
usedTokens: plan.usedTokens,
|
|
13181
|
+
gained
|
|
13182
|
+
});
|
|
13183
|
+
}
|
|
13184
|
+
const lines = [question === "" ? "No question: planning for the repository as a whole." : "Question: " + question];
|
|
13185
|
+
for (const row of rows) {
|
|
13186
|
+
lines.push(
|
|
13187
|
+
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" : "") + ")")
|
|
13188
|
+
);
|
|
13189
|
+
}
|
|
13190
|
+
return { text: lines.join("\n"), structured: { budgets: rows } };
|
|
13191
|
+
}
|
|
13192
|
+
};
|
|
13087
13193
|
var testsTool = {
|
|
13088
13194
|
name: "snapshot_tests",
|
|
13089
13195
|
title: "Tests that cover a file, and files a test covers",
|
|
@@ -14110,6 +14216,110 @@ var planForTool = {
|
|
|
14110
14216
|
return { text: lines.join("\n"), structured: plan };
|
|
14111
14217
|
}
|
|
14112
14218
|
};
|
|
14219
|
+
var answerTool = {
|
|
14220
|
+
name: "snapshot_answer",
|
|
14221
|
+
title: "Question in, budgeted context out",
|
|
14222
|
+
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.",
|
|
14223
|
+
inputSchema: {
|
|
14224
|
+
type: "object",
|
|
14225
|
+
properties: {
|
|
14226
|
+
question: { type: "string", description: "What you need to answer." },
|
|
14227
|
+
maxTokens: { type: "integer", description: "Budget for the whole block (default 20000).", minimum: 500 },
|
|
14228
|
+
linesPerFile: { type: "integer", description: "Head lines per file (default 60).", minimum: 10 },
|
|
14229
|
+
includeTests: { type: "boolean", description: "Include test files (default false)." },
|
|
14230
|
+
root: ROOT_PROPERTY,
|
|
14231
|
+
outDir: OUT_DIR_PROPERTY
|
|
14232
|
+
},
|
|
14233
|
+
required: ["question"],
|
|
14234
|
+
additionalProperties: false
|
|
14235
|
+
},
|
|
14236
|
+
outputSchema: {
|
|
14237
|
+
type: "object",
|
|
14238
|
+
properties: {
|
|
14239
|
+
question: { type: "string" },
|
|
14240
|
+
budgetTokens: { type: "integer" },
|
|
14241
|
+
usedTokens: { type: "integer" },
|
|
14242
|
+
files: { type: "array", items: { type: "object" } },
|
|
14243
|
+
omitted: { type: "array", items: { type: "object" } }
|
|
14244
|
+
}
|
|
14245
|
+
},
|
|
14246
|
+
annotations: READ_ONLY,
|
|
14247
|
+
async handler(args, context) {
|
|
14248
|
+
const question = typeof args.question === "string" ? args.question.trim() : "";
|
|
14249
|
+
if (question.length === 0) return { text: "question must be a non-empty string", isError: true };
|
|
14250
|
+
const prepared = await prepare(args, context, outDirOverride(args));
|
|
14251
|
+
if (!prepared.ok) return prepared.outcome;
|
|
14252
|
+
const read = readManifest3(prepared.workspace);
|
|
14253
|
+
if (!read.ok) return { text: read.message + " Call snapshot_generate first.", isError: true };
|
|
14254
|
+
const maxTokens = Math.max(500, typeof args.maxTokens === "number" ? args.maxTokens : 2e4);
|
|
14255
|
+
const linesPerFile = Math.max(10, typeof args.linesPerFile === "number" ? args.linesPerFile : 60);
|
|
14256
|
+
const plan = planForQuestion(read.manifest, question, {
|
|
14257
|
+
maxTokens,
|
|
14258
|
+
...args.includeTests === true ? { includeTests: true } : {}
|
|
14259
|
+
});
|
|
14260
|
+
const blocks = [];
|
|
14261
|
+
const omitted = [];
|
|
14262
|
+
let used = 0;
|
|
14263
|
+
const parts = /* @__PURE__ */ new Map();
|
|
14264
|
+
for (const planned of plan.files) {
|
|
14265
|
+
if (used >= maxTokens) {
|
|
14266
|
+
omitted.push({ path: planned.path, reason: "the budget was spent on earlier files" });
|
|
14267
|
+
continue;
|
|
14268
|
+
}
|
|
14269
|
+
const partPath = partPathFor(prepared.workspace, planned.part);
|
|
14270
|
+
if (partPath === null) {
|
|
14271
|
+
omitted.push({ path: planned.path, reason: "its part is not in the snapshot" });
|
|
14272
|
+
continue;
|
|
14273
|
+
}
|
|
14274
|
+
let partText = parts.get(partPath);
|
|
14275
|
+
if (partText === void 0) {
|
|
14276
|
+
try {
|
|
14277
|
+
partText = fs24__namespace.readFileSync(partPath, "utf8");
|
|
14278
|
+
} catch {
|
|
14279
|
+
omitted.push({ path: planned.path, reason: "its part could not be read" });
|
|
14280
|
+
continue;
|
|
14281
|
+
}
|
|
14282
|
+
parts.set(partPath, partText);
|
|
14283
|
+
}
|
|
14284
|
+
const section = findSection(parsePartSections(partText), planned.path);
|
|
14285
|
+
if (section === null) {
|
|
14286
|
+
omitted.push({ path: planned.path, reason: "no section in its part" });
|
|
14287
|
+
continue;
|
|
14288
|
+
}
|
|
14289
|
+
const window = windowText(section.body, 1, linesPerFile);
|
|
14290
|
+
const text2 = window.text;
|
|
14291
|
+
const tokens = estimateTokens(text2);
|
|
14292
|
+
if (used + tokens > maxTokens && blocks.length > 0) {
|
|
14293
|
+
omitted.push({ path: planned.path, reason: "did not fit the remaining budget" });
|
|
14294
|
+
continue;
|
|
14295
|
+
}
|
|
14296
|
+
const numbered = text2.split("\n").map((line, index) => String(index + 1).padStart(5, " ") + " " + line).join("\n");
|
|
14297
|
+
blocks.push({ path: planned.path, why: planned.why, tokens, text: numbered, truncated: window.truncated, totalLines: window.totalLines });
|
|
14298
|
+
used += tokens;
|
|
14299
|
+
}
|
|
14300
|
+
const lines = [
|
|
14301
|
+
"# Answer context: " + question,
|
|
14302
|
+
"Budget: " + used + " of " + maxTokens + " tokens; " + blocks.length + " file(s)."
|
|
14303
|
+
];
|
|
14304
|
+
for (const block of blocks) {
|
|
14305
|
+
lines.push("");
|
|
14306
|
+
lines.push("## " + block.path + " (" + block.tokens + " tokens, " + (block.truncated ? "first lines of " + block.totalLines : "whole file") + ")");
|
|
14307
|
+
lines.push("Why: " + block.why);
|
|
14308
|
+
lines.push("```");
|
|
14309
|
+
lines.push(block.text);
|
|
14310
|
+
lines.push("```");
|
|
14311
|
+
}
|
|
14312
|
+
if (omitted.length > 0) {
|
|
14313
|
+
lines.push("");
|
|
14314
|
+
lines.push("Not included:");
|
|
14315
|
+
for (const entry of omitted) lines.push("- " + entry.path + " - " + entry.reason);
|
|
14316
|
+
}
|
|
14317
|
+
return {
|
|
14318
|
+
text: lines.join("\n"),
|
|
14319
|
+
structured: { question, budgetTokens: maxTokens, usedTokens: used, files: blocks, omitted }
|
|
14320
|
+
};
|
|
14321
|
+
}
|
|
14322
|
+
};
|
|
14113
14323
|
var healthTool = {
|
|
14114
14324
|
name: "snapshot_health",
|
|
14115
14325
|
title: "Snapshot health audit",
|
|
@@ -14960,6 +15170,7 @@ var explainTool = {
|
|
|
14960
15170
|
var TOOL_COSTS = {
|
|
14961
15171
|
snapshot_status: "cheap",
|
|
14962
15172
|
snapshot_health: "expensive",
|
|
15173
|
+
snapshot_budget: "medium",
|
|
14963
15174
|
snapshot_history: "cheap",
|
|
14964
15175
|
snapshot_tests: "cheap",
|
|
14965
15176
|
snapshot_workspace: "cheap",
|
|
@@ -14975,6 +15186,7 @@ var TOOL_COSTS = {
|
|
|
14975
15186
|
snapshot_context: "medium",
|
|
14976
15187
|
snapshot_query: "cheap",
|
|
14977
15188
|
snapshot_plan_for: "cheap",
|
|
15189
|
+
snapshot_answer: "medium",
|
|
14978
15190
|
snapshot_plan: "expensive",
|
|
14979
15191
|
snapshot_generate: "expensive",
|
|
14980
15192
|
snapshot_validate: "medium",
|
|
@@ -14987,6 +15199,7 @@ function buildTools() {
|
|
|
14987
15199
|
return [
|
|
14988
15200
|
statusTool,
|
|
14989
15201
|
healthTool,
|
|
15202
|
+
budgetTool,
|
|
14990
15203
|
historyTool,
|
|
14991
15204
|
testsTool,
|
|
14992
15205
|
workspaceTool,
|
|
@@ -15002,6 +15215,7 @@ function buildTools() {
|
|
|
15002
15215
|
contextTool,
|
|
15003
15216
|
queryTool,
|
|
15004
15217
|
planForTool,
|
|
15218
|
+
answerTool,
|
|
15005
15219
|
planTool,
|
|
15006
15220
|
generateTool,
|
|
15007
15221
|
validateTool,
|
|
@@ -16394,7 +16608,7 @@ diff, and the commit, are then yours.
|
|
|
16394
16608
|
## When the client speaks MCP
|
|
16395
16609
|
|
|
16396
16610
|
If the agent runs inside an MCP client, \`npx ${PACKAGE_NAME2}@latest mcp\` serves this repository
|
|
16397
|
-
as
|
|
16611
|
+
as 26 tools over stdio instead of shelling out. Its reads come from the snapshot rather than
|
|
16398
16612
|
the working tree, so excluded files and redacted values never reach the context. Use
|
|
16399
16613
|
\`snapshot_locate\` before \`snapshot_read\`, and \`snapshot_validate\` before trusting a snapshot
|
|
16400
16614
|
from an earlier session.
|
|
@@ -19747,6 +19961,7 @@ function generateSnapshot(configInput, options) {
|
|
|
19747
19961
|
}
|
|
19748
19962
|
}
|
|
19749
19963
|
let sliceBlock;
|
|
19964
|
+
let selectionReport = null;
|
|
19750
19965
|
if (options?.slice !== void 0) {
|
|
19751
19966
|
const byFile = files.filter((file) => isSourceSummary(file.summary)).map((file) => ({
|
|
19752
19967
|
path: file.relativePath,
|
|
@@ -19770,6 +19985,11 @@ function generateSnapshot(configInput, options) {
|
|
|
19770
19985
|
files: plan.files.map((file) => file.path),
|
|
19771
19986
|
dropped: scanned - plan.files.length
|
|
19772
19987
|
};
|
|
19988
|
+
selectionReport = {
|
|
19989
|
+
kind: "slice",
|
|
19990
|
+
detail: "Question: " + options.slice.question + "\nBudget: " + plan.budgetTokens.toLocaleString("en-US") + " tokens",
|
|
19991
|
+
files: plan.files.map((file) => ({ path: file.path, tokens: file.tokens, why: file.why }))
|
|
19992
|
+
};
|
|
19773
19993
|
}
|
|
19774
19994
|
let budgetBlock;
|
|
19775
19995
|
if (options?.budgetTokens !== void 0) {
|
|
@@ -19795,12 +20015,26 @@ function generateSnapshot(configInput, options) {
|
|
|
19795
20015
|
const keep = /* @__PURE__ */ new Set();
|
|
19796
20016
|
let used = 0;
|
|
19797
20017
|
const selected = [];
|
|
20018
|
+
const chosen = [];
|
|
19798
20019
|
for (const item of ranked) {
|
|
19799
20020
|
if (used + item.tokens > budget) continue;
|
|
19800
20021
|
keep.add(item.file.relativePath);
|
|
19801
20022
|
selected.push(item.file.relativePath);
|
|
20023
|
+
chosen.push({
|
|
20024
|
+
path: item.file.relativePath,
|
|
20025
|
+
tokens: item.tokens,
|
|
20026
|
+
why: (entry(item.file.relativePath) ? "entry point" : "not an entry point") + "; " + (importers.get(item.file.relativePath) ?? 0) + " importer(s); layer " + item.file.layer
|
|
20027
|
+
});
|
|
19802
20028
|
used += item.tokens;
|
|
19803
20029
|
}
|
|
20030
|
+
const nextInLine = [];
|
|
20031
|
+
let headroom = budget - used;
|
|
20032
|
+
for (const item of ranked) {
|
|
20033
|
+
if (keep.has(item.file.relativePath)) continue;
|
|
20034
|
+
if (nextInLine.length >= 10) break;
|
|
20035
|
+
nextInLine.push({ path: item.file.relativePath, tokens: item.tokens });
|
|
20036
|
+
headroom = Math.max(headroom, item.tokens);
|
|
20037
|
+
}
|
|
19804
20038
|
const scanned = files.length;
|
|
19805
20039
|
const byLayer = {};
|
|
19806
20040
|
let entryKept = 0;
|
|
@@ -19829,7 +20063,14 @@ function generateSnapshot(configInput, options) {
|
|
|
19829
20063
|
usedTokens: used,
|
|
19830
20064
|
files: selected,
|
|
19831
20065
|
dropped: scanned - selected.length,
|
|
19832
|
-
coverage: { byLayer, entryPoints: { kept: entryKept, total: entryTotal }, symbols: { kept: symbolsKept, total: symbolsTotal } }
|
|
20066
|
+
coverage: { byLayer, entryPoints: { kept: entryKept, total: entryTotal }, symbols: { kept: symbolsKept, total: symbolsTotal } },
|
|
20067
|
+
headroomTokens: Math.max(0, budget - used),
|
|
20068
|
+
nextInLine
|
|
20069
|
+
};
|
|
20070
|
+
selectionReport = {
|
|
20071
|
+
kind: "budget",
|
|
20072
|
+
detail: "Budget: " + budget.toLocaleString("en-US") + " tokens",
|
|
20073
|
+
files: chosen
|
|
19833
20074
|
};
|
|
19834
20075
|
if (entryTotal > 0 && entryKept < entryTotal) {
|
|
19835
20076
|
warnings.push(
|
|
@@ -20138,6 +20379,8 @@ function generateSnapshot(configInput, options) {
|
|
|
20138
20379
|
}) : null;
|
|
20139
20380
|
if (promptText !== null) manifest.artifacts.prompt = artifactRecord(promptText);
|
|
20140
20381
|
if (projectTree !== null) manifest.artifacts.projectTree = artifactRecord(projectTree);
|
|
20382
|
+
const selectionText = selectionReport === null ? null : generateSelectionReport(manifest, selectionReport);
|
|
20383
|
+
if (selectionText !== null) manifest.artifacts.selection = artifactRecord(selectionText);
|
|
20141
20384
|
let monolithJson = null;
|
|
20142
20385
|
let monolithMarkdown = null;
|
|
20143
20386
|
let monolithXml = null;
|
|
@@ -20294,6 +20537,9 @@ function generateSnapshot(configInput, options) {
|
|
|
20294
20537
|
if (tokenTree !== null) {
|
|
20295
20538
|
writeArtifact(reportsDir, "tokens.md", tokenTree.text);
|
|
20296
20539
|
}
|
|
20540
|
+
if (selectionText !== null) {
|
|
20541
|
+
writeArtifact(reportsDir, "selection.md", selectionText);
|
|
20542
|
+
}
|
|
20297
20543
|
if (sarifText !== null) {
|
|
20298
20544
|
writeArtifact(reportsDir, "audit.sarif", sarifText);
|
|
20299
20545
|
}
|
|
@@ -22152,6 +22398,15 @@ ${USAGE}
|
|
|
22152
22398
|
info(` - Entry points: ${coverage.entryPoints.kept} of ${coverage.entryPoints.total}`);
|
|
22153
22399
|
info(` - Symbols: ${coverage.symbols.kept} of ${coverage.symbols.total}`);
|
|
22154
22400
|
}
|
|
22401
|
+
if (manifest.budget.headroomTokens !== void 0) {
|
|
22402
|
+
info(` - Headroom: ${formatNumber(manifest.budget.headroomTokens)} tokens`);
|
|
22403
|
+
}
|
|
22404
|
+
if (manifest.budget.nextInLine !== void 0 && manifest.budget.nextInLine.length > 0) {
|
|
22405
|
+
const next = manifest.budget.nextInLine.slice(0, 5);
|
|
22406
|
+
info(
|
|
22407
|
+
" - Next in line: " + next.map((item) => item.path + " (" + formatNumber(item.tokens) + ")").join(", ") + (manifest.budget.nextInLine.length > next.length ? ", \u2026" : "")
|
|
22408
|
+
);
|
|
22409
|
+
}
|
|
22155
22410
|
}
|
|
22156
22411
|
if (manifest.delta !== void 0) {
|
|
22157
22412
|
const delta = manifest.delta;
|
package/dist/cli.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-
|
|
1
|
+
import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-Cr5H2Y3t.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The machine-readable description of this tool.
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-
|
|
1
|
+
import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-Cr5H2Y3t.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The machine-readable description of this tool.
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { startHttpTransport } from './chunk-
|
|
2
|
-
import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, buildAgentContract, startWebServer, runStdioServer, parseRemoteSource, assertPublicHost, cloneRepository, makeCloneDirectory, loadConfigFileDetailed, resolveConfig, validateSnapshot, auditSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, signManifest, loadSigningKey, writeSignature, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, COMMAND_OPTION_SCOPE, commandsForOption, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, SKILL_NAME, renderSkill, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, escapeControls, runWithStdoutCapture, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderContractText, renderExplainText } from './chunk-
|
|
3
|
-
export { buildAgentContract } from './chunk-
|
|
1
|
+
import { startHttpTransport } from './chunk-VI3JLKPX.js';
|
|
2
|
+
import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, buildAgentContract, startWebServer, runStdioServer, parseRemoteSource, assertPublicHost, cloneRepository, makeCloneDirectory, loadConfigFileDetailed, resolveConfig, validateSnapshot, auditSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, signManifest, loadSigningKey, writeSignature, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, COMMAND_OPTION_SCOPE, commandsForOption, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, SKILL_NAME, renderSkill, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, escapeControls, runWithStdoutCapture, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderContractText, renderExplainText } from './chunk-PDLN24ZZ.js';
|
|
3
|
+
export { buildAgentContract } from './chunk-PDLN24ZZ.js';
|
|
4
4
|
import { spawnSync } from 'child_process';
|
|
5
5
|
import * as fs2 from 'fs';
|
|
6
6
|
import * as path2 from 'path';
|
|
@@ -1476,6 +1476,15 @@ ${USAGE}
|
|
|
1476
1476
|
info(` - Entry points: ${coverage.entryPoints.kept} of ${coverage.entryPoints.total}`);
|
|
1477
1477
|
info(` - Symbols: ${coverage.symbols.kept} of ${coverage.symbols.total}`);
|
|
1478
1478
|
}
|
|
1479
|
+
if (manifest.budget.headroomTokens !== void 0) {
|
|
1480
|
+
info(` - Headroom: ${formatNumber(manifest.budget.headroomTokens)} tokens`);
|
|
1481
|
+
}
|
|
1482
|
+
if (manifest.budget.nextInLine !== void 0 && manifest.budget.nextInLine.length > 0) {
|
|
1483
|
+
const next = manifest.budget.nextInLine.slice(0, 5);
|
|
1484
|
+
info(
|
|
1485
|
+
" - Next in line: " + next.map((item) => item.path + " (" + formatNumber(item.tokens) + ")").join(", ") + (manifest.budget.nextInLine.length > next.length ? ", \u2026" : "")
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1479
1488
|
}
|
|
1480
1489
|
if (manifest.delta !== void 0) {
|
|
1481
1490
|
const delta = manifest.delta;
|