codebase-snapshot 0.12.1 → 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 +27 -0
- package/README.md +1 -1
- package/dist/bin.js +101 -32
- package/dist/{chunk-H4FSGTEW.js → chunk-74ZAF64D.js} +84 -31
- package/dist/{chunk-BXWV2OXE.js → chunk-BITMWXYS.js} +18 -2
- package/dist/cli.cjs +101 -32
- package/dist/cli.js +3 -3
- package/dist/index.cjs +84 -31
- 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/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.2";
|
|
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';
|
|
@@ -9259,7 +9308,7 @@ function buildAgentContract() {
|
|
|
9259
9308
|
type: "string",
|
|
9260
9309
|
default: "unset",
|
|
9261
9310
|
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."
|
|
9311
|
+
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
9312
|
},
|
|
9264
9313
|
{
|
|
9265
9314
|
flag: "--prompt-task",
|
|
@@ -9779,6 +9828,8 @@ function ensureSingleRead(uri, text, advice) {
|
|
|
9779
9828
|
}
|
|
9780
9829
|
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
9830
|
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.";
|
|
9831
|
+
var PROMPT_URI = "snapshot://prompt";
|
|
9832
|
+
var PROMPT_ADVICE = "PROMPT.md is written whole and never truncated; regenerate it with snapshot_generate, then read it from the snapshot directory.";
|
|
9782
9833
|
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
9834
|
var PART_URI = /^snapshot:\/\/parts\/(\d+)$/;
|
|
9784
9835
|
var REPORT_URIS = /* @__PURE__ */ new Map([
|
|
@@ -9829,6 +9880,13 @@ function buildResourceProvider() {
|
|
|
9829
9880
|
title: "Agent skill",
|
|
9830
9881
|
description: "Usage guidance for an agent working with this tool.",
|
|
9831
9882
|
mimeType: "text/markdown"
|
|
9883
|
+
},
|
|
9884
|
+
{
|
|
9885
|
+
uri: PROMPT_URI,
|
|
9886
|
+
name: "prompt",
|
|
9887
|
+
title: "Snapshot brief",
|
|
9888
|
+
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.",
|
|
9889
|
+
mimeType: "text/markdown"
|
|
9832
9890
|
}
|
|
9833
9891
|
];
|
|
9834
9892
|
for (const [uri, report] of REPORT_URIS) {
|
|
@@ -9893,6 +9951,13 @@ function buildResourceProvider() {
|
|
|
9893
9951
|
}
|
|
9894
9952
|
const workspace = await workspaceFor(context);
|
|
9895
9953
|
if ("error" in workspace) return null;
|
|
9954
|
+
if (uri === PROMPT_URI) {
|
|
9955
|
+
const text = readFileIfPresent(
|
|
9956
|
+
path5__namespace.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
9957
|
+
);
|
|
9958
|
+
if (text === null) return null;
|
|
9959
|
+
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, PROMPT_ADVICE) };
|
|
9960
|
+
}
|
|
9896
9961
|
const report = REPORT_URIS.get(uri);
|
|
9897
9962
|
if (report) {
|
|
9898
9963
|
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-BITMWXYS.js';
|
|
2
|
+
export { generateInWorker } from './chunk-74ZAF64D.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.2 (project dependency ^0.12.2)
|
|
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.2
|
|
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.2
|
|
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.2 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.2", "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.2 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.2",
|
|
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",
|