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
package/CHANGELOG.md
CHANGED
|
@@ -8,8 +8,11 @@ All notable changes to `codebase-snapshot`.
|
|
|
8
8
|
|
|
9
9
|
This package started its public life as `@ankurhalder/codebase-snapshot`, which reached 4.4.1. It
|
|
10
10
|
moved to the unscoped name and **restarted at 0.9.0**, so the numbers below are not a continuation of
|
|
11
|
-
the old line — `0.9.0` is newer than `4.4.1`, not older.
|
|
12
|
-
|
|
11
|
+
the old line — `0.9.0` is newer than `4.4.1`, not older.
|
|
12
|
+
|
|
13
|
+
The line stays at **`0.12.x`**. Every change ships as a patch release: there is no `0.13`, and
|
|
14
|
+
`1.0.0` is not planned. A feature that would normally justify a minor bump is released as
|
|
15
|
+
`0.12.<n+1>` with the same rigour; the number is not the promise, the entry below is.
|
|
13
16
|
|
|
14
17
|
Two versions exist on the registry that are not releases, and both are deprecated:
|
|
15
18
|
|
|
@@ -23,6 +26,54 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
23
26
|
|
|
24
27
|
---
|
|
25
28
|
|
|
29
|
+
## 0.12.2
|
|
30
|
+
|
|
31
|
+
Six defects in the brief, five of them found by attacking it rather than reading it.
|
|
32
|
+
|
|
33
|
+
- **A fenced sample heading was parsed as a section.** A brief that documents the format —
|
|
34
|
+
```` ```markdown ```` then `## Coverage` — was refused for redefining a measured section it never
|
|
35
|
+
defined. Fences are tracked now: content inside one is content, whatever it looks like.
|
|
36
|
+
- **Control characters in reproduced text reached the artifact.** A `NUL` (or a bidi override) in the
|
|
37
|
+
owner brief, a commit body or the README paragraph was written into `PROMPT.md` verbatim. Every
|
|
38
|
+
reproduced string is escaped the same way the rest of the tool escapes them.
|
|
39
|
+
- **`## Stakes:` fell into Owner notes.** A trailing colon is a typo, not a different heading, so the
|
|
40
|
+
canonical form drops trailing punctuation and the stakes render in their section.
|
|
41
|
+
- **The brief had no size limit.** A 240 kB brief produced a 240 kB `PROMPT.md`, which is a second
|
|
42
|
+
codebase rather than instruction. It is capped at 64 KiB, and the error names the size.
|
|
43
|
+
- **`config.brief.path` was recorded unmasked.** Every other user-supplied name in the manifest is
|
|
44
|
+
masked; a credential-shaped directory in the brief path was echoed into `manifest.json` and the
|
|
45
|
+
provenance line of `PROMPT.md`. It goes through the same masking now.
|
|
46
|
+
- **The shape guard ignored the fields added in 0.11 and 0.12.** A manifest with `promptTask: 5`, a
|
|
47
|
+
string `brief`, a negative `attachmentSlots` or `maxParts: 0` was accepted: `report` echoed it and
|
|
48
|
+
`validate` read it as unset. Each is refused by name now.
|
|
49
|
+
|
|
50
|
+
New: `snapshot://prompt` over MCP, so a client can read the brief before it attaches parts instead of
|
|
51
|
+
running the CLI to see it.
|
|
52
|
+
|
|
53
|
+
Everything else is unchanged. `0.12.2` is the same line: no `0.13`, no `1.0.0`.
|
|
54
|
+
|
|
55
|
+
Verified: 1 178 tests, 1 170 pass, 0 fail, 8 host skips; lint 225 files; every gate clean at 0.12.2.
|
|
56
|
+
## 0.12.1
|
|
57
|
+
|
|
58
|
+
Three defects in the facts 0.12.0 printed about a project, found by reading the artifact as the
|
|
59
|
+
model that receives it:
|
|
60
|
+
|
|
61
|
+
- **The README summary leaked markup.** A centred header wraps the first prose in `<p>` with `<br>`
|
|
62
|
+
and `<code>` inside it, and the brief printed the tags. Markup is now removed before the paragraph
|
|
63
|
+
is found, and heading elements are removed whole — after stripping tags, `<h1>Demo</h1>` became
|
|
64
|
+
the line "Demo", which read as the first paragraph and then ended it at the next blank line, so
|
|
65
|
+
the summary of every such README was its own title.
|
|
66
|
+
- **"Most recent releases" listed prose headings.** `CHANGELOG.md` has a `## A note on version
|
|
67
|
+
numbers`; the brief called it a release. Only version-shaped headings count now.
|
|
68
|
+
- **Commit bodies were cut mid-word.** A 400-character `slice` produced bodies ending in "…and the
|
|
69
|
+
bui…", which reads as a truncated file rather than an edited quotation. They are cut at a sentence
|
|
70
|
+
boundary, fall back to a word boundary, and no longer carry the pipes of a quoted markdown table.
|
|
71
|
+
|
|
72
|
+
Also: "The last 1 commits" is "commit", and two lines that wrapped past 100 columns were reflowed.
|
|
73
|
+
|
|
74
|
+
Nothing else changes; no setting, artifact or manifest field is different.
|
|
75
|
+
|
|
76
|
+
Verified: 1 171 tests, 1 163 pass, 0 fail, 8 host skips; lint 225 files; every gate clean at 0.12.1.
|
|
26
77
|
## 0.12.0
|
|
27
78
|
|
|
28
79
|
The brief stops being only generated. Facts can be proved from the repository; judgement cannot,
|
package/README.md
CHANGED
|
@@ -210,7 +210,7 @@ Everything an agent needs is available as data, and the tool can install its own
|
|
|
210
210
|
```bash
|
|
211
211
|
npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
|
|
212
212
|
npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
|
|
213
|
-
npx -y codebase-snapshot@0.12.
|
|
213
|
+
npx -y codebase-snapshot@0.12.2 mcp # or serve it over MCP
|
|
214
214
|
```
|
|
215
215
|
|
|
216
216
|
An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
|
package/dist/bin.js
CHANGED
|
@@ -2191,7 +2191,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2191
2191
|
|
|
2192
2192
|
// src/version.ts
|
|
2193
2193
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2194
|
-
var GENERATOR_VERSION = "0.12.
|
|
2194
|
+
var GENERATOR_VERSION = "0.12.2";
|
|
2195
2195
|
var SCHEMA_VERSION = "3.0.0";
|
|
2196
2196
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2197
2197
|
function isOurGeneratorName(name) {
|
|
@@ -2640,6 +2640,15 @@ function defaultIgnoreReason(relativePath, toolDirNames = DEFAULT_TOOL_DIR_NAMES
|
|
|
2640
2640
|
return null;
|
|
2641
2641
|
}
|
|
2642
2642
|
var COMMIT_BODY_LIMIT = 400;
|
|
2643
|
+
function truncateAtSentence(text2, limit) {
|
|
2644
|
+
if (text2.length <= limit) return text2;
|
|
2645
|
+
const window = text2.slice(0, limit);
|
|
2646
|
+
const sentence = Math.max(window.lastIndexOf(". "), window.lastIndexOf("; "));
|
|
2647
|
+
if (sentence > limit / 3) return window.slice(0, sentence + 1).trim();
|
|
2648
|
+
const space = window.lastIndexOf(" ");
|
|
2649
|
+
if (space > limit / 3) return window.slice(0, space).trim() + "\u2026";
|
|
2650
|
+
return window.trim() + "\u2026";
|
|
2651
|
+
}
|
|
2643
2652
|
function recentCommits(cwd, limit = 10) {
|
|
2644
2653
|
try {
|
|
2645
2654
|
const stdout = childProcess.execFileSync(
|
|
@@ -2658,10 +2667,10 @@ function recentCommits(cwd, limit = 10) {
|
|
|
2658
2667
|
const separator = record.indexOf("");
|
|
2659
2668
|
const subject = separator === -1 ? record : record.slice(0, separator);
|
|
2660
2669
|
const rawBody = separator === -1 ? "" : record.slice(separator + 1);
|
|
2661
|
-
const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ");
|
|
2670
|
+
const body = rawBody.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).join(" ").replace(/\s*\|\s*/g, " ").replace(/\s+/g, " ").trim();
|
|
2662
2671
|
return {
|
|
2663
2672
|
subject: subject.trim(),
|
|
2664
|
-
body: body
|
|
2673
|
+
body: truncateAtSentence(body, COMMIT_BODY_LIMIT)
|
|
2665
2674
|
};
|
|
2666
2675
|
}).filter((commit) => commit.subject.length > 0);
|
|
2667
2676
|
} catch {
|
|
@@ -3306,7 +3315,23 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
3306
3315
|
const preamble = [];
|
|
3307
3316
|
const sections = [];
|
|
3308
3317
|
let current = null;
|
|
3318
|
+
let fence = null;
|
|
3309
3319
|
for (const line of source.split(/\r?\n/)) {
|
|
3320
|
+
const fenceLine = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
3321
|
+
if (fenceLine) {
|
|
3322
|
+
const marker2 = fenceLine[1];
|
|
3323
|
+
const char = marker2[0];
|
|
3324
|
+
if (fence === null) fence = { char, length: marker2.length };
|
|
3325
|
+
else if (char === fence.char && marker2.length >= fence.length) fence = null;
|
|
3326
|
+
if (current) current.body.push(line);
|
|
3327
|
+
else preamble.push(line);
|
|
3328
|
+
continue;
|
|
3329
|
+
}
|
|
3330
|
+
if (fence !== null) {
|
|
3331
|
+
if (current) current.body.push(line);
|
|
3332
|
+
else preamble.push(line);
|
|
3333
|
+
continue;
|
|
3334
|
+
}
|
|
3310
3335
|
const heading = /^##\s+(.+?)\s*$/.exec(line);
|
|
3311
3336
|
if (heading) {
|
|
3312
3337
|
current = { heading: heading[1], body: [] };
|
|
@@ -3318,7 +3343,7 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
3318
3343
|
}
|
|
3319
3344
|
const recognised = {};
|
|
3320
3345
|
const notes = [];
|
|
3321
|
-
const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
|
|
3346
|
+
const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
|
|
3322
3347
|
const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
|
|
3323
3348
|
const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
|
|
3324
3349
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3862,6 +3887,7 @@ function resolvePromptTask(value) {
|
|
|
3862
3887
|
'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
|
|
3863
3888
|
);
|
|
3864
3889
|
}
|
|
3890
|
+
var MAX_BRIEF_BYTES = 64 * 1024;
|
|
3865
3891
|
function readConfiguredBrief(cwd, value) {
|
|
3866
3892
|
if (value === void 0 || value === null) return void 0;
|
|
3867
3893
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -3879,6 +3905,12 @@ function readConfiguredBrief(cwd, value) {
|
|
|
3879
3905
|
'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
|
|
3880
3906
|
);
|
|
3881
3907
|
}
|
|
3908
|
+
const bytes = Buffer.byteLength(text2, "utf8");
|
|
3909
|
+
if (bytes > MAX_BRIEF_BYTES) {
|
|
3910
|
+
throw new Error(
|
|
3911
|
+
'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."
|
|
3912
|
+
);
|
|
3913
|
+
}
|
|
3882
3914
|
const parsed = parseOwnerBrief(value, text2);
|
|
3883
3915
|
if (parsed.problems.length > 0) {
|
|
3884
3916
|
throw new Error(
|
|
@@ -6276,6 +6308,32 @@ function describeManifestShapeProblem(value) {
|
|
|
6276
6308
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
6277
6309
|
return 'missing "config" object';
|
|
6278
6310
|
}
|
|
6311
|
+
const recordedConfig = config;
|
|
6312
|
+
const promptTask = recordedConfig.promptTask;
|
|
6313
|
+
if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
|
|
6314
|
+
return '`config.promptTask` must be "audit", "review" or "explain"';
|
|
6315
|
+
}
|
|
6316
|
+
const recordedBrief = recordedConfig.brief;
|
|
6317
|
+
if (recordedBrief !== void 0) {
|
|
6318
|
+
if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
|
|
6319
|
+
return "`config.brief` must be an object";
|
|
6320
|
+
}
|
|
6321
|
+
const briefRecord = recordedBrief;
|
|
6322
|
+
if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
|
|
6323
|
+
return "`config.brief.path` must be a non-empty string";
|
|
6324
|
+
}
|
|
6325
|
+
if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
|
|
6326
|
+
return "`config.brief.digest` must be a sha256 hex digest";
|
|
6327
|
+
}
|
|
6328
|
+
}
|
|
6329
|
+
const recordedSlots = recordedConfig.attachmentSlots;
|
|
6330
|
+
if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
|
|
6331
|
+
return "`config.attachmentSlots` must be a non-negative integer";
|
|
6332
|
+
}
|
|
6333
|
+
const recordedMaxParts = recordedConfig.maxParts;
|
|
6334
|
+
if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
|
|
6335
|
+
return "`config.maxParts` must be a positive integer or null";
|
|
6336
|
+
}
|
|
6279
6337
|
const budgets = candidate.budgets;
|
|
6280
6338
|
if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
|
|
6281
6339
|
return 'missing "budgets" object';
|
|
@@ -9928,6 +9986,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
9928
9986
|
const brief = context.brief;
|
|
9929
9987
|
const wrote = (name) => artifacts?.[name] !== false;
|
|
9930
9988
|
const code = (value) => inlineCode(escapeControls(value));
|
|
9989
|
+
const text2 = (value) => escapeControls(value);
|
|
9931
9990
|
const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
|
|
9932
9991
|
const lines = [
|
|
9933
9992
|
"# PROMPT.md",
|
|
@@ -9946,18 +10005,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
9946
10005
|
"the snapshot is what exists.",
|
|
9947
10006
|
""
|
|
9948
10007
|
];
|
|
9949
|
-
if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
|
|
10008
|
+
if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
|
|
9950
10009
|
lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
|
|
9951
|
-
lines.push(...stakesSection(brief, code));
|
|
10010
|
+
lines.push(...stakesSection(brief, code, text2));
|
|
9952
10011
|
lines.push(...haveSection(wrote), "");
|
|
9953
|
-
lines.push(...whatThisIsSection(overview), "");
|
|
9954
|
-
lines.push(...systemSection(manifest, code, brief), "");
|
|
9955
|
-
lines.push(...historySection(history, brief, code), "");
|
|
9956
|
-
lines.push(...barSection(brief, code), "");
|
|
10012
|
+
lines.push(...whatThisIsSection(overview, text2), "");
|
|
10013
|
+
lines.push(...systemSection(manifest, code, brief, text2), "");
|
|
10014
|
+
lines.push(...historySection(history, brief, code, text2), "");
|
|
10015
|
+
lines.push(...barSection(brief, code, text2), "");
|
|
9957
10016
|
lines.push(...coverageSection(manifest, code, wrote("audit")), "");
|
|
9958
10017
|
lines.push(...answerSection(), "");
|
|
9959
|
-
lines.push(...calibrationSection(brief, code), "");
|
|
9960
|
-
lines.push(...ownerNotesSection(brief, code));
|
|
10018
|
+
lines.push(...calibrationSection(brief, code, text2), "");
|
|
10019
|
+
lines.push(...ownerNotesSection(brief, code, text2));
|
|
9961
10020
|
lines.push(...snapshotSection(manifest, code), "");
|
|
9962
10021
|
lines.push(...deliverySection(manifest, wrote("parts"), slots));
|
|
9963
10022
|
lines.push(
|
|
@@ -10036,10 +10095,10 @@ function haveSection(wrote) {
|
|
|
10036
10095
|
out.push(...bullets);
|
|
10037
10096
|
return out;
|
|
10038
10097
|
}
|
|
10039
|
-
function systemSection(manifest, code, brief) {
|
|
10098
|
+
function systemSection(manifest, code, brief, escape) {
|
|
10040
10099
|
const out = ["## The system", ""];
|
|
10041
10100
|
if (brief?.system !== void 0) {
|
|
10042
|
-
out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
|
|
10101
|
+
out.push(...ownerBlock(brief.system, brief.path, code, escape), "", "What the index records:", "");
|
|
10043
10102
|
}
|
|
10044
10103
|
const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
10045
10104
|
if (layers.length > 0) {
|
|
@@ -10098,9 +10157,9 @@ function systemSection(manifest, code, brief) {
|
|
|
10098
10157
|
}
|
|
10099
10158
|
return out;
|
|
10100
10159
|
}
|
|
10101
|
-
function historySection(history, brief, code) {
|
|
10160
|
+
function historySection(history, brief, code, escape) {
|
|
10102
10161
|
const out = ["## What came before", ""];
|
|
10103
|
-
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
|
|
10162
|
+
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
|
|
10104
10163
|
if (history.length === 0) {
|
|
10105
10164
|
out.push(
|
|
10106
10165
|
"No history was readable: this is not a git checkout, or git could not be run. Nothing about",
|
|
@@ -10109,20 +10168,20 @@ function historySection(history, brief, code) {
|
|
|
10109
10168
|
return out;
|
|
10110
10169
|
}
|
|
10111
10170
|
out.push(
|
|
10112
|
-
"The last " + formatNumber(history.length) + " commit
|
|
10113
|
-
"
|
|
10114
|
-
"
|
|
10171
|
+
"The last " + formatNumber(history.length) + " " + (history.length === 1 ? "commit" : "commits") + ", newest first. Subjects and bodies are claims",
|
|
10172
|
+
"by whoever wrote them, not evidence - the code beside them is the evidence. If one of these",
|
|
10173
|
+
"fixes looks incomplete, quote the lines and say which call site it missed.",
|
|
10115
10174
|
""
|
|
10116
10175
|
);
|
|
10117
10176
|
for (const commit of history) {
|
|
10118
|
-
out.push("- " + commit.subject);
|
|
10119
|
-
if (commit.body.length > 0) out.push(" " + commit.body);
|
|
10177
|
+
out.push("- " + escape(commit.subject));
|
|
10178
|
+
if (commit.body.length > 0) out.push(" " + escape(commit.body));
|
|
10120
10179
|
}
|
|
10121
10180
|
return out;
|
|
10122
10181
|
}
|
|
10123
|
-
function barSection(brief, code) {
|
|
10182
|
+
function barSection(brief, code, text2) {
|
|
10124
10183
|
if (brief?.bar !== void 0) {
|
|
10125
|
-
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
|
|
10184
|
+
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
|
|
10126
10185
|
}
|
|
10127
10186
|
return [
|
|
10128
10187
|
"## The bar",
|
|
@@ -10181,9 +10240,9 @@ function answerSection() {
|
|
|
10181
10240
|
" the gap you filled by asking instead of guessing."
|
|
10182
10241
|
];
|
|
10183
10242
|
}
|
|
10184
|
-
function calibrationSection(brief, code) {
|
|
10243
|
+
function calibrationSection(brief, code, text2) {
|
|
10185
10244
|
if (brief?.calibration !== void 0) {
|
|
10186
|
-
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
|
|
10245
|
+
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
|
|
10187
10246
|
}
|
|
10188
10247
|
return [
|
|
10189
10248
|
"## Calibration",
|
|
@@ -10241,20 +10300,20 @@ function jobSection(task, hasHistory) {
|
|
|
10241
10300
|
}
|
|
10242
10301
|
return out;
|
|
10243
10302
|
}
|
|
10244
|
-
function stakesSection(brief, code) {
|
|
10303
|
+
function stakesSection(brief, code, text2) {
|
|
10245
10304
|
if (brief?.stakes === void 0) return [];
|
|
10246
|
-
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
|
|
10305
|
+
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
|
|
10247
10306
|
}
|
|
10248
|
-
function whatThisIsSection(overview) {
|
|
10307
|
+
function whatThisIsSection(overview, escape) {
|
|
10249
10308
|
const body = [];
|
|
10250
10309
|
if (overview.description !== void 0) {
|
|
10251
|
-
body.push("- Declared in `package.json`: " + overview.description);
|
|
10310
|
+
body.push("- Declared in `package.json`: " + escape(overview.description));
|
|
10252
10311
|
}
|
|
10253
10312
|
if (overview.summary !== void 0) {
|
|
10254
|
-
body.push("- From the `README.md` first paragraph: " + overview.summary);
|
|
10313
|
+
body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
|
|
10255
10314
|
}
|
|
10256
10315
|
if (overview.releases.length > 0) {
|
|
10257
|
-
body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
|
|
10316
|
+
body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
|
|
10258
10317
|
}
|
|
10259
10318
|
if (body.length === 0) return [];
|
|
10260
10319
|
return [
|
|
@@ -10266,16 +10325,16 @@ function whatThisIsSection(overview) {
|
|
|
10266
10325
|
""
|
|
10267
10326
|
];
|
|
10268
10327
|
}
|
|
10269
|
-
function ownerNotesSection(brief, code) {
|
|
10328
|
+
function ownerNotesSection(brief, code, text2) {
|
|
10270
10329
|
if (brief === void 0 || brief.notes.length === 0) return [];
|
|
10271
10330
|
const out = ["## Owner notes", ""];
|
|
10272
10331
|
for (const note of brief.notes) {
|
|
10273
|
-
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
|
|
10332
|
+
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
|
|
10274
10333
|
}
|
|
10275
10334
|
return out;
|
|
10276
10335
|
}
|
|
10277
|
-
function ownerBlock(
|
|
10278
|
-
return ["> Written by the project owner in " + code(path23) + ", not generated.", "",
|
|
10336
|
+
function ownerBlock(body, path23, code, escape) {
|
|
10337
|
+
return ["> Written by the project owner in " + code(path23) + ", not generated.", "", escape(body)];
|
|
10279
10338
|
}
|
|
10280
10339
|
function snapshotSection(manifest, code) {
|
|
10281
10340
|
const out = ["## This snapshot", ""];
|
|
@@ -10375,7 +10434,8 @@ function deliverySection(manifest, partsWritten, slots) {
|
|
|
10375
10434
|
);
|
|
10376
10435
|
if (parts > 1) {
|
|
10377
10436
|
out.push(
|
|
10378
|
-
" Either raise `--max-part-bytes` to merge the parts, or set
|
|
10437
|
+
" Either raise `--max-part-bytes` to merge the parts, or set",
|
|
10438
|
+
" `--max-parts " + slots + "` and let the parts grow to the count instead."
|
|
10379
10439
|
);
|
|
10380
10440
|
}
|
|
10381
10441
|
} else {
|
|
@@ -10622,13 +10682,13 @@ function readDescription(cwd) {
|
|
|
10622
10682
|
function readSummary(cwd) {
|
|
10623
10683
|
const raw = readText(path13.join(cwd, "README.md"));
|
|
10624
10684
|
if (raw === null) return {};
|
|
10625
|
-
const
|
|
10685
|
+
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, "'");
|
|
10626
10686
|
const paragraph = [];
|
|
10627
|
-
for (const line of
|
|
10687
|
+
for (const line of text2.split(/\r?\n/)) {
|
|
10628
10688
|
const trimmed = line.trim();
|
|
10629
10689
|
if (paragraph.length === 0) {
|
|
10630
10690
|
if (trimmed.length === 0) continue;
|
|
10631
|
-
if (/^#/.test(trimmed) || /^!\[/.test(trimmed) ||
|
|
10691
|
+
if (/^#/.test(trimmed) || /^!\[/.test(trimmed) || /^[-*|]/.test(trimmed)) continue;
|
|
10632
10692
|
if (/^\[[^\]]+\]:/.test(trimmed)) continue;
|
|
10633
10693
|
} else if (trimmed.length === 0 || /^#/.test(trimmed)) {
|
|
10634
10694
|
break;
|
|
@@ -10637,12 +10697,18 @@ function readSummary(cwd) {
|
|
|
10637
10697
|
}
|
|
10638
10698
|
const summary = paragraph.join(" ").replace(/\s+/g, " ").trim();
|
|
10639
10699
|
if (summary.length === 0) return {};
|
|
10640
|
-
return { summary: summary
|
|
10700
|
+
return { summary: truncate(summary, SUMMARY_LIMIT) };
|
|
10701
|
+
}
|
|
10702
|
+
function truncate(text2, limit) {
|
|
10703
|
+
if (text2.length <= limit) return text2;
|
|
10704
|
+
const window = text2.slice(0, limit);
|
|
10705
|
+
const space = window.lastIndexOf(" ");
|
|
10706
|
+
return (space > limit / 2 ? window.slice(0, space) : window).trim() + "\u2026";
|
|
10641
10707
|
}
|
|
10642
10708
|
function readReleases(cwd) {
|
|
10643
10709
|
const raw = readText(path13.join(cwd, "CHANGELOG.md"));
|
|
10644
10710
|
if (raw === null) return [];
|
|
10645
|
-
const headings = raw.split(/\r?\n/).
|
|
10711
|
+
const headings = raw.split(/\r?\n/).map((line) => /^##\s+(.+?)\s*$/.exec(line)?.[1]?.trim()).filter((heading) => heading !== void 0 && /^v?\d+\.\d+/.test(heading));
|
|
10646
10712
|
return headings.slice(0, MAX_RELEASES);
|
|
10647
10713
|
}
|
|
10648
10714
|
|
|
@@ -11447,6 +11513,7 @@ function maskOwnerBrief(brief, secretRules) {
|
|
|
11447
11513
|
const mask = (value) => maskPathText(value, secretRules);
|
|
11448
11514
|
return {
|
|
11449
11515
|
...brief,
|
|
11516
|
+
path: mask(brief.path),
|
|
11450
11517
|
...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
|
|
11451
11518
|
...brief.system === void 0 ? {} : { system: mask(brief.system) },
|
|
11452
11519
|
...brief.history === void 0 ? {} : { history: mask(brief.history) },
|
|
@@ -12720,7 +12787,9 @@ function generateSnapshot(configInput, options) {
|
|
|
12720
12787
|
// configuration drift.
|
|
12721
12788
|
maxParts: config.maxParts ?? null,
|
|
12722
12789
|
promptTask: config.promptTask,
|
|
12723
|
-
|
|
12790
|
+
// The path is user input like every other name in this block: a credential-shaped
|
|
12791
|
+
// directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
|
|
12792
|
+
...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
|
|
12724
12793
|
discovery: config.discovery ?? "auto",
|
|
12725
12794
|
// A changed-files scope decides which files are in the snapshot, so the manifest that
|
|
12726
12795
|
// describes the run has to name it.
|
|
@@ -14909,7 +14978,7 @@ function buildAgentContract() {
|
|
|
14909
14978
|
type: "string",
|
|
14910
14979
|
default: "unset",
|
|
14911
14980
|
appliesTo: optionAppliesTo("brief"),
|
|
14912
|
-
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."
|
|
14981
|
+
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."
|
|
14913
14982
|
},
|
|
14914
14983
|
{
|
|
14915
14984
|
flag: "--prompt-task",
|
|
@@ -15620,6 +15689,8 @@ function ensureSingleRead(uri, text2, advice) {
|
|
|
15620
15689
|
}
|
|
15621
15690
|
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.";
|
|
15622
15691
|
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.";
|
|
15692
|
+
var PROMPT_URI = "snapshot://prompt";
|
|
15693
|
+
var PROMPT_ADVICE = "PROMPT.md is written whole and never truncated; regenerate it with snapshot_generate, then read it from the snapshot directory.";
|
|
15623
15694
|
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.";
|
|
15624
15695
|
var PART_URI = /^snapshot:\/\/parts\/(\d+)$/;
|
|
15625
15696
|
var REPORT_URIS = /* @__PURE__ */ new Map([
|
|
@@ -15670,6 +15741,13 @@ function buildResourceProvider() {
|
|
|
15670
15741
|
title: "Agent skill",
|
|
15671
15742
|
description: "Usage guidance for an agent working with this tool.",
|
|
15672
15743
|
mimeType: "text/markdown"
|
|
15744
|
+
},
|
|
15745
|
+
{
|
|
15746
|
+
uri: PROMPT_URI,
|
|
15747
|
+
name: "prompt",
|
|
15748
|
+
title: "Snapshot brief",
|
|
15749
|
+
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.",
|
|
15750
|
+
mimeType: "text/markdown"
|
|
15673
15751
|
}
|
|
15674
15752
|
];
|
|
15675
15753
|
for (const [uri, report] of REPORT_URIS) {
|
|
@@ -15734,6 +15812,13 @@ function buildResourceProvider() {
|
|
|
15734
15812
|
}
|
|
15735
15813
|
const workspace = await workspaceFor(context);
|
|
15736
15814
|
if ("error" in workspace) return null;
|
|
15815
|
+
if (uri === PROMPT_URI) {
|
|
15816
|
+
const text2 = readFileIfPresent(
|
|
15817
|
+
path21.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
15818
|
+
);
|
|
15819
|
+
if (text2 === null) return null;
|
|
15820
|
+
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, PROMPT_ADVICE) };
|
|
15821
|
+
}
|
|
15737
15822
|
const report = REPORT_URIS.get(uri);
|
|
15738
15823
|
if (report) {
|
|
15739
15824
|
const text2 = readFileIfPresent(
|