ultra11y 2.22.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/LICENSE +21 -0
- package/README.md +223 -0
- package/docker/Dockerfile +7 -0
- package/docker/package.json +9 -0
- package/docker/runner.mjs +23 -0
- package/package.json +73 -0
- package/scripts/bench.mjs +151 -0
- package/scripts/build-act-corpus.mjs +143 -0
- package/scripts/build-adjudication.mjs +503 -0
- package/scripts/build-pack-rgaa.mjs +397 -0
- package/scripts/build-standards.mjs +548 -0
- package/scripts/copy-bundle.mjs +39 -0
- package/scripts/import-pack.mjs +107 -0
- package/scripts/sync-engine.mjs +84 -0
- package/scripts/sync-version.mjs +43 -0
- package/scripts/ultra11y.mjs +52739 -0
- package/scripts/vendor/act-testcases.json +12297 -0
- package/scripts/vendor/rgaa/SOURCE.json +8 -0
- package/scripts/vendor/rgaa/criteres.json +4144 -0
- package/scripts/vendor/rgaa/glossaire.json +480 -0
- package/scripts/vendor/wcag-2.2-fr.json +82 -0
- package/scripts/vendor/wcag-2.2-sc-universe.json +950 -0
- package/scripts/vendor/wcag-2.2-sc.json +574 -0
- package/scripts/verify-rgaa-source.mjs +126 -0
- package/scripts/verify-skill-bundle.mjs +91 -0
- package/skills/review-a11y/SKILL.md +123 -0
- package/skills/review-a11y/scripts/ultra11y.mjs +52739 -0
- package/skills/ultra11y/SKILL.md +292 -0
- package/skills/ultra11y/references/act.md +163 -0
- package/skills/ultra11y/references/adjudication.md +599 -0
- package/skills/ultra11y/references/audit.md +100 -0
- package/skills/ultra11y/references/authoring.md +37 -0
- package/skills/ultra11y/references/automation.md +113 -0
- package/skills/ultra11y/references/correction.md +41 -0
- package/skills/ultra11y/references/criteria.md +129 -0
- package/skills/ultra11y/references/cross-file.md +82 -0
- package/skills/ultra11y/references/dynamic.md +152 -0
- package/skills/ultra11y/references/false-positives.md +81 -0
- package/skills/ultra11y/references/fix.md +46 -0
- package/skills/ultra11y/references/focus-and-logic.md +64 -0
- package/skills/ultra11y/references/forbidden-patterns.md +61 -0
- package/skills/ultra11y/references/forms-and-errors.md +147 -0
- package/skills/ultra11y/references/guidance.md +55 -0
- package/skills/ultra11y/references/judgment.md +90 -0
- package/skills/ultra11y/references/media-and-motion.md +116 -0
- package/skills/ultra11y/references/methodology.md +72 -0
- package/skills/ultra11y/references/naming.md +117 -0
- package/skills/ultra11y/references/orchestration.md +44 -0
- package/skills/ultra11y/references/packs.md +193 -0
- package/skills/ultra11y/references/prd.md +104 -0
- package/skills/ultra11y/references/rendered.md +110 -0
- package/skills/ultra11y/references/scale.md +49 -0
- package/skills/ultra11y/references/standards.md +97 -0
- package/skills/ultra11y/references/structure.md +138 -0
- package/skills/ultra11y/references/verify.md +88 -0
- package/skills/ultra11y/references/widgets.md +106 -0
- package/skills/ultra11y/scripts/ultra11y.mjs +52739 -0
- package/src/act.ts +441 -0
- package/src/adjudicate.ts +630 -0
- package/src/aria.ts +230 -0
- package/src/audit.ts +396 -0
- package/src/auditor.ts +399 -0
- package/src/autofill.ts +102 -0
- package/src/axe-map.ts +294 -0
- package/src/baseline.ts +75 -0
- package/src/capture.ts +182 -0
- package/src/check.ts +243 -0
- package/src/cli.ts +1927 -0
- package/src/color.ts +102 -0
- package/src/config.ts +182 -0
- package/src/crawl.ts +75 -0
- package/src/criteria.ts +183 -0
- package/src/data/adjudication.json +770 -0
- package/src/data/guidance/rgaa.json +2395 -0
- package/src/data/standards/rgaa.glossary.json +478 -0
- package/src/data/standards/rgaa.json +3454 -0
- package/src/data/wcag-universe.json +530 -0
- package/src/data/wcag.json +1178 -0
- package/src/discover.ts +203 -0
- package/src/fix/codemods.ts +76 -0
- package/src/fix/diff.ts +64 -0
- package/src/fix/edits.ts +126 -0
- package/src/fix.ts +215 -0
- package/src/gh.ts +214 -0
- package/src/glob.ts +206 -0
- package/src/graph/build.ts +114 -0
- package/src/graph/engine-resolve.ts +0 -0
- package/src/graph/graph.ts +126 -0
- package/src/graph/imports.ts +359 -0
- package/src/graph/resolve.ts +73 -0
- package/src/graph/tsconfig.ts +113 -0
- package/src/grounding.ts +119 -0
- package/src/guidance/index.ts +45 -0
- package/src/guidance/types.ts +36 -0
- package/src/init.ts +113 -0
- package/src/mcp/handlers.ts +388 -0
- package/src/mcp/http.ts +260 -0
- package/src/mcp/prompts.ts +183 -0
- package/src/mcp/protocol.ts +187 -0
- package/src/mcp/resources.ts +136 -0
- package/src/mcp/server.ts +228 -0
- package/src/mcp/stdio.ts +119 -0
- package/src/mcp/tools.ts +347 -0
- package/src/messages.ts +1011 -0
- package/src/name.ts +174 -0
- package/src/orchestrate-templates.ts +231 -0
- package/src/orchestrate.ts +186 -0
- package/src/output.ts +108 -0
- package/src/pack.ts +187 -0
- package/src/parse/html.ts +258 -0
- package/src/parse/jsx-ast.ts +67 -0
- package/src/parse/jsx-bridge.ts +247 -0
- package/src/parse/jsx.ts +19 -0
- package/src/parse/source.ts +75 -0
- package/src/prd.ts +406 -0
- package/src/project-lock.ts +42 -0
- package/src/render.ts +307 -0
- package/src/report.ts +399 -0
- package/src/rules/colors.ts +125 -0
- package/src/rules/cross-registry.ts +264 -0
- package/src/rules/cross-rule.ts +83 -0
- package/src/rules/forms.ts +590 -0
- package/src/rules/frames.ts +33 -0
- package/src/rules/headings.ts +227 -0
- package/src/rules/images.ts +200 -0
- package/src/rules/links.ts +193 -0
- package/src/rules/mandatory.ts +173 -0
- package/src/rules/multimedia.ts +77 -0
- package/src/rules/navigation.ts +190 -0
- package/src/rules/presentation.ts +75 -0
- package/src/rules/registry.ts +57 -0
- package/src/rules/rule.ts +122 -0
- package/src/rules/scripts-aria.ts +636 -0
- package/src/rules/tables.ts +264 -0
- package/src/rules/timing.ts +55 -0
- package/src/sample.ts +176 -0
- package/src/scan-local.ts +866 -0
- package/src/scan.ts +538 -0
- package/src/standards/derive.ts +195 -0
- package/src/standards/index.ts +31 -0
- package/src/standards/pack-rules.ts +111 -0
- package/src/standards/pack.ts +81 -0
- package/src/standards/registry.ts +100 -0
- package/src/standards/types.ts +202 -0
- package/src/standards/validate.ts +544 -0
- package/src/standards/vocabulary.ts +75 -0
- package/src/types.ts +355 -0
- package/src/util.ts +32 -0
- package/src/vendor/codeindex-engine.d.mts +1009 -0
- package/src/vendor/codeindex-engine.mjs +13701 -0
- package/src/vendor/engine.meta.json +9 -0
- package/src/verify.ts +275 -0
- package/src/wcag.ts +128 -0
|
@@ -0,0 +1,1009 @@
|
|
|
1
|
+
declare const ENGINE_VERSION = "2.20.1";
|
|
2
|
+
declare const SCHEMA_VERSION = 4;
|
|
3
|
+
declare const EXTRACTOR_VERSION = 10;
|
|
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
|
+
ignoreDirs?: string[];
|
|
125
|
+
}
|
|
126
|
+
interface WalkedFile {
|
|
127
|
+
rel: string;
|
|
128
|
+
abs: string;
|
|
129
|
+
size: number;
|
|
130
|
+
ext: string;
|
|
131
|
+
mtimeMs: number;
|
|
132
|
+
}
|
|
133
|
+
interface WalkResult {
|
|
134
|
+
files: WalkedFile[];
|
|
135
|
+
capped: boolean;
|
|
136
|
+
excluded: number;
|
|
137
|
+
}
|
|
138
|
+
declare const DEFAULT_MAX_FILES = 20000;
|
|
139
|
+
declare function walk(root: string, opts?: WalkOptions): WalkResult;
|
|
140
|
+
declare function readText(abs: string): string;
|
|
141
|
+
|
|
142
|
+
interface RepoScan {
|
|
143
|
+
root: string;
|
|
144
|
+
commit?: string;
|
|
145
|
+
files: FileRecord[];
|
|
146
|
+
languages: Record<string, number>;
|
|
147
|
+
docText: Map<string, string>;
|
|
148
|
+
mtimes: Map<string, number>;
|
|
149
|
+
capped: boolean;
|
|
150
|
+
excluded: number;
|
|
151
|
+
contentUnchanged: boolean;
|
|
152
|
+
cacheDirty: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface ScanOptions {
|
|
155
|
+
include?: string[];
|
|
156
|
+
exclude?: string[];
|
|
157
|
+
scope?: string;
|
|
158
|
+
gitignore?: boolean;
|
|
159
|
+
ignoreDirs?: string[];
|
|
160
|
+
maxBytes?: number;
|
|
161
|
+
maxFiles?: number;
|
|
162
|
+
maxCallsPerFile?: number;
|
|
163
|
+
out?: string;
|
|
164
|
+
cache?: Map<string, {
|
|
165
|
+
hash: string;
|
|
166
|
+
record: FileRecord;
|
|
167
|
+
size?: number;
|
|
168
|
+
mtimeMs?: number;
|
|
169
|
+
}>;
|
|
170
|
+
fullHash?: boolean;
|
|
171
|
+
precomputedWalk?: WalkResult;
|
|
172
|
+
extracted?: Map<string, ExtractedRecord>;
|
|
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;
|
|
195
|
+
declare function scanRepo(root: string, opts?: ScanOptions): RepoScan;
|
|
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
|
+
|
|
266
|
+
declare function compileGlobs(globs: string[] | undefined): ((rel: string) => boolean) | null;
|
|
267
|
+
|
|
268
|
+
interface IgnoreRule {
|
|
269
|
+
re: RegExp;
|
|
270
|
+
negated: boolean;
|
|
271
|
+
dirOnly: boolean;
|
|
272
|
+
}
|
|
273
|
+
declare function parseGitignore(content: string, baseRel: string): IgnoreRule[];
|
|
274
|
+
declare function isIgnored(rules: readonly IgnoreRule[], rel: string, isDir: boolean): boolean;
|
|
275
|
+
|
|
276
|
+
declare const MARKDOWN_EXT: Set<string>;
|
|
277
|
+
declare function isDoc(rel: string, ext: string): boolean;
|
|
278
|
+
declare function isCode(ext: string): boolean;
|
|
279
|
+
declare function classify(rel: string, ext: string): FileKind;
|
|
280
|
+
|
|
281
|
+
type FileCategory = "code" | "test" | "config" | "schema" | "i18n" | "doc" | "style" | "asset" | "data" | "other";
|
|
282
|
+
declare function categorize(rel: string, ext: string): FileCategory;
|
|
283
|
+
|
|
284
|
+
declare function extToLang(ext: string): string;
|
|
285
|
+
|
|
286
|
+
declare function extractSymbols(rel: string, ext: string, content: string): CodeSymbol[];
|
|
287
|
+
declare function languageOf(ext: string): string;
|
|
288
|
+
|
|
289
|
+
interface CodeInfo {
|
|
290
|
+
symbols: CodeSymbol[];
|
|
291
|
+
summary?: string;
|
|
292
|
+
refs: RawRef[];
|
|
293
|
+
pkg?: string;
|
|
294
|
+
idents?: string[];
|
|
295
|
+
calls?: {
|
|
296
|
+
name: string;
|
|
297
|
+
line: number;
|
|
298
|
+
receiver?: string;
|
|
299
|
+
}[];
|
|
300
|
+
importedNames?: string[];
|
|
301
|
+
}
|
|
302
|
+
declare function extractCode(rel: string, ext: string, content: string, opts?: {
|
|
303
|
+
maxCallsPerFile?: number;
|
|
304
|
+
}): CodeInfo;
|
|
305
|
+
|
|
306
|
+
interface MarkdownInfo {
|
|
307
|
+
title?: string;
|
|
308
|
+
summary?: string;
|
|
309
|
+
headings: string[];
|
|
310
|
+
refs: RawRef[];
|
|
311
|
+
}
|
|
312
|
+
declare function extractMarkdown(content: string): MarkdownInfo;
|
|
313
|
+
|
|
314
|
+
declare function grammarKeyForExt(ext: string): string | undefined;
|
|
315
|
+
type GrammarsTierName = "adjacent" | "env" | "cache" | "none";
|
|
316
|
+
interface GrammarsTier {
|
|
317
|
+
tier: GrammarsTierName;
|
|
318
|
+
dir?: string;
|
|
319
|
+
cacheDir: string;
|
|
320
|
+
}
|
|
321
|
+
declare function sharedGrammarsCacheDir(): string;
|
|
322
|
+
declare function resolveGrammarsTier(opts?: {
|
|
323
|
+
moduleDir?: string;
|
|
324
|
+
}): GrammarsTier;
|
|
325
|
+
declare function resolveGrammarsDir(opts?: {
|
|
326
|
+
moduleDir?: string;
|
|
327
|
+
}): string | undefined;
|
|
328
|
+
declare function ensureGrammars(keys: Iterable<string>): Promise<void>;
|
|
329
|
+
declare function allGrammarKeys(): string[];
|
|
330
|
+
declare function grammarKeysForExts(exts: Iterable<string>): string[];
|
|
331
|
+
declare function grammarReady(key: string): boolean;
|
|
332
|
+
|
|
333
|
+
interface AstResult {
|
|
334
|
+
symbols: CodeSymbol[];
|
|
335
|
+
refs: RawRef[];
|
|
336
|
+
pkg?: string;
|
|
337
|
+
idents: string[];
|
|
338
|
+
calls: {
|
|
339
|
+
name: string;
|
|
340
|
+
line: number;
|
|
341
|
+
receiver?: string;
|
|
342
|
+
}[];
|
|
343
|
+
importedNames: string[];
|
|
344
|
+
}
|
|
345
|
+
declare function extractAst(rel: string, ext: string, content: string, opts?: {
|
|
346
|
+
maxCalls?: number;
|
|
347
|
+
imports?: boolean;
|
|
348
|
+
}): AstResult | undefined;
|
|
349
|
+
|
|
350
|
+
declare const DEFAULT_GRAMMARS_URL = "https://github.com/maxgfr/codeindex/releases/download/v2.20.1/grammars-2.20.1.tar.gz";
|
|
351
|
+
interface GrammarsPullTarget {
|
|
352
|
+
url: string;
|
|
353
|
+
sha256Url?: string;
|
|
354
|
+
}
|
|
355
|
+
declare function resolveGrammarsPullTarget(): GrammarsPullTarget;
|
|
356
|
+
declare function fetchGrammarsTarball(url: string, expectedSha256?: string): Promise<Uint8Array>;
|
|
357
|
+
declare function fetchExpectedSha256(url: string): Promise<string>;
|
|
358
|
+
declare function extractTarInto(rawTar: Uint8Array, destDir: string): string[];
|
|
359
|
+
declare function extractGrammarsTarball(bytes: Uint8Array, destDir: string): string[];
|
|
360
|
+
interface GrammarsPullResult {
|
|
361
|
+
ok: boolean;
|
|
362
|
+
status: "up-to-date" | "pulled" | "failed";
|
|
363
|
+
cacheDir: string;
|
|
364
|
+
/** One human-readable line; the CLI writes it to stderr, a library caller may log or drop it. */
|
|
365
|
+
message: string;
|
|
366
|
+
}
|
|
367
|
+
declare function pullGrammars(cacheDir: string, opts?: {
|
|
368
|
+
onNote?: (msg: string) => void;
|
|
369
|
+
}): Promise<GrammarsPullResult>;
|
|
370
|
+
|
|
371
|
+
interface WarmGrammarsResult {
|
|
372
|
+
/** Tier AFTER the warm-up (a successful pull moves "none" → "cache"). */
|
|
373
|
+
tier: GrammarsTierName;
|
|
374
|
+
/** True when at least one requested grammar is loaded ⇒ the AST tier is live. */
|
|
375
|
+
ready: boolean;
|
|
376
|
+
/** True when this call populated the shared cache over the network. */
|
|
377
|
+
pulled: boolean;
|
|
378
|
+
/** Everything written to `onNote`, in order — so a caller can persist the trail in its run artifacts. */
|
|
379
|
+
notes: string[];
|
|
380
|
+
}
|
|
381
|
+
interface WarmGrammarsOptions {
|
|
382
|
+
/** Grammars to load. Default: every shipped grammar. Narrow it with `grammarKeysForExts` when the repo's languages are known. */
|
|
383
|
+
keys?: Iterable<string>;
|
|
384
|
+
/** Fetch the wasms into the shared cache when nothing is resolvable. Default true; `CODEINDEX_NO_GRAMMARS_PULL=1` forces false. */
|
|
385
|
+
pull?: boolean;
|
|
386
|
+
/** Prefix for the diagnostics ("ultrasec: …"). Default "codeindex". */
|
|
387
|
+
label?: string;
|
|
388
|
+
/** Where diagnostics go. Default: process.stderr. Pass a sink to keep stdout/stderr clean. */
|
|
389
|
+
onNote?: (msg: string) => void;
|
|
390
|
+
}
|
|
391
|
+
declare function warmGrammars(opts?: WarmGrammarsOptions): Promise<WarmGrammarsResult>;
|
|
392
|
+
|
|
393
|
+
type Resolution = {
|
|
394
|
+
kind: "resolved";
|
|
395
|
+
target: string;
|
|
396
|
+
} | {
|
|
397
|
+
kind: "external";
|
|
398
|
+
} | {
|
|
399
|
+
kind: "dangling";
|
|
400
|
+
reason: string;
|
|
401
|
+
};
|
|
402
|
+
interface TsPath {
|
|
403
|
+
prefix: string;
|
|
404
|
+
star: boolean;
|
|
405
|
+
targets: string[];
|
|
406
|
+
}
|
|
407
|
+
interface TsConfigScope {
|
|
408
|
+
dir: string;
|
|
409
|
+
baseUrl: string;
|
|
410
|
+
paths: TsPath[];
|
|
411
|
+
}
|
|
412
|
+
interface ExportEntry {
|
|
413
|
+
key: string;
|
|
414
|
+
star: boolean;
|
|
415
|
+
targets: string[];
|
|
416
|
+
}
|
|
417
|
+
interface WorkspacePackage$1 {
|
|
418
|
+
name: string;
|
|
419
|
+
dir: string;
|
|
420
|
+
exportEntries: ExportEntry[];
|
|
421
|
+
mainCandidates: string[];
|
|
422
|
+
}
|
|
423
|
+
interface GoModule {
|
|
424
|
+
module: string;
|
|
425
|
+
dir: string;
|
|
426
|
+
replaces: {
|
|
427
|
+
from: string;
|
|
428
|
+
toDir: string;
|
|
429
|
+
}[];
|
|
430
|
+
}
|
|
431
|
+
interface RustCrate {
|
|
432
|
+
name: string;
|
|
433
|
+
dir: string;
|
|
434
|
+
srcDir: string;
|
|
435
|
+
rootFile?: string;
|
|
436
|
+
}
|
|
437
|
+
interface ResolveContext {
|
|
438
|
+
fileSet: Set<string>;
|
|
439
|
+
dirSet: Set<string>;
|
|
440
|
+
filesByDir: Map<string, string[]>;
|
|
441
|
+
tsConfigs: TsConfigScope[];
|
|
442
|
+
goModules: GoModule[];
|
|
443
|
+
rustCrates: RustCrate[];
|
|
444
|
+
javaRoots: string[];
|
|
445
|
+
pyRoots: string[];
|
|
446
|
+
workspacePackages: WorkspacePackage$1[];
|
|
447
|
+
cIncludeRoots: string[];
|
|
448
|
+
rubyLibRoots: string[];
|
|
449
|
+
phpPsr4: {
|
|
450
|
+
prefix: string;
|
|
451
|
+
dir: string;
|
|
452
|
+
}[];
|
|
453
|
+
csharpNamespaces: Map<string, string[]>;
|
|
454
|
+
warnings: string[];
|
|
455
|
+
}
|
|
456
|
+
declare function buildResolveContext(scan: RepoScan): ResolveContext;
|
|
457
|
+
declare function resolveDocLink(fromRel: string, spec: string, ctx: ResolveContext): Resolution;
|
|
458
|
+
declare function resolveImport(fromRel: string, ext: string, spec: string, ctx: ResolveContext): Resolution;
|
|
459
|
+
|
|
460
|
+
interface ModuleInfo {
|
|
461
|
+
slug: string;
|
|
462
|
+
path: string;
|
|
463
|
+
title: string;
|
|
464
|
+
tier: Tier;
|
|
465
|
+
members: string[];
|
|
466
|
+
summary: string;
|
|
467
|
+
}
|
|
468
|
+
declare function isTestFile(rel: string): boolean;
|
|
469
|
+
declare function tierForPath(path: string): Tier | null;
|
|
470
|
+
declare function buildModules(scan: RepoScan): {
|
|
471
|
+
modules: ModuleInfo[];
|
|
472
|
+
moduleOf: Map<string, string>;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
declare function uniqueSymbolDefs(scan: RepoScan): Map<string, string>;
|
|
476
|
+
declare function buildGraph(scan: RepoScan, ctx: ResolveContext, modules: ModuleInfo[], moduleOf: Map<string, string>, meta?: {
|
|
477
|
+
version?: string;
|
|
478
|
+
schemaVersion?: number;
|
|
479
|
+
}): Graph;
|
|
480
|
+
|
|
481
|
+
declare function resolveCallEdges(scan: RepoScan, importPairs: Set<string>): Edge[];
|
|
482
|
+
|
|
483
|
+
interface CallerSite {
|
|
484
|
+
file: string;
|
|
485
|
+
line: number;
|
|
486
|
+
confidence?: "corroborated" | "unique-name";
|
|
487
|
+
}
|
|
488
|
+
interface CallerIndexOptions {
|
|
489
|
+
recall?: boolean;
|
|
490
|
+
}
|
|
491
|
+
interface CallerEntry {
|
|
492
|
+
def: CodeSymbol;
|
|
493
|
+
callers: CallerSite[];
|
|
494
|
+
}
|
|
495
|
+
type CallerIndex = Map<string, CallerEntry>;
|
|
496
|
+
declare function computeImportPairs(scan: RepoScan): Set<string>;
|
|
497
|
+
declare function buildCallerIndex(scan: RepoScan, importPairs?: Set<string>, opts?: CallerIndexOptions): CallerIndex;
|
|
498
|
+
declare function enclosingSymbol(scan: RepoScan, file: string, line: number): CodeSymbol | undefined;
|
|
499
|
+
interface RawCallerSite {
|
|
500
|
+
file: string;
|
|
501
|
+
line: number;
|
|
502
|
+
receiver?: string;
|
|
503
|
+
enclosingSymbol?: CodeSymbol;
|
|
504
|
+
}
|
|
505
|
+
type RawCallerIndex = Map<string, RawCallerSite[]>;
|
|
506
|
+
declare function buildRawCallerIndex(scan: RepoScan): RawCallerIndex;
|
|
507
|
+
|
|
508
|
+
declare function symbolsOverview(scan: RepoScan, rel: string): CodeSymbol[];
|
|
509
|
+
interface SymbolMatch extends CodeSymbol {
|
|
510
|
+
body?: string;
|
|
511
|
+
}
|
|
512
|
+
interface FindSymbolOptions {
|
|
513
|
+
substring?: boolean;
|
|
514
|
+
includeBody?: boolean;
|
|
515
|
+
maxResults?: number;
|
|
516
|
+
}
|
|
517
|
+
declare function findSymbol(scan: RepoScan, namePath: string, opts?: FindSymbolOptions): SymbolMatch[];
|
|
518
|
+
interface SymbolReferences {
|
|
519
|
+
defs: CodeSymbol[];
|
|
520
|
+
callSites: CallerSite[];
|
|
521
|
+
referencingFiles: string[];
|
|
522
|
+
}
|
|
523
|
+
declare function findReferences(scan: RepoScan, name: string): SymbolReferences;
|
|
524
|
+
|
|
525
|
+
interface EditResult {
|
|
526
|
+
file: string;
|
|
527
|
+
startLine: number;
|
|
528
|
+
endLine: number;
|
|
529
|
+
lines: number;
|
|
530
|
+
}
|
|
531
|
+
declare function resolveUniqueSymbol(scan: RepoScan, namePath: string, file?: string): CodeSymbol;
|
|
532
|
+
declare function replaceSymbolBody(scan: RepoScan, namePath: string, body: string, file?: string): EditResult;
|
|
533
|
+
declare function insertAfterSymbol(scan: RepoScan, namePath: string, body: string, file?: string): EditResult;
|
|
534
|
+
declare function insertBeforeSymbol(scan: RepoScan, namePath: string, body: string, file?: string): EditResult;
|
|
535
|
+
|
|
536
|
+
declare function writeMemory(repo: string, name: string, content: string): string;
|
|
537
|
+
declare function readMemory(repo: string, name: string): string | undefined;
|
|
538
|
+
declare function deleteMemory(repo: string, name: string): boolean;
|
|
539
|
+
declare function listMemories(repo: string): string[];
|
|
540
|
+
|
|
541
|
+
type WorkspaceKind = "npm" | "pnpm" | "lerna" | "nx" | "cargo" | "go" | "maven" | "uv" | "composer" | "gradle";
|
|
542
|
+
interface WorkspacePackage {
|
|
543
|
+
name: string;
|
|
544
|
+
dir: string;
|
|
545
|
+
kind: WorkspaceKind;
|
|
546
|
+
manifest: string;
|
|
547
|
+
description?: string;
|
|
548
|
+
dependsOn?: string[];
|
|
549
|
+
}
|
|
550
|
+
interface WorkspaceInfo {
|
|
551
|
+
packages: WorkspacePackage[];
|
|
552
|
+
cycle?: string[];
|
|
553
|
+
topoOrder: string[];
|
|
554
|
+
warnings: string[];
|
|
555
|
+
packageOf(rel: string): WorkspacePackage | undefined;
|
|
556
|
+
}
|
|
557
|
+
declare function detectWorkspaces(root: string): WorkspaceInfo;
|
|
558
|
+
|
|
559
|
+
declare function pagerankOf(ids: string[], edges: Edge[], damping?: number): Map<string, number>;
|
|
560
|
+
declare function betweennessOf(ids: string[], edges: Edge[]): Map<string, number>;
|
|
561
|
+
declare function applyCentrality(graph: Graph): string[];
|
|
562
|
+
|
|
563
|
+
declare function communityOf(graph: Graph, slug: string): number | undefined;
|
|
564
|
+
declare function detectCommunities(modules: ModuleNode[], edges: Edge[], previous?: Record<string, string[]>): Map<string, number>;
|
|
565
|
+
|
|
566
|
+
declare function isTestPath(rel: string): boolean;
|
|
567
|
+
interface TestMap {
|
|
568
|
+
testFiles: Set<string>;
|
|
569
|
+
testedByFile: Map<string, string[]>;
|
|
570
|
+
testedByModule: Map<string, string[]>;
|
|
571
|
+
}
|
|
572
|
+
declare function computeTestMap(graph: Graph): TestMap;
|
|
573
|
+
declare function testsForModule(graph: Graph, slug: string): string[];
|
|
574
|
+
declare function untestedModules(graph: Graph): ModuleNode[];
|
|
575
|
+
|
|
576
|
+
declare function computeSurprises(graph: Graph): SurpriseEdge[];
|
|
577
|
+
declare function isSurprising(graph: Graph, from: string, to: string): boolean;
|
|
578
|
+
|
|
579
|
+
declare function computeSymbolRefs(scan: RepoScan): Map<string, Set<string>>;
|
|
580
|
+
declare function buildSymbolIndex(scan: RepoScan, refs?: Map<string, Set<string>>): SymbolIndex;
|
|
581
|
+
declare function renderSymbolsJson(index: SymbolIndex): string;
|
|
582
|
+
|
|
583
|
+
declare function renderGraphJson(graph: Graph): string;
|
|
584
|
+
|
|
585
|
+
interface RenderScipOptions {
|
|
586
|
+
projectRoot?: string;
|
|
587
|
+
toolVersion?: string;
|
|
588
|
+
}
|
|
589
|
+
declare function renderScip(scan: RepoScan, opts?: RenderScipOptions): Uint8Array;
|
|
590
|
+
|
|
591
|
+
declare function headCommit(dir: string): string | undefined;
|
|
592
|
+
interface DiffFile {
|
|
593
|
+
path: string;
|
|
594
|
+
status: "added" | "modified" | "deleted" | "renamed";
|
|
595
|
+
oldPath?: string;
|
|
596
|
+
binary?: boolean;
|
|
597
|
+
linesAdded?: number;
|
|
598
|
+
linesDeleted?: number;
|
|
599
|
+
}
|
|
600
|
+
interface Hunk {
|
|
601
|
+
start: number;
|
|
602
|
+
end: number;
|
|
603
|
+
approx?: boolean;
|
|
604
|
+
}
|
|
605
|
+
interface DiffSpec {
|
|
606
|
+
mergeBase?: string;
|
|
607
|
+
staged?: boolean;
|
|
608
|
+
}
|
|
609
|
+
declare function isGitWorktree(dir: string): boolean;
|
|
610
|
+
declare function resolveBaseRef(dir: string, base?: string): {
|
|
611
|
+
ref: string;
|
|
612
|
+
mergeBase: string;
|
|
613
|
+
note?: string;
|
|
614
|
+
} | {
|
|
615
|
+
error: string;
|
|
616
|
+
};
|
|
617
|
+
declare function diffFiles(dir: string, spec: DiffSpec): DiffFile[];
|
|
618
|
+
declare function diffHunks(dir: string, spec: DiffSpec): Map<string, Hunk[]>;
|
|
619
|
+
declare function untrackedFiles(dir: string): string[];
|
|
620
|
+
declare function gitChurn(dir: string, opts?: {
|
|
621
|
+
since?: string;
|
|
622
|
+
}): {
|
|
623
|
+
churn: Map<string, number>;
|
|
624
|
+
ok: boolean;
|
|
625
|
+
};
|
|
626
|
+
declare function changedSince(dir: string, ref: string): Set<string>;
|
|
627
|
+
|
|
628
|
+
interface SearchHit {
|
|
629
|
+
file: string;
|
|
630
|
+
line: number;
|
|
631
|
+
text: string;
|
|
632
|
+
}
|
|
633
|
+
interface GrepOptions {
|
|
634
|
+
globs?: string[];
|
|
635
|
+
maxHits?: number;
|
|
636
|
+
ignoreCase?: boolean;
|
|
637
|
+
noRipgrep?: boolean;
|
|
638
|
+
}
|
|
639
|
+
declare function grepRepo(root: string, pattern: string, opts?: GrepOptions): SearchHit[];
|
|
640
|
+
|
|
641
|
+
interface SearchOptions {
|
|
642
|
+
limit?: number;
|
|
643
|
+
fuzzy?: boolean;
|
|
644
|
+
}
|
|
645
|
+
interface SearchResult {
|
|
646
|
+
file: string;
|
|
647
|
+
score: number;
|
|
648
|
+
matchedTerms: string[];
|
|
649
|
+
topSymbols: string[];
|
|
650
|
+
fuzzyTerms?: string[];
|
|
651
|
+
}
|
|
652
|
+
declare function subtokens(raw: string): string[];
|
|
653
|
+
declare function searchIndex(scan: RepoScan, query: string, opts?: SearchOptions): SearchResult[];
|
|
654
|
+
|
|
655
|
+
declare const EMBED_VERSION = 1;
|
|
656
|
+
interface StaticEmbedModel {
|
|
657
|
+
modelId: string;
|
|
658
|
+
dim: number;
|
|
659
|
+
unk: string;
|
|
660
|
+
unkId: number;
|
|
661
|
+
vocabSize: number;
|
|
662
|
+
vocab: Map<string, number>;
|
|
663
|
+
weights: Float64Array;
|
|
664
|
+
}
|
|
665
|
+
declare function resolveEmbedModelDir(repo?: string): string | undefined;
|
|
666
|
+
declare function hasEmbedModel(repo?: string): boolean;
|
|
667
|
+
declare function loadEmbedModel(dir?: string): StaticEmbedModel | undefined;
|
|
668
|
+
interface EmbedPullTarget {
|
|
669
|
+
url: string;
|
|
670
|
+
sha256?: string;
|
|
671
|
+
}
|
|
672
|
+
declare function resolveEmbedPullUrl(): EmbedPullTarget;
|
|
673
|
+
|
|
674
|
+
declare function basicTokenize(text: string): string[];
|
|
675
|
+
declare function wordpiece(word: string, model: StaticEmbedModel): number[];
|
|
676
|
+
declare function tokenize(text: string, model: StaticEmbedModel): number[];
|
|
677
|
+
declare function roundHalfToEven(x: number): number;
|
|
678
|
+
declare function quantize(vec: ArrayLike<number>): Int8Array;
|
|
679
|
+
declare function encode(model: StaticEmbedModel, text: string): Int8Array;
|
|
680
|
+
declare function intDot(a: Int8Array, b: Int8Array): number;
|
|
681
|
+
|
|
682
|
+
interface EmbeddingRecord {
|
|
683
|
+
file: string;
|
|
684
|
+
symbol?: string;
|
|
685
|
+
line?: number;
|
|
686
|
+
vec: Int8Array;
|
|
687
|
+
}
|
|
688
|
+
interface EmbeddingIndex {
|
|
689
|
+
embedVersion: number;
|
|
690
|
+
modelId: string;
|
|
691
|
+
dim: number;
|
|
692
|
+
records: EmbeddingRecord[];
|
|
693
|
+
}
|
|
694
|
+
interface EmbeddingUnit {
|
|
695
|
+
file: string;
|
|
696
|
+
symbol?: string;
|
|
697
|
+
line?: number;
|
|
698
|
+
text: string;
|
|
699
|
+
}
|
|
700
|
+
declare function embeddingUnits(scan: RepoScan): EmbeddingUnit[];
|
|
701
|
+
declare function buildEmbeddingIndex(scan: RepoScan, model: StaticEmbedModel): EmbeddingIndex;
|
|
702
|
+
declare function serializeEmbeddings(index: EmbeddingIndex): Uint8Array;
|
|
703
|
+
declare function deserializeEmbeddings(bytes: Uint8Array): EmbeddingIndex;
|
|
704
|
+
|
|
705
|
+
interface SemanticSearchOptions extends SearchOptions {
|
|
706
|
+
model?: StaticEmbedModel;
|
|
707
|
+
queryVec?: Int8Array;
|
|
708
|
+
rrfK?: number;
|
|
709
|
+
}
|
|
710
|
+
interface SemanticSearchResult extends SearchResult {
|
|
711
|
+
semanticSymbol?: string;
|
|
712
|
+
}
|
|
713
|
+
declare function searchSemantic(scan: RepoScan, query: string, index: EmbeddingIndex | undefined, opts?: SemanticSearchOptions): SemanticSearchResult[];
|
|
714
|
+
|
|
715
|
+
interface EmbedEndpointOptions {
|
|
716
|
+
url?: string;
|
|
717
|
+
timeoutMs?: number;
|
|
718
|
+
headers?: Record<string, string>;
|
|
719
|
+
batchSize?: number;
|
|
720
|
+
}
|
|
721
|
+
declare function resolveEmbedEndpoint(opts?: EmbedEndpointOptions): string | undefined;
|
|
722
|
+
declare function embedEndpointUrl(base: string): string;
|
|
723
|
+
declare function healthzUrl(base: string): string;
|
|
724
|
+
declare function embedViaEndpoint(texts: string[], opts?: EmbedEndpointOptions): Promise<number[][]>;
|
|
725
|
+
declare function probeEndpoint(base: string, opts?: EmbedEndpointOptions): Promise<boolean>;
|
|
726
|
+
declare function encodeQueryViaEndpoint(query: string, opts?: EmbedEndpointOptions): Promise<Int8Array>;
|
|
727
|
+
declare function buildEndpointIndex(scan: RepoScan, opts?: EmbedEndpointOptions): Promise<EmbeddingIndex>;
|
|
728
|
+
|
|
729
|
+
type RuleSeverity = "error" | "warn";
|
|
730
|
+
interface ForbiddenEdgeRule {
|
|
731
|
+
name: string;
|
|
732
|
+
from: string | string[];
|
|
733
|
+
to: string | string[];
|
|
734
|
+
kind?: EdgeKind[];
|
|
735
|
+
severity?: RuleSeverity;
|
|
736
|
+
comment?: string;
|
|
737
|
+
}
|
|
738
|
+
interface BuiltinRule {
|
|
739
|
+
name: string;
|
|
740
|
+
builtin: "cycles" | "orphans";
|
|
741
|
+
severity?: RuleSeverity;
|
|
742
|
+
comment?: string;
|
|
743
|
+
}
|
|
744
|
+
type ArchRule = ForbiddenEdgeRule | BuiltinRule;
|
|
745
|
+
interface RuleViolation {
|
|
746
|
+
rule: string;
|
|
747
|
+
from: string;
|
|
748
|
+
to: string;
|
|
749
|
+
kind: EdgeKind | "cycle" | "orphan";
|
|
750
|
+
severity: RuleSeverity;
|
|
751
|
+
comment?: string;
|
|
752
|
+
}
|
|
753
|
+
declare function parseRules(input: unknown): ArchRule[];
|
|
754
|
+
declare function checkRules(graph: Graph, rules: ArchRule[]): RuleViolation[];
|
|
755
|
+
|
|
756
|
+
interface ChangeCoupling {
|
|
757
|
+
a: string;
|
|
758
|
+
b: string;
|
|
759
|
+
together: number;
|
|
760
|
+
totalA: number;
|
|
761
|
+
totalB: number;
|
|
762
|
+
strength: number;
|
|
763
|
+
}
|
|
764
|
+
interface CouplingOptions {
|
|
765
|
+
since?: string;
|
|
766
|
+
maxCommitFiles?: number;
|
|
767
|
+
minTogether?: number;
|
|
768
|
+
maxPairs?: number;
|
|
769
|
+
}
|
|
770
|
+
declare function changeCoupling(dir: string, opts?: CouplingOptions): {
|
|
771
|
+
ok: boolean;
|
|
772
|
+
couplings: ChangeCoupling[];
|
|
773
|
+
};
|
|
774
|
+
interface Hotspot {
|
|
775
|
+
rel: string;
|
|
776
|
+
lines: number;
|
|
777
|
+
commits: number;
|
|
778
|
+
score: number;
|
|
779
|
+
}
|
|
780
|
+
declare function rankHotspots(scan: RepoScan, churn: Map<string, number>, top?: number): Hotspot[];
|
|
781
|
+
|
|
782
|
+
interface RepoMapOptions {
|
|
783
|
+
budgetTokens?: number;
|
|
784
|
+
maxSymbolsPerFile?: number;
|
|
785
|
+
}
|
|
786
|
+
declare function renderRepoMap(scan: RepoScan, graph: Graph, opts?: RepoMapOptions): string;
|
|
787
|
+
|
|
788
|
+
interface DeadSymbol {
|
|
789
|
+
name: string;
|
|
790
|
+
file: string;
|
|
791
|
+
line: number;
|
|
792
|
+
kind: string;
|
|
793
|
+
tier: "unreferenced" | "uncalled";
|
|
794
|
+
}
|
|
795
|
+
declare function findDeadCode(scan: RepoScan): DeadSymbol[];
|
|
796
|
+
|
|
797
|
+
declare function complexityOfSource(source: string): number;
|
|
798
|
+
interface SymbolComplexity {
|
|
799
|
+
file: string;
|
|
800
|
+
name: string;
|
|
801
|
+
line: number;
|
|
802
|
+
endLine?: number;
|
|
803
|
+
complexity: number;
|
|
804
|
+
}
|
|
805
|
+
declare function symbolComplexity(scan: RepoScan, rel?: string, top?: number): SymbolComplexity[];
|
|
806
|
+
interface RiskHotspot {
|
|
807
|
+
file: string;
|
|
808
|
+
complexity: number;
|
|
809
|
+
commits: number;
|
|
810
|
+
score: number;
|
|
811
|
+
}
|
|
812
|
+
declare function riskHotspots(scan: RepoScan, churn: Map<string, number>, top?: number): RiskHotspot[];
|
|
813
|
+
|
|
814
|
+
interface MermaidOptions {
|
|
815
|
+
module?: string;
|
|
816
|
+
maxEdges?: number;
|
|
817
|
+
}
|
|
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;
|
|
965
|
+
|
|
966
|
+
interface McpServerOptions {
|
|
967
|
+
serverInfo?: {
|
|
968
|
+
name?: string;
|
|
969
|
+
version?: string;
|
|
970
|
+
};
|
|
971
|
+
defaultRepo?: string;
|
|
972
|
+
maxResponseBytes?: number;
|
|
973
|
+
}
|
|
974
|
+
declare function runMcpServer(opts?: McpServerOptions): Promise<void>;
|
|
975
|
+
|
|
976
|
+
declare function rewriteCommand(cmd: string, bin?: string): string | undefined;
|
|
977
|
+
|
|
978
|
+
declare function sha1(s: string | Uint8Array): string;
|
|
979
|
+
declare function shortHash(s: string, n?: number): string;
|
|
980
|
+
|
|
981
|
+
declare function byStr(a: string, b: string): number;
|
|
982
|
+
declare function byKey<T>(keyOf: (x: T) => string): (a: T, b: T) => number;
|
|
983
|
+
|
|
984
|
+
interface ShResult {
|
|
985
|
+
ok: boolean;
|
|
986
|
+
status: number | null;
|
|
987
|
+
stdout: string;
|
|
988
|
+
stderr: string;
|
|
989
|
+
missing: boolean;
|
|
990
|
+
}
|
|
991
|
+
declare function sh(cmd: string, args: string[], opts?: {
|
|
992
|
+
cwd?: string;
|
|
993
|
+
input?: string;
|
|
994
|
+
timeoutMs?: number;
|
|
995
|
+
env?: Record<string, string | undefined>;
|
|
996
|
+
}): ShResult;
|
|
997
|
+
declare function have(cmd: string): boolean;
|
|
998
|
+
declare function slugify(input: string): string;
|
|
999
|
+
declare function clip(s: string, max: number): string;
|
|
1000
|
+
declare function clipInline(s: string, max: number): string;
|
|
1001
|
+
declare function escapeRegExp(s: string): string;
|
|
1002
|
+
declare function foldText(s: string): string;
|
|
1003
|
+
declare function keywords(question: string): string[];
|
|
1004
|
+
declare function rankedKeywords(question: string): string[];
|
|
1005
|
+
declare function rrf<T>(lists: T[][], keyOf: (item: T) => string, k?: number): Map<string, number>;
|
|
1006
|
+
|
|
1007
|
+
declare function runCli(rawArgv: string[]): Promise<void>;
|
|
1008
|
+
|
|
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 };
|