codebase-snapshot 0.20.0 → 0.20.3
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 +80 -0
- package/README.md +1 -1
- package/dist/bin.js +651 -15
- package/dist/{chunk-S27VYVC4.js → chunk-7JQRJBMP.js} +639 -14
- package/dist/{chunk-JCGCY6R3.js → chunk-TUL3I7O6.js} +1 -1
- package/dist/cli.cjs +651 -15
- package/dist/cli.d.cts +5 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +15 -4
- package/dist/index.cjs +639 -14
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +639 -13
- package/dist/mcp.js +2 -2
- package/docs/cli.md +12 -7
- package/docs/deploy.md +2 -2
- package/docs/health.md +78 -32
- package/docs/mcp.md +5 -5
- package/package.json +5 -2
package/dist/cli.cjs
CHANGED
|
@@ -2229,7 +2229,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2229
2229
|
|
|
2230
2230
|
// src/version.ts
|
|
2231
2231
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2232
|
-
var GENERATOR_VERSION = "0.20.
|
|
2232
|
+
var GENERATOR_VERSION = "0.20.3";
|
|
2233
2233
|
var SCHEMA_VERSION = "3.0.0";
|
|
2234
2234
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2235
2235
|
function isOurGeneratorName(name) {
|
|
@@ -10122,7 +10122,10 @@ function generateMonolithJson(manifest, filesWithContent) {
|
|
|
10122
10122
|
...manifest,
|
|
10123
10123
|
selfReference: "This manifest is embedded in full-codebase.json, which cannot record its own digest. manifest.json holds the byteSize and sha256 of this file."
|
|
10124
10124
|
};
|
|
10125
|
-
|
|
10125
|
+
const files = filesWithContent.map(
|
|
10126
|
+
(file) => file.content === void 0 ? file : { ...file, content: file.content.replace(/\r\n|\r/g, "\n") }
|
|
10127
|
+
);
|
|
10128
|
+
return JSON.stringify({ manifest: embedded, files }, null, 2);
|
|
10126
10129
|
}
|
|
10127
10130
|
function xmlAttribute(value) {
|
|
10128
10131
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
@@ -12037,13 +12040,14 @@ function secretTokens(text2) {
|
|
|
12037
12040
|
}
|
|
12038
12041
|
return [...tokens];
|
|
12039
12042
|
}
|
|
12040
|
-
function
|
|
12043
|
+
function readArtifactTexts(snapshotDir) {
|
|
12044
|
+
const texts = [];
|
|
12041
12045
|
for (const relative15 of walk(snapshotDir)) {
|
|
12042
12046
|
if (!TEXT_ARTIFACT.test(relative15)) continue;
|
|
12043
12047
|
const text2 = readText2(path27__namespace.join(snapshotDir, relative15));
|
|
12044
|
-
if (text2 !== null
|
|
12048
|
+
if (text2 !== null) texts.push(text2);
|
|
12045
12049
|
}
|
|
12046
|
-
return
|
|
12050
|
+
return texts;
|
|
12047
12051
|
}
|
|
12048
12052
|
function findHostPaths(snapshotDir, repoDir) {
|
|
12049
12053
|
const patterns = [
|
|
@@ -12084,6 +12088,135 @@ function staleAgainstRepository(manifest, repoDir) {
|
|
|
12084
12088
|
if (head === recorded) return null;
|
|
12085
12089
|
return "HEAD is " + head.slice(0, 8) + " but the snapshot was generated at " + recorded.slice(0, 8) + "; regenerate before trusting it.";
|
|
12086
12090
|
}
|
|
12091
|
+
function summaryClaims(summary) {
|
|
12092
|
+
if ("imports" in summary) {
|
|
12093
|
+
const fields = [
|
|
12094
|
+
["imports", summary.imports],
|
|
12095
|
+
["reExports", summary.reExports],
|
|
12096
|
+
["exports", summary.exports],
|
|
12097
|
+
["functions", summary.functions],
|
|
12098
|
+
["classes", summary.classes],
|
|
12099
|
+
["interfaces", summary.interfaces],
|
|
12100
|
+
["types", summary.types],
|
|
12101
|
+
["enums", summary.enums],
|
|
12102
|
+
["variables", summary.variables],
|
|
12103
|
+
["reactComponents", summary.reactComponents],
|
|
12104
|
+
["hooks", summary.hooks],
|
|
12105
|
+
["routeHandlers", summary.routeHandlers]
|
|
12106
|
+
];
|
|
12107
|
+
const claims = [];
|
|
12108
|
+
for (const [field, values] of fields) {
|
|
12109
|
+
for (const value of values) {
|
|
12110
|
+
if (typeof value !== "string" || value === "") continue;
|
|
12111
|
+
if (field === "routeHandlers" && value.includes(" ")) {
|
|
12112
|
+
const route = value.slice(value.indexOf(" ") + 1).trim();
|
|
12113
|
+
if (route !== "") claims.push({ field, value: route });
|
|
12114
|
+
continue;
|
|
12115
|
+
}
|
|
12116
|
+
claims.push({ field, value });
|
|
12117
|
+
}
|
|
12118
|
+
}
|
|
12119
|
+
return claims;
|
|
12120
|
+
}
|
|
12121
|
+
if ("keys" in summary) {
|
|
12122
|
+
return [...summary.keys, ...summary.sampleKeys].map((key) => ({
|
|
12123
|
+
field: "keys",
|
|
12124
|
+
value: '"' + key + '"'
|
|
12125
|
+
}));
|
|
12126
|
+
}
|
|
12127
|
+
return summary.headings.map((heading) => ({ field: "headings", value: heading }));
|
|
12128
|
+
}
|
|
12129
|
+
function reportNumber(text2, label) {
|
|
12130
|
+
const match = new RegExp("\\*\\*" + escapeRegExp(label) + ":\\*\\* `([0-9][0-9,]*)`").exec(text2);
|
|
12131
|
+
return match === null ? null : Number(match[1].replace(/,/g, ""));
|
|
12132
|
+
}
|
|
12133
|
+
function reportMib(text2, label) {
|
|
12134
|
+
const match = new RegExp(
|
|
12135
|
+
"\\*\\*" + escapeRegExp(label) + ":\\*\\* `([0-9]+(?:\\.[0-9]+)?) MiB`"
|
|
12136
|
+
).exec(text2);
|
|
12137
|
+
return match === null ? null : Number(match[1]);
|
|
12138
|
+
}
|
|
12139
|
+
function maskCompatible(sourceLine, bodyLine) {
|
|
12140
|
+
const normalised = bodyLine.split(PEM_REDACTION_MARKER).join(REDACTION_MARKER);
|
|
12141
|
+
let cursor = 0;
|
|
12142
|
+
for (const piece of normalised.split(REDACTION_MARKER)) {
|
|
12143
|
+
if (piece === "") continue;
|
|
12144
|
+
const at = sourceLine.indexOf(piece, cursor);
|
|
12145
|
+
if (at === -1) return false;
|
|
12146
|
+
cursor = at + piece.length;
|
|
12147
|
+
}
|
|
12148
|
+
return true;
|
|
12149
|
+
}
|
|
12150
|
+
function firstBodyMismatch(expected, actual) {
|
|
12151
|
+
const sourceLines = expected.split("\n");
|
|
12152
|
+
const bodyLines = actual.split("\n");
|
|
12153
|
+
const shared = Math.min(sourceLines.length, bodyLines.length);
|
|
12154
|
+
for (let index = 0; index < shared; index += 1) {
|
|
12155
|
+
if (sourceLines[index] === bodyLines[index]) continue;
|
|
12156
|
+
if (!bodyLines[index].includes(REDACTION_MARKER) && !bodyLines[index].includes(PEM_REDACTION_MARKER)) {
|
|
12157
|
+
return index + 1;
|
|
12158
|
+
}
|
|
12159
|
+
if (!maskCompatible(sourceLines[index], bodyLines[index])) return index + 1;
|
|
12160
|
+
}
|
|
12161
|
+
return sourceLines.length === bodyLines.length ? null : shared + 1;
|
|
12162
|
+
}
|
|
12163
|
+
function decodeXmlAttribute(value) {
|
|
12164
|
+
return value.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
12165
|
+
}
|
|
12166
|
+
function jsonPackBodies(text2) {
|
|
12167
|
+
try {
|
|
12168
|
+
const parsed = JSON.parse(text2);
|
|
12169
|
+
if (!Array.isArray(parsed?.files)) return null;
|
|
12170
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
12171
|
+
for (const entry of parsed.files) {
|
|
12172
|
+
if (typeof entry?.relativePath !== "string" || typeof entry.content !== "string") continue;
|
|
12173
|
+
bodies.set(entry.relativePath, entry.content);
|
|
12174
|
+
}
|
|
12175
|
+
return bodies;
|
|
12176
|
+
} catch {
|
|
12177
|
+
return null;
|
|
12178
|
+
}
|
|
12179
|
+
}
|
|
12180
|
+
function xmlPackBodies(text2) {
|
|
12181
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
12182
|
+
const filePattern = / <file path="([^"]*)"[^>]*>\n([\s\S]*?)\n <\/file>/g;
|
|
12183
|
+
for (const match of text2.matchAll(filePattern)) {
|
|
12184
|
+
const content = [...match[2].matchAll(/<!\[CDATA\[([\s\S]*?)\]\]>/g)].map((part) => part[1]).join("");
|
|
12185
|
+
bodies.set(decodeXmlAttribute(match[1]), content);
|
|
12186
|
+
}
|
|
12187
|
+
return bodies.size === 0 ? null : bodies;
|
|
12188
|
+
}
|
|
12189
|
+
function markdownPackBodies(text2) {
|
|
12190
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
12191
|
+
const lines = text2.split("\n");
|
|
12192
|
+
let index = 0;
|
|
12193
|
+
while (index < lines.length) {
|
|
12194
|
+
if (!lines[index].startsWith("## File: ")) {
|
|
12195
|
+
index += 1;
|
|
12196
|
+
continue;
|
|
12197
|
+
}
|
|
12198
|
+
const filePath = lines[index].slice("## File: ".length).trim();
|
|
12199
|
+
let cursor = index + 1;
|
|
12200
|
+
while (cursor < lines.length && !/^`{3,}/.test(lines[cursor])) {
|
|
12201
|
+
if (lines[cursor].startsWith("## File: ")) break;
|
|
12202
|
+
cursor += 1;
|
|
12203
|
+
}
|
|
12204
|
+
const fence = /^(`{3,})/.exec(lines[cursor] ?? "");
|
|
12205
|
+
if (fence === null) {
|
|
12206
|
+
index = cursor + 1;
|
|
12207
|
+
continue;
|
|
12208
|
+
}
|
|
12209
|
+
const body = [];
|
|
12210
|
+
let bodyLine = cursor + 1;
|
|
12211
|
+
while (bodyLine < lines.length && lines[bodyLine] !== fence[1]) {
|
|
12212
|
+
body.push(lines[bodyLine]);
|
|
12213
|
+
bodyLine += 1;
|
|
12214
|
+
}
|
|
12215
|
+
bodies.set(filePath, body.join("\n"));
|
|
12216
|
+
index = bodyLine + 1;
|
|
12217
|
+
}
|
|
12218
|
+
return bodies.size === 0 ? null : bodies;
|
|
12219
|
+
}
|
|
12087
12220
|
function auditSnapshot(options) {
|
|
12088
12221
|
const snapshotDir = path27__namespace.resolve(options.snapshotDir);
|
|
12089
12222
|
const repoDir = path27__namespace.resolve(options.repoDir);
|
|
@@ -12290,6 +12423,272 @@ function auditSnapshot(options) {
|
|
|
12290
12423
|
bookkeeping.length + " mismatch(es): " + sample(bookkeeping)
|
|
12291
12424
|
)
|
|
12292
12425
|
);
|
|
12426
|
+
const fileByPath = new Map(manifest.files.map((file) => [file.relativePath, file]));
|
|
12427
|
+
const partTexts = /* @__PURE__ */ new Map();
|
|
12428
|
+
const partSections = /* @__PURE__ */ new Map();
|
|
12429
|
+
const bodyByPath = /* @__PURE__ */ new Map();
|
|
12430
|
+
const anchorToPath = new Map(
|
|
12431
|
+
manifest.files.map((file) => [anchorForPath(file.relativePath), file.relativePath])
|
|
12432
|
+
);
|
|
12433
|
+
for (const part of manifest.parts) {
|
|
12434
|
+
const partText = readText2(path27__namespace.join(snapshotDir, "parts", part.filename));
|
|
12435
|
+
if (partText === null) continue;
|
|
12436
|
+
const sections = parsePartSections(partText);
|
|
12437
|
+
partTexts.set(part.filename, partText);
|
|
12438
|
+
partSections.set(part.filename, sections);
|
|
12439
|
+
for (const section of sections) {
|
|
12440
|
+
if (section.anchor === null) continue;
|
|
12441
|
+
const relativePath = anchorToPath.get(section.anchor);
|
|
12442
|
+
if (relativePath !== void 0) bodyByPath.set(relativePath, section.body);
|
|
12443
|
+
}
|
|
12444
|
+
}
|
|
12445
|
+
const summaryProblems = [];
|
|
12446
|
+
let claimsChecked = 0;
|
|
12447
|
+
let summarisedFiles = 0;
|
|
12448
|
+
for (const file of manifest.files) {
|
|
12449
|
+
if (file.summary === void 0) continue;
|
|
12450
|
+
if (file.inclusionMode === "preview" || file.emptyLinesRemoved === true) continue;
|
|
12451
|
+
const body = bodyByPath.get(file.relativePath);
|
|
12452
|
+
if (body === void 0) continue;
|
|
12453
|
+
summarisedFiles += 1;
|
|
12454
|
+
for (const claim of summaryClaims(file.summary)) {
|
|
12455
|
+
if (claim.value.includes(REDACTION_MARKER)) continue;
|
|
12456
|
+
claimsChecked += 1;
|
|
12457
|
+
if (!body.includes(claim.value)) {
|
|
12458
|
+
summaryProblems.push(file.relativePath + " (" + claim.field + ")");
|
|
12459
|
+
}
|
|
12460
|
+
}
|
|
12461
|
+
}
|
|
12462
|
+
checks.push(
|
|
12463
|
+
summarisedFiles === 0 ? check(
|
|
12464
|
+
"summary.truth",
|
|
12465
|
+
"Every summary claim appears in the body",
|
|
12466
|
+
"critical",
|
|
12467
|
+
"skip",
|
|
12468
|
+
"No summarised file could be compared with a body."
|
|
12469
|
+
) : summaryProblems.length === 0 ? check(
|
|
12470
|
+
"summary.truth",
|
|
12471
|
+
"Every summary claim appears in the body",
|
|
12472
|
+
"critical",
|
|
12473
|
+
"pass",
|
|
12474
|
+
claimsChecked + " claim(s) across " + summarisedFiles + " file(s) are present in the parts."
|
|
12475
|
+
) : check(
|
|
12476
|
+
"summary.truth",
|
|
12477
|
+
"Every summary claim appears in the body",
|
|
12478
|
+
"critical",
|
|
12479
|
+
"fail",
|
|
12480
|
+
summaryProblems.length + " claim(s) name something the body does not contain: " + sample(summaryProblems)
|
|
12481
|
+
)
|
|
12482
|
+
);
|
|
12483
|
+
const reportProblems = [];
|
|
12484
|
+
let reportClaims = 0;
|
|
12485
|
+
const compareNumber = (label, actual, expected) => {
|
|
12486
|
+
if (actual === null) return;
|
|
12487
|
+
reportClaims += 1;
|
|
12488
|
+
if (actual !== expected) {
|
|
12489
|
+
reportProblems.push(label + " says " + actual + ", the manifest says " + expected);
|
|
12490
|
+
}
|
|
12491
|
+
};
|
|
12492
|
+
const compareMib = (label, actual, bytes) => {
|
|
12493
|
+
if (actual === null) return;
|
|
12494
|
+
reportClaims += 1;
|
|
12495
|
+
const expected = Number((bytes / (1024 * 1024)).toFixed(2));
|
|
12496
|
+
if (Math.abs(actual - expected) > 0.011) {
|
|
12497
|
+
reportProblems.push(label + " says " + actual + " MiB, the manifest says " + expected);
|
|
12498
|
+
}
|
|
12499
|
+
};
|
|
12500
|
+
if (manifest.artifacts?.readme != null) {
|
|
12501
|
+
const text2 = readText2(path27__namespace.join(snapshotDir, "README.md"));
|
|
12502
|
+
if (text2 === null) {
|
|
12503
|
+
reportProblems.push("README.md is recorded but unreadable");
|
|
12504
|
+
} else {
|
|
12505
|
+
compareNumber("README total files", reportNumber(text2, "Total Tracked Files"), manifest.counts.totalFiles);
|
|
12506
|
+
compareNumber("README source lines", reportNumber(text2, "Source Lines"), manifest.counts.totalLines);
|
|
12507
|
+
compareNumber(
|
|
12508
|
+
"README emitted lines",
|
|
12509
|
+
reportNumber(text2, "Emitted Lines"),
|
|
12510
|
+
manifest.totals.emittedLines ?? manifest.counts.totalLines
|
|
12511
|
+
);
|
|
12512
|
+
const partsWritten = manifest.config.artifacts?.parts !== false;
|
|
12513
|
+
compareNumber("README part count", reportNumber(text2, "Part Count"), partsWritten ? manifest.counts.partsCount : 0);
|
|
12514
|
+
compareMib("README total size", reportMib(text2, "Total Size"), manifest.counts.totalSizeBytes);
|
|
12515
|
+
compareMib("README emitted content", reportMib(text2, "Emitted Content"), manifest.totals.totalContentBytes);
|
|
12516
|
+
const rows = [...text2.matchAll(/^\| \[([^\]]+)\]\(parts\/([^)]+)\) \| (\d+) \| ([0-9.]+) KB \|/gm)];
|
|
12517
|
+
if (rows.length > 0) {
|
|
12518
|
+
reportClaims += rows.length;
|
|
12519
|
+
if (rows.length !== manifest.parts.length) {
|
|
12520
|
+
reportProblems.push("README tables " + rows.length + " part(s), the manifest holds " + manifest.parts.length);
|
|
12521
|
+
}
|
|
12522
|
+
for (const row of rows) {
|
|
12523
|
+
const part = manifest.parts.find((candidate) => candidate.filename === row[2]);
|
|
12524
|
+
if (part === void 0) {
|
|
12525
|
+
reportProblems.push("README names " + row[2] + ", which the manifest does not hold");
|
|
12526
|
+
continue;
|
|
12527
|
+
}
|
|
12528
|
+
if (Number(row[3]) !== part.fileCount) {
|
|
12529
|
+
reportProblems.push("README " + row[2] + " says " + row[3] + " file(s), the manifest says " + part.fileCount);
|
|
12530
|
+
}
|
|
12531
|
+
const stated = Number(row[4]);
|
|
12532
|
+
const expected = Number((part.byteSize / 1024).toFixed(1));
|
|
12533
|
+
if (Math.abs(stated - expected) > 0.11) {
|
|
12534
|
+
reportProblems.push("README " + row[2] + " says " + stated + " KB, the manifest says " + expected);
|
|
12535
|
+
}
|
|
12536
|
+
}
|
|
12537
|
+
}
|
|
12538
|
+
}
|
|
12539
|
+
}
|
|
12540
|
+
if (manifest.artifacts?.prompt != null) {
|
|
12541
|
+
const text2 = readText2(path27__namespace.join(snapshotDir, "PROMPT.md"));
|
|
12542
|
+
if (text2 === null) {
|
|
12543
|
+
reportProblems.push("PROMPT.md is recorded but unreadable");
|
|
12544
|
+
} else {
|
|
12545
|
+
const fingerprint = /^- Fingerprint: \x60([0-9a-f]{12,64})\x60/m.exec(text2);
|
|
12546
|
+
if (fingerprint !== null) {
|
|
12547
|
+
reportClaims += 1;
|
|
12548
|
+
if (fingerprint[1] !== manifest.fingerprint) reportProblems.push("PROMPT names a different fingerprint");
|
|
12549
|
+
}
|
|
12550
|
+
const generated = /^- Generated: \x60([^\x60]+)\x60 from branch \x60([^\x60]+)\x60 at commit \x60([0-9a-f]+)\x60/m.exec(text2);
|
|
12551
|
+
if (generated !== null) {
|
|
12552
|
+
reportClaims += 3;
|
|
12553
|
+
if (generated[1] !== manifest.generatedAt) reportProblems.push("PROMPT names a different generation time");
|
|
12554
|
+
if (generated[2] !== manifest.git.branch) reportProblems.push("PROMPT names a different branch");
|
|
12555
|
+
if (!manifest.git.commit.startsWith(generated[3])) reportProblems.push("PROMPT names a different commit");
|
|
12556
|
+
}
|
|
12557
|
+
const validation = /^- Validation: the generation-time check was \x60([^\x60]+)\x60/m.exec(text2);
|
|
12558
|
+
if (validation !== null) {
|
|
12559
|
+
reportClaims += 1;
|
|
12560
|
+
if (validation[1] !== manifest.validation.status) reportProblems.push("PROMPT quotes a different validation status");
|
|
12561
|
+
}
|
|
12562
|
+
const partsLine = /^- Parts: ([\d,]+) at a ([\d,]+) KB ceiling/m.exec(text2);
|
|
12563
|
+
if (partsLine !== null) {
|
|
12564
|
+
reportClaims += 2;
|
|
12565
|
+
if (Number(partsLine[1].replace(/,/g, "")) !== manifest.parts.length) {
|
|
12566
|
+
reportProblems.push("PROMPT says " + partsLine[1] + " part(s), the manifest holds " + manifest.parts.length);
|
|
12567
|
+
}
|
|
12568
|
+
const ceiling = Math.round(manifest.budgets.maxPartBytes / 1024);
|
|
12569
|
+
if (Number(partsLine[2].replace(/,/g, "")) !== ceiling) {
|
|
12570
|
+
reportProblems.push("PROMPT says a " + partsLine[2] + " KB ceiling, the manifest says " + ceiling);
|
|
12571
|
+
}
|
|
12572
|
+
}
|
|
12573
|
+
for (const row of text2.matchAll(/^ - \x60([^\x60]+)\x60 - ([\d,]+) file\(s\)$/gm)) {
|
|
12574
|
+
reportClaims += 1;
|
|
12575
|
+
const part = manifest.parts.find((candidate) => candidate.filename === row[1]);
|
|
12576
|
+
if (part === void 0) {
|
|
12577
|
+
reportProblems.push("PROMPT names " + row[1] + ", which the manifest does not hold");
|
|
12578
|
+
} else if (Number(row[2].replace(/,/g, "")) !== part.fileCount) {
|
|
12579
|
+
reportProblems.push("PROMPT " + row[1] + " says " + row[2] + " file(s), the manifest says " + part.fileCount);
|
|
12580
|
+
}
|
|
12581
|
+
}
|
|
12582
|
+
const coverage = /^- ([\d,]+) paths were found; ([\d,]+) (?:is|are) in the parts and ([\d,]+) (?:was|were) skipped/m.exec(text2);
|
|
12583
|
+
if (coverage !== null) {
|
|
12584
|
+
reportClaims += 3;
|
|
12585
|
+
if (Number(coverage[1].replace(/,/g, "")) !== manifest.totals.candidateFiles) {
|
|
12586
|
+
reportProblems.push("PROMPT says " + coverage[1] + " paths were found, the manifest says " + manifest.totals.candidateFiles);
|
|
12587
|
+
}
|
|
12588
|
+
if (Number(coverage[2].replace(/,/g, "")) !== manifest.totals.includedFiles) {
|
|
12589
|
+
reportProblems.push("PROMPT says " + coverage[2] + " are in the parts, the manifest says " + manifest.totals.includedFiles);
|
|
12590
|
+
}
|
|
12591
|
+
if (Number(coverage[3].replace(/,/g, "")) !== manifest.counts.skippedCount) {
|
|
12592
|
+
reportProblems.push("PROMPT says " + coverage[3] + " were skipped, the manifest says " + manifest.counts.skippedCount);
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12595
|
+
const partial = /^- Partial files: (none|[\d,]+)\./m.exec(text2);
|
|
12596
|
+
if (partial !== null) {
|
|
12597
|
+
reportClaims += 1;
|
|
12598
|
+
const stated = partial[1] === "none" ? 0 : Number(partial[1].replace(/,/g, ""));
|
|
12599
|
+
if (stated !== manifest.incomplete.length) {
|
|
12600
|
+
reportProblems.push("PROMPT says " + partial[1] + " partial file(s), the manifest holds " + manifest.incomplete.length);
|
|
12601
|
+
}
|
|
12602
|
+
}
|
|
12603
|
+
if (text2.includes("- Redacted: no line matched a secret rule.")) {
|
|
12604
|
+
reportClaims += 1;
|
|
12605
|
+
if (manifest.totals.redactedLines !== 0) {
|
|
12606
|
+
reportProblems.push("PROMPT says nothing was redacted, the manifest says " + manifest.totals.redactedLines);
|
|
12607
|
+
}
|
|
12608
|
+
} else {
|
|
12609
|
+
const redacted = /^- Redacted: ([\d,]+) line\(s\) had values masked/m.exec(text2);
|
|
12610
|
+
if (redacted !== null) {
|
|
12611
|
+
reportClaims += 1;
|
|
12612
|
+
if (Number(redacted[1].replace(/,/g, "")) !== manifest.totals.redactedLines) {
|
|
12613
|
+
reportProblems.push("PROMPT says " + redacted[1] + " redacted line(s), the manifest says " + manifest.totals.redactedLines);
|
|
12614
|
+
}
|
|
12615
|
+
}
|
|
12616
|
+
}
|
|
12617
|
+
const layersLine = /^- Layers, by file count: (.+)$/m.exec(text2);
|
|
12618
|
+
if (layersLine !== null) {
|
|
12619
|
+
for (const layer2 of layersLine[1].matchAll(/\x60([^\x60]+)\x60 ([\d,]+)/g)) {
|
|
12620
|
+
reportClaims += 1;
|
|
12621
|
+
const expected = manifest.layers[layer2[1]] ?? 0;
|
|
12622
|
+
if (Number(layer2[2].replace(/,/g, "")) !== expected) {
|
|
12623
|
+
reportProblems.push("PROMPT layer " + layer2[1] + " says " + layer2[2] + ", the manifest says " + expected);
|
|
12624
|
+
}
|
|
12625
|
+
}
|
|
12626
|
+
}
|
|
12627
|
+
}
|
|
12628
|
+
}
|
|
12629
|
+
checks.push(
|
|
12630
|
+
reportProblems.length > 0 ? check(
|
|
12631
|
+
"report.truth",
|
|
12632
|
+
"The reports quote this run, not another",
|
|
12633
|
+
"critical",
|
|
12634
|
+
"fail",
|
|
12635
|
+
reportProblems.length + " disagreement(s): " + sample(reportProblems)
|
|
12636
|
+
) : reportClaims === 0 ? check(
|
|
12637
|
+
"report.truth",
|
|
12638
|
+
"The reports quote this run, not another",
|
|
12639
|
+
"critical",
|
|
12640
|
+
"skip",
|
|
12641
|
+
"No report in the current shape could be compared with the manifest."
|
|
12642
|
+
) : check(
|
|
12643
|
+
"report.truth",
|
|
12644
|
+
"The reports quote this run, not another",
|
|
12645
|
+
"critical",
|
|
12646
|
+
"pass",
|
|
12647
|
+
reportClaims + " figure(s) in README.md and PROMPT.md agree with the manifest."
|
|
12648
|
+
)
|
|
12649
|
+
);
|
|
12650
|
+
const indexProblems = [];
|
|
12651
|
+
const indexedPaths = /* @__PURE__ */ new Set();
|
|
12652
|
+
const checkIndexed = (kind, relativePath, part) => {
|
|
12653
|
+
const file = fileByPath.get(relativePath);
|
|
12654
|
+
if (file === void 0) {
|
|
12655
|
+
indexProblems.push(kind + " names " + relativePath + ", which is not in files[]");
|
|
12656
|
+
return;
|
|
12657
|
+
}
|
|
12658
|
+
if (part !== void 0 && file.part !== part) {
|
|
12659
|
+
indexProblems.push(kind + " puts " + relativePath + " in " + part + ", the manifest says " + file.part);
|
|
12660
|
+
}
|
|
12661
|
+
};
|
|
12662
|
+
for (const route of manifest.indexes.routes) checkIndexed("routes", route.path, route.part);
|
|
12663
|
+
for (const component of manifest.indexes.components) checkIndexed("components", component.path, component.part);
|
|
12664
|
+
for (const handler of manifest.indexes.handlers) checkIndexed("handlers", handler.path, handler.part);
|
|
12665
|
+
for (const directive of manifest.indexes.directives) checkIndexed("directives", directive.path);
|
|
12666
|
+
for (const entry of manifest.indexes.imports.byFile) {
|
|
12667
|
+
checkIndexed("imports.byFile", entry.path);
|
|
12668
|
+
if (indexedPaths.has(entry.path)) indexProblems.push("imports.byFile lists " + entry.path + " twice");
|
|
12669
|
+
indexedPaths.add(entry.path);
|
|
12670
|
+
}
|
|
12671
|
+
for (const entry of manifest.indexes.imports.centralFiles) {
|
|
12672
|
+
checkIndexed("centralFiles", entry.path);
|
|
12673
|
+
if (entry.importedByCount < 1) {
|
|
12674
|
+
indexProblems.push("centralFiles says " + entry.path + " has " + entry.importedByCount + " importer(s)");
|
|
12675
|
+
}
|
|
12676
|
+
}
|
|
12677
|
+
checks.push(
|
|
12678
|
+
indexProblems.length === 0 ? check(
|
|
12679
|
+
"indexes.consistent",
|
|
12680
|
+
"Every index entry names a file in the snapshot",
|
|
12681
|
+
"critical",
|
|
12682
|
+
"pass",
|
|
12683
|
+
manifest.indexes.imports.byFile.length + " import edge(s) and " + (manifest.indexes.routes.length + manifest.indexes.components.length + manifest.indexes.handlers.length) + " route/component/handler entry(s) resolve."
|
|
12684
|
+
) : check(
|
|
12685
|
+
"indexes.consistent",
|
|
12686
|
+
"Every index entry names a file in the snapshot",
|
|
12687
|
+
"critical",
|
|
12688
|
+
"fail",
|
|
12689
|
+
indexProblems.length + " index problem(s): " + sample(indexProblems)
|
|
12690
|
+
)
|
|
12691
|
+
);
|
|
12293
12692
|
const packReaders = [
|
|
12294
12693
|
{
|
|
12295
12694
|
key: "fullJson",
|
|
@@ -12366,9 +12765,8 @@ function auditSnapshot(options) {
|
|
|
12366
12765
|
const bodyProblems = [];
|
|
12367
12766
|
let bodiesChecked = 0;
|
|
12368
12767
|
for (const part of manifest.parts) {
|
|
12369
|
-
const
|
|
12370
|
-
if (
|
|
12371
|
-
const sections = parsePartSections(partText);
|
|
12768
|
+
const sections = partSections.get(part.filename);
|
|
12769
|
+
if (sections === void 0) continue;
|
|
12372
12770
|
for (const file of manifest.files) {
|
|
12373
12771
|
if (file.part !== part.filename) continue;
|
|
12374
12772
|
const section = findSection(sections, file.relativePath);
|
|
@@ -12376,6 +12774,7 @@ function auditSnapshot(options) {
|
|
|
12376
12774
|
bodyProblems.push(file.relativePath + " has no section in " + part.filename);
|
|
12377
12775
|
continue;
|
|
12378
12776
|
}
|
|
12777
|
+
bodyByPath.set(file.relativePath, section.body);
|
|
12379
12778
|
bodiesChecked += 1;
|
|
12380
12779
|
const bytes = Buffer.byteLength(section.body, "utf8");
|
|
12381
12780
|
const bodyLines = section.body === "" ? 0 : section.body.split("\n").length - (section.body.endsWith("\n") ? 1 : 0);
|
|
@@ -12401,6 +12800,198 @@ function auditSnapshot(options) {
|
|
|
12401
12800
|
bodyProblems.length + " file(s) disagree: " + sample(bodyProblems)
|
|
12402
12801
|
)
|
|
12403
12802
|
);
|
|
12803
|
+
const structureProblems = [];
|
|
12804
|
+
let sectionsChecked = 0;
|
|
12805
|
+
for (const part of manifest.parts) {
|
|
12806
|
+
const text2 = partTexts.get(part.filename);
|
|
12807
|
+
const sections = partSections.get(part.filename);
|
|
12808
|
+
if (text2 === void 0 || sections === void 0) continue;
|
|
12809
|
+
const header = /^# Codebase Snapshot Part (\d+) of (\d+)$/m.exec(text2);
|
|
12810
|
+
if (header !== null) {
|
|
12811
|
+
if (Number(header[1]) !== part.index) {
|
|
12812
|
+
structureProblems.push(part.filename + " says part " + header[1] + ", the manifest says " + part.index);
|
|
12813
|
+
}
|
|
12814
|
+
if (Number(header[2]) !== manifest.parts.length) {
|
|
12815
|
+
structureProblems.push(part.filename + " says " + header[2] + " parts, the manifest holds " + manifest.parts.length);
|
|
12816
|
+
}
|
|
12817
|
+
}
|
|
12818
|
+
const filesLine = /^- Files: (\d+)$/m.exec(text2);
|
|
12819
|
+
if (filesLine !== null && Number(filesLine[1]) !== part.fileCount) {
|
|
12820
|
+
structureProblems.push(part.filename + " says " + filesLine[1] + " file(s), the manifest says " + part.fileCount);
|
|
12821
|
+
}
|
|
12822
|
+
const fingerprintLine = /^- Content Fingerprint: (\S+)$/m.exec(text2);
|
|
12823
|
+
if (fingerprintLine !== null && fingerprintLine[1] !== manifest.fingerprint) {
|
|
12824
|
+
structureProblems.push(part.filename + " names a different content fingerprint");
|
|
12825
|
+
}
|
|
12826
|
+
const tokenLine = /^- Estimated Tokens: ~([0-9,]+)$/m.exec(text2);
|
|
12827
|
+
if (tokenLine !== null && Number(tokenLine[1].replace(/,/g, "")) !== part.estimatedTokens) {
|
|
12828
|
+
structureProblems.push(part.filename + " says " + tokenLine[1] + " tokens, the manifest says " + part.estimatedTokens);
|
|
12829
|
+
}
|
|
12830
|
+
if (sections.length !== part.fileCount) {
|
|
12831
|
+
structureProblems.push(part.filename + " holds " + sections.length + " section(s), the manifest says " + part.fileCount);
|
|
12832
|
+
}
|
|
12833
|
+
const expectedAnchors = new Set(part.includedFiles.map((entry) => anchorForPath(entry.relativePath)));
|
|
12834
|
+
for (const section of sections) {
|
|
12835
|
+
if (section.anchor === null || !expectedAnchors.has(section.anchor)) {
|
|
12836
|
+
structureProblems.push(part.filename + " holds a section for " + section.path + ", which the manifest does not list");
|
|
12837
|
+
}
|
|
12838
|
+
}
|
|
12839
|
+
const expectedOrder = part.includedFiles.map((entry) => anchorForPath(entry.relativePath)).join("\n");
|
|
12840
|
+
const actualOrder = sections.map((section) => section.anchor).filter((anchor) => anchor !== null).join("\n");
|
|
12841
|
+
if (actualOrder !== expectedOrder) {
|
|
12842
|
+
structureProblems.push(part.filename + " orders its sections differently than the manifest");
|
|
12843
|
+
}
|
|
12844
|
+
for (const entry of part.includedFiles) {
|
|
12845
|
+
const file = fileByPath.get(entry.relativePath);
|
|
12846
|
+
if (file === void 0) continue;
|
|
12847
|
+
const section = findSection(sections, entry.relativePath);
|
|
12848
|
+
if (section === null) {
|
|
12849
|
+
structureProblems.push(entry.relativePath + " has no section in " + part.filename);
|
|
12850
|
+
continue;
|
|
12851
|
+
}
|
|
12852
|
+
sectionsChecked += 1;
|
|
12853
|
+
if (section.path !== displayPath(entry.relativePath)) {
|
|
12854
|
+
structureProblems.push(entry.relativePath + " is headed " + section.path);
|
|
12855
|
+
}
|
|
12856
|
+
if (section.inclusion !== null && section.inclusion !== file.inclusionMode) {
|
|
12857
|
+
structureProblems.push(entry.relativePath + " declares " + section.inclusion + ", the manifest says " + file.inclusionMode);
|
|
12858
|
+
}
|
|
12859
|
+
if (section.includedLines !== null && section.includedLines !== file.includedLines) {
|
|
12860
|
+
structureProblems.push(entry.relativePath + " declares " + section.includedLines + " line(s), the manifest says " + file.includedLines);
|
|
12861
|
+
}
|
|
12862
|
+
}
|
|
12863
|
+
}
|
|
12864
|
+
checks.push(
|
|
12865
|
+
structureProblems.length === 0 ? check(
|
|
12866
|
+
"markdown.structure",
|
|
12867
|
+
"Every section sits where the manifest says",
|
|
12868
|
+
"critical",
|
|
12869
|
+
"pass",
|
|
12870
|
+
sectionsChecked + " section(s) in " + manifest.parts.length + " part(s) match their heading, metadata and order."
|
|
12871
|
+
) : check(
|
|
12872
|
+
"markdown.structure",
|
|
12873
|
+
"Every section sits where the manifest says",
|
|
12874
|
+
"critical",
|
|
12875
|
+
"fail",
|
|
12876
|
+
structureProblems.length + " structural problem(s): " + sample(structureProblems)
|
|
12877
|
+
)
|
|
12878
|
+
);
|
|
12879
|
+
const packCandidates = [
|
|
12880
|
+
{ key: "fullJson", file: "full-codebase.json", label: "JSON", read: jsonPackBodies },
|
|
12881
|
+
{ key: "fullXml", file: "full-codebase.xml", label: "XML", read: xmlPackBodies },
|
|
12882
|
+
{ key: "fullMarkdown", file: "full-codebase.md", label: "markdown", read: markdownPackBodies }
|
|
12883
|
+
];
|
|
12884
|
+
const packsWanted = packCandidates.filter((pack) => manifest.artifacts?.[pack.key] != null);
|
|
12885
|
+
if (packsWanted.length > 0) {
|
|
12886
|
+
const renderedPaths = new Map(
|
|
12887
|
+
manifest.files.map((file) => [escapeControls(file.relativePath), file.relativePath])
|
|
12888
|
+
);
|
|
12889
|
+
const packProblems = [];
|
|
12890
|
+
let packBodies = 0;
|
|
12891
|
+
let packSkipped = 0;
|
|
12892
|
+
for (const pack of packsWanted) {
|
|
12893
|
+
const text2 = readText2(path27__namespace.join(snapshotDir, pack.file));
|
|
12894
|
+
if (text2 === null) continue;
|
|
12895
|
+
const bodies = pack.read(text2);
|
|
12896
|
+
if (bodies === null) {
|
|
12897
|
+
packProblems.push(pack.file + " could not be read as a file pack");
|
|
12898
|
+
continue;
|
|
12899
|
+
}
|
|
12900
|
+
for (const [entryPath, body] of bodies) {
|
|
12901
|
+
const relativePath = pack.key === "fullMarkdown" ? renderedPaths.get(entryPath) ?? entryPath : entryPath;
|
|
12902
|
+
const file = fileByPath.get(relativePath);
|
|
12903
|
+
if (file === void 0) continue;
|
|
12904
|
+
if (file.inclusionMode === "preview" || file.inclusionMode === "signatures") {
|
|
12905
|
+
packSkipped += 1;
|
|
12906
|
+
continue;
|
|
12907
|
+
}
|
|
12908
|
+
const partBody = bodyByPath.get(relativePath);
|
|
12909
|
+
if (partBody === void 0) continue;
|
|
12910
|
+
packBodies += 1;
|
|
12911
|
+
const normalised = pack.key === "fullMarkdown" ? body : emittedBody(body);
|
|
12912
|
+
if (normalised !== partBody) {
|
|
12913
|
+
packProblems.push(pack.file + ": " + relativePath + " holds a different body");
|
|
12914
|
+
}
|
|
12915
|
+
}
|
|
12916
|
+
}
|
|
12917
|
+
checks.push(
|
|
12918
|
+
packProblems.length === 0 ? check(
|
|
12919
|
+
"packs.bodies",
|
|
12920
|
+
"Every pack body is the body the parts carry",
|
|
12921
|
+
"critical",
|
|
12922
|
+
"pass",
|
|
12923
|
+
packBodies + " full body/bodies match across " + packsWanted.length + " pack(s)" + (packSkipped > 0 ? "; " + packSkipped + " preview/signature body(s) are whole-file by design." : ".")
|
|
12924
|
+
) : check(
|
|
12925
|
+
"packs.bodies",
|
|
12926
|
+
"Every pack body is the body the parts carry",
|
|
12927
|
+
"critical",
|
|
12928
|
+
"fail",
|
|
12929
|
+
packProblems.length + " body/bodies differ: " + sample(packProblems)
|
|
12930
|
+
)
|
|
12931
|
+
);
|
|
12932
|
+
}
|
|
12933
|
+
if (options.deep !== true) {
|
|
12934
|
+
checks.push(
|
|
12935
|
+
check(
|
|
12936
|
+
"fidelity.bodies",
|
|
12937
|
+
"Every full body replays from the source bytes",
|
|
12938
|
+
"critical",
|
|
12939
|
+
"skip",
|
|
12940
|
+
"Run health --deep to replay each full body against the file on disk."
|
|
12941
|
+
)
|
|
12942
|
+
);
|
|
12943
|
+
} else {
|
|
12944
|
+
const replayProblems = [];
|
|
12945
|
+
let replayed = 0;
|
|
12946
|
+
let unreplayable = 0;
|
|
12947
|
+
for (const file of manifest.files) {
|
|
12948
|
+
if (file.inclusionMode !== "full" || file.emptyLinesRemoved === true) {
|
|
12949
|
+
unreplayable += 1;
|
|
12950
|
+
continue;
|
|
12951
|
+
}
|
|
12952
|
+
const body = bodyByPath.get(file.relativePath);
|
|
12953
|
+
if (body === void 0) {
|
|
12954
|
+
unreplayable += 1;
|
|
12955
|
+
continue;
|
|
12956
|
+
}
|
|
12957
|
+
const bytes = readBytes(path27__namespace.join(repoDir, file.relativePath));
|
|
12958
|
+
if (bytes === null || sha256(bytes) !== file.hashSha256) {
|
|
12959
|
+
unreplayable += 1;
|
|
12960
|
+
continue;
|
|
12961
|
+
}
|
|
12962
|
+
const decoded = decodeText(bytes);
|
|
12963
|
+
if (decoded.binary) {
|
|
12964
|
+
replayProblems.push(file.relativePath + " is binary on disk");
|
|
12965
|
+
continue;
|
|
12966
|
+
}
|
|
12967
|
+
const expected = emittedBody(decoded.text);
|
|
12968
|
+
if (expected === body) {
|
|
12969
|
+
replayed += 1;
|
|
12970
|
+
continue;
|
|
12971
|
+
}
|
|
12972
|
+
const line = firstBodyMismatch(expected, body);
|
|
12973
|
+
if (line === null) {
|
|
12974
|
+
replayed += 1;
|
|
12975
|
+
continue;
|
|
12976
|
+
}
|
|
12977
|
+
replayProblems.push(file.relativePath + " line " + line + " is not the source line");
|
|
12978
|
+
}
|
|
12979
|
+
checks.push(
|
|
12980
|
+
replayProblems.length === 0 ? check(
|
|
12981
|
+
"fidelity.bodies",
|
|
12982
|
+
"Every full body replays from the source bytes",
|
|
12983
|
+
"critical",
|
|
12984
|
+
"pass",
|
|
12985
|
+
replayed + " full body/bodies replayed byte-for-byte (redaction allowed); " + unreplayable + " not replayable by design or because the file moved."
|
|
12986
|
+
) : check(
|
|
12987
|
+
"fidelity.bodies",
|
|
12988
|
+
"Every full body replays from the source bytes",
|
|
12989
|
+
"critical",
|
|
12990
|
+
"fail",
|
|
12991
|
+
replayProblems.length + " body/bodies disagree with the source: " + sample(replayProblems)
|
|
12992
|
+
)
|
|
12993
|
+
);
|
|
12994
|
+
}
|
|
12404
12995
|
const indexParent = path27__namespace.dirname(snapshotDir);
|
|
12405
12996
|
const indexPath = path27__namespace.join(indexParent, "WORKSPACE.json");
|
|
12406
12997
|
if (fs24__namespace.existsSync(indexPath)) {
|
|
@@ -12523,13 +13114,15 @@ function auditSnapshot(options) {
|
|
|
12523
13114
|
);
|
|
12524
13115
|
const leakedFrom = [];
|
|
12525
13116
|
let compared = 0;
|
|
13117
|
+
const artifactTexts = readArtifactTexts(snapshotDir);
|
|
13118
|
+
const artifactContains = (token) => artifactTexts.some((text2) => text2.includes(token));
|
|
12526
13119
|
for (const record of skippedSensitive.slice(0, 40)) {
|
|
12527
13120
|
if (record.path.includes("[REDACTED") || compared > 400) continue;
|
|
12528
13121
|
const text2 = readText2(path27__namespace.join(repoDir, record.path));
|
|
12529
13122
|
if (text2 === null) continue;
|
|
12530
13123
|
for (const token of secretTokens(text2)) {
|
|
12531
13124
|
compared += 1;
|
|
12532
|
-
if (
|
|
13125
|
+
if (artifactContains(token)) leakedFrom.push(record.path);
|
|
12533
13126
|
}
|
|
12534
13127
|
}
|
|
12535
13128
|
checks.push(
|
|
@@ -12564,9 +13157,13 @@ function auditSnapshot(options) {
|
|
|
12564
13157
|
)
|
|
12565
13158
|
);
|
|
12566
13159
|
let recomputed = 0;
|
|
13160
|
+
const partTokens = /* @__PURE__ */ new Map();
|
|
12567
13161
|
for (const part of manifest.parts) {
|
|
12568
|
-
const text2 =
|
|
12569
|
-
if (text2
|
|
13162
|
+
const text2 = partTexts.get(part.filename);
|
|
13163
|
+
if (text2 === void 0) continue;
|
|
13164
|
+
const tokens = estimateTokens(text2);
|
|
13165
|
+
partTokens.set(part.filename, tokens);
|
|
13166
|
+
recomputed += tokens;
|
|
12570
13167
|
}
|
|
12571
13168
|
const recorded = manifest.totals.estimatedTokens ?? null;
|
|
12572
13169
|
checks.push(
|
|
@@ -12590,6 +13187,22 @@ function auditSnapshot(options) {
|
|
|
12590
13187
|
"Recorded " + recorded + ", recomputed " + recomputed + ": the manifest no longer describes these parts."
|
|
12591
13188
|
)
|
|
12592
13189
|
);
|
|
13190
|
+
const partSizes = [...partTokens.values()];
|
|
13191
|
+
const largestPart = partSizes.length === 0 ? 0 : Math.max(...partSizes);
|
|
13192
|
+
const largestFile = manifest.files.reduce((largest, file) => {
|
|
13193
|
+
const body = bodyByPath.get(file.relativePath);
|
|
13194
|
+
return body === void 0 ? largest : Math.max(largest, estimateTokens(body));
|
|
13195
|
+
}, 0);
|
|
13196
|
+
const fits = (window) => partSizes.filter((tokens) => tokens <= window).length;
|
|
13197
|
+
checks.push(
|
|
13198
|
+
check(
|
|
13199
|
+
"tokens.fit",
|
|
13200
|
+
"The parts fit a context window",
|
|
13201
|
+
"warning",
|
|
13202
|
+
largestPart > 2e5 || largestFile > 2e5 ? "warn" : "pass",
|
|
13203
|
+
manifest.parts.length + " part(s); largest about " + largestPart + " tokens, " + fits(32e3) + " fit 32k, " + fits(128e3) + " fit 128k, " + fits(2e5) + " fit 200k; largest single file about " + largestFile + " tokens."
|
|
13204
|
+
)
|
|
13205
|
+
);
|
|
12593
13206
|
const overBudget = manifest.parts.filter(
|
|
12594
13207
|
(part) => part.byteSize > manifest.budgets.maxPartBytes
|
|
12595
13208
|
);
|
|
@@ -14448,6 +15061,10 @@ var healthTool = {
|
|
|
14448
15061
|
minimum: 1024,
|
|
14449
15062
|
description: "Cap on the text the secret and host-path scans read (default 8 MB)."
|
|
14450
15063
|
},
|
|
15064
|
+
deep: {
|
|
15065
|
+
type: "boolean",
|
|
15066
|
+
description: "Replay every full body against the source on disk. Slower, and catches a generator that wrote the wrong bytes."
|
|
15067
|
+
},
|
|
14451
15068
|
root: ROOT_PROPERTY,
|
|
14452
15069
|
outDir: OUT_DIR_PROPERTY
|
|
14453
15070
|
},
|
|
@@ -14469,7 +15086,8 @@ var healthTool = {
|
|
|
14469
15086
|
const report2 = auditSnapshot({
|
|
14470
15087
|
snapshotDir: path27__namespace.resolve(workspace.root, workspace.config.outDir),
|
|
14471
15088
|
repoDir: workspace.root,
|
|
14472
|
-
...typeof args.maxScanBytes === "number" ? { maxScanBytes: args.maxScanBytes } : {}
|
|
15089
|
+
...typeof args.maxScanBytes === "number" ? { maxScanBytes: args.maxScanBytes } : {},
|
|
15090
|
+
...args.deep === true ? { deep: true } : {}
|
|
14473
15091
|
});
|
|
14474
15092
|
const lines = [
|
|
14475
15093
|
"Health: " + report2.score + "/100 (" + report2.counts.pass + " passed, " + report2.counts.warn + " warning(s), " + report2.counts.fail + " failed)",
|
|
@@ -15630,7 +16248,7 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
15630
16248
|
],
|
|
15631
16249
|
// The health audit resolves the config only to find the output directory; --strict decides the
|
|
15632
16250
|
// exit code, and every other setting would be a promise the command does not keep.
|
|
15633
|
-
health: ["cwd", "out-dir", "format", "strict", "all-members", "no-update-check", "help"],
|
|
16251
|
+
health: ["cwd", "out-dir", "format", "strict", "all-members", "deep", "no-update-check", "help"],
|
|
15634
16252
|
validate: VALIDATE_OPTIONS,
|
|
15635
16253
|
// `report` reads `manifest.json` and prints what is there; a generation setting would change
|
|
15636
16254
|
// nothing. The seven generation flags used to be listed here and were accepted as silent no-ops
|
|
@@ -15954,7 +16572,7 @@ function buildAgentContract() {
|
|
|
15954
16572
|
{
|
|
15955
16573
|
name: "health",
|
|
15956
16574
|
aliases: [],
|
|
15957
|
-
summary: "Audit a generated snapshot against the repository it describes: manifest shape, part hashes, artifact claims, unmasked secrets in any artifact, values from excluded sensitive files, host paths, the recorded token count and freshness. Exits 0 clean, 1 when a check fails, 2 with --strict when a critical check fails.",
|
|
16575
|
+
summary: "Audit a generated snapshot against the repository it describes: manifest shape, part hashes, artifact claims, summary and report truthfulness, pack bodies, unmasked secrets in any artifact, values from excluded sensitive files, host paths, the recorded token count and freshness; --deep also replays every full body from the source. Exits 0 clean, 1 when a check fails, 2 with --strict when a critical check fails.",
|
|
15958
16576
|
positionals: [],
|
|
15959
16577
|
exits: [0, 1, 2]
|
|
15960
16578
|
},
|
|
@@ -16325,6 +16943,13 @@ function buildAgentContract() {
|
|
|
16325
16943
|
appliesTo: optionAppliesTo("strict"),
|
|
16326
16944
|
summary: "health only: exit 2 when a critical check fails, and 1 when a warning is the only thing left. Without it a critical check exits 1 and warnings exit 0."
|
|
16327
16945
|
},
|
|
16946
|
+
{
|
|
16947
|
+
flag: "--deep",
|
|
16948
|
+
type: "boolean",
|
|
16949
|
+
default: false,
|
|
16950
|
+
appliesTo: optionAppliesTo("deep"),
|
|
16951
|
+
summary: "health only: replay every full body from the source bytes on disk and compare it with the part. The only allowed difference is a redaction marker. Costs one full read of the tree."
|
|
16952
|
+
},
|
|
16328
16953
|
{
|
|
16329
16954
|
flag: "--changed-since",
|
|
16330
16955
|
type: "string",
|
|
@@ -21326,6 +21951,7 @@ var CLI_OPTIONS = {
|
|
|
21326
21951
|
only: { type: "string" },
|
|
21327
21952
|
ignore: { type: "string" },
|
|
21328
21953
|
"all-members": { type: "boolean" },
|
|
21954
|
+
deep: { type: "boolean" },
|
|
21329
21955
|
help: { type: "boolean", short: "h" },
|
|
21330
21956
|
version: { type: "boolean", short: "v" }
|
|
21331
21957
|
};
|
|
@@ -21433,6 +22059,11 @@ Options:
|
|
|
21433
22059
|
--install-hook As for init
|
|
21434
22060
|
--preset / --include / --exclude / --force As for init
|
|
21435
22061
|
|
|
22062
|
+
health only:
|
|
22063
|
+
--strict Treat warnings as failures (exit 2 on a critical failure)
|
|
22064
|
+
--all-members Audit every snapshot a --workspace run wrote
|
|
22065
|
+
--deep Replay every full body against the source on disk
|
|
22066
|
+
|
|
21436
22067
|
skill only:
|
|
21437
22068
|
--install Write the skill into the repository instead of printing
|
|
21438
22069
|
--target <name> claude | cursor | all (default: all)
|
|
@@ -21777,6 +22408,7 @@ function parseCliArgs(argv) {
|
|
|
21777
22408
|
only: values.only === void 0 ? void 0 : String(values.only).split(",").map((item) => item.trim()).filter(Boolean),
|
|
21778
22409
|
ignore: values.ignore === void 0 ? void 0 : String(values.ignore).split(",").map((item) => item.trim()).filter(Boolean),
|
|
21779
22410
|
allMembers: values["all-members"] === true ? true : void 0,
|
|
22411
|
+
deep: values.deep === true ? true : void 0,
|
|
21780
22412
|
budgetTokens: values["budget-tokens"] === void 0 ? void 0 : parsePositiveInteger(values["budget-tokens"], "budget-tokens", 500),
|
|
21781
22413
|
delta: values.delta === void 0 ? void 0 : String(values.delta),
|
|
21782
22414
|
slice: values.slice === void 0 ? void 0 : String(values.slice),
|
|
@@ -22592,7 +23224,11 @@ ${USAGE}
|
|
|
22592
23224
|
return 0;
|
|
22593
23225
|
}
|
|
22594
23226
|
const snapshotDir = path27__namespace.resolve(resolved.cwd, resolved.outDir);
|
|
22595
|
-
const report2 = auditSnapshot({
|
|
23227
|
+
const report2 = auditSnapshot({
|
|
23228
|
+
snapshotDir,
|
|
23229
|
+
repoDir: resolved.cwd,
|
|
23230
|
+
...invocation.deep === true ? { deep: true } : {}
|
|
23231
|
+
});
|
|
22596
23232
|
emit(invocation.format, report2, () => renderHealthText(report2));
|
|
22597
23233
|
if (report2.counts.fail > 0) return invocation.strict === true ? 2 : 1;
|
|
22598
23234
|
if (invocation.strict === true && report2.counts.warn > 0) return 1;
|