codebase-snapshot 0.12.0 → 0.12.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 +53 -2
- package/README.md +1 -1
- package/dist/bin.js +128 -43
- package/dist/{chunk-6HXDYIJS.js → chunk-74ZAF64D.js} +111 -42
- package/dist/{chunk-5FPYVWP3.js → chunk-BITMWXYS.js} +18 -2
- package/dist/cli.cjs +128 -43
- package/dist/cli.js +3 -3
- package/dist/index.cjs +111 -42
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +68 -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.2";
|
|
3981
3997
|
var SCHEMA_VERSION = "3.0.0";
|
|
3982
3998
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
3983
3999
|
function isOurGeneratorName(name) {
|
|
@@ -4426,6 +4442,15 @@ function defaultIgnoreReason(relativePath, toolDirNames = DEFAULT_TOOL_DIR_NAMES
|
|
|
4426
4442
|
return null;
|
|
4427
4443
|
}
|
|
4428
4444
|
var COMMIT_BODY_LIMIT = 400;
|
|
4445
|
+
function truncateAtSentence(text2, limit) {
|
|
4446
|
+
if (text2.length <= limit) return text2;
|
|
4447
|
+
const window = text2.slice(0, limit);
|
|
4448
|
+
const sentence = Math.max(window.lastIndexOf(". "), window.lastIndexOf("; "));
|
|
4449
|
+
if (sentence > limit / 3) return window.slice(0, sentence + 1).trim();
|
|
4450
|
+
const space = window.lastIndexOf(" ");
|
|
4451
|
+
if (space > limit / 3) return window.slice(0, space).trim() + "\u2026";
|
|
4452
|
+
return window.trim() + "\u2026";
|
|
4453
|
+
}
|
|
4429
4454
|
function recentCommits(cwd, limit = 10) {
|
|
4430
4455
|
try {
|
|
4431
4456
|
const stdout = childProcess.execFileSync(
|
|
@@ -4444,10 +4469,10 @@ function recentCommits(cwd, limit = 10) {
|
|
|
4444
4469
|
const separator = record.indexOf("");
|
|
4445
4470
|
const subject = separator === -1 ? record : record.slice(0, separator);
|
|
4446
4471
|
const rawBody = separator === -1 ? "" : record.slice(separator + 1);
|
|
4447
|
-
const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ");
|
|
4472
|
+
const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ").replace(/\s*\|\s*/g, " ").replace(/\s+/g, " ").trim();
|
|
4448
4473
|
return {
|
|
4449
4474
|
subject: subject.trim(),
|
|
4450
|
-
body: body
|
|
4475
|
+
body: truncateAtSentence(body, COMMIT_BODY_LIMIT)
|
|
4451
4476
|
};
|
|
4452
4477
|
}).filter((commit) => commit.subject.length > 0);
|
|
4453
4478
|
} catch {
|
|
@@ -5397,6 +5422,7 @@ function resolvePromptTask(value) {
|
|
|
5397
5422
|
'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
|
|
5398
5423
|
);
|
|
5399
5424
|
}
|
|
5425
|
+
var MAX_BRIEF_BYTES = 64 * 1024;
|
|
5400
5426
|
function readConfiguredBrief(cwd, value) {
|
|
5401
5427
|
if (value === void 0 || value === null) return void 0;
|
|
5402
5428
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -5414,6 +5440,12 @@ function readConfiguredBrief(cwd, value) {
|
|
|
5414
5440
|
'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
|
|
5415
5441
|
);
|
|
5416
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
|
+
}
|
|
5417
5449
|
const parsed = parseOwnerBrief(value, text2);
|
|
5418
5450
|
if (parsed.problems.length > 0) {
|
|
5419
5451
|
throw new Error(
|
|
@@ -6880,6 +6912,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
6880
6912
|
const brief = context.brief;
|
|
6881
6913
|
const wrote = (name) => artifacts?.[name] !== false;
|
|
6882
6914
|
const code = (value) => inlineCode(escapeControls(value));
|
|
6915
|
+
const text2 = (value) => escapeControls(value);
|
|
6883
6916
|
const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
|
|
6884
6917
|
const lines = [
|
|
6885
6918
|
"# PROMPT.md",
|
|
@@ -6898,18 +6931,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
6898
6931
|
"the snapshot is what exists.",
|
|
6899
6932
|
""
|
|
6900
6933
|
];
|
|
6901
|
-
if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
|
|
6934
|
+
if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
|
|
6902
6935
|
lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
|
|
6903
|
-
lines.push(...stakesSection(brief, code));
|
|
6936
|
+
lines.push(...stakesSection(brief, code, text2));
|
|
6904
6937
|
lines.push(...haveSection(wrote), "");
|
|
6905
|
-
lines.push(...whatThisIsSection(overview), "");
|
|
6906
|
-
lines.push(...systemSection(manifest, code, brief), "");
|
|
6907
|
-
lines.push(...historySection(history, brief, code), "");
|
|
6908
|
-
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), "");
|
|
6909
6942
|
lines.push(...coverageSection(manifest, code, wrote("audit")), "");
|
|
6910
6943
|
lines.push(...answerSection(), "");
|
|
6911
|
-
lines.push(...calibrationSection(brief, code), "");
|
|
6912
|
-
lines.push(...ownerNotesSection(brief, code));
|
|
6944
|
+
lines.push(...calibrationSection(brief, code, text2), "");
|
|
6945
|
+
lines.push(...ownerNotesSection(brief, code, text2));
|
|
6913
6946
|
lines.push(...snapshotSection(manifest, code), "");
|
|
6914
6947
|
lines.push(...deliverySection(manifest, wrote("parts"), slots));
|
|
6915
6948
|
lines.push(
|
|
@@ -6988,10 +7021,10 @@ function haveSection(wrote) {
|
|
|
6988
7021
|
out.push(...bullets);
|
|
6989
7022
|
return out;
|
|
6990
7023
|
}
|
|
6991
|
-
function systemSection(manifest, code, brief) {
|
|
7024
|
+
function systemSection(manifest, code, brief, escape) {
|
|
6992
7025
|
const out = ["## The system", ""];
|
|
6993
7026
|
if (brief?.system !== void 0) {
|
|
6994
|
-
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:", "");
|
|
6995
7028
|
}
|
|
6996
7029
|
const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
6997
7030
|
if (layers.length > 0) {
|
|
@@ -7050,9 +7083,9 @@ function systemSection(manifest, code, brief) {
|
|
|
7050
7083
|
}
|
|
7051
7084
|
return out;
|
|
7052
7085
|
}
|
|
7053
|
-
function historySection(history, brief, code) {
|
|
7086
|
+
function historySection(history, brief, code, escape) {
|
|
7054
7087
|
const out = ["## What came before", ""];
|
|
7055
|
-
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
|
|
7088
|
+
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
|
|
7056
7089
|
if (history.length === 0) {
|
|
7057
7090
|
out.push(
|
|
7058
7091
|
"No history was readable: this is not a git checkout, or git could not be run. Nothing about",
|
|
@@ -7061,20 +7094,20 @@ function historySection(history, brief, code) {
|
|
|
7061
7094
|
return out;
|
|
7062
7095
|
}
|
|
7063
7096
|
out.push(
|
|
7064
|
-
"The last " + formatNumber(history.length) + " commit
|
|
7065
|
-
"
|
|
7066
|
-
"
|
|
7097
|
+
"The last " + formatNumber(history.length) + " " + (history.length === 1 ? "commit" : "commits") + ", newest first. Subjects and bodies are claims",
|
|
7098
|
+
"by whoever wrote them, not evidence - the code beside them is the evidence. If one of these",
|
|
7099
|
+
"fixes looks incomplete, quote the lines and say which call site it missed.",
|
|
7067
7100
|
""
|
|
7068
7101
|
);
|
|
7069
7102
|
for (const commit of history) {
|
|
7070
|
-
out.push("- " + commit.subject);
|
|
7071
|
-
if (commit.body.length > 0) out.push(" " + commit.body);
|
|
7103
|
+
out.push("- " + escape(commit.subject));
|
|
7104
|
+
if (commit.body.length > 0) out.push(" " + escape(commit.body));
|
|
7072
7105
|
}
|
|
7073
7106
|
return out;
|
|
7074
7107
|
}
|
|
7075
|
-
function barSection(brief, code) {
|
|
7108
|
+
function barSection(brief, code, text2) {
|
|
7076
7109
|
if (brief?.bar !== void 0) {
|
|
7077
|
-
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
|
|
7110
|
+
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
|
|
7078
7111
|
}
|
|
7079
7112
|
return [
|
|
7080
7113
|
"## The bar",
|
|
@@ -7133,9 +7166,9 @@ function answerSection() {
|
|
|
7133
7166
|
" the gap you filled by asking instead of guessing."
|
|
7134
7167
|
];
|
|
7135
7168
|
}
|
|
7136
|
-
function calibrationSection(brief, code) {
|
|
7169
|
+
function calibrationSection(brief, code, text2) {
|
|
7137
7170
|
if (brief?.calibration !== void 0) {
|
|
7138
|
-
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
|
|
7171
|
+
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
|
|
7139
7172
|
}
|
|
7140
7173
|
return [
|
|
7141
7174
|
"## Calibration",
|
|
@@ -7193,20 +7226,20 @@ function jobSection(task, hasHistory) {
|
|
|
7193
7226
|
}
|
|
7194
7227
|
return out;
|
|
7195
7228
|
}
|
|
7196
|
-
function stakesSection(brief, code) {
|
|
7229
|
+
function stakesSection(brief, code, text2) {
|
|
7197
7230
|
if (brief?.stakes === void 0) return [];
|
|
7198
|
-
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
|
|
7231
|
+
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
|
|
7199
7232
|
}
|
|
7200
|
-
function whatThisIsSection(overview) {
|
|
7233
|
+
function whatThisIsSection(overview, escape) {
|
|
7201
7234
|
const body = [];
|
|
7202
7235
|
if (overview.description !== void 0) {
|
|
7203
|
-
body.push("- Declared in `package.json`: " + overview.description);
|
|
7236
|
+
body.push("- Declared in `package.json`: " + escape(overview.description));
|
|
7204
7237
|
}
|
|
7205
7238
|
if (overview.summary !== void 0) {
|
|
7206
|
-
body.push("- From the `README.md` first paragraph: " + overview.summary);
|
|
7239
|
+
body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
|
|
7207
7240
|
}
|
|
7208
7241
|
if (overview.releases.length > 0) {
|
|
7209
|
-
body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
|
|
7242
|
+
body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
|
|
7210
7243
|
}
|
|
7211
7244
|
if (body.length === 0) return [];
|
|
7212
7245
|
return [
|
|
@@ -7218,16 +7251,16 @@ function whatThisIsSection(overview) {
|
|
|
7218
7251
|
""
|
|
7219
7252
|
];
|
|
7220
7253
|
}
|
|
7221
|
-
function ownerNotesSection(brief, code) {
|
|
7254
|
+
function ownerNotesSection(brief, code, text2) {
|
|
7222
7255
|
if (brief === void 0 || brief.notes.length === 0) return [];
|
|
7223
7256
|
const out = ["## Owner notes", ""];
|
|
7224
7257
|
for (const note of brief.notes) {
|
|
7225
|
-
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
|
|
7258
|
+
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
|
|
7226
7259
|
}
|
|
7227
7260
|
return out;
|
|
7228
7261
|
}
|
|
7229
|
-
function ownerBlock(
|
|
7230
|
-
return ["> Written by the project owner in " + code(path18) + ", not generated.", "",
|
|
7262
|
+
function ownerBlock(body, path18, code, escape) {
|
|
7263
|
+
return ["> Written by the project owner in " + code(path18) + ", not generated.", "", escape(body)];
|
|
7231
7264
|
}
|
|
7232
7265
|
function snapshotSection(manifest, code) {
|
|
7233
7266
|
const out = ["## This snapshot", ""];
|
|
@@ -7327,7 +7360,8 @@ function deliverySection(manifest, partsWritten, slots) {
|
|
|
7327
7360
|
);
|
|
7328
7361
|
if (parts > 1) {
|
|
7329
7362
|
out.push(
|
|
7330
|
-
" Either raise `--max-part-bytes` to merge the parts, or set
|
|
7363
|
+
" Either raise `--max-part-bytes` to merge the parts, or set",
|
|
7364
|
+
" `--max-parts " + slots + "` and let the parts grow to the count instead."
|
|
7331
7365
|
);
|
|
7332
7366
|
}
|
|
7333
7367
|
} else {
|
|
@@ -7865,13 +7899,13 @@ function readDescription(cwd) {
|
|
|
7865
7899
|
function readSummary(cwd) {
|
|
7866
7900
|
const raw = readText(path17.join(cwd, "README.md"));
|
|
7867
7901
|
if (raw === null) return {};
|
|
7868
|
-
const
|
|
7902
|
+
const text2 = raw.replace(/<h[1-6][^>]*>[\s\S]*?<\/h[1-6]>/gi, "\n").replace(/<\/(p|div|section|header|footer|li)>/gi, "\n").replace(/<br\s*\/?>/gi, " ").replace(/<[^>]*>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
|
|
7869
7903
|
const paragraph = [];
|
|
7870
|
-
for (const line of
|
|
7904
|
+
for (const line of text2.split(/\r?\n/)) {
|
|
7871
7905
|
const trimmed = line.trim();
|
|
7872
7906
|
if (paragraph.length === 0) {
|
|
7873
7907
|
if (trimmed.length === 0) continue;
|
|
7874
|
-
if (/^#/.test(trimmed) || /^!\[/.test(trimmed) ||
|
|
7908
|
+
if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
|
|
7875
7909
|
if (/^\[[^\]]+\]:/.test(trimmed)) continue;
|
|
7876
7910
|
} else if (trimmed.length === 0 || /^#/.test(trimmed)) {
|
|
7877
7911
|
break;
|
|
@@ -7880,12 +7914,18 @@ function readSummary(cwd) {
|
|
|
7880
7914
|
}
|
|
7881
7915
|
const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
|
|
7882
7916
|
if (summary.length === 0) return {};
|
|
7883
|
-
return { summary: summary
|
|
7917
|
+
return { summary: truncate(summary, SUMMARY_LIMIT) };
|
|
7918
|
+
}
|
|
7919
|
+
function truncate(text2, limit) {
|
|
7920
|
+
if (text2.length <= limit) return text2;
|
|
7921
|
+
const window = text2.slice(0, limit);
|
|
7922
|
+
const space = window.lastIndexOf(" ");
|
|
7923
|
+
return (space > limit / 2 ? window.slice(0, space) : window).trim() + "\u2026";
|
|
7884
7924
|
}
|
|
7885
7925
|
function readReleases(cwd) {
|
|
7886
7926
|
const raw = readText(path17.join(cwd, "CHANGELOG.md"));
|
|
7887
7927
|
if (raw === null) return [];
|
|
7888
|
-
const headings = raw.split(/\r?\n/).
|
|
7928
|
+
const headings = raw.split(/\r?\n/).map((line) => /^##\s+(.+?)\s*$/.exec(line)?.[1]?.trim()).filter((heading) => heading !== void 0 && /^v?\d+\.\d+/.test(heading));
|
|
7889
7929
|
return headings.slice(0, MAX_RELEASES);
|
|
7890
7930
|
}
|
|
7891
7931
|
var LANGUAGE_BY_EXTENSION = {
|
|
@@ -8087,6 +8127,32 @@ function describeManifestShapeProblem(value) {
|
|
|
8087
8127
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
8088
8128
|
return 'missing "config" object';
|
|
8089
8129
|
}
|
|
8130
|
+
const recordedConfig = config;
|
|
8131
|
+
const promptTask = recordedConfig.promptTask;
|
|
8132
|
+
if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
|
|
8133
|
+
return '`config.promptTask` must be "audit", "review" or "explain"';
|
|
8134
|
+
}
|
|
8135
|
+
const recordedBrief = recordedConfig.brief;
|
|
8136
|
+
if (recordedBrief !== void 0) {
|
|
8137
|
+
if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
|
|
8138
|
+
return "`config.brief` must be an object";
|
|
8139
|
+
}
|
|
8140
|
+
const briefRecord = recordedBrief;
|
|
8141
|
+
if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
|
|
8142
|
+
return "`config.brief.path` must be a non-empty string";
|
|
8143
|
+
}
|
|
8144
|
+
if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
|
|
8145
|
+
return "`config.brief.digest` must be a sha256 hex digest";
|
|
8146
|
+
}
|
|
8147
|
+
}
|
|
8148
|
+
const recordedSlots = recordedConfig.attachmentSlots;
|
|
8149
|
+
if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
|
|
8150
|
+
return "`config.attachmentSlots` must be a non-negative integer";
|
|
8151
|
+
}
|
|
8152
|
+
const recordedMaxParts = recordedConfig.maxParts;
|
|
8153
|
+
if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
|
|
8154
|
+
return "`config.maxParts` must be a positive integer or null";
|
|
8155
|
+
}
|
|
8090
8156
|
const budgets = candidate.budgets;
|
|
8091
8157
|
if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
|
|
8092
8158
|
return 'missing "budgets" object';
|
|
@@ -11423,6 +11489,7 @@ function maskOwnerBrief(brief, secretRules) {
|
|
|
11423
11489
|
const mask = (value) => maskPathText(value, secretRules);
|
|
11424
11490
|
return {
|
|
11425
11491
|
...brief,
|
|
11492
|
+
path: mask(brief.path),
|
|
11426
11493
|
...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
|
|
11427
11494
|
...brief.system === void 0 ? {} : { system: mask(brief.system) },
|
|
11428
11495
|
...brief.history === void 0 ? {} : { history: mask(brief.history) },
|
|
@@ -12696,7 +12763,9 @@ function generateSnapshot(configInput, options) {
|
|
|
12696
12763
|
// configuration drift.
|
|
12697
12764
|
maxParts: config.maxParts ?? null,
|
|
12698
12765
|
promptTask: config.promptTask,
|
|
12699
|
-
|
|
12766
|
+
// The path is user input like every other name in this block: a credential-shaped
|
|
12767
|
+
// directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
|
|
12768
|
+
...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
|
|
12700
12769
|
discovery: config.discovery ?? "auto",
|
|
12701
12770
|
// A changed-files scope decides which files are in the snapshot, so the manifest that
|
|
12702
12771
|
// 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-74ZAF64D.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(
|