@maxgfr/codeindex 2.17.1 → 2.18.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/README.md +26 -3
- package/docs/MIGRATION.md +107 -0
- package/package.json +1 -1
- package/scripts/engine.d.mts +242 -18
- package/scripts/engine.mjs +1730 -721
- package/src/ast/extract.ts +180 -142
- package/src/coupling.ts +0 -0
- package/src/delta.ts +417 -0
- package/src/derived.ts +17 -0
- package/src/engine-cli.ts +145 -24
- package/src/engine.ts +31 -4
- package/src/extract/code.ts +4 -1
- package/src/graph.ts +0 -0
- package/src/mcp.ts +469 -212
- package/src/pool.ts +271 -0
- package/src/preload.ts +159 -0
- package/src/render/scip.ts +80 -20
- package/src/render/symbols-json.ts +3 -2
- package/src/scan.ts +142 -17
- package/src/traverse.ts +164 -0
- package/src/types.ts +1 -1
- package/src/viz.ts +91 -1
package/README.md
CHANGED
|
@@ -16,7 +16,10 @@ engine as a single file instead of taking an npm dependency.
|
|
|
16
16
|
- **Walk** a repo deterministically: ignore lists, binary/lockfile skips, size
|
|
17
17
|
and count caps (`capped` flag, never silent truncation), symlink-cycle guard.
|
|
18
18
|
- **Scan** every file into a `FileRecord`: classification, language, symbols,
|
|
19
|
-
imports, headings, hashes — with an incremental cache fastpath.
|
|
19
|
+
imports, headings, hashes — with an incremental cache fastpath. Extraction
|
|
20
|
+
runs across worker threads by default (`--workers`, `CODEINDEX_WORKERS`);
|
|
21
|
+
artifacts are byte-identical either way, and anything that would make a
|
|
22
|
+
worker's result differ falls back to the single-threaded path.
|
|
20
23
|
- **Extract symbols** via tree-sitter (13 languages, when the wasm sidecar is
|
|
21
24
|
present) or per-language regex rules (15 languages, always available).
|
|
22
25
|
- **Resolve imports** across languages: tsconfig paths, package `exports`,
|
|
@@ -228,7 +231,27 @@ about another checkout. `--server-name <name>` overrides the announced
|
|
|
228
231
|
**Prime the index first** and activation becomes a load, not a rebuild:
|
|
229
232
|
`codeindex index --repo <dir> --out <dir>/.codeindex`. The first tool call
|
|
230
233
|
deserializes those artifacts when the engine version, commit and artifact
|
|
231
|
-
hashes all match.
|
|
234
|
+
hashes all match. The same index also makes every CLI read command
|
|
235
|
+
(`search`, `symbols`, `graph`, `repomap`, …) a lookup instead of a rebuild.
|
|
236
|
+
|
|
237
|
+
### Protocol, and what it costs an agent
|
|
238
|
+
|
|
239
|
+
The server negotiates its protocol version: it answers with whatever revision
|
|
240
|
+
the client asked for among `2024-11-05`, `2025-03-26`, `2025-06-18` and
|
|
241
|
+
`2025-11-25`, and otherwise with the newest. Fields a later revision
|
|
242
|
+
introduced are only sent to clients that asked for it, so an older client sees
|
|
243
|
+
exactly what it saw before.
|
|
244
|
+
|
|
245
|
+
From `2025-03-26` every tool carries behaviour annotations — `readOnlyHint` on
|
|
246
|
+
the 21 read tools, `destructiveHint`/`idempotentHint` on the five that write —
|
|
247
|
+
which is what lets a host auto-approve reads and confirm only writes.
|
|
248
|
+
|
|
249
|
+
Responses are capped (`--max-response-bytes`, default 1 MB). Under the cap
|
|
250
|
+
nothing changes. Over it — where a whole-repo `graph` on a large monorepo runs
|
|
251
|
+
to millions of tokens and no client can accept it — the response is replaced by
|
|
252
|
+
a short notice naming the size, the artifact already on disk, and the narrower
|
|
253
|
+
tool that answers the question. Most tools also take a `limit`/`maxResults`/
|
|
254
|
+
`top`/`maxEdges` argument to stay well under it.
|
|
232
255
|
|
|
233
256
|
`engine.mjs` is a pure side-effect-free library (safe for consumers to inline
|
|
234
257
|
into their own CLIs); `cli.mjs` is the thin standalone CLI/MCP wrapper.
|
|
@@ -264,7 +287,7 @@ a consumer can stamp its own identity into artifacts it persists.
|
|
|
264
287
|
|
|
265
288
|
## Benchmarks
|
|
266
289
|
|
|
267
|
-
Measured against
|
|
290
|
+
Measured against universal-ctags, Serena (LSP over MCP) and Graphify with a
|
|
268
291
|
reproducible harness (`scripts/bench/`); full methodology, fairness notes and
|
|
269
292
|
all scenarios in [BENCHMARKS.md](./BENCHMARKS.md).
|
|
270
293
|
|
package/docs/MIGRATION.md
CHANGED
|
@@ -272,6 +272,113 @@ with no `.codeindex/` behaves exactly as before.
|
|
|
272
272
|
sidecar keeps its own memoization path (the graph/symbols shas are all the
|
|
273
273
|
guard checks).
|
|
274
274
|
|
|
275
|
+
## v2.18.0 — parallel extraction, persisted-index reads, MCP protocol negotiation
|
|
276
|
+
|
|
277
|
+
Large release, all **additive**: `SCHEMA_VERSION` / `EMBED_VERSION` /
|
|
278
|
+
`EXTRACTOR_VERSION` are untouched, `graph.json` / `symbols.json` / `index.scip`
|
|
279
|
+
stay **byte-identical**, and every existing export keeps its signature. **No
|
|
280
|
+
re-pin is required.** New capabilities are opt-in by calling the new functions
|
|
281
|
+
or passing the new options.
|
|
282
|
+
|
|
283
|
+
### Extraction is faster and its records are unchanged
|
|
284
|
+
|
|
285
|
+
`extractAst` folded its four full-tree traversals into one and reads children
|
|
286
|
+
via `namedChildren` instead of per-index `namedChild(i)`. Results are identical;
|
|
287
|
+
this is purely fewer wasm boundary crossings.
|
|
288
|
+
|
|
289
|
+
One signature grew: `extractAst(rel, ext, content, opts)` accepts
|
|
290
|
+
`opts.imports` (**default `true`**), which computes `refs` and `pkg`. The
|
|
291
|
+
default preserves today's contract, so a consumer reading `ast.refs` needs no
|
|
292
|
+
change. `extractCode` passes `false` because it recomputes both with regex and
|
|
293
|
+
discarded the AST's versions — that dead work is now skipped.
|
|
294
|
+
|
|
295
|
+
### `scanSummary` — a file count without parsing the repo
|
|
296
|
+
|
|
297
|
+
`scanSummary(root, opts)` returns `{root, commit, fileCount, languages, capped,
|
|
298
|
+
excluded}` from the walk plus the path classifiers, with **no read, hash or
|
|
299
|
+
parse**. It shares the kept-file loop with `scanRepo`, so the two cannot report
|
|
300
|
+
different numbers. Use it wherever you only need the histogram — the CLI `scan`
|
|
301
|
+
command went from 6.7s to 0.17s on a 7k-file repo. `scanRepo` is unchanged.
|
|
302
|
+
|
|
303
|
+
### `scanRepoParallel` — worker_threads extraction (opt-in, degrades silently)
|
|
304
|
+
|
|
305
|
+
`scanRepoParallel(root, opts)` is **async** and returns the same `RepoScan`
|
|
306
|
+
`scanRepo` would, byte for byte. Code files are read/hashed/extracted across
|
|
307
|
+
`min(cores-1, 8)` workers; docs and everything else stay on the main thread.
|
|
308
|
+
`opts.workers` (or `CODEINDEX_WORKERS`) sets the count; `0` or `1` is the
|
|
309
|
+
sequential path.
|
|
310
|
+
|
|
311
|
+
`scanRepo` stays **synchronous and sequential** — the pipeline never becomes
|
|
312
|
+
async, and consumers calling it are unaffected.
|
|
313
|
+
|
|
314
|
+
Two things to know before switching:
|
|
315
|
+
|
|
316
|
+
- **It degrades to sequential rather than risk a different result.** Workers
|
|
317
|
+
report the grammar keys they actually readied; any disagreement with the main
|
|
318
|
+
thread discards the whole parallel run. So does a failure to resolve the
|
|
319
|
+
engine URL, spawn, or complete. `extractInParallel` never throws.
|
|
320
|
+
- **The worker imports the engine BY URL, so it must be a real file.** The URL
|
|
321
|
+
is resolved the way grammars are: the running module when it is
|
|
322
|
+
`engine.mjs`, else an adjacent `engine.mjs`. **If you re-bundle the engine
|
|
323
|
+
into your own entry, neither resolves and you get the sequential path** — by
|
|
324
|
+
design, since importing your bundle in a worker would run your top-level code.
|
|
325
|
+
Vendoring `scripts/engine.mjs` as a file (the documented layout) works.
|
|
326
|
+
|
|
327
|
+
Memory is the trade: each worker carries its own tree-sitter wasm arena. On a
|
|
328
|
+
7k-file repo, 1.63s / 1424 MB parallel versus 5.03s / 1019 MB sequential.
|
|
329
|
+
|
|
330
|
+
New exports: `scanRepoParallel`, `extractInParallel`, `runExtractWorker`,
|
|
331
|
+
`workerCount`, `keptCodeFiles`, `buildCodeRecord`, type `ExtractedRecord`, and
|
|
332
|
+
`ScanOptions.extracted` (populated by `scanRepoParallel` — never set it by hand).
|
|
333
|
+
|
|
334
|
+
`runExtractWorker` must stay exported from any re-export of the barrel: the
|
|
335
|
+
worker bootstrap imports it by name, and a missing export is indistinguishable
|
|
336
|
+
from "this is not the engine".
|
|
337
|
+
|
|
338
|
+
### The persisted-index preload is public and no longer MCP-only
|
|
339
|
+
|
|
340
|
+
v2.15.0 said these helpers were "entirely internal to `mcp.ts`". They now live
|
|
341
|
+
in `src/preload.ts` and are exported: `preloadSession`, `preloadArtifacts`,
|
|
342
|
+
`readPersistedIndex`, `toCacheMap`, `INDEX_DIR`, plus types `PersistedMeta`,
|
|
343
|
+
`PersistedCacheEntry`, `PersistedCacheMap`. `toCacheMap` is still re-exported
|
|
344
|
+
from `mcp.ts`, so existing imports keep working.
|
|
345
|
+
|
|
346
|
+
The freshness guard is unchanged — same T4 oracle, same "never throws, always
|
|
347
|
+
degrades to a cold build" contract. Every CLI read command now goes through it,
|
|
348
|
+
which is where the 5s → 0.3s figures come from.
|
|
349
|
+
|
|
350
|
+
### MCP: protocol negotiation, response cap, and closed CLI gaps
|
|
351
|
+
|
|
352
|
+
- **Protocol is negotiated.** The server reads `params.protocolVersion` and
|
|
353
|
+
answers with it when it speaks it (`2024-11-05`, `2025-03-26`, `2025-06-18`,
|
|
354
|
+
`2025-11-25`), else with the newest. **A client that asks for `2024-11-05`
|
|
355
|
+
receives exactly the bytes it received before** — `title` and `annotations`
|
|
356
|
+
are gated on the negotiated version. Clients that never send `initialize` are
|
|
357
|
+
treated as `2024-11-05`.
|
|
358
|
+
- **Responses are capped, not paginated.** Under `maxResponseBytes` (default
|
|
359
|
+
1e6, `--max-response-bytes`) a response is byte-identical to before. Over it —
|
|
360
|
+
where no MCP client could consume the payload anyway — it is replaced by a
|
|
361
|
+
parseable notice naming the size, the on-disk artifact, and the narrower tool.
|
|
362
|
+
New exports: `capResponse`, `DEFAULT_MAX_RESPONSE_BYTES`, `resourceLinkFor`,
|
|
363
|
+
`negotiateProtocol`, `validateArgs`.
|
|
364
|
+
- **Arguments are type-checked** against the declared `inputSchema`, returning
|
|
365
|
+
a Tool Execution Error (`isError`). Previously a wrong-typed argument was
|
|
366
|
+
silently ignored. If you drive this server programmatically with loosely
|
|
367
|
+
typed arguments, a call that used to fall back to a default now errors —
|
|
368
|
+
numeric strings (`"50"`) are still accepted.
|
|
369
|
+
- **New optional tool arguments**, all defaulting to today's behaviour:
|
|
370
|
+
`find_symbol.maxResults`, `complexity.top`, `complexity.since` (risk mode
|
|
371
|
+
previously dropped it), `mermaid.maxEdges`, `dead_code.limit`, `grep.scope`
|
|
372
|
+
(was CLI-only), `callers.recall` (was CLI-only), `check_rules.configPath`.
|
|
373
|
+
`check_rules` no longer requires `rules` when `configPath` is given.
|
|
374
|
+
- **Session cache is a 4-entry LRU**, not one entry, so alternating repos or
|
|
375
|
+
scopes no longer forces a cold rebuild each call.
|
|
376
|
+
|
|
377
|
+
### New CLI flags
|
|
378
|
+
|
|
379
|
+
`--workers <n>` (index), `--index <dir>` and `--no-index-cache` (read commands),
|
|
380
|
+
`--max-response-bytes <n>` (mcp).
|
|
381
|
+
|
|
275
382
|
## Typical mapping (what to replace with what)
|
|
276
383
|
|
|
277
384
|
What a consumer usually deletes from its own codebase, and the engine export
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxgfr/codeindex",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "Self-contained, deterministic repo-indexing engine: walk + language detection + symbol/import extraction (tree-sitter AST with regex fallback) + import resolution + typed cross-file link-graph + analytics. Ships as a single zero-dependency engine.mjs that consumer tools vendor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.33.0",
|
package/scripts/engine.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const ENGINE_VERSION = "2.
|
|
1
|
+
declare const ENGINE_VERSION = "2.18.0";
|
|
2
2
|
declare const SCHEMA_VERSION = 4;
|
|
3
3
|
declare const EXTRACTOR_VERSION = 10;
|
|
4
4
|
type FileKind = "code" | "doc" | "config" | "asset" | "other";
|
|
@@ -169,9 +169,100 @@ interface ScanOptions {
|
|
|
169
169
|
}>;
|
|
170
170
|
fullHash?: boolean;
|
|
171
171
|
precomputedWalk?: WalkResult;
|
|
172
|
+
extracted?: Map<string, ExtractedRecord>;
|
|
172
173
|
}
|
|
174
|
+
interface ExtractedRecord {
|
|
175
|
+
size: number;
|
|
176
|
+
mtimeMs: number;
|
|
177
|
+
record: FileRecord;
|
|
178
|
+
}
|
|
179
|
+
declare function buildCodeRecord(rel: string, ext: string, size: number, content: string, hash: string, lang: string, opts?: {
|
|
180
|
+
maxCallsPerFile?: number;
|
|
181
|
+
}): FileRecord;
|
|
182
|
+
declare function keptCodeFiles(root: string, opts?: ScanOptions): {
|
|
183
|
+
f: WalkedFile;
|
|
184
|
+
lang: string;
|
|
185
|
+
}[];
|
|
186
|
+
interface ScanSummary {
|
|
187
|
+
root: string;
|
|
188
|
+
commit?: string;
|
|
189
|
+
fileCount: number;
|
|
190
|
+
languages: Record<string, number>;
|
|
191
|
+
capped: boolean;
|
|
192
|
+
excluded: number;
|
|
193
|
+
}
|
|
194
|
+
declare function scanSummary(root: string, opts?: ScanOptions): ScanSummary;
|
|
173
195
|
declare function scanRepo(root: string, opts?: ScanOptions): RepoScan;
|
|
174
196
|
|
|
197
|
+
interface BuildIndexOptions extends ScanOptions {
|
|
198
|
+
meta?: {
|
|
199
|
+
version?: string;
|
|
200
|
+
schemaVersion?: number;
|
|
201
|
+
};
|
|
202
|
+
previousCommunities?: Record<string, string[]>;
|
|
203
|
+
}
|
|
204
|
+
interface IndexArtifacts {
|
|
205
|
+
scan: RepoScan;
|
|
206
|
+
graph: Graph;
|
|
207
|
+
symbols: SymbolIndex;
|
|
208
|
+
}
|
|
209
|
+
declare function buildIndexArtifacts(repo: string, opts?: BuildIndexOptions): IndexArtifacts;
|
|
210
|
+
declare function buildArtifactsFromScan(scan: RepoScan, opts?: BuildIndexOptions): IndexArtifacts;
|
|
211
|
+
|
|
212
|
+
declare const INDEX_DIR = ".codeindex";
|
|
213
|
+
type PersistedCacheEntry = {
|
|
214
|
+
hash: string;
|
|
215
|
+
record: FileRecord;
|
|
216
|
+
size?: number;
|
|
217
|
+
mtimeMs?: number;
|
|
218
|
+
};
|
|
219
|
+
type PersistedCacheMap = Map<string, PersistedCacheEntry>;
|
|
220
|
+
interface PersistedMeta {
|
|
221
|
+
engineVersion?: string;
|
|
222
|
+
commit?: string;
|
|
223
|
+
graphSha1?: string;
|
|
224
|
+
symbolsSha1?: string;
|
|
225
|
+
}
|
|
226
|
+
declare function toCacheMap(scan: RepoScan): PersistedCacheMap;
|
|
227
|
+
declare function readPersistedIndex(repo: string, indexDir?: string): {
|
|
228
|
+
cacheMap: PersistedCacheMap;
|
|
229
|
+
meta: PersistedMeta;
|
|
230
|
+
} | undefined;
|
|
231
|
+
declare function preloadArtifacts(repo: string, scan: RepoScan, meta: PersistedMeta, indexDir?: string): IndexArtifacts | undefined;
|
|
232
|
+
declare function preloadSession(repo: string, opts: Omit<ScanOptions, "cache">, indexDir?: string): {
|
|
233
|
+
scan: RepoScan;
|
|
234
|
+
cacheMap: PersistedCacheMap;
|
|
235
|
+
arts?: IndexArtifacts;
|
|
236
|
+
} | undefined;
|
|
237
|
+
|
|
238
|
+
interface Job {
|
|
239
|
+
abs: string;
|
|
240
|
+
rel: string;
|
|
241
|
+
ext: string;
|
|
242
|
+
}
|
|
243
|
+
interface WorkerInput {
|
|
244
|
+
jobs: Job[];
|
|
245
|
+
grammarKeys: string[];
|
|
246
|
+
maxCallsPerFile?: number;
|
|
247
|
+
}
|
|
248
|
+
interface WorkerOutput {
|
|
249
|
+
ready: string[];
|
|
250
|
+
records: {
|
|
251
|
+
rel: string;
|
|
252
|
+
size: number;
|
|
253
|
+
mtimeMs: number;
|
|
254
|
+
record: FileRecord;
|
|
255
|
+
}[];
|
|
256
|
+
}
|
|
257
|
+
declare function workerCount(requested?: number): number;
|
|
258
|
+
declare function runExtractWorker(input: WorkerInput, post: (out: WorkerOutput) => void): Promise<void>;
|
|
259
|
+
declare function extractInParallel(jobs: Job[], grammarKeys: string[], count: number, opts?: {
|
|
260
|
+
maxCallsPerFile?: number;
|
|
261
|
+
}): Promise<Map<string, ExtractedRecord> | undefined>;
|
|
262
|
+
declare function scanRepoParallel(root: string, opts?: ScanOptions & {
|
|
263
|
+
workers?: number;
|
|
264
|
+
}): Promise<RepoScan>;
|
|
265
|
+
|
|
175
266
|
declare function compileGlobs(globs: string[] | undefined): ((rel: string) => boolean) | null;
|
|
176
267
|
|
|
177
268
|
interface IgnoreRule {
|
|
@@ -253,9 +344,10 @@ interface AstResult {
|
|
|
253
344
|
}
|
|
254
345
|
declare function extractAst(rel: string, ext: string, content: string, opts?: {
|
|
255
346
|
maxCalls?: number;
|
|
347
|
+
imports?: boolean;
|
|
256
348
|
}): AstResult | undefined;
|
|
257
349
|
|
|
258
|
-
declare const DEFAULT_GRAMMARS_URL = "https://github.com/maxgfr/codeindex/releases/download/v2.
|
|
350
|
+
declare const DEFAULT_GRAMMARS_URL = "https://github.com/maxgfr/codeindex/releases/download/v2.18.0/grammars-2.18.0.tar.gz";
|
|
259
351
|
interface GrammarsPullTarget {
|
|
260
352
|
url: string;
|
|
261
353
|
sha256Url?: string;
|
|
@@ -496,21 +588,6 @@ interface RenderScipOptions {
|
|
|
496
588
|
}
|
|
497
589
|
declare function renderScip(scan: RepoScan, opts?: RenderScipOptions): Uint8Array;
|
|
498
590
|
|
|
499
|
-
interface BuildIndexOptions extends ScanOptions {
|
|
500
|
-
meta?: {
|
|
501
|
-
version?: string;
|
|
502
|
-
schemaVersion?: number;
|
|
503
|
-
};
|
|
504
|
-
previousCommunities?: Record<string, string[]>;
|
|
505
|
-
}
|
|
506
|
-
interface IndexArtifacts {
|
|
507
|
-
scan: RepoScan;
|
|
508
|
-
graph: Graph;
|
|
509
|
-
symbols: SymbolIndex;
|
|
510
|
-
}
|
|
511
|
-
declare function buildIndexArtifacts(repo: string, opts?: BuildIndexOptions): IndexArtifacts;
|
|
512
|
-
declare function buildArtifactsFromScan(scan: RepoScan, opts?: BuildIndexOptions): IndexArtifacts;
|
|
513
|
-
|
|
514
591
|
declare function headCommit(dir: string): string | undefined;
|
|
515
592
|
interface DiffFile {
|
|
516
593
|
path: string;
|
|
@@ -739,6 +816,152 @@ interface MermaidOptions {
|
|
|
739
816
|
maxEdges?: number;
|
|
740
817
|
}
|
|
741
818
|
declare function renderMermaid(graph: Graph, opts?: MermaidOptions): string;
|
|
819
|
+
interface ClusteredMermaidResult {
|
|
820
|
+
content: string;
|
|
821
|
+
shownModules: number;
|
|
822
|
+
totalModules: number;
|
|
823
|
+
shownEdges: number;
|
|
824
|
+
totalEdges: number;
|
|
825
|
+
}
|
|
826
|
+
interface ClusteredMermaidOptions {
|
|
827
|
+
maxModules?: number;
|
|
828
|
+
maxEdges?: number;
|
|
829
|
+
title?: string;
|
|
830
|
+
}
|
|
831
|
+
declare function renderMermaidClustered(graph: Graph, opts?: ClusteredMermaidOptions): ClusteredMermaidResult;
|
|
832
|
+
|
|
833
|
+
declare function hubThreshold(degrees: number[]): number;
|
|
834
|
+
interface ImpactedFile {
|
|
835
|
+
rel: string;
|
|
836
|
+
module: string;
|
|
837
|
+
depth: number;
|
|
838
|
+
}
|
|
839
|
+
interface ImpactResult {
|
|
840
|
+
target: string;
|
|
841
|
+
scope: "module" | "file";
|
|
842
|
+
seeds: string[];
|
|
843
|
+
files: ImpactedFile[];
|
|
844
|
+
modules: string[];
|
|
845
|
+
}
|
|
846
|
+
declare function reverseClosure(edges: Edge[], seeds: string[], depth?: number): Map<string, number>;
|
|
847
|
+
declare function impactOf(graph: Graph, target: string, depth?: number): ImpactResult | undefined;
|
|
848
|
+
interface NeighborLink {
|
|
849
|
+
node: string;
|
|
850
|
+
direction: "out" | "in";
|
|
851
|
+
kind: string;
|
|
852
|
+
weight: number;
|
|
853
|
+
depth: number;
|
|
854
|
+
confidence?: "extracted" | "inferred";
|
|
855
|
+
}
|
|
856
|
+
interface NeighborResult {
|
|
857
|
+
target: string;
|
|
858
|
+
scope: "module" | "file";
|
|
859
|
+
links: NeighborLink[];
|
|
860
|
+
members?: string[];
|
|
861
|
+
}
|
|
862
|
+
declare function neighborsOf(graph: Graph, target: string, depth?: number, kinds?: Set<string>): NeighborResult | undefined;
|
|
863
|
+
|
|
864
|
+
interface DeltaOptions {
|
|
865
|
+
base?: string;
|
|
866
|
+
staged?: boolean;
|
|
867
|
+
depth?: number;
|
|
868
|
+
}
|
|
869
|
+
interface ChangedSymbol {
|
|
870
|
+
name: string;
|
|
871
|
+
kind: string;
|
|
872
|
+
exported: boolean;
|
|
873
|
+
line: number;
|
|
874
|
+
endLine?: number;
|
|
875
|
+
parent?: string;
|
|
876
|
+
approx?: boolean;
|
|
877
|
+
}
|
|
878
|
+
interface DeltaChange {
|
|
879
|
+
path: string;
|
|
880
|
+
status: DiffFile["status"];
|
|
881
|
+
oldPath?: string;
|
|
882
|
+
binary?: boolean;
|
|
883
|
+
linesAdded?: number;
|
|
884
|
+
linesDeleted?: number;
|
|
885
|
+
module?: string;
|
|
886
|
+
hunks: {
|
|
887
|
+
start: number;
|
|
888
|
+
end: number;
|
|
889
|
+
}[];
|
|
890
|
+
symbols: ChangedSymbol[];
|
|
891
|
+
}
|
|
892
|
+
interface DeltaModule {
|
|
893
|
+
slug: string;
|
|
894
|
+
path: string;
|
|
895
|
+
score: number;
|
|
896
|
+
bucket: "HIGH" | "MEDIUM" | "LOW";
|
|
897
|
+
reasons: string[];
|
|
898
|
+
changedFiles: string[];
|
|
899
|
+
changedSymbols: {
|
|
900
|
+
total: number;
|
|
901
|
+
exported: number;
|
|
902
|
+
};
|
|
903
|
+
impact: {
|
|
904
|
+
directFiles: number;
|
|
905
|
+
transitiveFiles: number;
|
|
906
|
+
modules: string[];
|
|
907
|
+
};
|
|
908
|
+
tests: {
|
|
909
|
+
status: "covered" | "gap" | "n/a";
|
|
910
|
+
files: string[];
|
|
911
|
+
};
|
|
912
|
+
open: string[];
|
|
913
|
+
}
|
|
914
|
+
interface DeltaResult {
|
|
915
|
+
base: {
|
|
916
|
+
ref: string;
|
|
917
|
+
mergeBase: string;
|
|
918
|
+
staged: boolean;
|
|
919
|
+
};
|
|
920
|
+
indexCommit?: string;
|
|
921
|
+
depth: number;
|
|
922
|
+
changes: DeltaChange[];
|
|
923
|
+
modules: DeltaModule[];
|
|
924
|
+
dangling: {
|
|
925
|
+
from: string;
|
|
926
|
+
spec: string;
|
|
927
|
+
reason: string;
|
|
928
|
+
}[];
|
|
929
|
+
deleted: string[];
|
|
930
|
+
unindexed: string[];
|
|
931
|
+
notes: string[];
|
|
932
|
+
}
|
|
933
|
+
type DeltaError = {
|
|
934
|
+
error: string;
|
|
935
|
+
};
|
|
936
|
+
declare const RISK_WEIGHTS: {
|
|
937
|
+
readonly exportedChange: 25;
|
|
938
|
+
readonly hubHigh: 20;
|
|
939
|
+
readonly hubMed: 10;
|
|
940
|
+
readonly blastHigh: 20;
|
|
941
|
+
readonly blastMed: 10;
|
|
942
|
+
readonly testGap: 20;
|
|
943
|
+
readonly surprise: 10;
|
|
944
|
+
readonly dangling: 15;
|
|
945
|
+
};
|
|
946
|
+
declare const DEFAULT_DELTA_DEPTH = 2;
|
|
947
|
+
interface NamedDef {
|
|
948
|
+
name: string;
|
|
949
|
+
file: string;
|
|
950
|
+
line: number;
|
|
951
|
+
endLine?: number;
|
|
952
|
+
kind: string;
|
|
953
|
+
exported: boolean;
|
|
954
|
+
parent?: string;
|
|
955
|
+
}
|
|
956
|
+
declare function symbolsInHunks(defs: NamedDef[], hunks: Hunk[]): ChangedSymbol[];
|
|
957
|
+
declare function computeDelta(graph: Graph, symbols: SymbolIndex | undefined, diff: {
|
|
958
|
+
files: DiffFile[];
|
|
959
|
+
hunks: Map<string, Hunk[]>;
|
|
960
|
+
base: DeltaResult["base"];
|
|
961
|
+
notes?: string[];
|
|
962
|
+
}, depth?: number): DeltaResult;
|
|
963
|
+
declare function deltaFor(repo: string, graph: Graph, symbols: SymbolIndex | undefined, opts?: DeltaOptions): DeltaResult | DeltaError;
|
|
964
|
+
declare function formatDeltaPanel(res: DeltaResult): string;
|
|
742
965
|
|
|
743
966
|
interface McpServerOptions {
|
|
744
967
|
serverInfo?: {
|
|
@@ -746,6 +969,7 @@ interface McpServerOptions {
|
|
|
746
969
|
version?: string;
|
|
747
970
|
};
|
|
748
971
|
defaultRepo?: string;
|
|
972
|
+
maxResponseBytes?: number;
|
|
749
973
|
}
|
|
750
974
|
declare function runMcpServer(opts?: McpServerOptions): Promise<void>;
|
|
751
975
|
|
|
@@ -782,4 +1006,4 @@ declare function rrf<T>(lists: T[][], keyOf: (item: T) => string, k?: number): M
|
|
|
782
1006
|
|
|
783
1007
|
declare function runCli(rawArgv: string[]): Promise<void>;
|
|
784
1008
|
|
|
785
|
-
export { type ArchRule, type BuildIndexOptions, type BuiltinRule, type CallerEntry, type CallerIndex, type CallerIndexOptions, type CallerSite, type ChangeCoupling, type CodeInfo, type CodeSymbol, type CouplingOptions, DEFAULT_GRAMMARS_URL, DEFAULT_MAX_FILES, type DeadSymbol, type DiffFile, type DiffSpec, EMBED_VERSION, ENGINE_VERSION, EXTRACTOR_VERSION, type Edge, type EdgeKind, type EditResult, type EmbedEndpointOptions, type EmbedPullTarget, type EmbeddingIndex, type EmbeddingRecord, type EmbeddingUnit, type FileCategory, type FileKind, type FileNode, type FileRecord, type FindSymbolOptions, type ForbiddenEdgeRule, type GrammarsPullResult, type GrammarsPullTarget, type GrammarsTier, type GrammarsTierName, type Graph, type GrepOptions, type Hotspot, type Hunk, type IgnoreRule, type IndexArtifacts, MARKDOWN_EXT, type MarkdownInfo, type McpServerOptions, type MermaidOptions, type ModuleInfo, type ModuleNode, type RawCallerIndex, type RawCallerSite, type RawRef, type RenderScipOptions, type RepoMapOptions, type RepoScan, type Resolution, type ResolveContext, type RiskHotspot, type RuleSeverity, type RuleViolation, SCHEMA_VERSION, type ScanOptions, type SearchHit, type SearchOptions, type SearchResult, type SemanticSearchOptions, type SemanticSearchResult, type ShResult, type StaticEmbedModel, type SurpriseEdge, type SymbolComplexity, type SymbolIndex, type SymbolMatch, type SymbolReferences, type TestMap, type Tier, type WalkOptions, type WalkResult, type WalkedFile, type WarmGrammarsOptions, type WarmGrammarsResult, type WorkspaceInfo, type WorkspaceKind, type WorkspacePackage, allGrammarKeys, applyCentrality, basicTokenize, betweennessOf, buildArtifactsFromScan, buildCallerIndex, buildEmbeddingIndex, buildEndpointIndex, buildGraph, buildIndexArtifacts, buildModules, buildRawCallerIndex, buildResolveContext, buildSymbolIndex, byKey, byStr, categorize, changeCoupling, changedSince, checkRules, classify, clip, clipInline, communityOf, compileGlobs, complexityOfSource, computeImportPairs, computeSurprises, computeSymbolRefs, computeTestMap, deleteMemory, deserializeEmbeddings, detectCommunities, detectWorkspaces, diffFiles, diffHunks, embedEndpointUrl, embedViaEndpoint, embeddingUnits, enclosingSymbol, encode, encodeQueryViaEndpoint, ensureGrammars, escapeRegExp, extToLang, extractAst, extractCode, extractGrammarsTarball, extractMarkdown, extractSymbols, extractTarInto, fetchExpectedSha256, fetchGrammarsTarball, findDeadCode, findReferences, findSymbol, foldText, gitChurn, grammarKeyForExt, grammarKeysForExts, grammarReady, grepRepo, hasEmbedModel, have, headCommit, healthzUrl, insertAfterSymbol, insertBeforeSymbol, intDot, isCode, isDoc, isGitWorktree, isIgnored, isSurprising, isTestFile, isTestPath, keywords, languageOf, listMemories, loadEmbedModel, pagerankOf, parseGitignore, parseRules, probeEndpoint, pullGrammars, quantize, rankHotspots, rankedKeywords, readMemory, readText, renderGraphJson, renderMermaid, renderRepoMap, renderScip, renderSymbolsJson, replaceSymbolBody, resolveBaseRef, resolveCallEdges, resolveDocLink, resolveEmbedEndpoint, resolveEmbedModelDir, resolveEmbedPullUrl, resolveGrammarsDir, resolveGrammarsPullTarget, resolveGrammarsTier, resolveImport, resolveUniqueSymbol, rewriteCommand, riskHotspots, roundHalfToEven, rrf, runCli, runMcpServer, scanRepo, searchIndex, searchSemantic, serializeEmbeddings, sh, sha1, sharedGrammarsCacheDir, shortHash, slugify, subtokens, symbolComplexity, symbolsOverview, testsForModule, tierForPath, tokenize, uniqueSymbolDefs, untestedModules, untrackedFiles, walk, warmGrammars, wordpiece, writeMemory };
|
|
1009
|
+
export { type ArchRule, type BuildIndexOptions, type BuiltinRule, type CallerEntry, type CallerIndex, type CallerIndexOptions, type CallerSite, type ChangeCoupling, type ChangedSymbol, type ClusteredMermaidOptions, type ClusteredMermaidResult, type CodeInfo, type CodeSymbol, type CouplingOptions, DEFAULT_DELTA_DEPTH, DEFAULT_GRAMMARS_URL, DEFAULT_MAX_FILES, type DeadSymbol, type DeltaChange, type DeltaError, type DeltaModule, type DeltaOptions, type DeltaResult, type DiffFile, type DiffSpec, EMBED_VERSION, ENGINE_VERSION, EXTRACTOR_VERSION, type Edge, type EdgeKind, type EditResult, type EmbedEndpointOptions, type EmbedPullTarget, type EmbeddingIndex, type EmbeddingRecord, type EmbeddingUnit, type ExtractedRecord, type FileCategory, type FileKind, type FileNode, type FileRecord, type FindSymbolOptions, type ForbiddenEdgeRule, type GrammarsPullResult, type GrammarsPullTarget, type GrammarsTier, type GrammarsTierName, type Graph, type GrepOptions, type Hotspot, type Hunk, INDEX_DIR, type IgnoreRule, type ImpactResult, type ImpactedFile, type IndexArtifacts, MARKDOWN_EXT, type MarkdownInfo, type McpServerOptions, type MermaidOptions, type ModuleInfo, type ModuleNode, type NeighborLink, type NeighborResult, type PersistedCacheEntry, type PersistedCacheMap, type PersistedMeta, RISK_WEIGHTS, type RawCallerIndex, type RawCallerSite, type RawRef, type RenderScipOptions, type RepoMapOptions, type RepoScan, type Resolution, type ResolveContext, type RiskHotspot, type RuleSeverity, type RuleViolation, SCHEMA_VERSION, type ScanOptions, type ScanSummary, type SearchHit, type SearchOptions, type SearchResult, type SemanticSearchOptions, type SemanticSearchResult, type ShResult, type StaticEmbedModel, type SurpriseEdge, type SymbolComplexity, type SymbolIndex, type SymbolMatch, type SymbolReferences, type TestMap, type Tier, type WalkOptions, type WalkResult, type WalkedFile, type WarmGrammarsOptions, type WarmGrammarsResult, type WorkspaceInfo, type WorkspaceKind, type WorkspacePackage, allGrammarKeys, applyCentrality, basicTokenize, betweennessOf, buildArtifactsFromScan, buildCallerIndex, buildCodeRecord, buildEmbeddingIndex, buildEndpointIndex, buildGraph, buildIndexArtifacts, buildModules, buildRawCallerIndex, buildResolveContext, buildSymbolIndex, byKey, byStr, categorize, changeCoupling, changedSince, checkRules, classify, clip, clipInline, communityOf, compileGlobs, complexityOfSource, computeDelta, computeImportPairs, computeSurprises, computeSymbolRefs, computeTestMap, deleteMemory, deltaFor, deserializeEmbeddings, detectCommunities, detectWorkspaces, diffFiles, diffHunks, embedEndpointUrl, embedViaEndpoint, embeddingUnits, enclosingSymbol, encode, encodeQueryViaEndpoint, ensureGrammars, escapeRegExp, extToLang, extractAst, extractCode, extractGrammarsTarball, extractInParallel, extractMarkdown, extractSymbols, extractTarInto, fetchExpectedSha256, fetchGrammarsTarball, findDeadCode, findReferences, findSymbol, foldText, formatDeltaPanel, gitChurn, grammarKeyForExt, grammarKeysForExts, grammarReady, grepRepo, hasEmbedModel, have, headCommit, healthzUrl, hubThreshold, impactOf, insertAfterSymbol, insertBeforeSymbol, intDot, isCode, isDoc, isGitWorktree, isIgnored, isSurprising, isTestFile, isTestPath, keptCodeFiles, keywords, languageOf, listMemories, loadEmbedModel, neighborsOf, pagerankOf, parseGitignore, parseRules, preloadArtifacts, preloadSession, probeEndpoint, pullGrammars, quantize, rankHotspots, rankedKeywords, readMemory, readPersistedIndex, readText, renderGraphJson, renderMermaid, renderMermaidClustered, renderRepoMap, renderScip, renderSymbolsJson, replaceSymbolBody, resolveBaseRef, resolveCallEdges, resolveDocLink, resolveEmbedEndpoint, resolveEmbedModelDir, resolveEmbedPullUrl, resolveGrammarsDir, resolveGrammarsPullTarget, resolveGrammarsTier, resolveImport, resolveUniqueSymbol, reverseClosure, rewriteCommand, riskHotspots, roundHalfToEven, rrf, runCli, runExtractWorker, runMcpServer, scanRepo, scanRepoParallel, scanSummary, searchIndex, searchSemantic, serializeEmbeddings, sh, sha1, sharedGrammarsCacheDir, shortHash, slugify, subtokens, symbolComplexity, symbolsInHunks, symbolsOverview, testsForModule, tierForPath, toCacheMap, tokenize, uniqueSymbolDefs, untestedModules, untrackedFiles, walk, warmGrammars, wordpiece, workerCount, writeMemory };
|