codebase-snapshot 0.12.3 → 0.12.5
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 +31 -0
- package/README.md +1 -1
- package/dist/bin.js +63 -19
- package/dist/{chunk-DEFKIYRZ.js → chunk-AGEIQXX3.js} +26 -15
- package/dist/{chunk-GIWY4HXZ.js → chunk-XVWGXMFP.js} +33 -3
- package/dist/cli.cjs +63 -19
- package/dist/cli.js +8 -5
- package/dist/index.cjs +26 -15
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +33 -3
- package/dist/mcp.d.cts +8 -0
- package/dist/mcp.d.ts +8 -0
- package/dist/mcp.js +2 -2
- package/docs/cli.md +3 -3
- package/docs/mcp.md +8 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,37 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
|
+
## 0.12.5
|
|
30
|
+
|
|
31
|
+
A lost-file bug in the experimental `maxParts`, found by fuzzing part budgets rather than reading
|
|
32
|
+
code.
|
|
33
|
+
|
|
34
|
+
- **Growing the budget dropped files from the layout.** Every probe re-partitioned the same file
|
|
35
|
+
records, which the previous probe had already assigned and truncated. When the probes disagreed,
|
|
36
|
+
files ended up with no part: three parts were written without them, `Integrity: failed`, and the
|
|
37
|
+
run exited 1 — after printing "Snapshot generated". Probes now run on a copy of the records, and
|
|
38
|
+
the real records are partitioned exactly once, at the chosen budget. 120 randomised budgets
|
|
39
|
+
(1-30 files, 4-64 KB, with and without token ceilings) found no failure after the fix; the
|
|
40
|
+
reproduction is a test.
|
|
41
|
+
- **A failed verification was announced as success.** The banner printed a tick above "Integrity:
|
|
42
|
+
failed" and then exited 1. It says what happened now.
|
|
43
|
+
|
|
44
|
+
`--max-parts` remains experimental and off by default. Verified: 1 181 tests, 1 173 pass, 0 fail,
|
|
45
|
+
8 host skips; lint 225 files; every gate clean at 0.12.5.
|
|
46
|
+
## 0.12.4
|
|
47
|
+
|
|
48
|
+
Two ways the MCP surface described itself wrongly.
|
|
49
|
+
|
|
50
|
+
- **`describe` did not list `snapshot://prompt`.** The resource was served from 0.12.2 and missing
|
|
51
|
+
from `contract.mcp.resources`, which is generated from a leaf list precisely so it cannot drift.
|
|
52
|
+
It is in that list now, and a test compares the contract against a live `resources/list`.
|
|
53
|
+
- **A known resource that was simply absent said "Unknown resource".** `snapshot://prompt` in a
|
|
54
|
+
snapshot generated with `--skip-artifacts prompt`, or a report with its artifact disabled,
|
|
55
|
+
answered `-32602 "Unknown resource"` — telling the client its URI was wrong when the artifact had
|
|
56
|
+
been left out. Those reads now answer `-32002` (resource not found) with the cause and the fix;
|
|
57
|
+
a genuinely unknown URI is unchanged.
|
|
58
|
+
|
|
59
|
+
Verified: 1 180 tests, 1 172 pass, 0 fail, 8 host skips; lint 225 files; every gate clean at 0.12.4.
|
|
29
60
|
## 0.12.3
|
|
30
61
|
|
|
31
62
|
A read of what the tool says, rather than what it does.
|
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.5 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.5";
|
|
2195
2195
|
var SCHEMA_VERSION = "3.0.0";
|
|
2196
2196
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2197
2197
|
function isOurGeneratorName(name) {
|
|
@@ -12339,23 +12339,34 @@ function runAfterGenerate(config, manifest) {
|
|
|
12339
12339
|
return Promise.resolve(returned).finally(releaseRedirect);
|
|
12340
12340
|
}
|
|
12341
12341
|
function partitionByBudget(files, config, fingerprint) {
|
|
12342
|
-
const configured = {
|
|
12343
|
-
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12344
|
-
budgets: config.budgets,
|
|
12345
|
-
maxPartBytes: config.maxPartBytes,
|
|
12346
|
-
warnings: []
|
|
12347
|
-
};
|
|
12348
12342
|
const limit = config.maxParts;
|
|
12349
|
-
if (limit === null || !config.artifacts.parts
|
|
12343
|
+
if (limit === null || !config.artifacts.parts) {
|
|
12344
|
+
return {
|
|
12345
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12346
|
+
budgets: config.budgets,
|
|
12347
|
+
maxPartBytes: config.maxPartBytes,
|
|
12348
|
+
warnings: []
|
|
12349
|
+
};
|
|
12350
|
+
}
|
|
12351
|
+
const probe = (budgets2) => partitionWithBudgets(structuredClone(files), budgets2, fingerprint);
|
|
12352
|
+
const configuredParts = probe(config.budgets);
|
|
12353
|
+
if (configuredParts.length <= limit) {
|
|
12354
|
+
return {
|
|
12355
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12356
|
+
budgets: config.budgets,
|
|
12357
|
+
maxPartBytes: config.maxPartBytes,
|
|
12358
|
+
warnings: []
|
|
12359
|
+
};
|
|
12360
|
+
}
|
|
12350
12361
|
const totalBytes = files.reduce((total, file) => total + file.includedBytes, 0);
|
|
12351
12362
|
let target = Math.max(config.budgets.default, Math.ceil(totalBytes * 1.15 / limit));
|
|
12352
12363
|
const seen = [];
|
|
12353
12364
|
let low = config.budgets.default;
|
|
12354
12365
|
let fitting = null;
|
|
12355
12366
|
for (let pass = 0; pass < 6; pass += 1) {
|
|
12356
|
-
const parts2 =
|
|
12367
|
+
const parts2 = probe(scaleBudgets(config.budgets, target));
|
|
12357
12368
|
if (parts2.length <= limit) {
|
|
12358
|
-
fitting = { target,
|
|
12369
|
+
fitting = { target, count: parts2.length };
|
|
12359
12370
|
break;
|
|
12360
12371
|
}
|
|
12361
12372
|
seen.push(parts2.length);
|
|
@@ -12369,13 +12380,13 @@ function partitionByBudget(files, config, fingerprint) {
|
|
|
12369
12380
|
}
|
|
12370
12381
|
for (let step = 0; step < 3 && fitting.target - low > 8192; step += 1) {
|
|
12371
12382
|
const middle = Math.round((low + fitting.target) / 2);
|
|
12372
|
-
const parts2 =
|
|
12373
|
-
if (parts2.length <= limit) fitting = { target: middle,
|
|
12383
|
+
const parts2 = probe(scaleBudgets(config.budgets, middle));
|
|
12384
|
+
if (parts2.length <= limit) fitting = { target: middle, count: parts2.length };
|
|
12374
12385
|
else low = middle;
|
|
12375
12386
|
}
|
|
12376
|
-
const
|
|
12377
|
-
const
|
|
12378
|
-
const maxPartBytes = Math.max(config.maxPartBytes,
|
|
12387
|
+
const budgets = scaleBudgets(config.budgets, fitting.target);
|
|
12388
|
+
const parts = partitionWithBudgets(files, budgets, fingerprint);
|
|
12389
|
+
const maxPartBytes = Math.max(config.maxPartBytes, budgets.default);
|
|
12379
12390
|
const warnings = [
|
|
12380
12391
|
`maxParts ${limit}: the part budget grew from ${formatNumber(config.maxPartBytes)} B to ${formatNumber(maxPartBytes)} B, and the snapshot now has ${formatNumber(parts.length)} part(s).`
|
|
12381
12392
|
];
|
|
@@ -14447,6 +14458,14 @@ var ERROR_CODES = {
|
|
|
14447
14458
|
* invent a partial one.
|
|
14448
14459
|
*/
|
|
14449
14460
|
resourceTooLarge: -32e3,
|
|
14461
|
+
/**
|
|
14462
|
+
* A known resource that this snapshot does not contain.
|
|
14463
|
+
*
|
|
14464
|
+
* `-32002` is the MCP code for "resource not found". Answering `-32602` ("Unknown resource")
|
|
14465
|
+
* for `snapshot://prompt` in a snapshot generated with `--skip-artifacts prompt` told the
|
|
14466
|
+
* client its URI was wrong when the artifact had simply been left out.
|
|
14467
|
+
*/
|
|
14468
|
+
resourceNotFound: -32002,
|
|
14450
14469
|
/**
|
|
14451
14470
|
* The server is at its concurrency limit.
|
|
14452
14471
|
*
|
|
@@ -14505,6 +14524,7 @@ var STATIC_RESOURCE_URIS = [
|
|
|
14505
14524
|
"snapshot://manifest",
|
|
14506
14525
|
"snapshot://contract",
|
|
14507
14526
|
"snapshot://skill",
|
|
14527
|
+
"snapshot://prompt",
|
|
14508
14528
|
"snapshot://reports/audit",
|
|
14509
14529
|
"snapshot://reports/tree",
|
|
14510
14530
|
"snapshot://reports/navigation"
|
|
@@ -15699,6 +15719,14 @@ var ResourceTooLargeError = class extends Error {
|
|
|
15699
15719
|
bytes;
|
|
15700
15720
|
limit;
|
|
15701
15721
|
};
|
|
15722
|
+
var ResourceNotFoundError = class extends Error {
|
|
15723
|
+
constructor(uri, message) {
|
|
15724
|
+
super(message);
|
|
15725
|
+
this.uri = uri;
|
|
15726
|
+
this.name = "ResourceNotFoundError";
|
|
15727
|
+
}
|
|
15728
|
+
uri;
|
|
15729
|
+
};
|
|
15702
15730
|
function refuseTooLarge(uri, bytes, advice) {
|
|
15703
15731
|
throw new ResourceTooLargeError(
|
|
15704
15732
|
uri,
|
|
@@ -15841,7 +15869,12 @@ function buildResourceProvider() {
|
|
|
15841
15869
|
const text2 = readFileIfPresent(
|
|
15842
15870
|
path21.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
15843
15871
|
);
|
|
15844
|
-
if (text2 === null)
|
|
15872
|
+
if (text2 === null) {
|
|
15873
|
+
throw new ResourceNotFoundError(
|
|
15874
|
+
uri,
|
|
15875
|
+
"This snapshot contains no PROMPT.md: the prompt artifact was disabled (artifacts.prompt = false or --skip-artifacts prompt), or nothing has been generated yet. Run snapshot_generate first."
|
|
15876
|
+
);
|
|
15877
|
+
}
|
|
15845
15878
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, PROMPT_ADVICE) };
|
|
15846
15879
|
}
|
|
15847
15880
|
const report = REPORT_URIS.get(uri);
|
|
@@ -15849,7 +15882,12 @@ function buildResourceProvider() {
|
|
|
15849
15882
|
const text2 = readFileIfPresent(
|
|
15850
15883
|
path21.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
|
|
15851
15884
|
);
|
|
15852
|
-
if (text2 === null)
|
|
15885
|
+
if (text2 === null) {
|
|
15886
|
+
throw new ResourceNotFoundError(
|
|
15887
|
+
uri,
|
|
15888
|
+
"This snapshot contains no " + report.file + ": that report was disabled, or nothing has been generated yet. Run snapshot_generate first."
|
|
15889
|
+
);
|
|
15890
|
+
}
|
|
15853
15891
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, REPORT_ADVICE) };
|
|
15854
15892
|
}
|
|
15855
15893
|
if (uri === "snapshot://manifest") {
|
|
@@ -16113,6 +16151,9 @@ function createMcpServer(options) {
|
|
|
16113
16151
|
try {
|
|
16114
16152
|
contents = await options.resources.read(uri, options.context);
|
|
16115
16153
|
} catch (error) {
|
|
16154
|
+
if (error instanceof ResourceNotFoundError) {
|
|
16155
|
+
return errorResponse(id, ERROR_CODES.resourceNotFound, error.message, { uri: error.uri });
|
|
16156
|
+
}
|
|
16116
16157
|
if (error instanceof ResourceTooLargeError) {
|
|
16117
16158
|
options.context.log(
|
|
16118
16159
|
`mcp: refused ${error.uri} (${error.bytes} bytes, limit ${error.limit}); returning it would truncate it`
|
|
@@ -17636,8 +17677,11 @@ ${USAGE}
|
|
|
17636
17677
|
info(` - Integrity: ${manifest.validation.status}`);
|
|
17637
17678
|
for (const error of manifest.validation.errors.slice(0, 10)) info(` - ${error}`);
|
|
17638
17679
|
} else {
|
|
17639
|
-
info(
|
|
17640
|
-
|
|
17680
|
+
info(
|
|
17681
|
+
manifest.validation.status === "passed" ? `
|
|
17682
|
+
\u2705 Snapshot generated in ${elapsed}s:` : `
|
|
17683
|
+
\u274C Snapshot written, but it failed verification (${manifest.validation.errors.length} problem(s)):`
|
|
17684
|
+
);
|
|
17641
17685
|
const skipCounts = /* @__PURE__ */ new Map();
|
|
17642
17686
|
for (const record of manifest.skipped) {
|
|
17643
17687
|
skipCounts.set(record.reason, (skipCounts.get(record.reason) ?? 0) + 1);
|
|
@@ -3993,7 +3993,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
3993
3993
|
|
|
3994
3994
|
// src/version.ts
|
|
3995
3995
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
3996
|
-
var GENERATOR_VERSION = "0.12.
|
|
3996
|
+
var GENERATOR_VERSION = "0.12.5";
|
|
3997
3997
|
var SCHEMA_VERSION = "3.0.0";
|
|
3998
3998
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
3999
3999
|
function isOurGeneratorName(name) {
|
|
@@ -12315,23 +12315,34 @@ function runAfterGenerate(config, manifest) {
|
|
|
12315
12315
|
return Promise.resolve(returned).finally(releaseRedirect);
|
|
12316
12316
|
}
|
|
12317
12317
|
function partitionByBudget(files, config, fingerprint) {
|
|
12318
|
-
const configured = {
|
|
12319
|
-
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12320
|
-
budgets: config.budgets,
|
|
12321
|
-
maxPartBytes: config.maxPartBytes,
|
|
12322
|
-
warnings: []
|
|
12323
|
-
};
|
|
12324
12318
|
const limit = config.maxParts;
|
|
12325
|
-
if (limit === null || !config.artifacts.parts
|
|
12319
|
+
if (limit === null || !config.artifacts.parts) {
|
|
12320
|
+
return {
|
|
12321
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12322
|
+
budgets: config.budgets,
|
|
12323
|
+
maxPartBytes: config.maxPartBytes,
|
|
12324
|
+
warnings: []
|
|
12325
|
+
};
|
|
12326
|
+
}
|
|
12327
|
+
const probe = (budgets2) => partitionWithBudgets(structuredClone(files), budgets2, fingerprint);
|
|
12328
|
+
const configuredParts = probe(config.budgets);
|
|
12329
|
+
if (configuredParts.length <= limit) {
|
|
12330
|
+
return {
|
|
12331
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12332
|
+
budgets: config.budgets,
|
|
12333
|
+
maxPartBytes: config.maxPartBytes,
|
|
12334
|
+
warnings: []
|
|
12335
|
+
};
|
|
12336
|
+
}
|
|
12326
12337
|
const totalBytes = files.reduce((total, file) => total + file.includedBytes, 0);
|
|
12327
12338
|
let target = Math.max(config.budgets.default, Math.ceil(totalBytes * 1.15 / limit));
|
|
12328
12339
|
const seen = [];
|
|
12329
12340
|
let low = config.budgets.default;
|
|
12330
12341
|
let fitting = null;
|
|
12331
12342
|
for (let pass = 0; pass < 6; pass += 1) {
|
|
12332
|
-
const parts2 =
|
|
12343
|
+
const parts2 = probe(scaleBudgets(config.budgets, target));
|
|
12333
12344
|
if (parts2.length <= limit) {
|
|
12334
|
-
fitting = { target,
|
|
12345
|
+
fitting = { target, count: parts2.length };
|
|
12335
12346
|
break;
|
|
12336
12347
|
}
|
|
12337
12348
|
seen.push(parts2.length);
|
|
@@ -12345,13 +12356,13 @@ function partitionByBudget(files, config, fingerprint) {
|
|
|
12345
12356
|
}
|
|
12346
12357
|
for (let step = 0; step < 3 && fitting.target - low > 8192; step += 1) {
|
|
12347
12358
|
const middle = Math.round((low + fitting.target) / 2);
|
|
12348
|
-
const parts2 =
|
|
12349
|
-
if (parts2.length <= limit) fitting = { target: middle,
|
|
12359
|
+
const parts2 = probe(scaleBudgets(config.budgets, middle));
|
|
12360
|
+
if (parts2.length <= limit) fitting = { target: middle, count: parts2.length };
|
|
12350
12361
|
else low = middle;
|
|
12351
12362
|
}
|
|
12352
|
-
const
|
|
12353
|
-
const
|
|
12354
|
-
const maxPartBytes = Math.max(config.maxPartBytes,
|
|
12363
|
+
const budgets = scaleBudgets(config.budgets, fitting.target);
|
|
12364
|
+
const parts = partitionWithBudgets(files, budgets, fingerprint);
|
|
12365
|
+
const maxPartBytes = Math.max(config.maxPartBytes, budgets.default);
|
|
12355
12366
|
const warnings = [
|
|
12356
12367
|
`maxParts ${limit}: the part budget grew from ${formatNumber(config.maxPartBytes)} B to ${formatNumber(maxPartBytes)} B, and the snapshot now has ${formatNumber(parts.length)} part(s).`
|
|
12357
12368
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-
|
|
1
|
+
import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-AGEIQXX3.js';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
|
|
@@ -26,6 +26,14 @@ var ERROR_CODES = {
|
|
|
26
26
|
* invent a partial one.
|
|
27
27
|
*/
|
|
28
28
|
resourceTooLarge: -32e3,
|
|
29
|
+
/**
|
|
30
|
+
* A known resource that this snapshot does not contain.
|
|
31
|
+
*
|
|
32
|
+
* `-32002` is the MCP code for "resource not found". Answering `-32602` ("Unknown resource")
|
|
33
|
+
* for `snapshot://prompt` in a snapshot generated with `--skip-artifacts prompt` told the
|
|
34
|
+
* client its URI was wrong when the artifact had simply been left out.
|
|
35
|
+
*/
|
|
36
|
+
resourceNotFound: -32002,
|
|
29
37
|
/**
|
|
30
38
|
* The server is at its concurrency limit.
|
|
31
39
|
*
|
|
@@ -1421,6 +1429,7 @@ var STATIC_RESOURCE_URIS = [
|
|
|
1421
1429
|
"snapshot://manifest",
|
|
1422
1430
|
"snapshot://contract",
|
|
1423
1431
|
"snapshot://skill",
|
|
1432
|
+
"snapshot://prompt",
|
|
1424
1433
|
"snapshot://reports/audit",
|
|
1425
1434
|
"snapshot://reports/tree",
|
|
1426
1435
|
"snapshot://reports/navigation"
|
|
@@ -2424,6 +2433,14 @@ var ResourceTooLargeError = class extends Error {
|
|
|
2424
2433
|
bytes;
|
|
2425
2434
|
limit;
|
|
2426
2435
|
};
|
|
2436
|
+
var ResourceNotFoundError = class extends Error {
|
|
2437
|
+
constructor(uri, message) {
|
|
2438
|
+
super(message);
|
|
2439
|
+
this.uri = uri;
|
|
2440
|
+
this.name = "ResourceNotFoundError";
|
|
2441
|
+
}
|
|
2442
|
+
uri;
|
|
2443
|
+
};
|
|
2427
2444
|
function refuseTooLarge(uri, bytes, advice) {
|
|
2428
2445
|
throw new ResourceTooLargeError(
|
|
2429
2446
|
uri,
|
|
@@ -2566,7 +2583,12 @@ function buildResourceProvider() {
|
|
|
2566
2583
|
const text = readFileIfPresent(
|
|
2567
2584
|
path.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
2568
2585
|
);
|
|
2569
|
-
if (text === null)
|
|
2586
|
+
if (text === null) {
|
|
2587
|
+
throw new ResourceNotFoundError(
|
|
2588
|
+
uri,
|
|
2589
|
+
"This snapshot contains no PROMPT.md: the prompt artifact was disabled (artifacts.prompt = false or --skip-artifacts prompt), or nothing has been generated yet. Run snapshot_generate first."
|
|
2590
|
+
);
|
|
2591
|
+
}
|
|
2570
2592
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, PROMPT_ADVICE) };
|
|
2571
2593
|
}
|
|
2572
2594
|
const report = REPORT_URIS.get(uri);
|
|
@@ -2574,7 +2596,12 @@ function buildResourceProvider() {
|
|
|
2574
2596
|
const text = readFileIfPresent(
|
|
2575
2597
|
path.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
|
|
2576
2598
|
);
|
|
2577
|
-
if (text === null)
|
|
2599
|
+
if (text === null) {
|
|
2600
|
+
throw new ResourceNotFoundError(
|
|
2601
|
+
uri,
|
|
2602
|
+
"This snapshot contains no " + report.file + ": that report was disabled, or nothing has been generated yet. Run snapshot_generate first."
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2578
2605
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, REPORT_ADVICE) };
|
|
2579
2606
|
}
|
|
2580
2607
|
if (uri === "snapshot://manifest") {
|
|
@@ -2838,6 +2865,9 @@ function createMcpServer(options) {
|
|
|
2838
2865
|
try {
|
|
2839
2866
|
contents = await options.resources.read(uri, options.context);
|
|
2840
2867
|
} catch (error) {
|
|
2868
|
+
if (error instanceof ResourceNotFoundError) {
|
|
2869
|
+
return errorResponse(id, ERROR_CODES.resourceNotFound, error.message, { uri: error.uri });
|
|
2870
|
+
}
|
|
2841
2871
|
if (error instanceof ResourceTooLargeError) {
|
|
2842
2872
|
options.context.log(
|
|
2843
2873
|
`mcp: refused ${error.uri} (${error.bytes} bytes, limit ${error.limit}); returning it would truncate it`
|
package/dist/cli.cjs
CHANGED
|
@@ -2220,7 +2220,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2220
2220
|
|
|
2221
2221
|
// src/version.ts
|
|
2222
2222
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2223
|
-
var GENERATOR_VERSION = "0.12.
|
|
2223
|
+
var GENERATOR_VERSION = "0.12.5";
|
|
2224
2224
|
var SCHEMA_VERSION = "3.0.0";
|
|
2225
2225
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2226
2226
|
function isOurGeneratorName(name) {
|
|
@@ -12265,23 +12265,34 @@ function runAfterGenerate(config, manifest) {
|
|
|
12265
12265
|
return Promise.resolve(returned).finally(releaseRedirect);
|
|
12266
12266
|
}
|
|
12267
12267
|
function partitionByBudget(files, config, fingerprint) {
|
|
12268
|
-
const configured = {
|
|
12269
|
-
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12270
|
-
budgets: config.budgets,
|
|
12271
|
-
maxPartBytes: config.maxPartBytes,
|
|
12272
|
-
warnings: []
|
|
12273
|
-
};
|
|
12274
12268
|
const limit = config.maxParts;
|
|
12275
|
-
if (limit === null || !config.artifacts.parts
|
|
12269
|
+
if (limit === null || !config.artifacts.parts) {
|
|
12270
|
+
return {
|
|
12271
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12272
|
+
budgets: config.budgets,
|
|
12273
|
+
maxPartBytes: config.maxPartBytes,
|
|
12274
|
+
warnings: []
|
|
12275
|
+
};
|
|
12276
|
+
}
|
|
12277
|
+
const probe = (budgets2) => partitionWithBudgets(structuredClone(files), budgets2, fingerprint);
|
|
12278
|
+
const configuredParts = probe(config.budgets);
|
|
12279
|
+
if (configuredParts.length <= limit) {
|
|
12280
|
+
return {
|
|
12281
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12282
|
+
budgets: config.budgets,
|
|
12283
|
+
maxPartBytes: config.maxPartBytes,
|
|
12284
|
+
warnings: []
|
|
12285
|
+
};
|
|
12286
|
+
}
|
|
12276
12287
|
const totalBytes = files.reduce((total, file) => total + file.includedBytes, 0);
|
|
12277
12288
|
let target = Math.max(config.budgets.default, Math.ceil(totalBytes * 1.15 / limit));
|
|
12278
12289
|
const seen = [];
|
|
12279
12290
|
let low = config.budgets.default;
|
|
12280
12291
|
let fitting = null;
|
|
12281
12292
|
for (let pass = 0; pass < 6; pass += 1) {
|
|
12282
|
-
const parts2 =
|
|
12293
|
+
const parts2 = probe(scaleBudgets(config.budgets, target));
|
|
12283
12294
|
if (parts2.length <= limit) {
|
|
12284
|
-
fitting = { target,
|
|
12295
|
+
fitting = { target, count: parts2.length };
|
|
12285
12296
|
break;
|
|
12286
12297
|
}
|
|
12287
12298
|
seen.push(parts2.length);
|
|
@@ -12295,13 +12306,13 @@ function partitionByBudget(files, config, fingerprint) {
|
|
|
12295
12306
|
}
|
|
12296
12307
|
for (let step = 0; step < 3 && fitting.target - low > 8192; step += 1) {
|
|
12297
12308
|
const middle = Math.round((low + fitting.target) / 2);
|
|
12298
|
-
const parts2 =
|
|
12299
|
-
if (parts2.length <= limit) fitting = { target: middle,
|
|
12309
|
+
const parts2 = probe(scaleBudgets(config.budgets, middle));
|
|
12310
|
+
if (parts2.length <= limit) fitting = { target: middle, count: parts2.length };
|
|
12300
12311
|
else low = middle;
|
|
12301
12312
|
}
|
|
12302
|
-
const
|
|
12303
|
-
const
|
|
12304
|
-
const maxPartBytes = Math.max(config.maxPartBytes,
|
|
12313
|
+
const budgets = scaleBudgets(config.budgets, fitting.target);
|
|
12314
|
+
const parts = partitionWithBudgets(files, budgets, fingerprint);
|
|
12315
|
+
const maxPartBytes = Math.max(config.maxPartBytes, budgets.default);
|
|
12305
12316
|
const warnings = [
|
|
12306
12317
|
`maxParts ${limit}: the part budget grew from ${formatNumber(config.maxPartBytes)} B to ${formatNumber(maxPartBytes)} B, and the snapshot now has ${formatNumber(parts.length)} part(s).`
|
|
12307
12318
|
];
|
|
@@ -14365,6 +14376,14 @@ var ERROR_CODES = {
|
|
|
14365
14376
|
* invent a partial one.
|
|
14366
14377
|
*/
|
|
14367
14378
|
resourceTooLarge: -32e3,
|
|
14379
|
+
/**
|
|
14380
|
+
* A known resource that this snapshot does not contain.
|
|
14381
|
+
*
|
|
14382
|
+
* `-32002` is the MCP code for "resource not found". Answering `-32602` ("Unknown resource")
|
|
14383
|
+
* for `snapshot://prompt` in a snapshot generated with `--skip-artifacts prompt` told the
|
|
14384
|
+
* client its URI was wrong when the artifact had simply been left out.
|
|
14385
|
+
*/
|
|
14386
|
+
resourceNotFound: -32002,
|
|
14368
14387
|
/**
|
|
14369
14388
|
* The server is at its concurrency limit.
|
|
14370
14389
|
*
|
|
@@ -14419,6 +14438,7 @@ var STATIC_RESOURCE_URIS = [
|
|
|
14419
14438
|
"snapshot://manifest",
|
|
14420
14439
|
"snapshot://contract",
|
|
14421
14440
|
"snapshot://skill",
|
|
14441
|
+
"snapshot://prompt",
|
|
14422
14442
|
"snapshot://reports/audit",
|
|
14423
14443
|
"snapshot://reports/tree",
|
|
14424
14444
|
"snapshot://reports/navigation"
|
|
@@ -15605,6 +15625,14 @@ var ResourceTooLargeError = class extends Error {
|
|
|
15605
15625
|
bytes;
|
|
15606
15626
|
limit;
|
|
15607
15627
|
};
|
|
15628
|
+
var ResourceNotFoundError = class extends Error {
|
|
15629
|
+
constructor(uri, message) {
|
|
15630
|
+
super(message);
|
|
15631
|
+
this.uri = uri;
|
|
15632
|
+
this.name = "ResourceNotFoundError";
|
|
15633
|
+
}
|
|
15634
|
+
uri;
|
|
15635
|
+
};
|
|
15608
15636
|
function refuseTooLarge(uri, bytes, advice) {
|
|
15609
15637
|
throw new ResourceTooLargeError(
|
|
15610
15638
|
uri,
|
|
@@ -15747,7 +15775,12 @@ function buildResourceProvider() {
|
|
|
15747
15775
|
const text2 = readFileIfPresent(
|
|
15748
15776
|
path17__namespace.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
15749
15777
|
);
|
|
15750
|
-
if (text2 === null)
|
|
15778
|
+
if (text2 === null) {
|
|
15779
|
+
throw new ResourceNotFoundError(
|
|
15780
|
+
uri,
|
|
15781
|
+
"This snapshot contains no PROMPT.md: the prompt artifact was disabled (artifacts.prompt = false or --skip-artifacts prompt), or nothing has been generated yet. Run snapshot_generate first."
|
|
15782
|
+
);
|
|
15783
|
+
}
|
|
15751
15784
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, PROMPT_ADVICE) };
|
|
15752
15785
|
}
|
|
15753
15786
|
const report = REPORT_URIS.get(uri);
|
|
@@ -15755,7 +15788,12 @@ function buildResourceProvider() {
|
|
|
15755
15788
|
const text2 = readFileIfPresent(
|
|
15756
15789
|
path17__namespace.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
|
|
15757
15790
|
);
|
|
15758
|
-
if (text2 === null)
|
|
15791
|
+
if (text2 === null) {
|
|
15792
|
+
throw new ResourceNotFoundError(
|
|
15793
|
+
uri,
|
|
15794
|
+
"This snapshot contains no " + report.file + ": that report was disabled, or nothing has been generated yet. Run snapshot_generate first."
|
|
15795
|
+
);
|
|
15796
|
+
}
|
|
15759
15797
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text2, REPORT_ADVICE) };
|
|
15760
15798
|
}
|
|
15761
15799
|
if (uri === "snapshot://manifest") {
|
|
@@ -16019,6 +16057,9 @@ function createMcpServer(options) {
|
|
|
16019
16057
|
try {
|
|
16020
16058
|
contents = await options.resources.read(uri, options.context);
|
|
16021
16059
|
} catch (error) {
|
|
16060
|
+
if (error instanceof ResourceNotFoundError) {
|
|
16061
|
+
return errorResponse(id, ERROR_CODES.resourceNotFound, error.message, { uri: error.uri });
|
|
16062
|
+
}
|
|
16022
16063
|
if (error instanceof ResourceTooLargeError) {
|
|
16023
16064
|
options.context.log(
|
|
16024
16065
|
`mcp: refused ${error.uri} (${error.bytes} bytes, limit ${error.limit}); returning it would truncate it`
|
|
@@ -17552,8 +17593,11 @@ ${USAGE}
|
|
|
17552
17593
|
info(` - Integrity: ${manifest.validation.status}`);
|
|
17553
17594
|
for (const error of manifest.validation.errors.slice(0, 10)) info(` - ${error}`);
|
|
17554
17595
|
} else {
|
|
17555
|
-
info(
|
|
17556
|
-
|
|
17596
|
+
info(
|
|
17597
|
+
manifest.validation.status === "passed" ? `
|
|
17598
|
+
\u2705 Snapshot generated in ${elapsed}s:` : `
|
|
17599
|
+
\u274C Snapshot written, but it failed verification (${manifest.validation.errors.length} problem(s)):`
|
|
17600
|
+
);
|
|
17557
17601
|
const skipCounts = /* @__PURE__ */ new Map();
|
|
17558
17602
|
for (const record of manifest.skipped) {
|
|
17559
17603
|
skipCounts.set(record.reason, (skipCounts.get(record.reason) ?? 0) + 1);
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-
|
|
2
|
-
export { buildAgentContract } from './chunk-
|
|
3
|
-
import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-
|
|
1
|
+
import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-XVWGXMFP.js';
|
|
2
|
+
export { buildAgentContract } from './chunk-XVWGXMFP.js';
|
|
3
|
+
import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-AGEIQXX3.js';
|
|
4
4
|
import { spawnSync } from 'child_process';
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import * as path2 from 'path';
|
|
@@ -1249,8 +1249,11 @@ ${USAGE}
|
|
|
1249
1249
|
info(` - Integrity: ${manifest.validation.status}`);
|
|
1250
1250
|
for (const error of manifest.validation.errors.slice(0, 10)) info(` - ${error}`);
|
|
1251
1251
|
} else {
|
|
1252
|
-
info(
|
|
1253
|
-
|
|
1252
|
+
info(
|
|
1253
|
+
manifest.validation.status === "passed" ? `
|
|
1254
|
+
\u2705 Snapshot generated in ${elapsed}s:` : `
|
|
1255
|
+
\u274C Snapshot written, but it failed verification (${manifest.validation.errors.length} problem(s)):`
|
|
1256
|
+
);
|
|
1254
1257
|
const skipCounts = /* @__PURE__ */ new Map();
|
|
1255
1258
|
for (const record of manifest.skipped) {
|
|
1256
1259
|
skipCounts.set(record.reason, (skipCounts.get(record.reason) ?? 0) + 1);
|
package/dist/index.cjs
CHANGED
|
@@ -4010,7 +4010,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
4010
4010
|
|
|
4011
4011
|
// src/version.ts
|
|
4012
4012
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
4013
|
-
var GENERATOR_VERSION = "0.12.
|
|
4013
|
+
var GENERATOR_VERSION = "0.12.5";
|
|
4014
4014
|
var SCHEMA_VERSION = "3.0.0";
|
|
4015
4015
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
4016
4016
|
function isOurGeneratorName(name) {
|
|
@@ -12217,23 +12217,34 @@ function runAfterGenerate(config, manifest) {
|
|
|
12217
12217
|
return Promise.resolve(returned).finally(releaseRedirect);
|
|
12218
12218
|
}
|
|
12219
12219
|
function partitionByBudget(files, config, fingerprint) {
|
|
12220
|
-
const configured = {
|
|
12221
|
-
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12222
|
-
budgets: config.budgets,
|
|
12223
|
-
maxPartBytes: config.maxPartBytes,
|
|
12224
|
-
warnings: []
|
|
12225
|
-
};
|
|
12226
12220
|
const limit = config.maxParts;
|
|
12227
|
-
if (limit === null || !config.artifacts.parts
|
|
12221
|
+
if (limit === null || !config.artifacts.parts) {
|
|
12222
|
+
return {
|
|
12223
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12224
|
+
budgets: config.budgets,
|
|
12225
|
+
maxPartBytes: config.maxPartBytes,
|
|
12226
|
+
warnings: []
|
|
12227
|
+
};
|
|
12228
|
+
}
|
|
12229
|
+
const probe = (budgets2) => partitionWithBudgets(structuredClone(files), budgets2, fingerprint);
|
|
12230
|
+
const configuredParts = probe(config.budgets);
|
|
12231
|
+
if (configuredParts.length <= limit) {
|
|
12232
|
+
return {
|
|
12233
|
+
parts: partitionWithBudgets(files, config.budgets, fingerprint),
|
|
12234
|
+
budgets: config.budgets,
|
|
12235
|
+
maxPartBytes: config.maxPartBytes,
|
|
12236
|
+
warnings: []
|
|
12237
|
+
};
|
|
12238
|
+
}
|
|
12228
12239
|
const totalBytes = files.reduce((total, file) => total + file.includedBytes, 0);
|
|
12229
12240
|
let target = Math.max(config.budgets.default, Math.ceil(totalBytes * 1.15 / limit));
|
|
12230
12241
|
const seen = [];
|
|
12231
12242
|
let low = config.budgets.default;
|
|
12232
12243
|
let fitting = null;
|
|
12233
12244
|
for (let pass = 0; pass < 6; pass += 1) {
|
|
12234
|
-
const parts2 =
|
|
12245
|
+
const parts2 = probe(scaleBudgets(config.budgets, target));
|
|
12235
12246
|
if (parts2.length <= limit) {
|
|
12236
|
-
fitting = { target,
|
|
12247
|
+
fitting = { target, count: parts2.length };
|
|
12237
12248
|
break;
|
|
12238
12249
|
}
|
|
12239
12250
|
seen.push(parts2.length);
|
|
@@ -12247,13 +12258,13 @@ function partitionByBudget(files, config, fingerprint) {
|
|
|
12247
12258
|
}
|
|
12248
12259
|
for (let step = 0; step < 3 && fitting.target - low > 8192; step += 1) {
|
|
12249
12260
|
const middle = Math.round((low + fitting.target) / 2);
|
|
12250
|
-
const parts2 =
|
|
12251
|
-
if (parts2.length <= limit) fitting = { target: middle,
|
|
12261
|
+
const parts2 = probe(scaleBudgets(config.budgets, middle));
|
|
12262
|
+
if (parts2.length <= limit) fitting = { target: middle, count: parts2.length };
|
|
12252
12263
|
else low = middle;
|
|
12253
12264
|
}
|
|
12254
|
-
const
|
|
12255
|
-
const
|
|
12256
|
-
const maxPartBytes = Math.max(config.maxPartBytes,
|
|
12265
|
+
const budgets = scaleBudgets(config.budgets, fitting.target);
|
|
12266
|
+
const parts = partitionWithBudgets(files, budgets, fingerprint);
|
|
12267
|
+
const maxPartBytes = Math.max(config.maxPartBytes, budgets.default);
|
|
12257
12268
|
const warnings = [
|
|
12258
12269
|
`maxParts ${limit}: the part budget grew from ${formatNumber(config.maxPartBytes)} B to ${formatNumber(maxPartBytes)} B, and the snapshot now has ${formatNumber(parts.length)} part(s).`
|
|
12259
12270
|
];
|
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.5";
|
|
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.5";
|
|
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-AGEIQXX3.js';
|
package/dist/mcp.cjs
CHANGED
|
@@ -61,6 +61,14 @@ var ERROR_CODES = {
|
|
|
61
61
|
* invent a partial one.
|
|
62
62
|
*/
|
|
63
63
|
resourceTooLarge: -32e3,
|
|
64
|
+
/**
|
|
65
|
+
* A known resource that this snapshot does not contain.
|
|
66
|
+
*
|
|
67
|
+
* `-32002` is the MCP code for "resource not found". Answering `-32602` ("Unknown resource")
|
|
68
|
+
* for `snapshot://prompt` in a snapshot generated with `--skip-artifacts prompt` told the
|
|
69
|
+
* client its URI was wrong when the artifact had simply been left out.
|
|
70
|
+
*/
|
|
71
|
+
resourceNotFound: -32002,
|
|
64
72
|
/**
|
|
65
73
|
* The server is at its concurrency limit.
|
|
66
74
|
*
|
|
@@ -2538,7 +2546,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2538
2546
|
|
|
2539
2547
|
// src/version.ts
|
|
2540
2548
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2541
|
-
var GENERATOR_VERSION = "0.12.
|
|
2549
|
+
var GENERATOR_VERSION = "0.12.5";
|
|
2542
2550
|
var SCHEMA_VERSION = "3.0.0";
|
|
2543
2551
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2544
2552
|
function isOurGeneratorName(name) {
|
|
@@ -8893,6 +8901,7 @@ var STATIC_RESOURCE_URIS = [
|
|
|
8893
8901
|
"snapshot://manifest",
|
|
8894
8902
|
"snapshot://contract",
|
|
8895
8903
|
"snapshot://skill",
|
|
8904
|
+
"snapshot://prompt",
|
|
8896
8905
|
"snapshot://reports/audit",
|
|
8897
8906
|
"snapshot://reports/tree",
|
|
8898
8907
|
"snapshot://reports/navigation"
|
|
@@ -9827,6 +9836,14 @@ var ResourceTooLargeError = class extends Error {
|
|
|
9827
9836
|
bytes;
|
|
9828
9837
|
limit;
|
|
9829
9838
|
};
|
|
9839
|
+
var ResourceNotFoundError = class extends Error {
|
|
9840
|
+
constructor(uri, message) {
|
|
9841
|
+
super(message);
|
|
9842
|
+
this.uri = uri;
|
|
9843
|
+
this.name = "ResourceNotFoundError";
|
|
9844
|
+
}
|
|
9845
|
+
uri;
|
|
9846
|
+
};
|
|
9830
9847
|
function refuseTooLarge(uri, bytes, advice) {
|
|
9831
9848
|
throw new ResourceTooLargeError(
|
|
9832
9849
|
uri,
|
|
@@ -9969,7 +9986,12 @@ function buildResourceProvider() {
|
|
|
9969
9986
|
const text = readFileIfPresent(
|
|
9970
9987
|
path5__namespace.resolve(workspace.root, workspace.config.outDir, "PROMPT.md")
|
|
9971
9988
|
);
|
|
9972
|
-
if (text === null)
|
|
9989
|
+
if (text === null) {
|
|
9990
|
+
throw new ResourceNotFoundError(
|
|
9991
|
+
uri,
|
|
9992
|
+
"This snapshot contains no PROMPT.md: the prompt artifact was disabled (artifacts.prompt = false or --skip-artifacts prompt), or nothing has been generated yet. Run snapshot_generate first."
|
|
9993
|
+
);
|
|
9994
|
+
}
|
|
9973
9995
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, PROMPT_ADVICE) };
|
|
9974
9996
|
}
|
|
9975
9997
|
const report = REPORT_URIS.get(uri);
|
|
@@ -9977,7 +9999,12 @@ function buildResourceProvider() {
|
|
|
9977
9999
|
const text = readFileIfPresent(
|
|
9978
10000
|
path5__namespace.resolve(workspace.root, workspace.config.outDir, "reports", report.file)
|
|
9979
10001
|
);
|
|
9980
|
-
if (text === null)
|
|
10002
|
+
if (text === null) {
|
|
10003
|
+
throw new ResourceNotFoundError(
|
|
10004
|
+
uri,
|
|
10005
|
+
"This snapshot contains no " + report.file + ": that report was disabled, or nothing has been generated yet. Run snapshot_generate first."
|
|
10006
|
+
);
|
|
10007
|
+
}
|
|
9981
10008
|
return { uri, mimeType: "text/markdown", text: ensureSingleRead(uri, text, REPORT_ADVICE) };
|
|
9982
10009
|
}
|
|
9983
10010
|
if (uri === "snapshot://manifest") {
|
|
@@ -10241,6 +10268,9 @@ function createMcpServer(options) {
|
|
|
10241
10268
|
try {
|
|
10242
10269
|
contents = await options.resources.read(uri, options.context);
|
|
10243
10270
|
} catch (error) {
|
|
10271
|
+
if (error instanceof ResourceNotFoundError) {
|
|
10272
|
+
return errorResponse(id, ERROR_CODES.resourceNotFound, error.message, { uri: error.uri });
|
|
10273
|
+
}
|
|
10244
10274
|
if (error instanceof ResourceTooLargeError) {
|
|
10245
10275
|
options.context.log(
|
|
10246
10276
|
`mcp: refused ${error.uri} (${error.bytes} bytes, limit ${error.limit}); returning it would truncate it`
|
package/dist/mcp.d.cts
CHANGED
|
@@ -68,6 +68,14 @@ declare const ERROR_CODES: {
|
|
|
68
68
|
* invent a partial one.
|
|
69
69
|
*/
|
|
70
70
|
readonly resourceTooLarge: -32000;
|
|
71
|
+
/**
|
|
72
|
+
* A known resource that this snapshot does not contain.
|
|
73
|
+
*
|
|
74
|
+
* `-32002` is the MCP code for "resource not found". Answering `-32602` ("Unknown resource")
|
|
75
|
+
* for `snapshot://prompt` in a snapshot generated with `--skip-artifacts prompt` told the
|
|
76
|
+
* client its URI was wrong when the artifact had simply been left out.
|
|
77
|
+
*/
|
|
78
|
+
readonly resourceNotFound: -32002;
|
|
71
79
|
/**
|
|
72
80
|
* The server is at its concurrency limit.
|
|
73
81
|
*
|
package/dist/mcp.d.ts
CHANGED
|
@@ -68,6 +68,14 @@ declare const ERROR_CODES: {
|
|
|
68
68
|
* invent a partial one.
|
|
69
69
|
*/
|
|
70
70
|
readonly resourceTooLarge: -32000;
|
|
71
|
+
/**
|
|
72
|
+
* A known resource that this snapshot does not contain.
|
|
73
|
+
*
|
|
74
|
+
* `-32002` is the MCP code for "resource not found". Answering `-32602` ("Unknown resource")
|
|
75
|
+
* for `snapshot://prompt` in a snapshot generated with `--skip-artifacts prompt` told the
|
|
76
|
+
* client its URI was wrong when the artifact had simply been left out.
|
|
77
|
+
*/
|
|
78
|
+
readonly resourceNotFound: -32002;
|
|
71
79
|
/**
|
|
72
80
|
* The server is at its concurrency limit.
|
|
73
81
|
*
|
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-XVWGXMFP.js';
|
|
2
|
+
export { generateInWorker } from './chunk-AGEIQXX3.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.5 (project dependency ^0.12.5)
|
|
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.5
|
|
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.5
|
|
248
248
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
249
249
|
```
|
|
250
250
|
|
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.5 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.5", "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.5 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
|
|
@@ -119,6 +119,11 @@ does not parse, and half a part is a fragment that looks complete. The rule appl
|
|
|
119
119
|
resource — `snapshot://manifest`, each `snapshot://parts/{index}`, the three reports,
|
|
120
120
|
`snapshot://prompt`, `snapshot://contract` and `snapshot://skill`.
|
|
121
121
|
|
|
122
|
+
A URI this build serves but this snapshot does not contain — `snapshot://prompt` when the prompt
|
|
123
|
+
artifact was disabled, a report when that artifact was — is answered with `-32002` (resource not
|
|
124
|
+
found) and a message naming the artifact and the cause. An unknown URI is still "Unknown resource":
|
|
125
|
+
the two are different mistakes and a client should be able to tell them apart.
|
|
126
|
+
|
|
122
127
|
Part resources carry their size in the description, so a client choosing between them can see that
|
|
123
128
|
one is 300 kB before attaching it; a part above the limit says in its description that it will be
|
|
124
129
|
refused rather than truncated.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-snapshot",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
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",
|