@maxgfr/codeindex 2.7.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.
Files changed (82) hide show
  1. package/README.md +115 -0
  2. package/docs/MIGRATION.md +100 -0
  3. package/package.json +89 -0
  4. package/scripts/cli.mjs +10 -0
  5. package/scripts/engine.d.mts +618 -0
  6. package/scripts/engine.mjs +10655 -0
  7. package/scripts/grammars/bash.wasm +0 -0
  8. package/scripts/grammars/c.wasm +0 -0
  9. package/scripts/grammars/c_sharp.wasm +0 -0
  10. package/scripts/grammars/cpp.wasm +0 -0
  11. package/scripts/grammars/go.wasm +0 -0
  12. package/scripts/grammars/java.wasm +0 -0
  13. package/scripts/grammars/javascript.wasm +0 -0
  14. package/scripts/grammars/lua.wasm +0 -0
  15. package/scripts/grammars/php.wasm +0 -0
  16. package/scripts/grammars/python.wasm +0 -0
  17. package/scripts/grammars/ruby.wasm +0 -0
  18. package/scripts/grammars/rust.wasm +0 -0
  19. package/scripts/grammars/scala.wasm +0 -0
  20. package/scripts/grammars/tsx.wasm +0 -0
  21. package/scripts/grammars/typescript.wasm +0 -0
  22. package/scripts/grammars/web-tree-sitter.wasm +0 -0
  23. package/src/ast/extract.ts +713 -0
  24. package/src/ast/loader.ts +104 -0
  25. package/src/bm25.ts +156 -0
  26. package/src/callers.ts +0 -0
  27. package/src/calls.ts +131 -0
  28. package/src/categorize.ts +80 -0
  29. package/src/centrality.ts +148 -0
  30. package/src/classify.ts +53 -0
  31. package/src/cli-entry.ts +16 -0
  32. package/src/community.ts +345 -0
  33. package/src/complexity.ts +69 -0
  34. package/src/coupling.ts +0 -0
  35. package/src/deadcode.ts +46 -0
  36. package/src/edit.ts +93 -0
  37. package/src/engine-cli.ts +278 -0
  38. package/src/engine.ts +148 -0
  39. package/src/extract/code.ts +376 -0
  40. package/src/extract/markdown.ts +135 -0
  41. package/src/git.ts +205 -0
  42. package/src/glob.ts +56 -0
  43. package/src/graph.ts +0 -0
  44. package/src/grep.ts +115 -0
  45. package/src/hash.ts +13 -0
  46. package/src/ignore.ts +134 -0
  47. package/src/lang/c.ts +26 -0
  48. package/src/lang/common.ts +68 -0
  49. package/src/lang/csharp.ts +22 -0
  50. package/src/lang/elixir.ts +18 -0
  51. package/src/lang/go.ts +22 -0
  52. package/src/lang/java.ts +19 -0
  53. package/src/lang/js-ts.ts +112 -0
  54. package/src/lang/kotlin.ts +20 -0
  55. package/src/lang/lua.ts +18 -0
  56. package/src/lang/php.ts +24 -0
  57. package/src/lang/python.ts +22 -0
  58. package/src/lang/registry.ts +54 -0
  59. package/src/lang/ruby.ts +17 -0
  60. package/src/lang/rust.ts +22 -0
  61. package/src/lang/scala.ts +19 -0
  62. package/src/lang/shell.ts +17 -0
  63. package/src/lang/swift.ts +23 -0
  64. package/src/mcp.ts +512 -0
  65. package/src/memory.ts +75 -0
  66. package/src/modules.ts +128 -0
  67. package/src/pipeline.ts +59 -0
  68. package/src/query.ts +118 -0
  69. package/src/render/graph-json.ts +16 -0
  70. package/src/render/symbols-json.ts +79 -0
  71. package/src/repomap.ts +52 -0
  72. package/src/resolve.ts +950 -0
  73. package/src/rules.ts +249 -0
  74. package/src/scan.ts +172 -0
  75. package/src/sort.ts +12 -0
  76. package/src/surprise.ts +58 -0
  77. package/src/tests-map.ts +105 -0
  78. package/src/types.ts +201 -0
  79. package/src/util.ts +169 -0
  80. package/src/viz.ts +44 -0
  81. package/src/walk.ts +216 -0
  82. package/src/workspaces.ts +748 -0
@@ -0,0 +1,618 @@
1
+ declare const ENGINE_VERSION = "2.7.0";
2
+ declare const SCHEMA_VERSION = 4;
3
+ declare const EXTRACTOR_VERSION = 6;
4
+ type FileKind = "code" | "doc" | "config" | "asset" | "other";
5
+ type EdgeKind = "contains" | "doc-link" | "import" | "call" | "use" | "mention";
6
+ type Tier = 0 | 1 | 2;
7
+ interface CodeSymbol {
8
+ name: string;
9
+ kind: string;
10
+ file: string;
11
+ line: number;
12
+ endLine?: number;
13
+ parent?: string;
14
+ signature?: string;
15
+ exported: boolean;
16
+ lang: string;
17
+ }
18
+ interface RawRef {
19
+ kind: "doc-link" | "import";
20
+ spec: string;
21
+ }
22
+ interface FileRecord {
23
+ rel: string;
24
+ ext: string;
25
+ size: number;
26
+ lines: number;
27
+ hash: string;
28
+ kind: FileKind;
29
+ lang: string;
30
+ title?: string;
31
+ summary?: string;
32
+ headings: string[];
33
+ symbols: CodeSymbol[];
34
+ refs: RawRef[];
35
+ pkg?: string;
36
+ idents?: string[];
37
+ calls?: {
38
+ name: string;
39
+ line: number;
40
+ receiver?: string;
41
+ }[];
42
+ importedNames?: string[];
43
+ }
44
+ interface FileNode {
45
+ id: string;
46
+ kind: "file";
47
+ rel: string;
48
+ fileKind: FileKind;
49
+ lang: string;
50
+ module: string;
51
+ title?: string;
52
+ summary?: string;
53
+ symbols: number;
54
+ lines: number;
55
+ degIn: number;
56
+ degOut: number;
57
+ pagerank?: number;
58
+ testFile?: true;
59
+ }
60
+ interface ModuleNode {
61
+ id: string;
62
+ kind: "module";
63
+ slug: string;
64
+ path: string;
65
+ title: string;
66
+ summary: string;
67
+ tier: Tier;
68
+ members: string[];
69
+ symbols: number;
70
+ degIn: number;
71
+ degOut: number;
72
+ community?: number;
73
+ pagerank?: number;
74
+ betweenness?: number;
75
+ testedBy?: string[];
76
+ }
77
+ interface Edge {
78
+ from: string;
79
+ to: string;
80
+ kind: EdgeKind;
81
+ weight: number;
82
+ dangling?: boolean;
83
+ reason?: string;
84
+ confidence?: "extracted" | "inferred";
85
+ }
86
+ interface Graph {
87
+ schemaVersion: number;
88
+ version: string;
89
+ commit?: string;
90
+ fileCount: number;
91
+ languages: Record<string, number>;
92
+ files: FileNode[];
93
+ modules: ModuleNode[];
94
+ fileEdges: Edge[];
95
+ moduleEdges: Edge[];
96
+ surprises?: SurpriseEdge[];
97
+ }
98
+ interface SurpriseEdge {
99
+ from: string;
100
+ to: string;
101
+ kind: EdgeKind;
102
+ weight: number;
103
+ communities: [number, number];
104
+ pairEdges: number;
105
+ }
106
+ interface SymbolIndex {
107
+ schemaVersion: number;
108
+ defs: Record<string, {
109
+ file: string;
110
+ line: number;
111
+ endLine?: number;
112
+ kind: string;
113
+ exported: boolean;
114
+ lang: string;
115
+ parent?: string;
116
+ }[]>;
117
+ refs: Record<string, string[]>;
118
+ }
119
+
120
+ interface WalkOptions {
121
+ maxFileBytes?: number;
122
+ maxFiles?: number;
123
+ gitignore?: boolean;
124
+ }
125
+ interface WalkedFile {
126
+ rel: string;
127
+ abs: string;
128
+ size: number;
129
+ ext: string;
130
+ mtimeMs: number;
131
+ }
132
+ interface WalkResult {
133
+ files: WalkedFile[];
134
+ capped: boolean;
135
+ excluded: number;
136
+ }
137
+ declare const DEFAULT_MAX_FILES = 20000;
138
+ declare function walk(root: string, opts?: WalkOptions): WalkResult;
139
+ declare function readText(abs: string): string;
140
+
141
+ interface RepoScan {
142
+ root: string;
143
+ commit?: string;
144
+ files: FileRecord[];
145
+ languages: Record<string, number>;
146
+ docText: Map<string, string>;
147
+ mtimes: Map<string, number>;
148
+ capped: boolean;
149
+ excluded: number;
150
+ }
151
+ interface ScanOptions {
152
+ include?: string[];
153
+ exclude?: string[];
154
+ scope?: string;
155
+ gitignore?: boolean;
156
+ maxBytes?: number;
157
+ maxFiles?: number;
158
+ out?: string;
159
+ cache?: Map<string, {
160
+ hash: string;
161
+ record: FileRecord;
162
+ size?: number;
163
+ mtimeMs?: number;
164
+ }>;
165
+ fullHash?: boolean;
166
+ }
167
+ declare function scanRepo(root: string, opts?: ScanOptions): RepoScan;
168
+
169
+ declare function compileGlobs(globs: string[] | undefined): ((rel: string) => boolean) | null;
170
+
171
+ interface IgnoreRule {
172
+ re: RegExp;
173
+ negated: boolean;
174
+ dirOnly: boolean;
175
+ }
176
+ declare function parseGitignore(content: string, baseRel: string): IgnoreRule[];
177
+ declare function isIgnored(rules: readonly IgnoreRule[], rel: string, isDir: boolean): boolean;
178
+
179
+ declare const MARKDOWN_EXT: Set<string>;
180
+ declare function isDoc(rel: string, ext: string): boolean;
181
+ declare function isCode(ext: string): boolean;
182
+ declare function classify(rel: string, ext: string): FileKind;
183
+
184
+ type FileCategory = "code" | "test" | "config" | "schema" | "i18n" | "doc" | "style" | "asset" | "data" | "other";
185
+ declare function categorize(rel: string, ext: string): FileCategory;
186
+
187
+ declare function extToLang(ext: string): string;
188
+
189
+ declare function extractSymbols(rel: string, ext: string, content: string): CodeSymbol[];
190
+ declare function languageOf(ext: string): string;
191
+
192
+ interface CodeInfo {
193
+ symbols: CodeSymbol[];
194
+ summary?: string;
195
+ refs: RawRef[];
196
+ pkg?: string;
197
+ idents?: string[];
198
+ calls?: {
199
+ name: string;
200
+ line: number;
201
+ receiver?: string;
202
+ }[];
203
+ importedNames?: string[];
204
+ }
205
+ declare function extractCode(rel: string, ext: string, content: string): CodeInfo;
206
+
207
+ interface MarkdownInfo {
208
+ title?: string;
209
+ summary?: string;
210
+ headings: string[];
211
+ refs: RawRef[];
212
+ }
213
+ declare function extractMarkdown(content: string): MarkdownInfo;
214
+
215
+ declare function grammarKeyForExt(ext: string): string | undefined;
216
+ declare function ensureGrammars(keys: Iterable<string>): Promise<void>;
217
+ declare function allGrammarKeys(): string[];
218
+ declare function grammarReady(key: string): boolean;
219
+
220
+ interface AstResult {
221
+ symbols: CodeSymbol[];
222
+ refs: RawRef[];
223
+ pkg?: string;
224
+ idents: string[];
225
+ calls: {
226
+ name: string;
227
+ line: number;
228
+ receiver?: string;
229
+ }[];
230
+ importedNames: string[];
231
+ }
232
+ declare function extractAst(rel: string, ext: string, content: string): AstResult | undefined;
233
+
234
+ type Resolution = {
235
+ kind: "resolved";
236
+ target: string;
237
+ } | {
238
+ kind: "external";
239
+ } | {
240
+ kind: "dangling";
241
+ reason: string;
242
+ };
243
+ interface TsPath {
244
+ prefix: string;
245
+ star: boolean;
246
+ targets: string[];
247
+ }
248
+ interface TsConfigScope {
249
+ dir: string;
250
+ baseUrl: string;
251
+ paths: TsPath[];
252
+ }
253
+ interface ExportEntry {
254
+ key: string;
255
+ star: boolean;
256
+ targets: string[];
257
+ }
258
+ interface WorkspacePackage$1 {
259
+ name: string;
260
+ dir: string;
261
+ exportEntries: ExportEntry[];
262
+ mainCandidates: string[];
263
+ }
264
+ interface GoModule {
265
+ module: string;
266
+ dir: string;
267
+ replaces: {
268
+ from: string;
269
+ toDir: string;
270
+ }[];
271
+ }
272
+ interface RustCrate {
273
+ name: string;
274
+ dir: string;
275
+ srcDir: string;
276
+ rootFile?: string;
277
+ }
278
+ interface ResolveContext {
279
+ fileSet: Set<string>;
280
+ dirSet: Set<string>;
281
+ filesByDir: Map<string, string[]>;
282
+ tsConfigs: TsConfigScope[];
283
+ goModules: GoModule[];
284
+ rustCrates: RustCrate[];
285
+ javaRoots: string[];
286
+ pyRoots: string[];
287
+ workspacePackages: WorkspacePackage$1[];
288
+ cIncludeRoots: string[];
289
+ rubyLibRoots: string[];
290
+ phpPsr4: {
291
+ prefix: string;
292
+ dir: string;
293
+ }[];
294
+ csharpNamespaces: Map<string, string[]>;
295
+ warnings: string[];
296
+ }
297
+ declare function buildResolveContext(scan: RepoScan): ResolveContext;
298
+ declare function resolveDocLink(fromRel: string, spec: string, ctx: ResolveContext): Resolution;
299
+ declare function resolveImport(fromRel: string, ext: string, spec: string, ctx: ResolveContext): Resolution;
300
+
301
+ interface ModuleInfo {
302
+ slug: string;
303
+ path: string;
304
+ title: string;
305
+ tier: Tier;
306
+ members: string[];
307
+ summary: string;
308
+ }
309
+ declare function isTestFile(rel: string): boolean;
310
+ declare function tierForPath(path: string): Tier | null;
311
+ declare function buildModules(scan: RepoScan): {
312
+ modules: ModuleInfo[];
313
+ moduleOf: Map<string, string>;
314
+ };
315
+
316
+ declare function uniqueSymbolDefs(scan: RepoScan): Map<string, string>;
317
+ declare function buildGraph(scan: RepoScan, ctx: ResolveContext, modules: ModuleInfo[], moduleOf: Map<string, string>, meta?: {
318
+ version?: string;
319
+ schemaVersion?: number;
320
+ }): Graph;
321
+
322
+ declare function resolveCallEdges(scan: RepoScan, importPairs: Set<string>): Edge[];
323
+
324
+ interface CallerSite {
325
+ file: string;
326
+ line: number;
327
+ confidence?: "corroborated" | "unique-name";
328
+ }
329
+ interface CallerIndexOptions {
330
+ recall?: boolean;
331
+ }
332
+ interface CallerEntry {
333
+ def: CodeSymbol;
334
+ callers: CallerSite[];
335
+ }
336
+ type CallerIndex = Map<string, CallerEntry>;
337
+ declare function computeImportPairs(scan: RepoScan): Set<string>;
338
+ declare function buildCallerIndex(scan: RepoScan, importPairs?: Set<string>, opts?: CallerIndexOptions): CallerIndex;
339
+ declare function enclosingSymbol(scan: RepoScan, file: string, line: number): CodeSymbol | undefined;
340
+
341
+ declare function symbolsOverview(scan: RepoScan, rel: string): CodeSymbol[];
342
+ interface SymbolMatch extends CodeSymbol {
343
+ body?: string;
344
+ }
345
+ interface FindSymbolOptions {
346
+ substring?: boolean;
347
+ includeBody?: boolean;
348
+ maxResults?: number;
349
+ }
350
+ declare function findSymbol(scan: RepoScan, namePath: string, opts?: FindSymbolOptions): SymbolMatch[];
351
+ interface SymbolReferences {
352
+ defs: CodeSymbol[];
353
+ callSites: CallerSite[];
354
+ referencingFiles: string[];
355
+ }
356
+ declare function findReferences(scan: RepoScan, name: string): SymbolReferences;
357
+
358
+ interface EditResult {
359
+ file: string;
360
+ startLine: number;
361
+ endLine: number;
362
+ lines: number;
363
+ }
364
+ declare function resolveUniqueSymbol(scan: RepoScan, namePath: string, file?: string): CodeSymbol;
365
+ declare function replaceSymbolBody(scan: RepoScan, namePath: string, body: string, file?: string): EditResult;
366
+ declare function insertAfterSymbol(scan: RepoScan, namePath: string, body: string, file?: string): EditResult;
367
+ declare function insertBeforeSymbol(scan: RepoScan, namePath: string, body: string, file?: string): EditResult;
368
+
369
+ declare function writeMemory(repo: string, name: string, content: string): string;
370
+ declare function readMemory(repo: string, name: string): string | undefined;
371
+ declare function deleteMemory(repo: string, name: string): boolean;
372
+ declare function listMemories(repo: string): string[];
373
+
374
+ type WorkspaceKind = "npm" | "pnpm" | "lerna" | "nx" | "cargo" | "go" | "maven" | "uv" | "composer" | "gradle";
375
+ interface WorkspacePackage {
376
+ name: string;
377
+ dir: string;
378
+ kind: WorkspaceKind;
379
+ manifest: string;
380
+ description?: string;
381
+ dependsOn?: string[];
382
+ }
383
+ interface WorkspaceInfo {
384
+ packages: WorkspacePackage[];
385
+ cycle?: string[];
386
+ topoOrder: string[];
387
+ warnings: string[];
388
+ packageOf(rel: string): WorkspacePackage | undefined;
389
+ }
390
+ declare function detectWorkspaces(root: string): WorkspaceInfo;
391
+
392
+ declare function pagerankOf(ids: string[], edges: Edge[], damping?: number): Map<string, number>;
393
+ declare function betweennessOf(ids: string[], edges: Edge[]): Map<string, number>;
394
+ declare function applyCentrality(graph: Graph): string[];
395
+
396
+ declare function communityOf(graph: Graph, slug: string): number | undefined;
397
+ declare function detectCommunities(modules: ModuleNode[], edges: Edge[], previous?: Record<string, string[]>): Map<string, number>;
398
+
399
+ declare function isTestPath(rel: string): boolean;
400
+ interface TestMap {
401
+ testFiles: Set<string>;
402
+ testedByFile: Map<string, string[]>;
403
+ testedByModule: Map<string, string[]>;
404
+ }
405
+ declare function computeTestMap(graph: Graph): TestMap;
406
+ declare function testsForModule(graph: Graph, slug: string): string[];
407
+ declare function untestedModules(graph: Graph): ModuleNode[];
408
+
409
+ declare function computeSurprises(graph: Graph): SurpriseEdge[];
410
+ declare function isSurprising(graph: Graph, from: string, to: string): boolean;
411
+
412
+ declare function computeSymbolRefs(scan: RepoScan): Map<string, Set<string>>;
413
+ declare function buildSymbolIndex(scan: RepoScan, refs?: Map<string, Set<string>>): SymbolIndex;
414
+ declare function renderSymbolsJson(index: SymbolIndex): string;
415
+
416
+ declare function renderGraphJson(graph: Graph): string;
417
+
418
+ interface BuildIndexOptions extends ScanOptions {
419
+ meta?: {
420
+ version?: string;
421
+ schemaVersion?: number;
422
+ };
423
+ previousCommunities?: Record<string, string[]>;
424
+ }
425
+ interface IndexArtifacts {
426
+ scan: RepoScan;
427
+ graph: Graph;
428
+ symbols: SymbolIndex;
429
+ }
430
+ declare function buildIndexArtifacts(repo: string, opts?: BuildIndexOptions): IndexArtifacts;
431
+
432
+ declare function headCommit(dir: string): string | undefined;
433
+ interface DiffFile {
434
+ path: string;
435
+ status: "added" | "modified" | "deleted" | "renamed";
436
+ oldPath?: string;
437
+ binary?: boolean;
438
+ linesAdded?: number;
439
+ linesDeleted?: number;
440
+ }
441
+ interface Hunk {
442
+ start: number;
443
+ end: number;
444
+ approx?: boolean;
445
+ }
446
+ interface DiffSpec {
447
+ mergeBase?: string;
448
+ staged?: boolean;
449
+ }
450
+ declare function isGitWorktree(dir: string): boolean;
451
+ declare function resolveBaseRef(dir: string, base?: string): {
452
+ ref: string;
453
+ mergeBase: string;
454
+ note?: string;
455
+ } | {
456
+ error: string;
457
+ };
458
+ declare function diffFiles(dir: string, spec: DiffSpec): DiffFile[];
459
+ declare function diffHunks(dir: string, spec: DiffSpec): Map<string, Hunk[]>;
460
+ declare function untrackedFiles(dir: string): string[];
461
+ declare function gitChurn(dir: string, opts?: {
462
+ since?: string;
463
+ }): {
464
+ churn: Map<string, number>;
465
+ ok: boolean;
466
+ };
467
+ declare function changedSince(dir: string, ref: string): Set<string>;
468
+
469
+ interface SearchHit {
470
+ file: string;
471
+ line: number;
472
+ text: string;
473
+ }
474
+ interface GrepOptions {
475
+ globs?: string[];
476
+ maxHits?: number;
477
+ ignoreCase?: boolean;
478
+ noRipgrep?: boolean;
479
+ }
480
+ declare function grepRepo(root: string, pattern: string, opts?: GrepOptions): SearchHit[];
481
+
482
+ interface SearchOptions {
483
+ limit?: number;
484
+ }
485
+ interface SearchResult {
486
+ file: string;
487
+ score: number;
488
+ matchedTerms: string[];
489
+ topSymbols: string[];
490
+ }
491
+ declare function subtokens(raw: string): string[];
492
+ declare function searchIndex(scan: RepoScan, query: string, opts?: SearchOptions): SearchResult[];
493
+
494
+ type RuleSeverity = "error" | "warn";
495
+ interface ForbiddenEdgeRule {
496
+ name: string;
497
+ from: string | string[];
498
+ to: string | string[];
499
+ kind?: EdgeKind[];
500
+ severity?: RuleSeverity;
501
+ comment?: string;
502
+ }
503
+ interface BuiltinRule {
504
+ name: string;
505
+ builtin: "cycles" | "orphans";
506
+ severity?: RuleSeverity;
507
+ comment?: string;
508
+ }
509
+ type ArchRule = ForbiddenEdgeRule | BuiltinRule;
510
+ interface RuleViolation {
511
+ rule: string;
512
+ from: string;
513
+ to: string;
514
+ kind: EdgeKind | "cycle" | "orphan";
515
+ severity: RuleSeverity;
516
+ comment?: string;
517
+ }
518
+ declare function parseRules(input: unknown): ArchRule[];
519
+ declare function checkRules(graph: Graph, rules: ArchRule[]): RuleViolation[];
520
+
521
+ interface ChangeCoupling {
522
+ a: string;
523
+ b: string;
524
+ together: number;
525
+ totalA: number;
526
+ totalB: number;
527
+ strength: number;
528
+ }
529
+ interface CouplingOptions {
530
+ since?: string;
531
+ maxCommitFiles?: number;
532
+ minTogether?: number;
533
+ maxPairs?: number;
534
+ }
535
+ declare function changeCoupling(dir: string, opts?: CouplingOptions): {
536
+ ok: boolean;
537
+ couplings: ChangeCoupling[];
538
+ };
539
+ interface Hotspot {
540
+ rel: string;
541
+ lines: number;
542
+ commits: number;
543
+ score: number;
544
+ }
545
+ declare function rankHotspots(scan: RepoScan, churn: Map<string, number>, top?: number): Hotspot[];
546
+
547
+ interface RepoMapOptions {
548
+ budgetTokens?: number;
549
+ maxSymbolsPerFile?: number;
550
+ }
551
+ declare function renderRepoMap(scan: RepoScan, graph: Graph, opts?: RepoMapOptions): string;
552
+
553
+ interface DeadSymbol {
554
+ name: string;
555
+ file: string;
556
+ line: number;
557
+ kind: string;
558
+ tier: "unreferenced" | "uncalled";
559
+ }
560
+ declare function findDeadCode(scan: RepoScan): DeadSymbol[];
561
+
562
+ declare function complexityOfSource(source: string): number;
563
+ interface SymbolComplexity {
564
+ file: string;
565
+ name: string;
566
+ line: number;
567
+ endLine?: number;
568
+ complexity: number;
569
+ }
570
+ declare function symbolComplexity(scan: RepoScan, rel?: string, top?: number): SymbolComplexity[];
571
+ interface RiskHotspot {
572
+ file: string;
573
+ complexity: number;
574
+ commits: number;
575
+ score: number;
576
+ }
577
+ declare function riskHotspots(scan: RepoScan, churn: Map<string, number>, top?: number): RiskHotspot[];
578
+
579
+ interface MermaidOptions {
580
+ module?: string;
581
+ maxEdges?: number;
582
+ }
583
+ declare function renderMermaid(graph: Graph, opts?: MermaidOptions): string;
584
+
585
+ declare function runMcpServer(): Promise<void>;
586
+
587
+ declare function sha1(s: string): string;
588
+ declare function shortHash(s: string, n?: number): string;
589
+
590
+ declare function byStr(a: string, b: string): number;
591
+ declare function byKey<T>(keyOf: (x: T) => string): (a: T, b: T) => number;
592
+
593
+ interface ShResult {
594
+ ok: boolean;
595
+ status: number | null;
596
+ stdout: string;
597
+ stderr: string;
598
+ missing: boolean;
599
+ }
600
+ declare function sh(cmd: string, args: string[], opts?: {
601
+ cwd?: string;
602
+ input?: string;
603
+ timeoutMs?: number;
604
+ env?: Record<string, string | undefined>;
605
+ }): ShResult;
606
+ declare function have(cmd: string): boolean;
607
+ declare function slugify(input: string): string;
608
+ declare function clip(s: string, max: number): string;
609
+ declare function clipInline(s: string, max: number): string;
610
+ declare function escapeRegExp(s: string): string;
611
+ declare function foldText(s: string): string;
612
+ declare function keywords(question: string): string[];
613
+ declare function rankedKeywords(question: string): string[];
614
+ declare function rrf<T>(lists: T[][], keyOf: (item: T) => string, k?: number): Map<string, number>;
615
+
616
+ declare function runCli(argv: string[]): Promise<void>;
617
+
618
+ export { type ArchRule, type BuildIndexOptions, type BuiltinRule, type CallerEntry, type CallerIndex, type CallerIndexOptions, type CallerSite, type ChangeCoupling, type CodeInfo, type CodeSymbol, type CouplingOptions, DEFAULT_MAX_FILES, type DeadSymbol, type DiffFile, type DiffSpec, ENGINE_VERSION, EXTRACTOR_VERSION, type Edge, type EdgeKind, type EditResult, type FileCategory, type FileKind, type FileNode, type FileRecord, type FindSymbolOptions, type ForbiddenEdgeRule, type Graph, type GrepOptions, type Hotspot, type Hunk, type IgnoreRule, type IndexArtifacts, MARKDOWN_EXT, type MarkdownInfo, type MermaidOptions, type ModuleInfo, type ModuleNode, type RawRef, 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 ShResult, type SurpriseEdge, type SymbolComplexity, type SymbolIndex, type SymbolMatch, type SymbolReferences, type TestMap, type Tier, type WalkOptions, type WalkResult, type WalkedFile, type WorkspaceInfo, type WorkspaceKind, type WorkspacePackage, allGrammarKeys, applyCentrality, betweennessOf, buildCallerIndex, buildGraph, buildIndexArtifacts, buildModules, buildResolveContext, buildSymbolIndex, byKey, byStr, categorize, changeCoupling, changedSince, checkRules, classify, clip, clipInline, communityOf, compileGlobs, complexityOfSource, computeImportPairs, computeSurprises, computeSymbolRefs, computeTestMap, deleteMemory, detectCommunities, detectWorkspaces, diffFiles, diffHunks, enclosingSymbol, ensureGrammars, escapeRegExp, extToLang, extractAst, extractCode, extractMarkdown, extractSymbols, findDeadCode, findReferences, findSymbol, foldText, gitChurn, grammarKeyForExt, grammarReady, grepRepo, have, headCommit, insertAfterSymbol, insertBeforeSymbol, isCode, isDoc, isGitWorktree, isIgnored, isSurprising, isTestFile, isTestPath, keywords, languageOf, listMemories, pagerankOf, parseGitignore, parseRules, rankHotspots, rankedKeywords, readMemory, readText, renderGraphJson, renderMermaid, renderRepoMap, renderSymbolsJson, replaceSymbolBody, resolveBaseRef, resolveCallEdges, resolveDocLink, resolveImport, resolveUniqueSymbol, riskHotspots, rrf, runCli, runMcpServer, scanRepo, searchIndex, sh, sha1, shortHash, slugify, subtokens, symbolComplexity, symbolsOverview, testsForModule, tierForPath, uniqueSymbolDefs, untestedModules, untrackedFiles, walk, writeMemory };