codebase-snapshot 0.20.13 → 0.21.0
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 +33 -6
- package/README.md +41 -19
- package/SECURITY.md +2 -2
- package/dist/bin.js +12482 -10348
- package/dist/{chunk-GNVRD7XS.js → chunk-TDPYLX7X.js} +6062 -4438
- package/dist/cli.cjs +11759 -9645
- package/dist/cli.d.cts +76 -2
- package/dist/cli.d.ts +76 -2
- package/dist/cli.js +549 -14
- package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-D56JeXwx.d.cts} +2 -2
- package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-DakxZs-l.d.ts} +2 -2
- package/dist/index.cjs +6037 -4435
- package/dist/index.d.cts +281 -63
- package/dist/index.d.ts +281 -63
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +10231 -4354
- package/dist/mcp.d.cts +13 -7
- package/dist/mcp.d.ts +13 -7
- package/dist/mcp.js +1 -1
- package/dist/{types-C5ytHMYz.d.ts → types-D5XYzksd.d.cts} +50 -2
- package/dist/{types-C5ytHMYz.d.cts → types-D5XYzksd.d.ts} +50 -2
- package/docs/about.md +86 -0
- package/docs/agent.md +28 -6
- package/docs/answer.md +99 -48
- package/docs/benchmarks.md +34 -34
- package/docs/brief.md +80 -81
- package/docs/cli.md +100 -25
- package/docs/codebase-token-budget.md +14 -13
- package/docs/contents.md +66 -0
- package/docs/deploy.md +2 -2
- package/docs/faq.md +112 -0
- package/docs/glossary.md +152 -0
- package/docs/health.md +1 -1
- package/docs/how-to-feed-a-repo-to-claude.md +6 -0
- package/docs/impact.md +102 -0
- package/docs/install.md +4 -3
- package/docs/llm-codebase-context.md +166 -0
- package/docs/mcp-server-for-codebase.md +155 -0
- package/docs/mcp.md +43 -66
- package/docs/migration.md +83 -90
- package/docs/output.md +1 -3
- package/docs/security-review.md +8 -8
- package/docs/slice.md +1 -1
- package/docs/tools.md +159 -185
- package/docs/troubleshooting.md +11 -11
- package/docs/vs-code2prompt.md +7 -0
- package/docs/vs-gitingest.md +7 -0
- package/docs/vs-repomix.md +10 -1
- package/docs/workspace.md +1 -1
- package/package.json +8 -2
package/dist/mcp.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-
|
|
1
|
+
export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-D56JeXwx.cjs';
|
|
2
2
|
import { Readable, Writable } from 'node:stream';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-D5XYzksd.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* JSON-RPC 2.0 envelopes and the Model Context Protocol revisions this server speaks.
|
|
@@ -184,7 +184,7 @@ interface ToolContext {
|
|
|
184
184
|
* Client-facing hints.
|
|
185
185
|
*
|
|
186
186
|
* `readOnlyHint` is the one that changes behaviour rather than appearance: clients use it to
|
|
187
|
-
* auto-approve a call.
|
|
187
|
+
* auto-approve a call. Six of the seven tools never write, so they are marked read-only;
|
|
188
188
|
* only `snapshot_generate` writes.
|
|
189
189
|
*/
|
|
190
190
|
interface ToolAnnotations {
|
|
@@ -360,6 +360,8 @@ interface McpServerOptions {
|
|
|
360
360
|
context: ToolContext;
|
|
361
361
|
/** Writes a JSON-RPC notification. Present on transports that can carry one mid-call. */
|
|
362
362
|
notify?: (message: JsonObject) => void;
|
|
363
|
+
/** Shared registry so stateless modern HTTP requests can cancel an earlier request. */
|
|
364
|
+
cancellations?: Map<JsonRpcId, () => void>;
|
|
363
365
|
}
|
|
364
366
|
interface McpServer {
|
|
365
367
|
/** Handles one already-parsed message. Returns null when no response is due. */
|
|
@@ -386,6 +388,10 @@ interface PartSection {
|
|
|
386
388
|
anchor: string | null;
|
|
387
389
|
/** The file body, without its fence. Redacted and possibly a bounded preview. */
|
|
388
390
|
body: string;
|
|
391
|
+
/** 1-based first body line in the part, when known. */
|
|
392
|
+
bodyStartLine?: number;
|
|
393
|
+
/** 1-based last body line in the part, when known. */
|
|
394
|
+
bodyEndLine?: number;
|
|
389
395
|
/** `full`, `preview` or `signatures`. */
|
|
390
396
|
inclusion: string | null;
|
|
391
397
|
includedLines: number | null;
|
|
@@ -472,6 +478,8 @@ interface ServerOptions {
|
|
|
472
478
|
noConfig?: boolean;
|
|
473
479
|
/** Where operational notes go. Never stdout, which carries protocol messages only. */
|
|
474
480
|
log?: (line: string) => void;
|
|
481
|
+
/** Optional map for a caller that owns one server's request ids; the default is per server. */
|
|
482
|
+
cancellations?: Map<JsonRpcId, () => void>;
|
|
475
483
|
}
|
|
476
484
|
/** Builds a server with every capability this package implements. */
|
|
477
485
|
declare function createServer(options: ServerOptions): McpServer;
|
|
@@ -584,10 +592,8 @@ declare function createLineReader(input: Readable, options: LineReaderOptions):
|
|
|
584
592
|
/**
|
|
585
593
|
* The instructions an MCP client shows its model at handshake.
|
|
586
594
|
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
* *order* rather than features — an agent that reads a part end to end has already lost the
|
|
590
|
-
* budget this tool exists to protect.
|
|
595
|
+
* Seven tools, one order: impact before editing, locate before reading, read a window, explain
|
|
596
|
+
* anything missing, validate before trusting, generate only when a persisted snapshot is wanted.
|
|
591
597
|
*/
|
|
592
598
|
declare const SERVER_INSTRUCTIONS: string;
|
|
593
599
|
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-
|
|
1
|
+
export { G as GenerateSummary, W as WorkerResults, g as generateInWorker } from './generate-worker-DakxZs-l.js';
|
|
2
2
|
import { Readable, Writable } from 'node:stream';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-D5XYzksd.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* JSON-RPC 2.0 envelopes and the Model Context Protocol revisions this server speaks.
|
|
@@ -184,7 +184,7 @@ interface ToolContext {
|
|
|
184
184
|
* Client-facing hints.
|
|
185
185
|
*
|
|
186
186
|
* `readOnlyHint` is the one that changes behaviour rather than appearance: clients use it to
|
|
187
|
-
* auto-approve a call.
|
|
187
|
+
* auto-approve a call. Six of the seven tools never write, so they are marked read-only;
|
|
188
188
|
* only `snapshot_generate` writes.
|
|
189
189
|
*/
|
|
190
190
|
interface ToolAnnotations {
|
|
@@ -360,6 +360,8 @@ interface McpServerOptions {
|
|
|
360
360
|
context: ToolContext;
|
|
361
361
|
/** Writes a JSON-RPC notification. Present on transports that can carry one mid-call. */
|
|
362
362
|
notify?: (message: JsonObject) => void;
|
|
363
|
+
/** Shared registry so stateless modern HTTP requests can cancel an earlier request. */
|
|
364
|
+
cancellations?: Map<JsonRpcId, () => void>;
|
|
363
365
|
}
|
|
364
366
|
interface McpServer {
|
|
365
367
|
/** Handles one already-parsed message. Returns null when no response is due. */
|
|
@@ -386,6 +388,10 @@ interface PartSection {
|
|
|
386
388
|
anchor: string | null;
|
|
387
389
|
/** The file body, without its fence. Redacted and possibly a bounded preview. */
|
|
388
390
|
body: string;
|
|
391
|
+
/** 1-based first body line in the part, when known. */
|
|
392
|
+
bodyStartLine?: number;
|
|
393
|
+
/** 1-based last body line in the part, when known. */
|
|
394
|
+
bodyEndLine?: number;
|
|
389
395
|
/** `full`, `preview` or `signatures`. */
|
|
390
396
|
inclusion: string | null;
|
|
391
397
|
includedLines: number | null;
|
|
@@ -472,6 +478,8 @@ interface ServerOptions {
|
|
|
472
478
|
noConfig?: boolean;
|
|
473
479
|
/** Where operational notes go. Never stdout, which carries protocol messages only. */
|
|
474
480
|
log?: (line: string) => void;
|
|
481
|
+
/** Optional map for a caller that owns one server's request ids; the default is per server. */
|
|
482
|
+
cancellations?: Map<JsonRpcId, () => void>;
|
|
475
483
|
}
|
|
476
484
|
/** Builds a server with every capability this package implements. */
|
|
477
485
|
declare function createServer(options: ServerOptions): McpServer;
|
|
@@ -584,10 +592,8 @@ declare function createLineReader(input: Readable, options: LineReaderOptions):
|
|
|
584
592
|
/**
|
|
585
593
|
* The instructions an MCP client shows its model at handshake.
|
|
586
594
|
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
* *order* rather than features — an agent that reads a part end to end has already lost the
|
|
590
|
-
* budget this tool exists to protect.
|
|
595
|
+
* Seven tools, one order: impact before editing, locate before reading, read a window, explain
|
|
596
|
+
* anything missing, validate before trusting, generate only when a persisted snapshot is wanted.
|
|
591
597
|
*/
|
|
592
598
|
declare const SERVER_INSTRUCTIONS: string;
|
|
593
599
|
|
package/dist/mcp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './chunk-WMEZFLUT.js';
|
|
2
|
-
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText } from './chunk-
|
|
2
|
+
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, REPORT_RESOURCE_URIS, RESOURCE_TEMPLATE_URIS, SERVER_INSTRUCTIONS, STATIC_RESOURCE_URIS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, generateInWorker, generateToken, inspectModernMeta, isCommentStrippable, negotiateLegacyVersion, parsePartSections, runStdioServer, startHttpTransport, stripComments, validateArguments, windowText } from './chunk-TDPYLX7X.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type Mode = "generate" | "validate" | "report";
|
|
2
|
-
type OutputFormat = "text" | "json";
|
|
2
|
+
type OutputFormat = "text" | "json" | "markdown" | "pr-comment";
|
|
3
3
|
/**
|
|
4
4
|
* How files are discovered.
|
|
5
5
|
*
|
|
@@ -24,6 +24,50 @@ type TextEncoding = "utf-8" | "utf-8-lossy" | "utf-16le" | "utf-16be";
|
|
|
24
24
|
* `comments-stripped` – comment text was removed (line numbers preserved) before emission.
|
|
25
25
|
*/
|
|
26
26
|
type InclusionMode = "full" | "preview" | "signatures" | "comments-stripped";
|
|
27
|
+
type IndexSourceKind = "snapshot" | "live-overlay" | "live-memory";
|
|
28
|
+
type FreshnessStatus = "current" | "stale" | "live-computed" | "unknown";
|
|
29
|
+
type CoverageStatus = "complete" | "partial";
|
|
30
|
+
type EdgeProvenance = "ts-semantic" | "ts-reexport" | "import-binding" | "tsconfig-alias" | "workspace-alias" | "relative-import" | "heuristic";
|
|
31
|
+
interface TrustEnvelope {
|
|
32
|
+
indexSource: IndexSourceKind;
|
|
33
|
+
freshness: FreshnessStatus;
|
|
34
|
+
coverage: CoverageStatus;
|
|
35
|
+
snapshotFingerprint?: string;
|
|
36
|
+
overlayStats?: {
|
|
37
|
+
reusedFromManifest: number;
|
|
38
|
+
reparsedChanged: number;
|
|
39
|
+
added: number;
|
|
40
|
+
deleted: number;
|
|
41
|
+
};
|
|
42
|
+
sensitiveExcludedCount: number;
|
|
43
|
+
redactedLines: number;
|
|
44
|
+
omittedCount: number;
|
|
45
|
+
unresolvedCount: number;
|
|
46
|
+
reasons: string[];
|
|
47
|
+
}
|
|
48
|
+
interface ImportBinding {
|
|
49
|
+
specifier: string;
|
|
50
|
+
importedNames: string[];
|
|
51
|
+
typeOnly: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface ReExportBinding {
|
|
54
|
+
specifier: string;
|
|
55
|
+
kind: "star" | "namespace" | "named";
|
|
56
|
+
entries?: Array<{
|
|
57
|
+
imported: string;
|
|
58
|
+
exported: string;
|
|
59
|
+
typeOnly?: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
alias?: string;
|
|
62
|
+
typeOnly: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface DeclarationSpan {
|
|
65
|
+
name: string;
|
|
66
|
+
kind: "function" | "class" | "interface" | "type" | "enum" | "variable" | "export";
|
|
67
|
+
exported: boolean;
|
|
68
|
+
startLine: number;
|
|
69
|
+
endLine: number;
|
|
70
|
+
}
|
|
27
71
|
interface SourceSummary {
|
|
28
72
|
directives: string[];
|
|
29
73
|
imports: string[];
|
|
@@ -51,6 +95,10 @@ interface SourceSummary {
|
|
|
51
95
|
* means both kinds are present.
|
|
52
96
|
*/
|
|
53
97
|
exportsKind?: "esm" | "cjs" | "mixed";
|
|
98
|
+
importBindings?: ImportBinding[];
|
|
99
|
+
reExportBindings?: ReExportBinding[];
|
|
100
|
+
declarationSpans?: DeclarationSpan[];
|
|
101
|
+
declarationSpansOmitted?: true;
|
|
54
102
|
}
|
|
55
103
|
interface JsonSummary {
|
|
56
104
|
shape: string;
|
|
@@ -1009,4 +1057,4 @@ interface ValidationResult {
|
|
|
1009
1057
|
warnings: string[];
|
|
1010
1058
|
}
|
|
1011
1059
|
|
|
1012
|
-
export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, FileEntry as F, HooksConfig as H,
|
|
1060
|
+
export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, EdgeProvenance as E, FileEntry as F, SummaryQuality as G, HooksConfig as H, ImportBinding as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, TruncationReason as N, OutputFormat as O, PromptTask as P, ValidationDrift as Q, ResolvedSnapshotConfig as R, SecretRule as S, TextEncoding as T, ValidationResult as V, SkipRecord as a, SourceSummary as b, SnapshotConfig as c, PartMetadata as d, SecretFinding as e, Manifest as f, TrustEnvelope as g, BudgetConfig as h, CoverageStatus as i, DeclarationSpan as j, FreshnessStatus as k, InclusionMode as l, IncompleteFile as m, IndexSourceKind as n, ManifestArtifact as o, ManifestConfigSnapshot as p, ManifestIndexes as q, ManifestTotals as r, Mode as s, OwnerBrief as t, PartFileEntry as u, ReExportBinding as v, ResolvedArtifacts as w, ResolvedBudgets as x, SecretRuleInput as y, SkipReason as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type Mode = "generate" | "validate" | "report";
|
|
2
|
-
type OutputFormat = "text" | "json";
|
|
2
|
+
type OutputFormat = "text" | "json" | "markdown" | "pr-comment";
|
|
3
3
|
/**
|
|
4
4
|
* How files are discovered.
|
|
5
5
|
*
|
|
@@ -24,6 +24,50 @@ type TextEncoding = "utf-8" | "utf-8-lossy" | "utf-16le" | "utf-16be";
|
|
|
24
24
|
* `comments-stripped` – comment text was removed (line numbers preserved) before emission.
|
|
25
25
|
*/
|
|
26
26
|
type InclusionMode = "full" | "preview" | "signatures" | "comments-stripped";
|
|
27
|
+
type IndexSourceKind = "snapshot" | "live-overlay" | "live-memory";
|
|
28
|
+
type FreshnessStatus = "current" | "stale" | "live-computed" | "unknown";
|
|
29
|
+
type CoverageStatus = "complete" | "partial";
|
|
30
|
+
type EdgeProvenance = "ts-semantic" | "ts-reexport" | "import-binding" | "tsconfig-alias" | "workspace-alias" | "relative-import" | "heuristic";
|
|
31
|
+
interface TrustEnvelope {
|
|
32
|
+
indexSource: IndexSourceKind;
|
|
33
|
+
freshness: FreshnessStatus;
|
|
34
|
+
coverage: CoverageStatus;
|
|
35
|
+
snapshotFingerprint?: string;
|
|
36
|
+
overlayStats?: {
|
|
37
|
+
reusedFromManifest: number;
|
|
38
|
+
reparsedChanged: number;
|
|
39
|
+
added: number;
|
|
40
|
+
deleted: number;
|
|
41
|
+
};
|
|
42
|
+
sensitiveExcludedCount: number;
|
|
43
|
+
redactedLines: number;
|
|
44
|
+
omittedCount: number;
|
|
45
|
+
unresolvedCount: number;
|
|
46
|
+
reasons: string[];
|
|
47
|
+
}
|
|
48
|
+
interface ImportBinding {
|
|
49
|
+
specifier: string;
|
|
50
|
+
importedNames: string[];
|
|
51
|
+
typeOnly: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface ReExportBinding {
|
|
54
|
+
specifier: string;
|
|
55
|
+
kind: "star" | "namespace" | "named";
|
|
56
|
+
entries?: Array<{
|
|
57
|
+
imported: string;
|
|
58
|
+
exported: string;
|
|
59
|
+
typeOnly?: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
alias?: string;
|
|
62
|
+
typeOnly: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface DeclarationSpan {
|
|
65
|
+
name: string;
|
|
66
|
+
kind: "function" | "class" | "interface" | "type" | "enum" | "variable" | "export";
|
|
67
|
+
exported: boolean;
|
|
68
|
+
startLine: number;
|
|
69
|
+
endLine: number;
|
|
70
|
+
}
|
|
27
71
|
interface SourceSummary {
|
|
28
72
|
directives: string[];
|
|
29
73
|
imports: string[];
|
|
@@ -51,6 +95,10 @@ interface SourceSummary {
|
|
|
51
95
|
* means both kinds are present.
|
|
52
96
|
*/
|
|
53
97
|
exportsKind?: "esm" | "cjs" | "mixed";
|
|
98
|
+
importBindings?: ImportBinding[];
|
|
99
|
+
reExportBindings?: ReExportBinding[];
|
|
100
|
+
declarationSpans?: DeclarationSpan[];
|
|
101
|
+
declarationSpansOmitted?: true;
|
|
54
102
|
}
|
|
55
103
|
interface JsonSummary {
|
|
56
104
|
shape: string;
|
|
@@ -1009,4 +1057,4 @@ interface ValidationResult {
|
|
|
1009
1057
|
warnings: string[];
|
|
1010
1058
|
}
|
|
1011
1059
|
|
|
1012
|
-
export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, FileEntry as F, HooksConfig as H,
|
|
1060
|
+
export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, DiscoveryMode as D, EdgeProvenance as E, FileEntry as F, SummaryQuality as G, HooksConfig as H, ImportBinding as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, TruncationReason as N, OutputFormat as O, PromptTask as P, ValidationDrift as Q, ResolvedSnapshotConfig as R, SecretRule as S, TextEncoding as T, ValidationResult as V, SkipRecord as a, SourceSummary as b, SnapshotConfig as c, PartMetadata as d, SecretFinding as e, Manifest as f, TrustEnvelope as g, BudgetConfig as h, CoverageStatus as i, DeclarationSpan as j, FreshnessStatus as k, InclusionMode as l, IncompleteFile as m, IndexSourceKind as n, ManifestArtifact as o, ManifestConfigSnapshot as p, ManifestIndexes as q, ManifestTotals as r, Mode as s, OwnerBrief as t, PartFileEntry as u, ReExportBinding as v, ResolvedArtifacts as w, ResolvedBudgets as x, SecretRuleInput as y, SkipReason as z };
|
package/docs/about.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# About codebase-snapshot
|
|
2
|
+
|
|
3
|
+
codebase-snapshot is a local CLI and MCP server for turning a repository into LLM-ready context
|
|
4
|
+
that a person or an agent can actually check. It is maintained by **Ankur Halder**, a software
|
|
5
|
+
engineer who builds developer tools and writes about context engineering.
|
|
6
|
+
|
|
7
|
+
This page exists for the same reason the rest of the documentation does: a technical claim is
|
|
8
|
+
easier to trust when you can see who made it, how it was tested, and how to correct it.
|
|
9
|
+
|
|
10
|
+
## What this project is
|
|
11
|
+
|
|
12
|
+
- A deterministic scanner that writes Markdown parts under a hard byte budget.
|
|
13
|
+
- A manifest that records every included file, every skipped path and the reason, and every file
|
|
14
|
+
whose body was shortened, with the missing line ranges.
|
|
15
|
+
- A secret redactor that masks matched values in place, and an audit that re-scans the result.
|
|
16
|
+
- A validator that re-hashes the tree and exits non-zero when the snapshot no longer matches it.
|
|
17
|
+
- A live index and an MCP server with seven read-only tools, so an agent can ask for the one
|
|
18
|
+
file, symbol or impact report it needs instead of reading the whole repository.
|
|
19
|
+
- A small, dependency-light TypeScript package: one runtime dependency, no native binary.
|
|
20
|
+
|
|
21
|
+
## What this project is not
|
|
22
|
+
|
|
23
|
+
- **Not a hosted service.** The CLI reads a directory you name and writes a directory you name.
|
|
24
|
+
The MCP server runs on your machine. Nothing is uploaded by the tool itself.
|
|
25
|
+
- **Not a code graph or a replacement for a compiler.** The language profiles are heuristics; the
|
|
26
|
+
optional TypeScript pass is confined and capped, and the docs say where it stops.
|
|
27
|
+
- **Not a guarantee that a model will answer correctly.** Better context removes one failure
|
|
28
|
+
mode. It does not replace tests, review or a reproducible build.
|
|
29
|
+
- **Not a secret scanner with a compliance certificate.** Redaction is defence in depth, not a
|
|
30
|
+
promise that every possible credential shape is known. The [security review](security-review.md)
|
|
31
|
+
states the residual risks plainly.
|
|
32
|
+
|
|
33
|
+
## How the claims are tested
|
|
34
|
+
|
|
35
|
+
The repository runs one offline gate before every publish: lint, typecheck, the test suite, a
|
|
36
|
+
tarball check, the docs site and a link audit. A separate deep run generates a real snapshot,
|
|
37
|
+
validates it against the source tree, verifies every git path is accounted for, and proves the
|
|
38
|
+
run is reproducible.
|
|
39
|
+
|
|
40
|
+
Every snapshot this project publishes about itself is generated by the tool and checked by the
|
|
41
|
+
same validator users get. The docs quote measured numbers, name the version and date, and keep
|
|
42
|
+
the script that produced them in the repository. When a number changes, the page changes with it
|
|
43
|
+
or the number is removed.
|
|
44
|
+
|
|
45
|
+
The site is built from the same Markdown that ships in the package. There is no second copy of
|
|
46
|
+
the prose to drift, and every page shows its last-updated date from git history.
|
|
47
|
+
|
|
48
|
+
## Editorial policy
|
|
49
|
+
|
|
50
|
+
- **Original, tested explanations.** Guides are written from the repository, the tests and real
|
|
51
|
+
runs, not assembled from other people's summaries.
|
|
52
|
+
- **No paid placements.** Comparisons are written by the maintainer and say where the other tool
|
|
53
|
+
is the better choice. There are no bought listicles, paid reviews or guaranteed-placement
|
|
54
|
+
schemes.
|
|
55
|
+
- **Corrections are public.** Open an issue at
|
|
56
|
+
[github.com/ankurhalder/codebase-snapshot/issues](https://github.com/ankurhalder/codebase-snapshot/issues)
|
|
57
|
+
with the page, the claim and the evidence. A correction is committed like any other change.
|
|
58
|
+
- **AI-assisted editing is used; mistakes are treated as defects.** Every command, number and
|
|
59
|
+
security claim is still required to survive the test suite and a manual read. A wrong claim is
|
|
60
|
+
corrected, not defended because a model wrote it.
|
|
61
|
+
|
|
62
|
+
## How this site is built
|
|
63
|
+
|
|
64
|
+
The source of truth is [README.md](https://github.com/ankurhalder/codebase-snapshot/blob/main/README.md)
|
|
65
|
+
and [docs/](https://github.com/ankurhalder/codebase-snapshot/tree/main/docs). A build script renders
|
|
66
|
+
them to static HTML with a canonical URL, a Markdown twin, structured data and a sitemap. There is
|
|
67
|
+
no client-side router and no JavaScript required to read a page.
|
|
68
|
+
|
|
69
|
+
The [llms.txt](https://ankurhalder.github.io/codebase-snapshot/llms.txt) and
|
|
70
|
+
[llms-full.txt](https://ankurhalder.github.io/codebase-snapshot/llms-full.txt) files are generated from
|
|
71
|
+
the same source for agents that prefer one fetch. They are an agent convenience, not a search-engine ranking
|
|
72
|
+
trick.
|
|
73
|
+
|
|
74
|
+
## Elsewhere
|
|
75
|
+
|
|
76
|
+
- Source and issues: [github.com/ankurhalder/codebase-snapshot](https://github.com/ankurhalder/codebase-snapshot)
|
|
77
|
+
- Package: [npmjs.com/package/codebase-snapshot](https://www.npmjs.com/package/codebase-snapshot)
|
|
78
|
+
- Author: [GitHub](https://github.com/ankurhalder), [npm](https://www.npmjs.com/~ankurhalder)
|
|
79
|
+
- MCP listings: [Glama](https://glama.ai/mcp/servers/ankurhalder/codebase-snapshot),
|
|
80
|
+
[M8ven](https://m8ven.ai/mcp/ankurhalder-codebase-snapshot-9hzkhs)
|
|
81
|
+
|
|
82
|
+
## Related
|
|
83
|
+
|
|
84
|
+
- [FAQ](faq.md) — short answers to the questions this page raises.
|
|
85
|
+
- [Security review](security-review.md) — the threat model and residual risks.
|
|
86
|
+
- [All documentation](contents.md) — every guide, reference and comparison.
|
package/docs/agent.md
CHANGED
|
@@ -32,6 +32,23 @@ Sets the project up — config, npm scripts, devDependency, `.gitignore`, instal
|
|
|
32
32
|
with no prompts. It keeps an existing config, and `--no-install` avoids touching the lockfile.
|
|
33
33
|
`setup` is the same operation as a command word.
|
|
34
34
|
|
|
35
|
+
### Reviewing a change
|
|
36
|
+
|
|
37
|
+
`impact` answers the question a reviewer actually has without reading the whole repository again,
|
|
38
|
+
and it does not require a prior `generate`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx codebase-snapshot impact --diff main --format json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
It reports changed files, the symbol-pruned reverse-import closure with the exact specifier for each
|
|
45
|
+
hop, and the tests that directly import a changed or affected file. A live index reuses a current
|
|
46
|
+
manifest, overlays uncommitted files, or scans in memory; `--no-live` requires the snapshot. The
|
|
47
|
+
same resolver handles `tsconfig` aliases. `changed[]` says whether each path is in the snapshot,
|
|
48
|
+
`unresolved[]` names internal imports that did not resolve, and `truncated`/`warnings` say when the
|
|
49
|
+
walk hit a limit. For a reviewer-ready pack, use `brief --diff <ref>`. The MCP equivalent is
|
|
50
|
+
`snapshot_impact` with `base` or `paths`.
|
|
51
|
+
|
|
35
52
|
### Do not rely on the bare command
|
|
36
53
|
|
|
37
54
|
```bash
|
|
@@ -84,16 +101,20 @@ npx codebase-snapshot skill > SKILL.md
|
|
|
84
101
|
|
|
85
102
|
| Target | Path | Read by |
|
|
86
103
|
| :--- | :--- | :--- |
|
|
104
|
+
| `agents` | `.agents/skills/codebase-snapshot/SKILL.md` | Portable agent skill registry |
|
|
87
105
|
| `claude` | `.claude/skills/codebase-snapshot/SKILL.md` | Claude Code auto-discovery |
|
|
88
106
|
| `cursor` | `.cursor/rules/codebase-snapshot.mdc` | Cursor rules |
|
|
89
107
|
|
|
90
108
|
```bash
|
|
91
109
|
npx codebase-snapshot skill --install --target claude # one registry
|
|
92
|
-
npx codebase-snapshot skill --install #
|
|
110
|
+
npx codebase-snapshot skill --install # all three (default)
|
|
111
|
+
npx codebase-snapshot skill --install --with-mcp # also merge .mcp.json
|
|
93
112
|
```
|
|
94
113
|
|
|
95
|
-
|
|
114
|
+
All three are **registries keyed by skill name**: the path carries `codebase-snapshot`, so the file
|
|
96
115
|
cannot be mistaken for your project's own documentation, and two skills cannot collide.
|
|
116
|
+
`--with-mcp` merges one `codebase-snapshot` entry into `.mcp.json` and leaves every other server
|
|
117
|
+
untouched; an existing different entry is kept and noted instead of clobbered.
|
|
97
118
|
|
|
98
119
|
**It never writes `AGENTS.md`.** That file is the repository's own agent contract — build
|
|
99
120
|
commands, conventions, house rules — and an install that creates or edits it puts a tool's
|
|
@@ -115,13 +136,14 @@ devDependency and the `.gitignore` entries for the snapshot directory, and nothi
|
|
|
115
136
|
|
|
116
137
|
## When the client speaks MCP
|
|
117
138
|
|
|
118
|
-
`codebase-snapshot mcp` serves the repository to a Model Context Protocol client over stdio:
|
|
139
|
+
`codebase-snapshot mcp` serves the repository to a Model Context Protocol client over stdio: 7
|
|
119
140
|
tools, `snapshot://` resources and seven prompts. Prefer it over shelling out when the agent already
|
|
120
141
|
has an MCP connection, for two reasons that are properties of the design rather than of the wiring:
|
|
121
142
|
|
|
122
|
-
- **Reads
|
|
123
|
-
|
|
124
|
-
stays redacted.
|
|
143
|
+
- **Reads are live by default.** The server indexes the working tree in memory, overlays uncommitted
|
|
144
|
+
edits, and needs no snapshot directory. A file the index excludes cannot be read back, and a
|
|
145
|
+
redacted value stays redacted. With `live: false`, `snapshot_read` extracts the emitted part
|
|
146
|
+
instead.
|
|
125
147
|
- **Staleness is a first-class question.** `snapshot_validate` answers "has the code moved since
|
|
126
148
|
this was built", which an agent with only a filesystem tool has no way to ask.
|
|
127
149
|
|
package/docs/answer.md
CHANGED
|
@@ -1,54 +1,105 @@
|
|
|
1
|
-
#
|
|
1
|
+
# One question, one bounded context
|
|
2
2
|
|
|
3
|
-
An agent
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## One call
|
|
3
|
+
An agent usually has one question and one budget, not a browsing session. `snapshot_context` is
|
|
4
|
+
the one-call answer: give it a question, files or symbols, and it returns the smallest redacted,
|
|
5
|
+
line-numbered context that fits the token ceiling. Every planned file that did not fit is named in
|
|
6
|
+
`omitted[]`, and the response carries the same `trust` envelope as every other read-only tool.
|
|
8
7
|
|
|
9
8
|
```json
|
|
10
|
-
{
|
|
9
|
+
{
|
|
10
|
+
"name": "snapshot_context",
|
|
11
|
+
"arguments": {
|
|
12
|
+
"question": "how does redaction decide what to mask?",
|
|
13
|
+
"maxTokens": 20000
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
```
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
`planOnly: true` returns the ranked reading plan without bodies. Use it when you want to choose
|
|
19
|
+
what to open yourself; use the default when you want the context in one call. With `files` and
|
|
20
|
+
`symbols`, the planner is skipped and those targets are assembled directly, still under the same
|
|
21
|
+
budget and with the same omission list.
|
|
22
|
+
|
|
23
|
+
The live index is used by default, so uncommitted edits and new files are visible without running
|
|
24
|
+
generate. live: false requires the persisted snapshot.
|
|
25
|
+
|
|
26
|
+
## When to use snapshot_context
|
|
27
|
+
|
|
28
|
+
- **An agent has one question and a token budget.** The tool returns a reading set, not a
|
|
29
|
+
repository. It is the difference between "here is the codebase" and "here is what answers this".
|
|
30
|
+
- **You want the plan before the bodies.** planOnly returns ranked files and token costs without
|
|
31
|
+
spending the budget on content. A caller can show the plan, ask a human to approve it, then fetch
|
|
32
|
+
the bodies.
|
|
33
|
+
- **You already know the files or symbols.** Pass files or symbols directly; the planner is skipped,
|
|
34
|
+
and the same budget and omission accounting still apply.
|
|
35
|
+
|
|
36
|
+
It is not the right tool for "review this whole pull request" (use a brief), "what does this change
|
|
37
|
+
break" (use impact), or "find a string" (use locate).
|
|
38
|
+
|
|
39
|
+
## What the planner does
|
|
40
|
+
|
|
41
|
+
The planner scores files from the question terms against paths, symbol names, layers and kinds. It
|
|
42
|
+
adds importer centrality, then pulls in the imports of the strongest matches and a bounded number of
|
|
43
|
+
their callers. It takes whole files while they fit, halves a large file when its head is affordable,
|
|
44
|
+
and stops when the budget is exhausted. Every file it did not take is named in omitted.
|
|
45
|
+
|
|
46
|
+
The scoring is deliberately simple and inspectable. It is not an embedding search and does not
|
|
47
|
+
claim semantic understanding; a question whose terms do not appear in a path or symbol will fall
|
|
48
|
+
back to the most-imported files, and the response says so in trust.reasons.
|
|
49
|
+
|
|
50
|
+
## What comes back
|
|
51
|
+
|
|
52
|
+
The structured response contains:
|
|
53
|
+
|
|
54
|
+
| Field | Meaning |
|
|
55
|
+
| :-- | :-- |
|
|
56
|
+
| budgetTokens | The ceiling the caller asked for. |
|
|
57
|
+
| usedTokens | The estimate actually spent on the returned bodies. |
|
|
58
|
+
| files | The chosen files, each with its part, layer, kind, line window and why it was chosen. |
|
|
59
|
+
| omitted | Every planned file that did not fit, with the reason. |
|
|
60
|
+
| trust | Index source, freshness, coverage, redaction count and named partial reasons. |
|
|
61
|
+
|
|
62
|
+
A file in files may be a window rather than the whole body. The window is line-numbered and states
|
|
63
|
+
whether more remains, so an agent can ask for the next page instead of assuming it has the file.
|
|
64
|
+
|
|
65
|
+
## A worked example
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
"name": "snapshot_context",
|
|
69
|
+
"arguments": {
|
|
70
|
+
"question": "how does redaction decide what to mask?",
|
|
71
|
+
"maxTokens": 12000,
|
|
72
|
+
"linesPerFile": 120
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
A run on this repository typically selects the redaction engine, its pattern catalogue, the tests
|
|
77
|
+
that exercise span masking and the scanner that decides which files are eligible. The response
|
|
78
|
+
names the files that did not fit; if the redaction tests are omitted, the trust envelope still says
|
|
79
|
+
coverage is complete for the plan, because the plan itself is what was bounded. Read omitted before
|
|
80
|
+
concluding that the answer is complete.
|
|
81
|
+
|
|
82
|
+
## Limits
|
|
83
|
+
|
|
84
|
+
- **Terms, not intent.** Synonyms the planner does not know are missed. Pass files or symbols when
|
|
85
|
+
you know the target.
|
|
86
|
+
- **Token estimates, not tokenizer counts.** The estimate is useful for choosing a budget; it is not
|
|
87
|
+
a model's exact count.
|
|
88
|
+
- **No write access.** The tool never edits or runs code. It returns context.
|
|
89
|
+
- **No guarantee of completeness.** A small budget can omit the one file that mattered; the omission
|
|
90
|
+
list is the honest part of the answer.
|
|
91
|
+
|
|
92
|
+
## The old tools
|
|
93
|
+
|
|
94
|
+
`snapshot_answer`, `snapshot_plan_for` and `snapshot_budget` were folded into
|
|
95
|
+
`snapshot_context` in 0.21.0. The plan/budget distinction is now `planOnly: true`; a multi-budget
|
|
96
|
+
comparison is a sequence of calls, which is cheaper than a tool that exists only to repeat the
|
|
97
|
+
planner.
|
|
98
|
+
|
|
99
|
+
→ [CLI reference](cli.md) · [MCP tools](tools.md) · [Impact](impact.md)
|
|
100
|
+
|
|
101
|
+
## Related
|
|
51
102
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
103
|
+
- [MCP tools](tools.md) — the other six tools and their schemas.
|
|
104
|
+
- [MCP server for a codebase](mcp-server-for-codebase.md) — setup and security.
|
|
105
|
+
- [LLM codebase context](llm-codebase-context.md) — the broader guide.
|