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