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
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,50 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
|
+
## 0.12.3
|
|
30
|
+
|
|
31
|
+
A read of what the tool says, rather than what it does.
|
|
32
|
+
|
|
33
|
+
- **Drift named the digest instead of the cause.** Editing the brief produced "the settings differ
|
|
34
|
+
(run generate)" and nothing else. `validate` compares `promptTask` and the brief digest directly
|
|
35
|
+
now: "brief: brief.md changed since this snapshot was generated", and "promptTask: manifest audit
|
|
36
|
+
vs current review". The generic line stays, because it is still true.
|
|
37
|
+
- **The digest explanation was incomplete.** `diff` said the digest covers "budgets, preview
|
|
38
|
+
thresholds, redaction rules and artifact selection"; it also covers the prompt task and the owner
|
|
39
|
+
brief since 0.12.0.
|
|
40
|
+
- **Singular counts read as plurals.** "1 path(s) were found; 1 are in the parts", "1 file(s) are
|
|
41
|
+
emitted as head/tail previews", "1 route(s)", "1 handler(s)", "1 file(s), 39 % of the included
|
|
42
|
+
bytes" - the plural is chosen now, the same way the part plan already did.
|
|
43
|
+
|
|
44
|
+
No behaviour changes beyond the words. Verified: 1 178 tests, 1 170 pass, 0 fail, 8 host skips;
|
|
45
|
+
lint 225 files; every gate clean at 0.12.3.
|
|
46
|
+
## 0.12.2
|
|
47
|
+
|
|
48
|
+
Six defects in the brief, five of them found by attacking it rather than reading it.
|
|
49
|
+
|
|
50
|
+
- **A fenced sample heading was parsed as a section.** A brief that documents the format —
|
|
51
|
+
```` ```markdown ```` then `## Coverage` — was refused for redefining a measured section it never
|
|
52
|
+
defined. Fences are tracked now: content inside one is content, whatever it looks like.
|
|
53
|
+
- **Control characters in reproduced text reached the artifact.** A `NUL` (or a bidi override) in the
|
|
54
|
+
owner brief, a commit body or the README paragraph was written into `PROMPT.md` verbatim. Every
|
|
55
|
+
reproduced string is escaped the same way the rest of the tool escapes them.
|
|
56
|
+
- **`## Stakes:` fell into Owner notes.** A trailing colon is a typo, not a different heading, so the
|
|
57
|
+
canonical form drops trailing punctuation and the stakes render in their section.
|
|
58
|
+
- **The brief had no size limit.** A 240 kB brief produced a 240 kB `PROMPT.md`, which is a second
|
|
59
|
+
codebase rather than instruction. It is capped at 64 KiB, and the error names the size.
|
|
60
|
+
- **`config.brief.path` was recorded unmasked.** Every other user-supplied name in the manifest is
|
|
61
|
+
masked; a credential-shaped directory in the brief path was echoed into `manifest.json` and the
|
|
62
|
+
provenance line of `PROMPT.md`. It goes through the same masking now.
|
|
63
|
+
- **The shape guard ignored the fields added in 0.11 and 0.12.** A manifest with `promptTask: 5`, a
|
|
64
|
+
string `brief`, a negative `attachmentSlots` or `maxParts: 0` was accepted: `report` echoed it and
|
|
65
|
+
`validate` read it as unset. Each is refused by name now.
|
|
66
|
+
|
|
67
|
+
New: `snapshot://prompt` over MCP, so a client can read the brief before it attaches parts instead of
|
|
68
|
+
running the CLI to see it.
|
|
69
|
+
|
|
70
|
+
Everything else is unchanged. `0.12.2` is the same line: no `0.13`, no `1.0.0`.
|
|
71
|
+
|
|
72
|
+
Verified: 1 178 tests, 1 170 pass, 0 fail, 8 host skips; lint 225 files; every gate clean at 0.12.2.
|
|
29
73
|
## 0.12.1
|
|
30
74
|
|
|
31
75
|
Three defects in the facts 0.12.0 printed about a project, found by reading the artifact as the
|
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.3 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.3";
|
|
2195
2195
|
var SCHEMA_VERSION = "3.0.0";
|
|
2196
2196
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2197
2197
|
function isOurGeneratorName(name) {
|
|
@@ -3315,7 +3315,23 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
3315
3315
|
const preamble = [];
|
|
3316
3316
|
const sections = [];
|
|
3317
3317
|
let current = null;
|
|
3318
|
+
let fence = null;
|
|
3318
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
|
+
}
|
|
3319
3335
|
const heading = /^##\s+(.+?)\s*$/.exec(line);
|
|
3320
3336
|
if (heading) {
|
|
3321
3337
|
current = { heading: heading[1], body: [] };
|
|
@@ -3327,7 +3343,7 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
3327
3343
|
}
|
|
3328
3344
|
const recognised = {};
|
|
3329
3345
|
const notes = [];
|
|
3330
|
-
const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
|
|
3346
|
+
const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
|
|
3331
3347
|
const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
|
|
3332
3348
|
const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
|
|
3333
3349
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3871,6 +3887,7 @@ function resolvePromptTask(value) {
|
|
|
3871
3887
|
'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
|
|
3872
3888
|
);
|
|
3873
3889
|
}
|
|
3890
|
+
var MAX_BRIEF_BYTES = 64 * 1024;
|
|
3874
3891
|
function readConfiguredBrief(cwd, value) {
|
|
3875
3892
|
if (value === void 0 || value === null) return void 0;
|
|
3876
3893
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -3888,6 +3905,12 @@ function readConfiguredBrief(cwd, value) {
|
|
|
3888
3905
|
'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
|
|
3889
3906
|
);
|
|
3890
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
|
+
}
|
|
3891
3914
|
const parsed = parseOwnerBrief(value, text2);
|
|
3892
3915
|
if (parsed.problems.length > 0) {
|
|
3893
3916
|
throw new Error(
|
|
@@ -6285,6 +6308,32 @@ function describeManifestShapeProblem(value) {
|
|
|
6285
6308
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
6286
6309
|
return 'missing "config" object';
|
|
6287
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
|
+
}
|
|
6288
6337
|
const budgets = candidate.budgets;
|
|
6289
6338
|
if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
|
|
6290
6339
|
return 'missing "budgets" object';
|
|
@@ -6842,6 +6891,20 @@ function validateSnapshot(configInput) {
|
|
|
6842
6891
|
`withDependents: manifest ${Boolean(recorded.withDependents)} vs current ${Boolean(config.withDependents)}`
|
|
6843
6892
|
);
|
|
6844
6893
|
}
|
|
6894
|
+
const recordedTask = recorded.promptTask;
|
|
6895
|
+
if (recordedTask !== void 0 && recordedTask !== config.promptTask) {
|
|
6896
|
+
drift.configMismatches.push(
|
|
6897
|
+
`promptTask: manifest ${String(recordedTask)} vs current ${config.promptTask}`
|
|
6898
|
+
);
|
|
6899
|
+
}
|
|
6900
|
+
const recordedBrief = recorded.brief;
|
|
6901
|
+
const recordedBriefDigest = recordedBrief !== void 0 && typeof recordedBrief.digest === "string" ? recordedBrief.digest : void 0;
|
|
6902
|
+
const currentBriefDigest = config.brief?.digest;
|
|
6903
|
+
if (recordedBriefDigest !== currentBriefDigest) {
|
|
6904
|
+
drift.configMismatches.push(
|
|
6905
|
+
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"
|
|
6906
|
+
);
|
|
6907
|
+
}
|
|
6845
6908
|
const effectiveDiscovery = config.discovery ?? "auto";
|
|
6846
6909
|
const recordedDiscovery = recorded.discovery;
|
|
6847
6910
|
if (recordedDiscovery !== void 0 && recordedDiscovery !== effectiveDiscovery) {
|
|
@@ -7222,7 +7285,7 @@ function describePayloadDiff(before, after, sourceFilesIdentical, secretRules) {
|
|
|
7222
7285
|
if (digestDiffers) {
|
|
7223
7286
|
codes.push("config-digest");
|
|
7224
7287
|
reasons.push(
|
|
7225
|
-
`configuration digest ${shortDigest(digestBefore)} \u2192 ${shortDigest(digestAfter)} (budgets, preview thresholds, redaction rules
|
|
7288
|
+
`configuration digest ${shortDigest(digestBefore)} \u2192 ${shortDigest(digestAfter)} (budgets, preview thresholds, redaction rules, artifact selection, the prompt task and the owner brief all count)`
|
|
7226
7289
|
);
|
|
7227
7290
|
} else if (digestBefore === null || digestAfter === null) {
|
|
7228
7291
|
const missing = digestBefore === null && digestAfter !== null ? "before" : digestAfter === null && digestBefore !== null ? "after" : "both";
|
|
@@ -9937,6 +10000,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
9937
10000
|
const brief = context.brief;
|
|
9938
10001
|
const wrote = (name) => artifacts?.[name] !== false;
|
|
9939
10002
|
const code = (value) => inlineCode(escapeControls(value));
|
|
10003
|
+
const text2 = (value) => escapeControls(value);
|
|
9940
10004
|
const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
|
|
9941
10005
|
const lines = [
|
|
9942
10006
|
"# PROMPT.md",
|
|
@@ -9955,18 +10019,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
9955
10019
|
"the snapshot is what exists.",
|
|
9956
10020
|
""
|
|
9957
10021
|
];
|
|
9958
|
-
if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
|
|
10022
|
+
if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
|
|
9959
10023
|
lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
|
|
9960
|
-
lines.push(...stakesSection(brief, code));
|
|
10024
|
+
lines.push(...stakesSection(brief, code, text2));
|
|
9961
10025
|
lines.push(...haveSection(wrote), "");
|
|
9962
|
-
lines.push(...whatThisIsSection(overview), "");
|
|
9963
|
-
lines.push(...systemSection(manifest, code, brief), "");
|
|
9964
|
-
lines.push(...historySection(history, brief, code), "");
|
|
9965
|
-
lines.push(...barSection(brief, code), "");
|
|
10026
|
+
lines.push(...whatThisIsSection(overview, text2), "");
|
|
10027
|
+
lines.push(...systemSection(manifest, code, brief, text2), "");
|
|
10028
|
+
lines.push(...historySection(history, brief, code, text2), "");
|
|
10029
|
+
lines.push(...barSection(brief, code, text2), "");
|
|
9966
10030
|
lines.push(...coverageSection(manifest, code, wrote("audit")), "");
|
|
9967
10031
|
lines.push(...answerSection(), "");
|
|
9968
|
-
lines.push(...calibrationSection(brief, code), "");
|
|
9969
|
-
lines.push(...ownerNotesSection(brief, code));
|
|
10032
|
+
lines.push(...calibrationSection(brief, code, text2), "");
|
|
10033
|
+
lines.push(...ownerNotesSection(brief, code, text2));
|
|
9970
10034
|
lines.push(...snapshotSection(manifest, code), "");
|
|
9971
10035
|
lines.push(...deliverySection(manifest, wrote("parts"), slots));
|
|
9972
10036
|
lines.push(
|
|
@@ -10045,10 +10109,10 @@ function haveSection(wrote) {
|
|
|
10045
10109
|
out.push(...bullets);
|
|
10046
10110
|
return out;
|
|
10047
10111
|
}
|
|
10048
|
-
function systemSection(manifest, code, brief) {
|
|
10112
|
+
function systemSection(manifest, code, brief, escape) {
|
|
10049
10113
|
const out = ["## The system", ""];
|
|
10050
10114
|
if (brief?.system !== void 0) {
|
|
10051
|
-
out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
|
|
10115
|
+
out.push(...ownerBlock(brief.system, brief.path, code, escape), "", "What the index records:", "");
|
|
10052
10116
|
}
|
|
10053
10117
|
const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
10054
10118
|
if (layers.length > 0) {
|
|
@@ -10081,9 +10145,17 @@ function systemSection(manifest, code, brief) {
|
|
|
10081
10145
|
);
|
|
10082
10146
|
} else {
|
|
10083
10147
|
const parts = [];
|
|
10084
|
-
if (routes > 0)
|
|
10085
|
-
|
|
10086
|
-
|
|
10148
|
+
if (routes > 0) {
|
|
10149
|
+
parts.push(
|
|
10150
|
+
formatNumber(routes) + (routes === 1 ? " route" : " routes") + ", e.g. " + routesShown.join(", ")
|
|
10151
|
+
);
|
|
10152
|
+
}
|
|
10153
|
+
if (handlers > 0) parts.push(formatNumber(handlers) + (handlers === 1 ? " handler" : " handlers"));
|
|
10154
|
+
if (components > 0) {
|
|
10155
|
+
parts.push(
|
|
10156
|
+
formatNumber(components) + (components === 1 ? " component" : " components") + ", e.g. " + componentsShown.join(", ")
|
|
10157
|
+
);
|
|
10158
|
+
}
|
|
10087
10159
|
out.push("- Surfaces the index found: " + parts.join("; ") + ".");
|
|
10088
10160
|
}
|
|
10089
10161
|
const largest = [...manifest.files].sort((a, b) => b.includedBytes - a.includedBytes).slice(0, MAX_LARGEST_FILES);
|
|
@@ -10100,16 +10172,16 @@ function systemSection(manifest, code, brief) {
|
|
|
10100
10172
|
const allBytes = manifest.files.reduce((total, file) => total + file.includedBytes, 0);
|
|
10101
10173
|
const share = allBytes === 0 ? 0 : Math.round(testBytes / allBytes * 100);
|
|
10102
10174
|
out.push(
|
|
10103
|
-
"- Tests: " + formatNumber(tests.length) + " file
|
|
10175
|
+
"- Tests: " + formatNumber(tests.length) + (tests.length === 1 ? " file, " : " files, ") + share + "% of the included bytes.",
|
|
10104
10176
|
" They are evidence of intent, not of behaviour: a fixture can encode a payload shape the",
|
|
10105
10177
|
" real system never sends."
|
|
10106
10178
|
);
|
|
10107
10179
|
}
|
|
10108
10180
|
return out;
|
|
10109
10181
|
}
|
|
10110
|
-
function historySection(history, brief, code) {
|
|
10182
|
+
function historySection(history, brief, code, escape) {
|
|
10111
10183
|
const out = ["## What came before", ""];
|
|
10112
|
-
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
|
|
10184
|
+
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
|
|
10113
10185
|
if (history.length === 0) {
|
|
10114
10186
|
out.push(
|
|
10115
10187
|
"No history was readable: this is not a git checkout, or git could not be run. Nothing about",
|
|
@@ -10124,14 +10196,14 @@ function historySection(history, brief, code) {
|
|
|
10124
10196
|
""
|
|
10125
10197
|
);
|
|
10126
10198
|
for (const commit of history) {
|
|
10127
|
-
out.push("- " + commit.subject);
|
|
10128
|
-
if (commit.body.length > 0) out.push(" " + commit.body);
|
|
10199
|
+
out.push("- " + escape(commit.subject));
|
|
10200
|
+
if (commit.body.length > 0) out.push(" " + escape(commit.body));
|
|
10129
10201
|
}
|
|
10130
10202
|
return out;
|
|
10131
10203
|
}
|
|
10132
|
-
function barSection(brief, code) {
|
|
10204
|
+
function barSection(brief, code, text2) {
|
|
10133
10205
|
if (brief?.bar !== void 0) {
|
|
10134
|
-
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
|
|
10206
|
+
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
|
|
10135
10207
|
}
|
|
10136
10208
|
return [
|
|
10137
10209
|
"## The bar",
|
|
@@ -10157,8 +10229,11 @@ function coverageSection(manifest, code, auditWritten) {
|
|
|
10157
10229
|
reasons.set(record.reason, (reasons.get(record.reason) ?? 0) + 1);
|
|
10158
10230
|
}
|
|
10159
10231
|
const tally = [...reasons.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([reason, count]) => code(reason) + " " + formatNumber(count)).join(", ");
|
|
10232
|
+
const found = manifest.totals.candidateFiles;
|
|
10233
|
+
const included = manifest.totals.includedFiles;
|
|
10234
|
+
const skipped = manifest.counts.skippedCount;
|
|
10160
10235
|
out.push(
|
|
10161
|
-
"- " + formatNumber(
|
|
10236
|
+
"- " + 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 + ")" : "") + ".",
|
|
10162
10237
|
" `manifest.skipped[]` names each one and why. An absent path is not a clean path."
|
|
10163
10238
|
);
|
|
10164
10239
|
out.push(...incompleteSection(manifest, code));
|
|
@@ -10190,9 +10265,9 @@ function answerSection() {
|
|
|
10190
10265
|
" the gap you filled by asking instead of guessing."
|
|
10191
10266
|
];
|
|
10192
10267
|
}
|
|
10193
|
-
function calibrationSection(brief, code) {
|
|
10268
|
+
function calibrationSection(brief, code, text2) {
|
|
10194
10269
|
if (brief?.calibration !== void 0) {
|
|
10195
|
-
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
|
|
10270
|
+
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
|
|
10196
10271
|
}
|
|
10197
10272
|
return [
|
|
10198
10273
|
"## Calibration",
|
|
@@ -10250,20 +10325,20 @@ function jobSection(task, hasHistory) {
|
|
|
10250
10325
|
}
|
|
10251
10326
|
return out;
|
|
10252
10327
|
}
|
|
10253
|
-
function stakesSection(brief, code) {
|
|
10328
|
+
function stakesSection(brief, code, text2) {
|
|
10254
10329
|
if (brief?.stakes === void 0) return [];
|
|
10255
|
-
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
|
|
10330
|
+
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
|
|
10256
10331
|
}
|
|
10257
|
-
function whatThisIsSection(overview) {
|
|
10332
|
+
function whatThisIsSection(overview, escape) {
|
|
10258
10333
|
const body = [];
|
|
10259
10334
|
if (overview.description !== void 0) {
|
|
10260
|
-
body.push("- Declared in `package.json`: " + overview.description);
|
|
10335
|
+
body.push("- Declared in `package.json`: " + escape(overview.description));
|
|
10261
10336
|
}
|
|
10262
10337
|
if (overview.summary !== void 0) {
|
|
10263
|
-
body.push("- From the `README.md` first paragraph: " + overview.summary);
|
|
10338
|
+
body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
|
|
10264
10339
|
}
|
|
10265
10340
|
if (overview.releases.length > 0) {
|
|
10266
|
-
body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
|
|
10341
|
+
body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
|
|
10267
10342
|
}
|
|
10268
10343
|
if (body.length === 0) return [];
|
|
10269
10344
|
return [
|
|
@@ -10275,16 +10350,16 @@ function whatThisIsSection(overview) {
|
|
|
10275
10350
|
""
|
|
10276
10351
|
];
|
|
10277
10352
|
}
|
|
10278
|
-
function ownerNotesSection(brief, code) {
|
|
10353
|
+
function ownerNotesSection(brief, code, text2) {
|
|
10279
10354
|
if (brief === void 0 || brief.notes.length === 0) return [];
|
|
10280
10355
|
const out = ["## Owner notes", ""];
|
|
10281
10356
|
for (const note of brief.notes) {
|
|
10282
|
-
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
|
|
10357
|
+
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
|
|
10283
10358
|
}
|
|
10284
10359
|
return out;
|
|
10285
10360
|
}
|
|
10286
|
-
function ownerBlock(
|
|
10287
|
-
return ["> Written by the project owner in " + code(path23) + ", not generated.", "",
|
|
10361
|
+
function ownerBlock(body, path23, code, escape) {
|
|
10362
|
+
return ["> Written by the project owner in " + code(path23) + ", not generated.", "", escape(body)];
|
|
10288
10363
|
}
|
|
10289
10364
|
function snapshotSection(manifest, code) {
|
|
10290
10365
|
const out = ["## This snapshot", ""];
|
|
@@ -11463,6 +11538,7 @@ function maskOwnerBrief(brief, secretRules) {
|
|
|
11463
11538
|
const mask = (value) => maskPathText(value, secretRules);
|
|
11464
11539
|
return {
|
|
11465
11540
|
...brief,
|
|
11541
|
+
path: mask(brief.path),
|
|
11466
11542
|
...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
|
|
11467
11543
|
...brief.system === void 0 ? {} : { system: mask(brief.system) },
|
|
11468
11544
|
...brief.history === void 0 ? {} : { history: mask(brief.history) },
|
|
@@ -12626,7 +12702,7 @@ function generateSnapshot(configInput, options) {
|
|
|
12626
12702
|
const shown = previewSummaryPaths.slice(0, ENCODING_PATHS_SHOWN).map((entry) => maskPathText(entry, config.secretRules));
|
|
12627
12703
|
const hidden = previewSummaryPaths.length - ENCODING_PATHS_SHOWN;
|
|
12628
12704
|
warnings.push(
|
|
12629
|
-
`${previewSummaryPaths.length} file
|
|
12705
|
+
`${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.`
|
|
12630
12706
|
);
|
|
12631
12707
|
}
|
|
12632
12708
|
if (oversizeSummaryPaths.length > 0) {
|
|
@@ -12736,7 +12812,9 @@ function generateSnapshot(configInput, options) {
|
|
|
12736
12812
|
// configuration drift.
|
|
12737
12813
|
maxParts: config.maxParts ?? null,
|
|
12738
12814
|
promptTask: config.promptTask,
|
|
12739
|
-
|
|
12815
|
+
// The path is user input like every other name in this block: a credential-shaped
|
|
12816
|
+
// directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
|
|
12817
|
+
...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
|
|
12740
12818
|
discovery: config.discovery ?? "auto",
|
|
12741
12819
|
// A changed-files scope decides which files are in the snapshot, so the manifest that
|
|
12742
12820
|
// describes the run has to name it.
|
|
@@ -14925,7 +15003,7 @@ function buildAgentContract() {
|
|
|
14925
15003
|
type: "string",
|
|
14926
15004
|
default: "unset",
|
|
14927
15005
|
appliesTo: optionAppliesTo("brief"),
|
|
14928
|
-
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."
|
|
15006
|
+
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."
|
|
14929
15007
|
},
|
|
14930
15008
|
{
|
|
14931
15009
|
flag: "--prompt-task",
|
|
@@ -15636,6 +15714,8 @@ function ensureSingleRead(uri, text2, advice) {
|
|
|
15636
15714
|
}
|
|
15637
15715
|
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.";
|
|
15638
15716
|
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.";
|
|
15717
|
+
var PROMPT_URI = "snapshot://prompt";
|
|
15718
|
+
var PROMPT_ADVICE = "PROMPT.md is written whole and never truncated; regenerate it with snapshot_generate, then read it from the snapshot directory.";
|
|
15639
15719
|
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.";
|
|
15640
15720
|
var PART_URI = /^snapshot:\/\/parts\/(\d+)$/;
|
|
15641
15721
|
var REPORT_URIS = /* @__PURE__ */ new Map([
|
|
@@ -15686,6 +15766,13 @@ function buildResourceProvider() {
|
|
|
15686
15766
|
title: "Agent skill",
|
|
15687
15767
|
description: "Usage guidance for an agent working with this tool.",
|
|
15688
15768
|
mimeType: "text/markdown"
|
|
15769
|
+
},
|
|
15770
|
+
{
|
|
15771
|
+
uri: PROMPT_URI,
|
|
15772
|
+
name: "prompt",
|
|
15773
|
+
title: "Snapshot brief",
|
|
15774
|
+
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.",
|
|
15775
|
+
mimeType: "text/markdown"
|
|
15689
15776
|
}
|
|
15690
15777
|
];
|
|
15691
15778
|
for (const [uri, report] of REPORT_URIS) {
|
|
@@ -15750,6 +15837,13 @@ function buildResourceProvider() {
|
|
|
15750
15837
|
}
|
|
15751
15838
|
const workspace = await workspaceFor(context);
|
|
15752
15839
|
if ("error" in workspace) return null;
|
|
15840
|
+
if (uri === PROMPT_URI) {
|
|
15841
|
+
const text2 = readFileIfPresent(
|
|
15842
|
+
path21.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
15843
|
+
);
|
|
15844
|
+
if (text2 === null) return null;
|
|
15845
|
+
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, PROMPT_ADVICE) };
|
|
15846
|
+
}
|
|
15753
15847
|
const report = REPORT_URIS.get(uri);
|
|
15754
15848
|
if (report) {
|
|
15755
15849
|
const text2 = readFileIfPresent(
|