codebase-snapshot 0.12.1 → 0.12.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 +44 -0
- package/README.md +1 -1
- package/dist/bin.js +133 -39
- package/dist/{chunk-H4FSGTEW.js → chunk-DEFKIYRZ.js} +116 -38
- package/dist/{chunk-BXWV2OXE.js → chunk-GIWY4HXZ.js} +18 -2
- package/dist/cli.cjs +133 -39
- package/dist/cli.js +3 -3
- package/dist/index.cjs +116 -38
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +82 -3
- package/dist/mcp.js +2 -2
- package/docs/cli.md +3 -3
- package/docs/configuration.md +5 -0
- package/docs/mcp.md +5 -4
- package/package.json +1 -1
|
@@ -1749,7 +1749,23 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
1749
1749
|
const preamble = [];
|
|
1750
1750
|
const sections = [];
|
|
1751
1751
|
let current = null;
|
|
1752
|
+
let fence = null;
|
|
1752
1753
|
for (const line of source.split(/\r?\n/)) {
|
|
1754
|
+
const fenceLine = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
1755
|
+
if (fenceLine) {
|
|
1756
|
+
const marker2 = fenceLine[1];
|
|
1757
|
+
const char = marker2[0];
|
|
1758
|
+
if (fence === null) fence = { char, length: marker2.length };
|
|
1759
|
+
else if (char === fence.char && marker2.length >= fence.length) fence = null;
|
|
1760
|
+
if (current) current.body.push(line);
|
|
1761
|
+
else preamble.push(line);
|
|
1762
|
+
continue;
|
|
1763
|
+
}
|
|
1764
|
+
if (fence !== null) {
|
|
1765
|
+
if (current) current.body.push(line);
|
|
1766
|
+
else preamble.push(line);
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1753
1769
|
const heading = /^##\s+(.+?)\s*$/.exec(line);
|
|
1754
1770
|
if (heading) {
|
|
1755
1771
|
current = { heading: heading[1], body: [] };
|
|
@@ -1761,7 +1777,7 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
1761
1777
|
}
|
|
1762
1778
|
const recognised = {};
|
|
1763
1779
|
const notes = [];
|
|
1764
|
-
const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
|
|
1780
|
+
const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
|
|
1765
1781
|
const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
|
|
1766
1782
|
const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
|
|
1767
1783
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3977,7 +3993,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
3977
3993
|
|
|
3978
3994
|
// src/version.ts
|
|
3979
3995
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
3980
|
-
var GENERATOR_VERSION = "0.12.
|
|
3996
|
+
var GENERATOR_VERSION = "0.12.3";
|
|
3981
3997
|
var SCHEMA_VERSION = "3.0.0";
|
|
3982
3998
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
3983
3999
|
function isOurGeneratorName(name) {
|
|
@@ -5406,6 +5422,7 @@ function resolvePromptTask(value) {
|
|
|
5406
5422
|
'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
|
|
5407
5423
|
);
|
|
5408
5424
|
}
|
|
5425
|
+
var MAX_BRIEF_BYTES = 64 * 1024;
|
|
5409
5426
|
function readConfiguredBrief(cwd, value) {
|
|
5410
5427
|
if (value === void 0 || value === null) return void 0;
|
|
5411
5428
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -5423,6 +5440,12 @@ function readConfiguredBrief(cwd, value) {
|
|
|
5423
5440
|
'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
|
|
5424
5441
|
);
|
|
5425
5442
|
}
|
|
5443
|
+
const bytes = Buffer.byteLength(text2, "utf8");
|
|
5444
|
+
if (bytes > MAX_BRIEF_BYTES) {
|
|
5445
|
+
throw new Error(
|
|
5446
|
+
'brief "' + value + '" is ' + bytes + " bytes; the limit is " + MAX_BRIEF_BYTES + ". Keep it to what a reader can act on, or move the detail into a document the snapshot carries."
|
|
5447
|
+
);
|
|
5448
|
+
}
|
|
5426
5449
|
const parsed = parseOwnerBrief(value, text2);
|
|
5427
5450
|
if (parsed.problems.length > 0) {
|
|
5428
5451
|
throw new Error(
|
|
@@ -6889,6 +6912,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
6889
6912
|
const brief = context.brief;
|
|
6890
6913
|
const wrote = (name) => artifacts?.[name] !== false;
|
|
6891
6914
|
const code = (value) => inlineCode(escapeControls(value));
|
|
6915
|
+
const text2 = (value) => escapeControls(value);
|
|
6892
6916
|
const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
|
|
6893
6917
|
const lines = [
|
|
6894
6918
|
"# PROMPT.md",
|
|
@@ -6907,18 +6931,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
6907
6931
|
"the snapshot is what exists.",
|
|
6908
6932
|
""
|
|
6909
6933
|
];
|
|
6910
|
-
if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
|
|
6934
|
+
if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
|
|
6911
6935
|
lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
|
|
6912
|
-
lines.push(...stakesSection(brief, code));
|
|
6936
|
+
lines.push(...stakesSection(brief, code, text2));
|
|
6913
6937
|
lines.push(...haveSection(wrote), "");
|
|
6914
|
-
lines.push(...whatThisIsSection(overview), "");
|
|
6915
|
-
lines.push(...systemSection(manifest, code, brief), "");
|
|
6916
|
-
lines.push(...historySection(history, brief, code), "");
|
|
6917
|
-
lines.push(...barSection(brief, code), "");
|
|
6938
|
+
lines.push(...whatThisIsSection(overview, text2), "");
|
|
6939
|
+
lines.push(...systemSection(manifest, code, brief, text2), "");
|
|
6940
|
+
lines.push(...historySection(history, brief, code, text2), "");
|
|
6941
|
+
lines.push(...barSection(brief, code, text2), "");
|
|
6918
6942
|
lines.push(...coverageSection(manifest, code, wrote("audit")), "");
|
|
6919
6943
|
lines.push(...answerSection(), "");
|
|
6920
|
-
lines.push(...calibrationSection(brief, code), "");
|
|
6921
|
-
lines.push(...ownerNotesSection(brief, code));
|
|
6944
|
+
lines.push(...calibrationSection(brief, code, text2), "");
|
|
6945
|
+
lines.push(...ownerNotesSection(brief, code, text2));
|
|
6922
6946
|
lines.push(...snapshotSection(manifest, code), "");
|
|
6923
6947
|
lines.push(...deliverySection(manifest, wrote("parts"), slots));
|
|
6924
6948
|
lines.push(
|
|
@@ -6997,10 +7021,10 @@ function haveSection(wrote) {
|
|
|
6997
7021
|
out.push(...bullets);
|
|
6998
7022
|
return out;
|
|
6999
7023
|
}
|
|
7000
|
-
function systemSection(manifest, code, brief) {
|
|
7024
|
+
function systemSection(manifest, code, brief, escape) {
|
|
7001
7025
|
const out = ["## The system", ""];
|
|
7002
7026
|
if (brief?.system !== void 0) {
|
|
7003
|
-
out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
|
|
7027
|
+
out.push(...ownerBlock(brief.system, brief.path, code, escape), "", "What the index records:", "");
|
|
7004
7028
|
}
|
|
7005
7029
|
const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
7006
7030
|
if (layers.length > 0) {
|
|
@@ -7033,9 +7057,17 @@ function systemSection(manifest, code, brief) {
|
|
|
7033
7057
|
);
|
|
7034
7058
|
} else {
|
|
7035
7059
|
const parts = [];
|
|
7036
|
-
if (routes > 0)
|
|
7037
|
-
|
|
7038
|
-
|
|
7060
|
+
if (routes > 0) {
|
|
7061
|
+
parts.push(
|
|
7062
|
+
formatNumber(routes) + (routes === 1 ? " route" : " routes") + ", e.g. " + routesShown.join(", ")
|
|
7063
|
+
);
|
|
7064
|
+
}
|
|
7065
|
+
if (handlers > 0) parts.push(formatNumber(handlers) + (handlers === 1 ? " handler" : " handlers"));
|
|
7066
|
+
if (components > 0) {
|
|
7067
|
+
parts.push(
|
|
7068
|
+
formatNumber(components) + (components === 1 ? " component" : " components") + ", e.g. " + componentsShown.join(", ")
|
|
7069
|
+
);
|
|
7070
|
+
}
|
|
7039
7071
|
out.push("- Surfaces the index found: " + parts.join("; ") + ".");
|
|
7040
7072
|
}
|
|
7041
7073
|
const largest = [...manifest.files].sort((a, b) => b.includedBytes - a.includedBytes).slice(0, MAX_LARGEST_FILES);
|
|
@@ -7052,16 +7084,16 @@ function systemSection(manifest, code, brief) {
|
|
|
7052
7084
|
const allBytes = manifest.files.reduce((total, file) => total + file.includedBytes, 0);
|
|
7053
7085
|
const share = allBytes === 0 ? 0 : Math.round(testBytes / allBytes * 100);
|
|
7054
7086
|
out.push(
|
|
7055
|
-
"- Tests: " + formatNumber(tests.length) + " file
|
|
7087
|
+
"- Tests: " + formatNumber(tests.length) + (tests.length === 1 ? " file, " : " files, ") + share + "% of the included bytes.",
|
|
7056
7088
|
" They are evidence of intent, not of behaviour: a fixture can encode a payload shape the",
|
|
7057
7089
|
" real system never sends."
|
|
7058
7090
|
);
|
|
7059
7091
|
}
|
|
7060
7092
|
return out;
|
|
7061
7093
|
}
|
|
7062
|
-
function historySection(history, brief, code) {
|
|
7094
|
+
function historySection(history, brief, code, escape) {
|
|
7063
7095
|
const out = ["## What came before", ""];
|
|
7064
|
-
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
|
|
7096
|
+
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
|
|
7065
7097
|
if (history.length === 0) {
|
|
7066
7098
|
out.push(
|
|
7067
7099
|
"No history was readable: this is not a git checkout, or git could not be run. Nothing about",
|
|
@@ -7076,14 +7108,14 @@ function historySection(history, brief, code) {
|
|
|
7076
7108
|
""
|
|
7077
7109
|
);
|
|
7078
7110
|
for (const commit of history) {
|
|
7079
|
-
out.push("- " + commit.subject);
|
|
7080
|
-
if (commit.body.length > 0) out.push(" " + commit.body);
|
|
7111
|
+
out.push("- " + escape(commit.subject));
|
|
7112
|
+
if (commit.body.length > 0) out.push(" " + escape(commit.body));
|
|
7081
7113
|
}
|
|
7082
7114
|
return out;
|
|
7083
7115
|
}
|
|
7084
|
-
function barSection(brief, code) {
|
|
7116
|
+
function barSection(brief, code, text2) {
|
|
7085
7117
|
if (brief?.bar !== void 0) {
|
|
7086
|
-
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
|
|
7118
|
+
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
|
|
7087
7119
|
}
|
|
7088
7120
|
return [
|
|
7089
7121
|
"## The bar",
|
|
@@ -7109,8 +7141,11 @@ function coverageSection(manifest, code, auditWritten) {
|
|
|
7109
7141
|
reasons.set(record.reason, (reasons.get(record.reason) ?? 0) + 1);
|
|
7110
7142
|
}
|
|
7111
7143
|
const tally = [...reasons.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([reason, count]) => code(reason) + " " + formatNumber(count)).join(", ");
|
|
7144
|
+
const found = manifest.totals.candidateFiles;
|
|
7145
|
+
const included = manifest.totals.includedFiles;
|
|
7146
|
+
const skipped = manifest.counts.skippedCount;
|
|
7112
7147
|
out.push(
|
|
7113
|
-
"- " + formatNumber(
|
|
7148
|
+
"- " + formatNumber(found) + (found === 1 ? " path was" : " paths were") + " found; " + formatNumber(included) + (included === 1 ? " is" : " are") + " in the parts and " + formatNumber(skipped) + (skipped === 1 ? " was" : " were") + " skipped" + (tally.length > 0 ? " (" + tally + ")" : "") + ".",
|
|
7114
7149
|
" `manifest.skipped[]` names each one and why. An absent path is not a clean path."
|
|
7115
7150
|
);
|
|
7116
7151
|
out.push(...incompleteSection(manifest, code));
|
|
@@ -7142,9 +7177,9 @@ function answerSection() {
|
|
|
7142
7177
|
" the gap you filled by asking instead of guessing."
|
|
7143
7178
|
];
|
|
7144
7179
|
}
|
|
7145
|
-
function calibrationSection(brief, code) {
|
|
7180
|
+
function calibrationSection(brief, code, text2) {
|
|
7146
7181
|
if (brief?.calibration !== void 0) {
|
|
7147
|
-
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
|
|
7182
|
+
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
|
|
7148
7183
|
}
|
|
7149
7184
|
return [
|
|
7150
7185
|
"## Calibration",
|
|
@@ -7202,20 +7237,20 @@ function jobSection(task, hasHistory) {
|
|
|
7202
7237
|
}
|
|
7203
7238
|
return out;
|
|
7204
7239
|
}
|
|
7205
|
-
function stakesSection(brief, code) {
|
|
7240
|
+
function stakesSection(brief, code, text2) {
|
|
7206
7241
|
if (brief?.stakes === void 0) return [];
|
|
7207
|
-
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
|
|
7242
|
+
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
|
|
7208
7243
|
}
|
|
7209
|
-
function whatThisIsSection(overview) {
|
|
7244
|
+
function whatThisIsSection(overview, escape) {
|
|
7210
7245
|
const body = [];
|
|
7211
7246
|
if (overview.description !== void 0) {
|
|
7212
|
-
body.push("- Declared in `package.json`: " + overview.description);
|
|
7247
|
+
body.push("- Declared in `package.json`: " + escape(overview.description));
|
|
7213
7248
|
}
|
|
7214
7249
|
if (overview.summary !== void 0) {
|
|
7215
|
-
body.push("- From the `README.md` first paragraph: " + overview.summary);
|
|
7250
|
+
body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
|
|
7216
7251
|
}
|
|
7217
7252
|
if (overview.releases.length > 0) {
|
|
7218
|
-
body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
|
|
7253
|
+
body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
|
|
7219
7254
|
}
|
|
7220
7255
|
if (body.length === 0) return [];
|
|
7221
7256
|
return [
|
|
@@ -7227,16 +7262,16 @@ function whatThisIsSection(overview) {
|
|
|
7227
7262
|
""
|
|
7228
7263
|
];
|
|
7229
7264
|
}
|
|
7230
|
-
function ownerNotesSection(brief, code) {
|
|
7265
|
+
function ownerNotesSection(brief, code, text2) {
|
|
7231
7266
|
if (brief === void 0 || brief.notes.length === 0) return [];
|
|
7232
7267
|
const out = ["## Owner notes", ""];
|
|
7233
7268
|
for (const note of brief.notes) {
|
|
7234
|
-
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
|
|
7269
|
+
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
|
|
7235
7270
|
}
|
|
7236
7271
|
return out;
|
|
7237
7272
|
}
|
|
7238
|
-
function ownerBlock(
|
|
7239
|
-
return ["> Written by the project owner in " + code(path18) + ", not generated.", "",
|
|
7273
|
+
function ownerBlock(body, path18, code, escape) {
|
|
7274
|
+
return ["> Written by the project owner in " + code(path18) + ", not generated.", "", escape(body)];
|
|
7240
7275
|
}
|
|
7241
7276
|
function snapshotSection(manifest, code) {
|
|
7242
7277
|
const out = ["## This snapshot", ""];
|
|
@@ -8103,6 +8138,32 @@ function describeManifestShapeProblem(value) {
|
|
|
8103
8138
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
8104
8139
|
return 'missing "config" object';
|
|
8105
8140
|
}
|
|
8141
|
+
const recordedConfig = config;
|
|
8142
|
+
const promptTask = recordedConfig.promptTask;
|
|
8143
|
+
if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
|
|
8144
|
+
return '`config.promptTask` must be "audit", "review" or "explain"';
|
|
8145
|
+
}
|
|
8146
|
+
const recordedBrief = recordedConfig.brief;
|
|
8147
|
+
if (recordedBrief !== void 0) {
|
|
8148
|
+
if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
|
|
8149
|
+
return "`config.brief` must be an object";
|
|
8150
|
+
}
|
|
8151
|
+
const briefRecord = recordedBrief;
|
|
8152
|
+
if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
|
|
8153
|
+
return "`config.brief.path` must be a non-empty string";
|
|
8154
|
+
}
|
|
8155
|
+
if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
|
|
8156
|
+
return "`config.brief.digest` must be a sha256 hex digest";
|
|
8157
|
+
}
|
|
8158
|
+
}
|
|
8159
|
+
const recordedSlots = recordedConfig.attachmentSlots;
|
|
8160
|
+
if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
|
|
8161
|
+
return "`config.attachmentSlots` must be a non-negative integer";
|
|
8162
|
+
}
|
|
8163
|
+
const recordedMaxParts = recordedConfig.maxParts;
|
|
8164
|
+
if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
|
|
8165
|
+
return "`config.maxParts` must be a positive integer or null";
|
|
8166
|
+
}
|
|
8106
8167
|
const budgets = candidate.budgets;
|
|
8107
8168
|
if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
|
|
8108
8169
|
return 'missing "budgets" object';
|
|
@@ -8660,6 +8721,20 @@ function validateSnapshot(configInput) {
|
|
|
8660
8721
|
`withDependents: manifest ${Boolean(recorded.withDependents)} vs current ${Boolean(config.withDependents)}`
|
|
8661
8722
|
);
|
|
8662
8723
|
}
|
|
8724
|
+
const recordedTask = recorded.promptTask;
|
|
8725
|
+
if (recordedTask !== void 0 && recordedTask !== config.promptTask) {
|
|
8726
|
+
drift.configMismatches.push(
|
|
8727
|
+
`promptTask: manifest ${String(recordedTask)} vs current ${config.promptTask}`
|
|
8728
|
+
);
|
|
8729
|
+
}
|
|
8730
|
+
const recordedBrief = recorded.brief;
|
|
8731
|
+
const recordedBriefDigest = recordedBrief !== void 0 && typeof recordedBrief.digest === "string" ? recordedBrief.digest : void 0;
|
|
8732
|
+
const currentBriefDigest = config.brief?.digest;
|
|
8733
|
+
if (recordedBriefDigest !== currentBriefDigest) {
|
|
8734
|
+
drift.configMismatches.push(
|
|
8735
|
+
recordedBriefDigest === void 0 ? "brief: none recorded vs current " + String(config.brief?.path) : currentBriefDigest === void 0 ? "brief: manifest " + String(recordedBrief?.path) + " vs current none" : "brief: " + String(recordedBrief?.path) + " changed since this snapshot was generated"
|
|
8736
|
+
);
|
|
8737
|
+
}
|
|
8663
8738
|
const effectiveDiscovery = config.discovery ?? "auto";
|
|
8664
8739
|
const recordedDiscovery = recorded.discovery;
|
|
8665
8740
|
if (recordedDiscovery !== void 0 && recordedDiscovery !== effectiveDiscovery) {
|
|
@@ -9461,7 +9536,7 @@ function describePayloadDiff(before, after, sourceFilesIdentical, secretRules) {
|
|
|
9461
9536
|
if (digestDiffers) {
|
|
9462
9537
|
codes.push("config-digest");
|
|
9463
9538
|
reasons.push(
|
|
9464
|
-
`configuration digest ${shortDigest(digestBefore)} \u2192 ${shortDigest(digestAfter)} (budgets, preview thresholds, redaction rules
|
|
9539
|
+
`configuration digest ${shortDigest(digestBefore)} \u2192 ${shortDigest(digestAfter)} (budgets, preview thresholds, redaction rules, artifact selection, the prompt task and the owner brief all count)`
|
|
9465
9540
|
);
|
|
9466
9541
|
} else if (digestBefore === null || digestAfter === null) {
|
|
9467
9542
|
const missing = digestBefore === null && digestAfter !== null ? "before" : digestAfter === null && digestBefore !== null ? "after" : "both";
|
|
@@ -11439,6 +11514,7 @@ function maskOwnerBrief(brief, secretRules) {
|
|
|
11439
11514
|
const mask = (value) => maskPathText(value, secretRules);
|
|
11440
11515
|
return {
|
|
11441
11516
|
...brief,
|
|
11517
|
+
path: mask(brief.path),
|
|
11442
11518
|
...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
|
|
11443
11519
|
...brief.system === void 0 ? {} : { system: mask(brief.system) },
|
|
11444
11520
|
...brief.history === void 0 ? {} : { history: mask(brief.history) },
|
|
@@ -12602,7 +12678,7 @@ function generateSnapshot(configInput, options) {
|
|
|
12602
12678
|
const shown = previewSummaryPaths.slice(0, ENCODING_PATHS_SHOWN).map((entry) => maskPathText(entry, config.secretRules));
|
|
12603
12679
|
const hidden = previewSummaryPaths.length - ENCODING_PATHS_SHOWN;
|
|
12604
12680
|
warnings.push(
|
|
12605
|
-
`${previewSummaryPaths.length} file
|
|
12681
|
+
`${previewSummaryPaths.length} ${previewSummaryPaths.length === 1 ? "file is" : "files are"} emitted as head/tail previews and were not parsed for a structural summary: ${shown.join(", ")}${hidden > 0 ? ` and ${hidden} more` : ""}. A whole-file summary would describe lines the snapshot does not carry; \`explain <path>\` names the preview budget.`
|
|
12606
12682
|
);
|
|
12607
12683
|
}
|
|
12608
12684
|
if (oversizeSummaryPaths.length > 0) {
|
|
@@ -12712,7 +12788,9 @@ function generateSnapshot(configInput, options) {
|
|
|
12712
12788
|
// configuration drift.
|
|
12713
12789
|
maxParts: config.maxParts ?? null,
|
|
12714
12790
|
promptTask: config.promptTask,
|
|
12715
|
-
|
|
12791
|
+
// The path is user input like every other name in this block: a credential-shaped
|
|
12792
|
+
// directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
|
|
12793
|
+
...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
|
|
12716
12794
|
discovery: config.discovery ?? "auto",
|
|
12717
12795
|
// A changed-files scope decides which files are in the snapshot, so the manifest that
|
|
12718
12796
|
// describes the run has to name it.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-
|
|
1
|
+
import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-DEFKIYRZ.js';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
|
|
@@ -1919,7 +1919,7 @@ function buildAgentContract() {
|
|
|
1919
1919
|
type: "string",
|
|
1920
1920
|
default: "unset",
|
|
1921
1921
|
appliesTo: optionAppliesTo("brief"),
|
|
1922
|
-
summary: "Path to the owner-written half of PROMPT.md: Stakes, The system, What came before, The bar and Calibration replace or extend the generated prose; any other heading is kept as Owner notes. The measured headings cannot be redefined. A missing file is an error and an edited file is config drift."
|
|
1922
|
+
summary: "Path to the owner-written half of PROMPT.md: Stakes, The system, What came before, The bar and Calibration replace or extend the generated prose; any other heading is kept as Owner notes. The measured headings cannot be redefined; fenced code is content, not headings. The file is capped at 64 KiB. A missing file is an error and an edited file is config drift."
|
|
1923
1923
|
},
|
|
1924
1924
|
{
|
|
1925
1925
|
flag: "--prompt-task",
|
|
@@ -2439,6 +2439,8 @@ function ensureSingleRead(uri, text, advice) {
|
|
|
2439
2439
|
}
|
|
2440
2440
|
var MANIFEST_ADVICE = "Cutting a JSON document at the limit leaves invalid JSON, so this resource is never truncated. Use the snapshot_locate, snapshot_read and snapshot_status tools instead \u2014 they read the manifest directly \u2014 or read manifest.json from the snapshot directory.";
|
|
2441
2441
|
var PART_ADVICE = "A part cut at the limit is a fragment of a file, not the file. Use snapshot_locate to find the file inside this part that you need, then snapshot_read for a bounded window of it.";
|
|
2442
|
+
var PROMPT_URI = "snapshot://prompt";
|
|
2443
|
+
var PROMPT_ADVICE = "PROMPT.md is written whole and never truncated; regenerate it with snapshot_generate, then read it from the snapshot directory.";
|
|
2442
2444
|
var REPORT_ADVICE = "A report cut at the limit would look complete and would not be. Read it from the snapshot directory instead: the file on disk is complete.";
|
|
2443
2445
|
var PART_URI = /^snapshot:\/\/parts\/(\d+)$/;
|
|
2444
2446
|
var REPORT_URIS = /* @__PURE__ */ new Map([
|
|
@@ -2489,6 +2491,13 @@ function buildResourceProvider() {
|
|
|
2489
2491
|
title: "Agent skill",
|
|
2490
2492
|
description: "Usage guidance for an agent working with this tool.",
|
|
2491
2493
|
mimeType: "text/markdown"
|
|
2494
|
+
},
|
|
2495
|
+
{
|
|
2496
|
+
uri: PROMPT_URI,
|
|
2497
|
+
name: "prompt",
|
|
2498
|
+
title: "Snapshot brief",
|
|
2499
|
+
description: "The brief for this snapshot: the job, what the snapshot contains, what it omits, the history it was built from and the standard the answer is held to. Read this before the parts; it names which part holds which file.",
|
|
2500
|
+
mimeType: "text/markdown"
|
|
2492
2501
|
}
|
|
2493
2502
|
];
|
|
2494
2503
|
for (const [uri, report] of REPORT_URIS) {
|
|
@@ -2553,6 +2562,13 @@ function buildResourceProvider() {
|
|
|
2553
2562
|
}
|
|
2554
2563
|
const workspace = await workspaceFor(context);
|
|
2555
2564
|
if ("error" in workspace) return null;
|
|
2565
|
+
if (uri === PROMPT_URI) {
|
|
2566
|
+
const text = readFileIfPresent(
|
|
2567
|
+
path.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
2568
|
+
);
|
|
2569
|
+
if (text === null) return null;
|
|
2570
|
+
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, PROMPT_ADVICE) };
|
|
2571
|
+
}
|
|
2556
2572
|
const report = REPORT_URIS.get(uri);
|
|
2557
2573
|
if (report) {
|
|
2558
2574
|
const text = readFileIfPresent(
|