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/dist/index.cjs
CHANGED
|
@@ -1766,7 +1766,23 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
1766
1766
|
const preamble = [];
|
|
1767
1767
|
const sections = [];
|
|
1768
1768
|
let current = null;
|
|
1769
|
+
let fence = null;
|
|
1769
1770
|
for (const line of source.split(/\r?\n/)) {
|
|
1771
|
+
const fenceLine = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
1772
|
+
if (fenceLine) {
|
|
1773
|
+
const marker2 = fenceLine[1];
|
|
1774
|
+
const char = marker2[0];
|
|
1775
|
+
if (fence === null) fence = { char, length: marker2.length };
|
|
1776
|
+
else if (char === fence.char && marker2.length >= fence.length) fence = null;
|
|
1777
|
+
if (current) current.body.push(line);
|
|
1778
|
+
else preamble.push(line);
|
|
1779
|
+
continue;
|
|
1780
|
+
}
|
|
1781
|
+
if (fence !== null) {
|
|
1782
|
+
if (current) current.body.push(line);
|
|
1783
|
+
else preamble.push(line);
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1770
1786
|
const heading = /^##\s+(.+?)\s*$/.exec(line);
|
|
1771
1787
|
if (heading) {
|
|
1772
1788
|
current = { heading: heading[1], body: [] };
|
|
@@ -1778,7 +1794,7 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
1778
1794
|
}
|
|
1779
1795
|
const recognised = {};
|
|
1780
1796
|
const notes = [];
|
|
1781
|
-
const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
|
|
1797
|
+
const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
|
|
1782
1798
|
const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
|
|
1783
1799
|
const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
|
|
1784
1800
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3994,7 +4010,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
3994
4010
|
|
|
3995
4011
|
// src/version.ts
|
|
3996
4012
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
3997
|
-
var GENERATOR_VERSION = "0.12.
|
|
4013
|
+
var GENERATOR_VERSION = "0.12.3";
|
|
3998
4014
|
var SCHEMA_VERSION = "3.0.0";
|
|
3999
4015
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
4000
4016
|
function isOurGeneratorName(name) {
|
|
@@ -5401,6 +5417,7 @@ function resolvePromptTask(value) {
|
|
|
5401
5417
|
'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
|
|
5402
5418
|
);
|
|
5403
5419
|
}
|
|
5420
|
+
var MAX_BRIEF_BYTES = 64 * 1024;
|
|
5404
5421
|
function readConfiguredBrief(cwd, value) {
|
|
5405
5422
|
if (value === void 0 || value === null) return void 0;
|
|
5406
5423
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -5418,6 +5435,12 @@ function readConfiguredBrief(cwd, value) {
|
|
|
5418
5435
|
'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
|
|
5419
5436
|
);
|
|
5420
5437
|
}
|
|
5438
|
+
const bytes = Buffer.byteLength(text2, "utf8");
|
|
5439
|
+
if (bytes > MAX_BRIEF_BYTES) {
|
|
5440
|
+
throw new Error(
|
|
5441
|
+
'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."
|
|
5442
|
+
);
|
|
5443
|
+
}
|
|
5421
5444
|
const parsed = parseOwnerBrief(value, text2);
|
|
5422
5445
|
if (parsed.problems.length > 0) {
|
|
5423
5446
|
throw new Error(
|
|
@@ -6884,6 +6907,7 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
6884
6907
|
const brief = context.brief;
|
|
6885
6908
|
const wrote = (name) => artifacts?.[name] !== false;
|
|
6886
6909
|
const code = (value) => inlineCode(escapeControls(value));
|
|
6910
|
+
const text2 = (value) => escapeControls(value);
|
|
6887
6911
|
const hasOwnerHistory = (brief?.history ?? "").trim().length > 0;
|
|
6888
6912
|
const lines = [
|
|
6889
6913
|
"# PROMPT.md",
|
|
@@ -6902,18 +6926,18 @@ function generatePrompt(manifest, artifacts, context = {}) {
|
|
|
6902
6926
|
"the snapshot is what exists.",
|
|
6903
6927
|
""
|
|
6904
6928
|
];
|
|
6905
|
-
if (brief?.preamble !== void 0) lines.push(brief.preamble, "");
|
|
6929
|
+
if (brief?.preamble !== void 0) lines.push(text2(brief.preamble), "");
|
|
6906
6930
|
lines.push(...jobSection(task, history.length > 0 || hasOwnerHistory), "");
|
|
6907
|
-
lines.push(...stakesSection(brief, code));
|
|
6931
|
+
lines.push(...stakesSection(brief, code, text2));
|
|
6908
6932
|
lines.push(...haveSection(wrote), "");
|
|
6909
|
-
lines.push(...whatThisIsSection(overview), "");
|
|
6910
|
-
lines.push(...systemSection(manifest, code, brief), "");
|
|
6911
|
-
lines.push(...historySection(history, brief, code), "");
|
|
6912
|
-
lines.push(...barSection(brief, code), "");
|
|
6933
|
+
lines.push(...whatThisIsSection(overview, text2), "");
|
|
6934
|
+
lines.push(...systemSection(manifest, code, brief, text2), "");
|
|
6935
|
+
lines.push(...historySection(history, brief, code, text2), "");
|
|
6936
|
+
lines.push(...barSection(brief, code, text2), "");
|
|
6913
6937
|
lines.push(...coverageSection(manifest, code, wrote("audit")), "");
|
|
6914
6938
|
lines.push(...answerSection(), "");
|
|
6915
|
-
lines.push(...calibrationSection(brief, code), "");
|
|
6916
|
-
lines.push(...ownerNotesSection(brief, code));
|
|
6939
|
+
lines.push(...calibrationSection(brief, code, text2), "");
|
|
6940
|
+
lines.push(...ownerNotesSection(brief, code, text2));
|
|
6917
6941
|
lines.push(...snapshotSection(manifest, code), "");
|
|
6918
6942
|
lines.push(...deliverySection(manifest, wrote("parts"), slots));
|
|
6919
6943
|
lines.push(
|
|
@@ -6992,10 +7016,10 @@ function haveSection(wrote) {
|
|
|
6992
7016
|
out.push(...bullets);
|
|
6993
7017
|
return out;
|
|
6994
7018
|
}
|
|
6995
|
-
function systemSection(manifest, code, brief) {
|
|
7019
|
+
function systemSection(manifest, code, brief, escape) {
|
|
6996
7020
|
const out = ["## The system", ""];
|
|
6997
7021
|
if (brief?.system !== void 0) {
|
|
6998
|
-
out.push(...ownerBlock(brief.system, brief.path, code), "", "What the index records:", "");
|
|
7022
|
+
out.push(...ownerBlock(brief.system, brief.path, code, escape), "", "What the index records:", "");
|
|
6999
7023
|
}
|
|
7000
7024
|
const layers = Object.entries(manifest.layers).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
7001
7025
|
if (layers.length > 0) {
|
|
@@ -7028,9 +7052,17 @@ function systemSection(manifest, code, brief) {
|
|
|
7028
7052
|
);
|
|
7029
7053
|
} else {
|
|
7030
7054
|
const parts = [];
|
|
7031
|
-
if (routes > 0)
|
|
7032
|
-
|
|
7033
|
-
|
|
7055
|
+
if (routes > 0) {
|
|
7056
|
+
parts.push(
|
|
7057
|
+
formatNumber(routes) + (routes === 1 ? " route" : " routes") + ", e.g. " + routesShown.join(", ")
|
|
7058
|
+
);
|
|
7059
|
+
}
|
|
7060
|
+
if (handlers > 0) parts.push(formatNumber(handlers) + (handlers === 1 ? " handler" : " handlers"));
|
|
7061
|
+
if (components > 0) {
|
|
7062
|
+
parts.push(
|
|
7063
|
+
formatNumber(components) + (components === 1 ? " component" : " components") + ", e.g. " + componentsShown.join(", ")
|
|
7064
|
+
);
|
|
7065
|
+
}
|
|
7034
7066
|
out.push("- Surfaces the index found: " + parts.join("; ") + ".");
|
|
7035
7067
|
}
|
|
7036
7068
|
const largest = [...manifest.files].sort((a, b) => b.includedBytes - a.includedBytes).slice(0, MAX_LARGEST_FILES);
|
|
@@ -7047,16 +7079,16 @@ function systemSection(manifest, code, brief) {
|
|
|
7047
7079
|
const allBytes = manifest.files.reduce((total, file) => total + file.includedBytes, 0);
|
|
7048
7080
|
const share = allBytes === 0 ? 0 : Math.round(testBytes / allBytes * 100);
|
|
7049
7081
|
out.push(
|
|
7050
|
-
"- Tests: " + formatNumber(tests.length) + " file
|
|
7082
|
+
"- Tests: " + formatNumber(tests.length) + (tests.length === 1 ? " file, " : " files, ") + share + "% of the included bytes.",
|
|
7051
7083
|
" They are evidence of intent, not of behaviour: a fixture can encode a payload shape the",
|
|
7052
7084
|
" real system never sends."
|
|
7053
7085
|
);
|
|
7054
7086
|
}
|
|
7055
7087
|
return out;
|
|
7056
7088
|
}
|
|
7057
|
-
function historySection(history, brief, code) {
|
|
7089
|
+
function historySection(history, brief, code, escape) {
|
|
7058
7090
|
const out = ["## What came before", ""];
|
|
7059
|
-
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code), "");
|
|
7091
|
+
if (brief?.history !== void 0) out.push(...ownerBlock(brief.history, brief.path, code, escape), "");
|
|
7060
7092
|
if (history.length === 0) {
|
|
7061
7093
|
out.push(
|
|
7062
7094
|
"No history was readable: this is not a git checkout, or git could not be run. Nothing about",
|
|
@@ -7071,14 +7103,14 @@ function historySection(history, brief, code) {
|
|
|
7071
7103
|
""
|
|
7072
7104
|
);
|
|
7073
7105
|
for (const commit of history) {
|
|
7074
|
-
out.push("- " + commit.subject);
|
|
7075
|
-
if (commit.body.length > 0) out.push(" " + commit.body);
|
|
7106
|
+
out.push("- " + escape(commit.subject));
|
|
7107
|
+
if (commit.body.length > 0) out.push(" " + escape(commit.body));
|
|
7076
7108
|
}
|
|
7077
7109
|
return out;
|
|
7078
7110
|
}
|
|
7079
|
-
function barSection(brief, code) {
|
|
7111
|
+
function barSection(brief, code, text2) {
|
|
7080
7112
|
if (brief?.bar !== void 0) {
|
|
7081
|
-
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code), ""];
|
|
7113
|
+
return ["## The bar", "", ...ownerBlock(brief.bar, brief.path, code, text2), ""];
|
|
7082
7114
|
}
|
|
7083
7115
|
return [
|
|
7084
7116
|
"## The bar",
|
|
@@ -7104,8 +7136,11 @@ function coverageSection(manifest, code, auditWritten) {
|
|
|
7104
7136
|
reasons.set(record.reason, (reasons.get(record.reason) ?? 0) + 1);
|
|
7105
7137
|
}
|
|
7106
7138
|
const tally = [...reasons.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([reason, count]) => code(reason) + " " + formatNumber(count)).join(", ");
|
|
7139
|
+
const found = manifest.totals.candidateFiles;
|
|
7140
|
+
const included = manifest.totals.includedFiles;
|
|
7141
|
+
const skipped = manifest.counts.skippedCount;
|
|
7107
7142
|
out.push(
|
|
7108
|
-
"- " + formatNumber(
|
|
7143
|
+
"- " + 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 + ")" : "") + ".",
|
|
7109
7144
|
" `manifest.skipped[]` names each one and why. An absent path is not a clean path."
|
|
7110
7145
|
);
|
|
7111
7146
|
out.push(...incompleteSection(manifest, code));
|
|
@@ -7137,9 +7172,9 @@ function answerSection() {
|
|
|
7137
7172
|
" the gap you filled by asking instead of guessing."
|
|
7138
7173
|
];
|
|
7139
7174
|
}
|
|
7140
|
-
function calibrationSection(brief, code) {
|
|
7175
|
+
function calibrationSection(brief, code, text2) {
|
|
7141
7176
|
if (brief?.calibration !== void 0) {
|
|
7142
|
-
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code), ""];
|
|
7177
|
+
return ["## Calibration", "", ...ownerBlock(brief.calibration, brief.path, code, text2), ""];
|
|
7143
7178
|
}
|
|
7144
7179
|
return [
|
|
7145
7180
|
"## Calibration",
|
|
@@ -7197,20 +7232,20 @@ function jobSection(task, hasHistory) {
|
|
|
7197
7232
|
}
|
|
7198
7233
|
return out;
|
|
7199
7234
|
}
|
|
7200
|
-
function stakesSection(brief, code) {
|
|
7235
|
+
function stakesSection(brief, code, text2) {
|
|
7201
7236
|
if (brief?.stakes === void 0) return [];
|
|
7202
|
-
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code), ""];
|
|
7237
|
+
return ["## Stakes", "", ...ownerBlock(brief.stakes, brief.path, code, text2), ""];
|
|
7203
7238
|
}
|
|
7204
|
-
function whatThisIsSection(overview) {
|
|
7239
|
+
function whatThisIsSection(overview, escape) {
|
|
7205
7240
|
const body = [];
|
|
7206
7241
|
if (overview.description !== void 0) {
|
|
7207
|
-
body.push("- Declared in `package.json`: " + overview.description);
|
|
7242
|
+
body.push("- Declared in `package.json`: " + escape(overview.description));
|
|
7208
7243
|
}
|
|
7209
7244
|
if (overview.summary !== void 0) {
|
|
7210
|
-
body.push("- From the `README.md` first paragraph: " + overview.summary);
|
|
7245
|
+
body.push("- From the `README.md` first paragraph: " + escape(overview.summary));
|
|
7211
7246
|
}
|
|
7212
7247
|
if (overview.releases.length > 0) {
|
|
7213
|
-
body.push("- Most recent releases: " + overview.releases.join("; ") + ".");
|
|
7248
|
+
body.push("- Most recent releases: " + overview.releases.map(escape).join("; ") + ".");
|
|
7214
7249
|
}
|
|
7215
7250
|
if (body.length === 0) return [];
|
|
7216
7251
|
return [
|
|
@@ -7222,16 +7257,16 @@ function whatThisIsSection(overview) {
|
|
|
7222
7257
|
""
|
|
7223
7258
|
];
|
|
7224
7259
|
}
|
|
7225
|
-
function ownerNotesSection(brief, code) {
|
|
7260
|
+
function ownerNotesSection(brief, code, text2) {
|
|
7226
7261
|
if (brief === void 0 || brief.notes.length === 0) return [];
|
|
7227
7262
|
const out = ["## Owner notes", ""];
|
|
7228
7263
|
for (const note of brief.notes) {
|
|
7229
|
-
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code), "");
|
|
7264
|
+
out.push("### " + note.heading, "", ...ownerBlock(note.body, brief.path, code, text2), "");
|
|
7230
7265
|
}
|
|
7231
7266
|
return out;
|
|
7232
7267
|
}
|
|
7233
|
-
function ownerBlock(
|
|
7234
|
-
return ["> Written by the project owner in " + code(path18) + ", not generated.", "",
|
|
7268
|
+
function ownerBlock(body, path18, code, escape) {
|
|
7269
|
+
return ["> Written by the project owner in " + code(path18) + ", not generated.", "", escape(body)];
|
|
7235
7270
|
}
|
|
7236
7271
|
function snapshotSection(manifest, code) {
|
|
7237
7272
|
const out = ["## This snapshot", ""];
|
|
@@ -8098,6 +8133,32 @@ function describeManifestShapeProblem(value) {
|
|
|
8098
8133
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
8099
8134
|
return 'missing "config" object';
|
|
8100
8135
|
}
|
|
8136
|
+
const recordedConfig = config;
|
|
8137
|
+
const promptTask = recordedConfig.promptTask;
|
|
8138
|
+
if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
|
|
8139
|
+
return '`config.promptTask` must be "audit", "review" or "explain"';
|
|
8140
|
+
}
|
|
8141
|
+
const recordedBrief = recordedConfig.brief;
|
|
8142
|
+
if (recordedBrief !== void 0) {
|
|
8143
|
+
if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
|
|
8144
|
+
return "`config.brief` must be an object";
|
|
8145
|
+
}
|
|
8146
|
+
const briefRecord = recordedBrief;
|
|
8147
|
+
if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
|
|
8148
|
+
return "`config.brief.path` must be a non-empty string";
|
|
8149
|
+
}
|
|
8150
|
+
if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
|
|
8151
|
+
return "`config.brief.digest` must be a sha256 hex digest";
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
const recordedSlots = recordedConfig.attachmentSlots;
|
|
8155
|
+
if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
|
|
8156
|
+
return "`config.attachmentSlots` must be a non-negative integer";
|
|
8157
|
+
}
|
|
8158
|
+
const recordedMaxParts = recordedConfig.maxParts;
|
|
8159
|
+
if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
|
|
8160
|
+
return "`config.maxParts` must be a positive integer or null";
|
|
8161
|
+
}
|
|
8101
8162
|
const budgets = candidate.budgets;
|
|
8102
8163
|
if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
|
|
8103
8164
|
return 'missing "budgets" object';
|
|
@@ -8655,6 +8716,20 @@ function validateSnapshot(configInput) {
|
|
|
8655
8716
|
`withDependents: manifest ${Boolean(recorded.withDependents)} vs current ${Boolean(config.withDependents)}`
|
|
8656
8717
|
);
|
|
8657
8718
|
}
|
|
8719
|
+
const recordedTask = recorded.promptTask;
|
|
8720
|
+
if (recordedTask !== void 0 && recordedTask !== config.promptTask) {
|
|
8721
|
+
drift.configMismatches.push(
|
|
8722
|
+
`promptTask: manifest ${String(recordedTask)} vs current ${config.promptTask}`
|
|
8723
|
+
);
|
|
8724
|
+
}
|
|
8725
|
+
const recordedBrief = recorded.brief;
|
|
8726
|
+
const recordedBriefDigest = recordedBrief !== void 0 && typeof recordedBrief.digest === "string" ? recordedBrief.digest : void 0;
|
|
8727
|
+
const currentBriefDigest = config.brief?.digest;
|
|
8728
|
+
if (recordedBriefDigest !== currentBriefDigest) {
|
|
8729
|
+
drift.configMismatches.push(
|
|
8730
|
+
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"
|
|
8731
|
+
);
|
|
8732
|
+
}
|
|
8658
8733
|
const effectiveDiscovery = config.discovery ?? "auto";
|
|
8659
8734
|
const recordedDiscovery = recorded.discovery;
|
|
8660
8735
|
if (recordedDiscovery !== void 0 && recordedDiscovery !== effectiveDiscovery) {
|
|
@@ -9456,7 +9531,7 @@ function describePayloadDiff(before, after, sourceFilesIdentical, secretRules) {
|
|
|
9456
9531
|
if (digestDiffers) {
|
|
9457
9532
|
codes.push("config-digest");
|
|
9458
9533
|
reasons.push(
|
|
9459
|
-
`configuration digest ${shortDigest(digestBefore)} \u2192 ${shortDigest(digestAfter)} (budgets, preview thresholds, redaction rules
|
|
9534
|
+
`configuration digest ${shortDigest(digestBefore)} \u2192 ${shortDigest(digestAfter)} (budgets, preview thresholds, redaction rules, artifact selection, the prompt task and the owner brief all count)`
|
|
9460
9535
|
);
|
|
9461
9536
|
} else if (digestBefore === null || digestAfter === null) {
|
|
9462
9537
|
const missing = digestBefore === null && digestAfter !== null ? "before" : digestAfter === null && digestBefore !== null ? "after" : "both";
|
|
@@ -11341,6 +11416,7 @@ function maskOwnerBrief(brief, secretRules) {
|
|
|
11341
11416
|
const mask = (value) => maskPathText(value, secretRules);
|
|
11342
11417
|
return {
|
|
11343
11418
|
...brief,
|
|
11419
|
+
path: mask(brief.path),
|
|
11344
11420
|
...brief.stakes === void 0 ? {} : { stakes: mask(brief.stakes) },
|
|
11345
11421
|
...brief.system === void 0 ? {} : { system: mask(brief.system) },
|
|
11346
11422
|
...brief.history === void 0 ? {} : { history: mask(brief.history) },
|
|
@@ -12504,7 +12580,7 @@ function generateSnapshot(configInput, options) {
|
|
|
12504
12580
|
const shown = previewSummaryPaths.slice(0, ENCODING_PATHS_SHOWN).map((entry) => maskPathText(entry, config.secretRules));
|
|
12505
12581
|
const hidden = previewSummaryPaths.length - ENCODING_PATHS_SHOWN;
|
|
12506
12582
|
warnings.push(
|
|
12507
|
-
`${previewSummaryPaths.length} file
|
|
12583
|
+
`${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.`
|
|
12508
12584
|
);
|
|
12509
12585
|
}
|
|
12510
12586
|
if (oversizeSummaryPaths.length > 0) {
|
|
@@ -12614,7 +12690,9 @@ function generateSnapshot(configInput, options) {
|
|
|
12614
12690
|
// configuration drift.
|
|
12615
12691
|
maxParts: config.maxParts ?? null,
|
|
12616
12692
|
promptTask: config.promptTask,
|
|
12617
|
-
|
|
12693
|
+
// The path is user input like every other name in this block: a credential-shaped
|
|
12694
|
+
// directory in it would otherwise be echoed into the manifest and PROMPT.md unmasked.
|
|
12695
|
+
...config.brief === void 0 ? {} : { brief: { path: maskName(config.brief.path), digest: config.brief.digest } },
|
|
12618
12696
|
discovery: config.discovery ?? "auto",
|
|
12619
12697
|
// A changed-files scope decides which files are in the snapshot, so the manifest that
|
|
12620
12698
|
// describes the run has to name it.
|
package/dist/index.d.cts
CHANGED
|
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
548
548
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
549
549
|
*/
|
|
550
550
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
551
|
-
declare const GENERATOR_VERSION = "0.12.
|
|
551
|
+
declare const GENERATOR_VERSION = "0.12.3";
|
|
552
552
|
/**
|
|
553
553
|
* The manifest and ownership-marker schema this build writes and understands.
|
|
554
554
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
548
548
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
549
549
|
*/
|
|
550
550
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
551
|
-
declare const GENERATOR_VERSION = "0.12.
|
|
551
|
+
declare const GENERATOR_VERSION = "0.12.3";
|
|
552
552
|
/**
|
|
553
553
|
* The manifest and ownership-marker schema this build writes and understands.
|
|
554
554
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-
|
|
1
|
+
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-DEFKIYRZ.js';
|
package/dist/mcp.cjs
CHANGED
|
@@ -294,7 +294,23 @@ function parseOwnerBrief(filePath, text) {
|
|
|
294
294
|
const preamble = [];
|
|
295
295
|
const sections = [];
|
|
296
296
|
let current = null;
|
|
297
|
+
let fence = null;
|
|
297
298
|
for (const line of source.split(/\r?\n/)) {
|
|
299
|
+
const fenceLine = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
300
|
+
if (fenceLine) {
|
|
301
|
+
const marker = fenceLine[1];
|
|
302
|
+
const char = marker[0];
|
|
303
|
+
if (fence === null) fence = { char, length: marker.length };
|
|
304
|
+
else if (char === fence.char && marker.length >= fence.length) fence = null;
|
|
305
|
+
if (current) current.body.push(line);
|
|
306
|
+
else preamble.push(line);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (fence !== null) {
|
|
310
|
+
if (current) current.body.push(line);
|
|
311
|
+
else preamble.push(line);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
298
314
|
const heading = /^##\s+(.+?)\s*$/.exec(line);
|
|
299
315
|
if (heading) {
|
|
300
316
|
current = { heading: heading[1], body: [] };
|
|
@@ -306,7 +322,7 @@ function parseOwnerBrief(filePath, text) {
|
|
|
306
322
|
}
|
|
307
323
|
const recognised = {};
|
|
308
324
|
const notes = [];
|
|
309
|
-
const canonical = (heading) => heading.trim().toLowerCase().replace(/\s+/g, " ");
|
|
325
|
+
const canonical = (heading) => heading.trim().replace(/[:.]+$/, "").trim().toLowerCase().replace(/\s+/g, " ");
|
|
310
326
|
const canonicalOwner = new Map(OWNER_SECTIONS.map((name) => [canonical(name), name]));
|
|
311
327
|
const canonicalReserved = new Set(RESERVED_SECTIONS.map(canonical));
|
|
312
328
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2522,7 +2538,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2522
2538
|
|
|
2523
2539
|
// src/version.ts
|
|
2524
2540
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2525
|
-
var GENERATOR_VERSION = "0.12.
|
|
2541
|
+
var GENERATOR_VERSION = "0.12.3";
|
|
2526
2542
|
var SCHEMA_VERSION = "3.0.0";
|
|
2527
2543
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2528
2544
|
function isOurGeneratorName(name) {
|
|
@@ -3867,6 +3883,7 @@ function resolvePromptTask(value) {
|
|
|
3867
3883
|
'promptTask must be one of "audit", "review" or "explain" (received ' + describeValue2(value) + ")."
|
|
3868
3884
|
);
|
|
3869
3885
|
}
|
|
3886
|
+
var MAX_BRIEF_BYTES = 64 * 1024;
|
|
3870
3887
|
function readConfiguredBrief(cwd, value) {
|
|
3871
3888
|
if (value === void 0 || value === null) return void 0;
|
|
3872
3889
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -3884,6 +3901,12 @@ function readConfiguredBrief(cwd, value) {
|
|
|
3884
3901
|
'brief "' + value + '" could not be read as a file; a snapshot must not ship without the half of the brief the owner wrote.'
|
|
3885
3902
|
);
|
|
3886
3903
|
}
|
|
3904
|
+
const bytes = Buffer.byteLength(text, "utf8");
|
|
3905
|
+
if (bytes > MAX_BRIEF_BYTES) {
|
|
3906
|
+
throw new Error(
|
|
3907
|
+
'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."
|
|
3908
|
+
);
|
|
3909
|
+
}
|
|
3887
3910
|
const parsed = parseOwnerBrief(value, text);
|
|
3888
3911
|
if (parsed.problems.length > 0) {
|
|
3889
3912
|
throw new Error(
|
|
@@ -6418,6 +6441,32 @@ function describeManifestShapeProblem(value) {
|
|
|
6418
6441
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
6419
6442
|
return 'missing "config" object';
|
|
6420
6443
|
}
|
|
6444
|
+
const recordedConfig = config;
|
|
6445
|
+
const promptTask = recordedConfig.promptTask;
|
|
6446
|
+
if (promptTask !== void 0 && promptTask !== "audit" && promptTask !== "review" && promptTask !== "explain") {
|
|
6447
|
+
return '`config.promptTask` must be "audit", "review" or "explain"';
|
|
6448
|
+
}
|
|
6449
|
+
const recordedBrief = recordedConfig.brief;
|
|
6450
|
+
if (recordedBrief !== void 0) {
|
|
6451
|
+
if (!recordedBrief || typeof recordedBrief !== "object" || Array.isArray(recordedBrief)) {
|
|
6452
|
+
return "`config.brief` must be an object";
|
|
6453
|
+
}
|
|
6454
|
+
const briefRecord = recordedBrief;
|
|
6455
|
+
if (typeof briefRecord.path !== "string" || briefRecord.path.length === 0) {
|
|
6456
|
+
return "`config.brief.path` must be a non-empty string";
|
|
6457
|
+
}
|
|
6458
|
+
if (typeof briefRecord.digest !== "string" || !/^[0-9a-f]{64}$/.test(briefRecord.digest)) {
|
|
6459
|
+
return "`config.brief.digest` must be a sha256 hex digest";
|
|
6460
|
+
}
|
|
6461
|
+
}
|
|
6462
|
+
const recordedSlots = recordedConfig.attachmentSlots;
|
|
6463
|
+
if (recordedSlots !== void 0 && (typeof recordedSlots !== "number" || !Number.isSafeInteger(recordedSlots) || recordedSlots < 0)) {
|
|
6464
|
+
return "`config.attachmentSlots` must be a non-negative integer";
|
|
6465
|
+
}
|
|
6466
|
+
const recordedMaxParts = recordedConfig.maxParts;
|
|
6467
|
+
if (recordedMaxParts !== void 0 && recordedMaxParts !== null && (typeof recordedMaxParts !== "number" || !Number.isSafeInteger(recordedMaxParts) || recordedMaxParts < 1)) {
|
|
6468
|
+
return "`config.maxParts` must be a positive integer or null";
|
|
6469
|
+
}
|
|
6421
6470
|
const budgets = candidate.budgets;
|
|
6422
6471
|
if (!budgets || typeof budgets !== "object" || Array.isArray(budgets)) {
|
|
6423
6472
|
return 'missing "budgets" object';
|
|
@@ -6975,6 +7024,20 @@ function validateSnapshot(configInput) {
|
|
|
6975
7024
|
`withDependents: manifest ${Boolean(recorded.withDependents)} vs current ${Boolean(config.withDependents)}`
|
|
6976
7025
|
);
|
|
6977
7026
|
}
|
|
7027
|
+
const recordedTask = recorded.promptTask;
|
|
7028
|
+
if (recordedTask !== void 0 && recordedTask !== config.promptTask) {
|
|
7029
|
+
drift.configMismatches.push(
|
|
7030
|
+
`promptTask: manifest ${String(recordedTask)} vs current ${config.promptTask}`
|
|
7031
|
+
);
|
|
7032
|
+
}
|
|
7033
|
+
const recordedBrief = recorded.brief;
|
|
7034
|
+
const recordedBriefDigest = recordedBrief !== void 0 && typeof recordedBrief.digest === "string" ? recordedBrief.digest : void 0;
|
|
7035
|
+
const currentBriefDigest = config.brief?.digest;
|
|
7036
|
+
if (recordedBriefDigest !== currentBriefDigest) {
|
|
7037
|
+
drift.configMismatches.push(
|
|
7038
|
+
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"
|
|
7039
|
+
);
|
|
7040
|
+
}
|
|
6978
7041
|
const effectiveDiscovery = config.discovery ?? "auto";
|
|
6979
7042
|
const recordedDiscovery = recorded.discovery;
|
|
6980
7043
|
if (recordedDiscovery !== void 0 && recordedDiscovery !== effectiveDiscovery) {
|
|
@@ -9259,7 +9322,7 @@ function buildAgentContract() {
|
|
|
9259
9322
|
type: "string",
|
|
9260
9323
|
default: "unset",
|
|
9261
9324
|
appliesTo: optionAppliesTo("brief"),
|
|
9262
|
-
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."
|
|
9325
|
+
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."
|
|
9263
9326
|
},
|
|
9264
9327
|
{
|
|
9265
9328
|
flag: "--prompt-task",
|
|
@@ -9779,6 +9842,8 @@ function ensureSingleRead(uri, text, advice) {
|
|
|
9779
9842
|
}
|
|
9780
9843
|
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.";
|
|
9781
9844
|
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.";
|
|
9845
|
+
var PROMPT_URI = "snapshot://prompt";
|
|
9846
|
+
var PROMPT_ADVICE = "PROMPT.md is written whole and never truncated; regenerate it with snapshot_generate, then read it from the snapshot directory.";
|
|
9782
9847
|
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.";
|
|
9783
9848
|
var PART_URI = /^snapshot:\/\/parts\/(\d+)$/;
|
|
9784
9849
|
var REPORT_URIS = /* @__PURE__ */ new Map([
|
|
@@ -9829,6 +9894,13 @@ function buildResourceProvider() {
|
|
|
9829
9894
|
title: "Agent skill",
|
|
9830
9895
|
description: "Usage guidance for an agent working with this tool.",
|
|
9831
9896
|
mimeType: "text/markdown"
|
|
9897
|
+
},
|
|
9898
|
+
{
|
|
9899
|
+
uri: PROMPT_URI,
|
|
9900
|
+
name: "prompt",
|
|
9901
|
+
title: "Snapshot brief",
|
|
9902
|
+
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.",
|
|
9903
|
+
mimeType: "text/markdown"
|
|
9832
9904
|
}
|
|
9833
9905
|
];
|
|
9834
9906
|
for (const [uri, report] of REPORT_URIS) {
|
|
@@ -9893,6 +9965,13 @@ function buildResourceProvider() {
|
|
|
9893
9965
|
}
|
|
9894
9966
|
const workspace = await workspaceFor(context);
|
|
9895
9967
|
if ("error" in workspace) return null;
|
|
9968
|
+
if (uri === PROMPT_URI) {
|
|
9969
|
+
const text = readFileIfPresent(
|
|
9970
|
+
path5__namespace.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
9971
|
+
);
|
|
9972
|
+
if (text === null) return null;
|
|
9973
|
+
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, PROMPT_ADVICE) };
|
|
9974
|
+
}
|
|
9896
9975
|
const report = REPORT_URIS.get(uri);
|
|
9897
9976
|
if (report) {
|
|
9898
9977
|
const text = readFileIfPresent(
|
package/dist/mcp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-
|
|
2
|
-
export { generateInWorker } from './chunk-
|
|
1
|
+
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-GIWY4HXZ.js';
|
|
2
|
+
export { generateInWorker } from './chunk-DEFKIYRZ.js';
|
package/docs/cli.md
CHANGED
|
@@ -97,7 +97,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
|
|
|
97
97
|
|
|
98
98
|
```
|
|
99
99
|
📸 Generating snapshot for: /path/to/repo
|
|
100
|
-
Branch: main | Part budget: 300 KB | Generator: 0.12.
|
|
100
|
+
Branch: main | Part budget: 300 KB | Generator: 0.12.3 (project dependency ^0.12.3)
|
|
101
101
|
|
|
102
102
|
✅ Snapshot generated in 0.14s:
|
|
103
103
|
- Tracked files: 121 included of 128 paths found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
|
|
@@ -192,7 +192,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
|
|
|
192
192
|
🚀 Setup for: /path/to/repo
|
|
193
193
|
✅ Created snapshot.config.ts (preset: nextjs)
|
|
194
194
|
Added npm scripts: snapshot, snapshot:validate
|
|
195
|
-
Added devDependency: codebase-snapshot ^0.12.
|
|
195
|
+
Added devDependency: codebase-snapshot ^0.12.3
|
|
196
196
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
197
197
|
⏳ Installing dependencies…
|
|
198
198
|
✅ Installed dependencies (npm install, 2.1s)
|
|
@@ -244,7 +244,7 @@ It also has three side effects on files you own, and it says so when it does the
|
|
|
244
244
|
```
|
|
245
245
|
✅ Created snapshot.config.ts (preset: node-lib)
|
|
246
246
|
Added npm scripts: snapshot, snapshot:validate
|
|
247
|
-
Added devDependency: codebase-snapshot ^0.12.
|
|
247
|
+
Added devDependency: codebase-snapshot ^0.12.3
|
|
248
248
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
249
249
|
```
|
|
250
250
|
|
package/docs/configuration.md
CHANGED
|
@@ -336,6 +336,11 @@ Any other `##` heading is kept, verbatim, under **Owner notes** — nothing is d
|
|
|
336
336
|
merge did not recognise it. Every owner section is marked in the output as written by the project
|
|
337
337
|
owner, so a reader can tell an assertion from a measurement.
|
|
338
338
|
|
|
339
|
+
A brief is capped at 64 KiB: past that it is a second codebase rather than instruction, and
|
|
340
|
+
the error names the size. Text inside a fenced code block is content — a sample `## Coverage` in a
|
|
341
|
+
documentation example is not a section — and `## Stakes:` is read as `## Stakes`, because the
|
|
342
|
+
colon is a typo rather than a different heading.
|
|
343
|
+
|
|
339
344
|
Three things are refused because they would make the document lie:
|
|
340
345
|
|
|
341
346
|
- a heading that redefines a **measured** section (`Coverage`, `This snapshot`, `Attaching this`,
|
package/docs/mcp.md
CHANGED
|
@@ -10,7 +10,7 @@ walk — that the client sees.
|
|
|
10
10
|
## Start it
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npx -y codebase-snapshot@0.12.
|
|
13
|
+
npx -y codebase-snapshot@0.12.3 mcp
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
|
|
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
|
|
|
25
25
|
"mcpServers": {
|
|
26
26
|
"codebase-snapshot": {
|
|
27
27
|
"command": "npx",
|
|
28
|
-
"args": ["-y", "codebase-snapshot@0.12.
|
|
28
|
+
"args": ["-y", "codebase-snapshot@0.12.3", "mcp", "--cwd", "/absolute/path/to/repo"]
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
|
|
|
34
34
|
Claude Code registers the same thing from a shell:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.12.
|
|
37
|
+
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.12.3 mcp --cwd /absolute/path/to/repo
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
On Windows, wrap the command as `cmd /c npx` with the same arguments — `npx` is a `.cmd` shim
|
|
@@ -106,6 +106,7 @@ Resources are the browse surface; tools are the act surface.
|
|
|
106
106
|
| `snapshot://reports/audit` | Secret findings, large files, parse diagnostics |
|
|
107
107
|
| `snapshot://reports/tree` | The directory tree of included files |
|
|
108
108
|
| `snapshot://reports/navigation` | File-to-part lookup |
|
|
109
|
+
| `snapshot://prompt` | `PROMPT.md` — the brief: the job, what the snapshot contains and omits, the history it was built from, and the owner half when a `brief` is configured |
|
|
109
110
|
| `snapshot://contract` | The machine-readable CLI contract |
|
|
110
111
|
| `snapshot://skill` | The agent skill, as one read |
|
|
111
112
|
|
|
@@ -116,7 +117,7 @@ JSON-RPC error `-32000` (the implementation-defined server-error range) and
|
|
|
116
117
|
the CLI for the contract or the skill. It never returns a truncated document: half a JSON manifest
|
|
117
118
|
does not parse, and half a part is a fragment that looks complete. The rule applies to every
|
|
118
119
|
resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the three reports,
|
|
119
|
-
`snapshot://contract` and `snapshot://skill`.
|
|
120
|
+
`snapshot://prompt`, `snapshot://contract` and `snapshot://skill`.
|
|
120
121
|
|
|
121
122
|
Part resources carry their size in the description, so a client choosing between them can see that
|
|
122
123
|
one is 300 kB before attaching it; a part above the limit says in its description that it will be
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-snapshot",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codebase-snapshot",
|