@omfalos/mokosh 0.1.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 +192 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +139 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +139 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +1135 -0
- package/dist/index.d.ts +1135 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mcp.d.mts +15 -0
- package/dist/mcp.d.ts +15 -0
- package/dist/mcp.js +28 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp.mjs +28 -0
- package/dist/mcp.mjs.map +1 -0
- package/package.json +103 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1135 @@
|
|
|
1
|
+
/** Tag applier strategy interface — one implementation per testing framework. */
|
|
2
|
+
type TagFramework = "vitest" | "playwright" | "cypress" | "jest";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description Top-level configuration for mokosh. All fields are optional; unset fields
|
|
6
|
+
* fall back to built-in defaults. Load this object via `loadMokoshConfig`, then activate
|
|
7
|
+
* it with `applyConfig` before calling `createImportMap`.
|
|
8
|
+
*/
|
|
9
|
+
interface MokoshConfig {
|
|
10
|
+
/** Additional directories to skip when scanning (merged with built-in defaults). */
|
|
11
|
+
ignoreDirs?: string[];
|
|
12
|
+
/** Additional file extensions to scan (merged with built-in defaults). */
|
|
13
|
+
extensions?: string[];
|
|
14
|
+
/** Override the default cache path (`mokosh-cache/graph.json`). */
|
|
15
|
+
cachePath?: string;
|
|
16
|
+
/** Default entry points used when none are provided on the CLI. */
|
|
17
|
+
entryPoints?: string[];
|
|
18
|
+
/** Additional basename substrings that mark a file as `"config"` category. */
|
|
19
|
+
configMatchers?: string[];
|
|
20
|
+
/** Additional basename substrings that mark a file as `"test"` category (e.g. `".unit."`). */
|
|
21
|
+
testPatterns?: string[];
|
|
22
|
+
/** Additional import specifiers that indicate a test file (e.g. `"@my-org/test-utils"`). */
|
|
23
|
+
testLibraries?: string[];
|
|
24
|
+
/** Ratio of export-statements to total statements required for `"barrel"` classification. Default: `0.8`. */
|
|
25
|
+
barrelThreshold?: number;
|
|
26
|
+
/** When true, enriches each node with `commitCount90d` and `lastAuthor` via git log. Only fetched for new/modified files. */
|
|
27
|
+
gitStats?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Tag-applier configuration for `--apply-tags`. Controls which format is written into
|
|
30
|
+
* test files. Defaults to `{ framework: "vitest" }` when unset.
|
|
31
|
+
*/
|
|
32
|
+
tagApplier?: {
|
|
33
|
+
/**
|
|
34
|
+
* Fallback test framework whose tag format to use for TS/JS files. Each file's actual
|
|
35
|
+
* framework is auto-detected from its imports (`@playwright/test`, `cypress`,
|
|
36
|
+
* `@jest/globals`, `vitest`), so a single repo can mix frameworks and each file is tagged
|
|
37
|
+
* in its own native format. This value is only used when a file has no detectable
|
|
38
|
+
* framework import (e.g. `globals: true` configs with no explicit import).
|
|
39
|
+
* - `"vitest"` — injects `{ tags: [...] }` in describe/test/it options (default)
|
|
40
|
+
* - `"playwright"` — injects `{ tag: ["@name"] }` with `@` prefix convention
|
|
41
|
+
* - `"cypress"` — injects `{ tags: ["@name"] }` for use with `@cypress/grep`
|
|
42
|
+
* - `"jest"` — writes a `/** @group name *\/` docblock for use with `jest-runner-groups`
|
|
43
|
+
*/
|
|
44
|
+
framework?: TagFramework;
|
|
45
|
+
/**
|
|
46
|
+
* Path-glob pattern (project-relative, e.g. `"tests/e2e/**"`) to fallback framework. Checked
|
|
47
|
+
* in object key order, first match wins, before falling back further to `framework`. Only
|
|
48
|
+
* consulted when a file's own imports don't reveal a framework — lets different directories
|
|
49
|
+
* default to different frameworks (e.g. e2e tests using Playwright globals, unit tests using
|
|
50
|
+
* Jest globals) instead of sharing one project-wide default.
|
|
51
|
+
*/
|
|
52
|
+
frameworkOverrides?: Record<string, TagFramework>;
|
|
53
|
+
};
|
|
54
|
+
/** Path to the Istanbul/v8 `coverage-summary.json` file, relative to the project root. When set, `coveragePct` is populated on each node after the graph is built. */
|
|
55
|
+
coverageReportPath?: string;
|
|
56
|
+
/** Default line-coverage threshold (0–100) used by `find_uncovered`. Defaults to `80` when not specified. */
|
|
57
|
+
coverageThreshold?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @description Loads a mokosh config file, probing standard filenames in `rootDirOrPath` or reading an explicit path when `isExplicitPath` is true.
|
|
61
|
+
* JS/CJS configs may export a plain object or a factory function; the MCP server passes `allowJs: false` to prevent arbitrary code execution.
|
|
62
|
+
* @param {string} rootDirOrPath - Directory to probe for standard config filenames, or absolute path to the config file when `isExplicitPath` is true.
|
|
63
|
+
* @param {{ allowJs?: boolean; isExplicitPath?: boolean }} options - `allowJs` (default `true`) controls whether `.js`/`.cjs` files are loaded; `isExplicitPath` treats the first arg as a direct file path.
|
|
64
|
+
* @returns {MokoshConfig} The parsed config, or an empty object when no config file is found.
|
|
65
|
+
*/
|
|
66
|
+
declare function loadMokoshConfig(rootDirOrPath: string, { allowJs, isExplicitPath }?: {
|
|
67
|
+
allowJs?: boolean;
|
|
68
|
+
isExplicitPath?: boolean;
|
|
69
|
+
}): MokoshConfig;
|
|
70
|
+
/**
|
|
71
|
+
* @description Applies a `MokoshConfig` to the global registries that control classification and scanning.
|
|
72
|
+
* Call this after `loadMokoshConfig` and before `createImportMap`.
|
|
73
|
+
* @param {MokoshConfig} config - The loaded config whose matchers, patterns, libraries, and thresholds are registered.
|
|
74
|
+
*/
|
|
75
|
+
declare function applyConfig(config: MokoshConfig): void;
|
|
76
|
+
|
|
77
|
+
declare const DEFAULT_IGNORE_DIRS: readonly string[];
|
|
78
|
+
declare const DEFAULT_EXTENSIONS: readonly string[];
|
|
79
|
+
interface ScanOptions {
|
|
80
|
+
/** Replaces the default ignore-dir list. Use `additionalIgnoreDirs` to extend instead. */
|
|
81
|
+
ignoreDirs?: string[];
|
|
82
|
+
/** Replaces the default extension list. Use `additionalExtensions` to extend instead. */
|
|
83
|
+
extensions?: string[];
|
|
84
|
+
/** Merged with `DEFAULT_IGNORE_DIRS` (additive). */
|
|
85
|
+
additionalIgnoreDirs?: string[];
|
|
86
|
+
/** Merged with `DEFAULT_EXTENSIONS` (additive). */
|
|
87
|
+
additionalExtensions?: string[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @description Reads an Istanbul/v8 `coverage-summary.json` file and returns a map of
|
|
92
|
+
* project-relative file paths to their line-coverage percentage (0–100).
|
|
93
|
+
* Returns an empty map when the file is missing, unreadable, or malformed — the
|
|
94
|
+
* caller can always proceed safely with no coverage data.
|
|
95
|
+
* @param rootDir - Absolute path to the project root; used to make paths relative.
|
|
96
|
+
* @param reportPath - Path to the coverage summary JSON, relative to `rootDir`.
|
|
97
|
+
* @returns A map of `relativePath → lineCoveragePct`.
|
|
98
|
+
*/
|
|
99
|
+
declare function loadCoverageMap(rootDir: string, reportPath: string): Map<string, number>;
|
|
100
|
+
|
|
101
|
+
type FileType = "javascript" | "typescript" | "css" | "scss" | "less" | "stylus" | "coffeescript" | "livescript" | "lua" | "gherkin" | "python" | "go" | "unknown";
|
|
102
|
+
type ImportType = "static" | "dynamic" | "require" | "re-export" | "side-effect";
|
|
103
|
+
type NodeCategory = "logic" | "ui" | "type-only" | "config" | "test" | "barrel" | "other";
|
|
104
|
+
type TagKind = "function" | "class" | "variable" | "type" | "import" | "library" | "comment-marker";
|
|
105
|
+
|
|
106
|
+
interface StructuredTag {
|
|
107
|
+
name: string;
|
|
108
|
+
kind: TagKind;
|
|
109
|
+
}
|
|
110
|
+
interface ExportedSymbol {
|
|
111
|
+
name: string;
|
|
112
|
+
doc?: string;
|
|
113
|
+
flags?: string[];
|
|
114
|
+
signature?: string;
|
|
115
|
+
}
|
|
116
|
+
interface ImportEdge {
|
|
117
|
+
fromPath: string;
|
|
118
|
+
toPath: string;
|
|
119
|
+
isStyle: boolean;
|
|
120
|
+
rawSpecifier: string;
|
|
121
|
+
type: ImportType;
|
|
122
|
+
symbols?: string[] | undefined;
|
|
123
|
+
isExternal?: boolean | undefined;
|
|
124
|
+
version?: string | undefined;
|
|
125
|
+
/** True when this import resolves to a sibling workspace package rather than an external npm dep. */
|
|
126
|
+
isWorkspace?: boolean | undefined;
|
|
127
|
+
/** The workspace package name (e.g. `"@myorg/shared"`) when `isWorkspace` is true. */
|
|
128
|
+
workspacePackage?: string | undefined;
|
|
129
|
+
/** Fraction of the target's exports consumed by this import (0–1). Only present for internal non-side-effect imports where the target has at least one export. */
|
|
130
|
+
exportUsageRatio?: number;
|
|
131
|
+
}
|
|
132
|
+
interface CallEdge {
|
|
133
|
+
from: string;
|
|
134
|
+
to: string;
|
|
135
|
+
toFile: string;
|
|
136
|
+
}
|
|
137
|
+
interface FunctionComplexity {
|
|
138
|
+
name: string;
|
|
139
|
+
line: number;
|
|
140
|
+
complexity: number;
|
|
141
|
+
cognitiveComplexity: number;
|
|
142
|
+
}
|
|
143
|
+
interface GraphNode {
|
|
144
|
+
path: string;
|
|
145
|
+
type: FileType;
|
|
146
|
+
category: NodeCategory;
|
|
147
|
+
imports: ImportEdge[];
|
|
148
|
+
exports: ExportedSymbol[];
|
|
149
|
+
tags: StructuredTag[];
|
|
150
|
+
}
|
|
151
|
+
interface FileNode extends GraphNode {
|
|
152
|
+
mtime: number;
|
|
153
|
+
size: number;
|
|
154
|
+
description?: string;
|
|
155
|
+
testedBy?: string[];
|
|
156
|
+
commitCount90d?: number;
|
|
157
|
+
lastAuthor?: string;
|
|
158
|
+
callEdges?: CallEdge[];
|
|
159
|
+
/** Line coverage percentage (0–100) from the last coverage report. Undefined when no report was loaded. */
|
|
160
|
+
coveragePct?: number;
|
|
161
|
+
/** Average exportUsageRatio across all outgoing internal import edges that have a computable ratio. */
|
|
162
|
+
avgExportUsage?: number;
|
|
163
|
+
/** Highest single-edge exportUsageRatio for this file — identifies the dependency whose API surface is most consumed. */
|
|
164
|
+
maxExportUsage?: number;
|
|
165
|
+
/** McCabe cyclomatic complexity (base 1). Counts independent decision paths through the file. Only present for TypeScript/JavaScript files. */
|
|
166
|
+
complexity?: number;
|
|
167
|
+
/** Cognitive complexity — nesting-penalised difficulty score. Higher values indicate harder-to-read code. Only present for TypeScript/JavaScript files. */
|
|
168
|
+
cognitiveComplexity?: number;
|
|
169
|
+
/** Per-function complexity breakdown. Covers named function declarations, const-assigned arrow/function expressions, and class methods/constructors/accessors — anonymous inline callbacks are not included. Only present for TypeScript/JavaScript files. */
|
|
170
|
+
functions?: FunctionComplexity[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface SerializedGraph {
|
|
174
|
+
nodes: FileNode[];
|
|
175
|
+
cycles?: string[][] | undefined;
|
|
176
|
+
}
|
|
177
|
+
interface DependencyGraph {
|
|
178
|
+
nodes: Map<string, FileNode>;
|
|
179
|
+
}
|
|
180
|
+
type TraversalVisitor = (node: FileNode, depth: number, parentPath: string | null) => undefined | boolean;
|
|
181
|
+
interface TraversalOptions {
|
|
182
|
+
maxDepth?: number;
|
|
183
|
+
direction?: "outgoing" | "incoming";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Graph class wrapping the raw node map with DFS traversal, cycle detection, serialization, and reverse-edge helpers. */
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @description Represents the dependency graph of the project.
|
|
190
|
+
* Wraps the raw node map with traversal, cycle detection, serialization, and
|
|
191
|
+
* reverse-index helpers. All node paths are project-relative strings.
|
|
192
|
+
*/
|
|
193
|
+
declare class Graph {
|
|
194
|
+
nodes: Map<string, FileNode>;
|
|
195
|
+
private _incomingEdgesCache;
|
|
196
|
+
private _callIncomingCache;
|
|
197
|
+
/**
|
|
198
|
+
* @param {Map<string, FileNode>} nodes - All parsed file nodes, keyed by project-relative path.
|
|
199
|
+
*/
|
|
200
|
+
constructor(nodes: Map<string, FileNode>);
|
|
201
|
+
/**
|
|
202
|
+
* @description Serializes the graph into a plain JSON-compatible object
|
|
203
|
+
* that can be written to disk and later restored via `deserialize`.
|
|
204
|
+
* @returns {SerializedGraph} A flat representation of all nodes in the graph.
|
|
205
|
+
*/
|
|
206
|
+
serialize(): SerializedGraph;
|
|
207
|
+
/**
|
|
208
|
+
* @description Reconstructs a Graph from a serialized snapshot, rebuilding
|
|
209
|
+
* the internal node map keyed by file path.
|
|
210
|
+
* @param {SerializedGraph} serialized - The plain object produced by `serialize`.
|
|
211
|
+
* @returns {Graph} A fully functional Graph instance.
|
|
212
|
+
*/
|
|
213
|
+
static deserialize(serialized: SerializedGraph): Graph;
|
|
214
|
+
/**
|
|
215
|
+
* @description Lazily builds and caches a reverse index mapping each file path
|
|
216
|
+
* to the list of files that import it. Used internally for incoming traversal.
|
|
217
|
+
* @returns {Map<string, string[]>} Map from target file path to list of importer file paths.
|
|
218
|
+
*/
|
|
219
|
+
private getIncomingEdgesMap;
|
|
220
|
+
/**
|
|
221
|
+
* @description Core DFS engine. Visits each reachable node once, calling visitor at each step.
|
|
222
|
+
* The caller provides a getNeighbors function so the same loop works for any edge type.
|
|
223
|
+
* @param startPath - Project-relative path of the node to start from.
|
|
224
|
+
* @param visitor - Called for each visited node; return `false` to prune the branch.
|
|
225
|
+
* @param options - `maxDepth` and `direction` (direction is interpreted by the caller's getNeighbors).
|
|
226
|
+
* @param getNeighbors - Returns the next paths to visit from a given path.
|
|
227
|
+
*/
|
|
228
|
+
private dfs;
|
|
229
|
+
/**
|
|
230
|
+
* @description Performs a DFS on the import dependency graph.
|
|
231
|
+
* Supports both outgoing and incoming (reverse) traversal.
|
|
232
|
+
* @param startPath - Project-relative path of the node to start from.
|
|
233
|
+
* @param visitor - Callback executed for each node; return `false` to stop traversing a branch.
|
|
234
|
+
* @param options - Configuration for `maxDepth` and `direction`.
|
|
235
|
+
*/
|
|
236
|
+
traverse(startPath: string, visitor: TraversalVisitor, options?: TraversalOptions): void;
|
|
237
|
+
/**
|
|
238
|
+
* @description Builds and caches a reverse index of call edges: target file path → list of
|
|
239
|
+
* source file paths whose exported functions call into it. Computed lazily on first access
|
|
240
|
+
* and reused for the lifetime of this Graph instance.
|
|
241
|
+
* @returns {Map<string, string[]>} Map from target file path to list of source file paths that call into it.
|
|
242
|
+
*/
|
|
243
|
+
private getCallIncomingCache;
|
|
244
|
+
/**
|
|
245
|
+
* @description Performs a DFS over call edges (exported-function → imported-symbol).
|
|
246
|
+
* Outgoing follows callEdges forward; incoming follows the reverse call index.
|
|
247
|
+
* @param startPath - Project-relative path of the node to start from.
|
|
248
|
+
* @param visitor - Callback executed for each node; return `false` to stop traversing a branch.
|
|
249
|
+
* @param options - Configuration for `maxDepth` and `direction`.
|
|
250
|
+
*/
|
|
251
|
+
traverseCalls(startPath: string, visitor: TraversalVisitor, options?: TraversalOptions): void;
|
|
252
|
+
/**
|
|
253
|
+
* @description Returns files whose exported functions call into the given file (one hop).
|
|
254
|
+
* @param filePath - Project-relative path of the target file.
|
|
255
|
+
* @returns Project-relative paths of all direct callers.
|
|
256
|
+
*/
|
|
257
|
+
getCallers(filePath: string): string[];
|
|
258
|
+
/**
|
|
259
|
+
* @description Returns all call edges originating from a file.
|
|
260
|
+
* @param filePath - Project-relative path of the source file.
|
|
261
|
+
* @returns The file's call edges, or an empty array if none exist.
|
|
262
|
+
*/
|
|
263
|
+
getCallEdgesFor(filePath: string): CallEdge[];
|
|
264
|
+
/**
|
|
265
|
+
* @description Returns the FileNodes that a given file directly imports —
|
|
266
|
+
* the first-hop outgoing neighbours in the import graph.
|
|
267
|
+
* @param path - Project-relative path of the node to look up.
|
|
268
|
+
* @returns Array of FileNodes imported by the given file; empty if the path is unknown.
|
|
269
|
+
*/
|
|
270
|
+
getNeighbors(path: string): FileNode[];
|
|
271
|
+
/**
|
|
272
|
+
* @description Identifies files that are not reachable from any entry point
|
|
273
|
+
* by walking the full import graph forward from each node.
|
|
274
|
+
* @param allFiles - Complete list of project-relative file paths to test.
|
|
275
|
+
* @returns Subset of `allFiles` that nothing imports, directly or transitively.
|
|
276
|
+
*/
|
|
277
|
+
findUnusedFiles(allFiles: string[]): string[];
|
|
278
|
+
/**
|
|
279
|
+
* @description Detects all circular import chains in the graph using DFS
|
|
280
|
+
* with a back-edge check. Each returned array is one cycle as an ordered path.
|
|
281
|
+
* @returns Array of cycles; each cycle is a list of file paths forming a loop.
|
|
282
|
+
*/
|
|
283
|
+
findCycles(): string[][];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Coarse kind of a public export derived from its type signature prefix.
|
|
288
|
+
* Used to distinguish runtime values from type-only exports without parsing the full signature.
|
|
289
|
+
*/
|
|
290
|
+
type ExportKind = "function" | "class" | "interface" | "type" | "enum" | "const" | "namespace" | "unknown";
|
|
291
|
+
/** A single named export surfaced by an entry point, resolved to its original defining file. */
|
|
292
|
+
interface PublicExport {
|
|
293
|
+
/** Exported symbol name. */
|
|
294
|
+
name: string;
|
|
295
|
+
/** Project-relative path of the file that originally defines this symbol. */
|
|
296
|
+
definedIn: string;
|
|
297
|
+
/** Coarse kind derived from the signature prefix. */
|
|
298
|
+
kind: ExportKind;
|
|
299
|
+
/** JSDoc summary when present on the defining export. */
|
|
300
|
+
doc?: string;
|
|
301
|
+
/** Type signature string when present (e.g. `"interface FileNode"`, `"class Graph"`). */
|
|
302
|
+
signature?: string;
|
|
303
|
+
}
|
|
304
|
+
/** The complete API surface report for one or more entry points. */
|
|
305
|
+
interface ApiSurface {
|
|
306
|
+
/** Project-relative paths used as public entry points for this report. */
|
|
307
|
+
entryPoints: string[];
|
|
308
|
+
/** All symbols accessible from any entry point via direct declaration or `export *` chains. */
|
|
309
|
+
publicExports: PublicExport[];
|
|
310
|
+
/**
|
|
311
|
+
* All non-test files transitively reachable from any entry point (excluding the entry points
|
|
312
|
+
* themselves). These form the implementation surface backing the public API.
|
|
313
|
+
*/
|
|
314
|
+
internalFiles: string[];
|
|
315
|
+
/**
|
|
316
|
+
* Non-test files NOT reachable from any entry point — separate consumers (CLI, MCP server),
|
|
317
|
+
* config, or truly unused files. Not automatically dead code.
|
|
318
|
+
*/
|
|
319
|
+
unreachableFromEntry: string[];
|
|
320
|
+
/**
|
|
321
|
+
* Test files in the graph that are not reachable from any entry point.
|
|
322
|
+
* Shown separately so they don't inflate the `unreachableFromEntry` signal.
|
|
323
|
+
*/
|
|
324
|
+
testFiles: string[];
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Attempts to auto-detect the primary public entry point by reading `package.json` from `root`.
|
|
328
|
+
* Handles modern conditional-exports objects as well as plain `main`/`module` fields.
|
|
329
|
+
* Converts `dist/index.js` → `src/index.ts` before checking the graph.
|
|
330
|
+
* Falls back to common candidates when `package.json` is absent or unparseable.
|
|
331
|
+
*
|
|
332
|
+
* @param {Graph} graph - The built dependency graph.
|
|
333
|
+
* @param {string} root - Absolute path to the project root.
|
|
334
|
+
* @returns {string | null} Project-relative path of the detected entry point, or `null` if none found.
|
|
335
|
+
*/
|
|
336
|
+
declare function detectEntryPoint(graph: Graph, root: string): string | null;
|
|
337
|
+
/**
|
|
338
|
+
* Detects all public entry points for a project by reading the `package.json exports` map.
|
|
339
|
+
* Each sub-path (`.`, `./utils`, etc.) is resolved to a project-relative graph path.
|
|
340
|
+
* Falls back to `main`/`module` fields, then to common `src/index.ts` candidates.
|
|
341
|
+
*
|
|
342
|
+
* @param {Graph} graph - The built dependency graph.
|
|
343
|
+
* @param {string} root - Absolute path to the project root.
|
|
344
|
+
* @returns {string[]} Ordered list of project-relative paths for all detected entry points.
|
|
345
|
+
*/
|
|
346
|
+
declare function detectAllEntryPoints(graph: Graph, root: string): string[];
|
|
347
|
+
declare function buildApiSurface(graph: Graph, entryPoints: string[]): ApiSurface;
|
|
348
|
+
|
|
349
|
+
/** Public types for the call-graph subsystem. */
|
|
350
|
+
/** A file and function name that calls the target function. */
|
|
351
|
+
interface CallerEntry {
|
|
352
|
+
/** Project-relative path of the file containing the caller. */
|
|
353
|
+
file: string;
|
|
354
|
+
/** Name of the function that makes the call. */
|
|
355
|
+
callerFunction: string;
|
|
356
|
+
}
|
|
357
|
+
/** A file and function name that the target function calls. */
|
|
358
|
+
interface CalleeEntry {
|
|
359
|
+
/** Project-relative path of the file containing the callee. */
|
|
360
|
+
file: string;
|
|
361
|
+
/** Name of the function being called. */
|
|
362
|
+
calleeFunction: string;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Function-level call relationships for a single named function.
|
|
366
|
+
* A token-efficient answer to "who calls X?" and "what does X call?"
|
|
367
|
+
* without sending the full graph to the AI.
|
|
368
|
+
*/
|
|
369
|
+
interface FunctionCallInfo {
|
|
370
|
+
/** The function name that was queried. */
|
|
371
|
+
functionName: string;
|
|
372
|
+
/**
|
|
373
|
+
* Project-relative path of the file that exports or defines this function.
|
|
374
|
+
* `null` when no file in the graph exports a symbol with this name.
|
|
375
|
+
*/
|
|
376
|
+
definedIn: string | null;
|
|
377
|
+
/** Files and functions that call this function. */
|
|
378
|
+
callers: CallerEntry[];
|
|
379
|
+
/** Files and functions that this function calls. */
|
|
380
|
+
callees: CalleeEntry[];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** Queries the call-edge graph to find callers and callees at the function level. */
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Queries the call graph for a named function, returning its callers and callees.
|
|
387
|
+
*
|
|
388
|
+
* Callers are found by scanning every node's `callEdges` for edges whose `to`
|
|
389
|
+
* field matches `functionName`. Callees are found by looking at the defining
|
|
390
|
+
* file's `callEdges` for edges whose `from` field matches `functionName`.
|
|
391
|
+
*
|
|
392
|
+
* Call edges are populated only for TypeScript/JavaScript files. Functions in
|
|
393
|
+
* other language files will return empty `callers` and `callees` arrays.
|
|
394
|
+
*
|
|
395
|
+
* @param {Graph} graph - The import graph that carries `callEdges` on each node.
|
|
396
|
+
* @param {string} functionName - Exact name of the function to look up.
|
|
397
|
+
* @returns {FunctionCallInfo} Caller/callee lists; `definedIn` is `null` if the function is not exported.
|
|
398
|
+
*/
|
|
399
|
+
declare function queryCallGraph(graph: Graph, functionName: string): FunctionCallInfo;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Pre-computed blast-radius map for every file in the graph.
|
|
403
|
+
*
|
|
404
|
+
* At small scales (< ~500 nodes) the live `graph.traverse` approach used by
|
|
405
|
+
* `get_affected` is fast enough (< 1ms per query). The cache pays off when:
|
|
406
|
+
* - The same file is queried many times in one session (O(1) vs O(n) per call)
|
|
407
|
+
* - The codebase exceeds ~1000 nodes and traversal cost becomes noticeable
|
|
408
|
+
* - The cache is persisted to disk and reused across MCP restarts
|
|
409
|
+
*/
|
|
410
|
+
interface ChangeImpactCache {
|
|
411
|
+
/**
|
|
412
|
+
* Map from project-relative file path to the list of all files that are
|
|
413
|
+
* transitively affected if that file changes (incoming traversal).
|
|
414
|
+
*/
|
|
415
|
+
impact: Map<string, string[]>;
|
|
416
|
+
/**
|
|
417
|
+
* Fingerprint of the graph this cache was built from.
|
|
418
|
+
* Used to detect stale caches without re-traversing the graph.
|
|
419
|
+
*/
|
|
420
|
+
graphHash: string;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Computes a lightweight fingerprint of the graph by hashing the sorted list of
|
|
424
|
+
* `path:mtime:size` tuples for every node. Any file addition, deletion, or
|
|
425
|
+
* modification will produce a different hash.
|
|
426
|
+
*
|
|
427
|
+
* @param graph - The graph to fingerprint.
|
|
428
|
+
* @returns A hex string hash.
|
|
429
|
+
*/
|
|
430
|
+
declare function computeGraphHash(graph: Graph): string;
|
|
431
|
+
/**
|
|
432
|
+
* Pre-computes the incoming blast-radius for every node in the graph.
|
|
433
|
+
*
|
|
434
|
+
* Runs one incoming traversal per node — O(n²) worst case but performed once.
|
|
435
|
+
* Results are stored in a `Map` for O(1) subsequent lookups.
|
|
436
|
+
*
|
|
437
|
+
* @param graph - The import graph to pre-compute.
|
|
438
|
+
* @returns A `ChangeImpactCache` ready for `queryChangeImpact`.
|
|
439
|
+
*/
|
|
440
|
+
declare function buildChangeImpactCache(graph: Graph): ChangeImpactCache;
|
|
441
|
+
/**
|
|
442
|
+
* Returns the list of files transitively affected by a change in `filePath`.
|
|
443
|
+
* Falls back to an empty array when the file is not in the cache.
|
|
444
|
+
*
|
|
445
|
+
* @param cache - A previously built `ChangeImpactCache`.
|
|
446
|
+
* @param filePath - Project-relative path of the changed file.
|
|
447
|
+
* @returns Sorted list of affected file paths.
|
|
448
|
+
*/
|
|
449
|
+
declare function queryChangeImpact(cache: ChangeImpactCache, filePath: string): string[];
|
|
450
|
+
/**
|
|
451
|
+
* Returns `true` when `cache` was built from the same graph as `graph`.
|
|
452
|
+
* Use this before trusting a deserialized cache loaded from disk.
|
|
453
|
+
*
|
|
454
|
+
* @param cache - The cache to validate.
|
|
455
|
+
* @param graph - The current graph to compare against.
|
|
456
|
+
* @returns `true` if the cache is still valid for this graph.
|
|
457
|
+
*/
|
|
458
|
+
declare function isChangeImpactCacheValid(cache: ChangeImpactCache, graph: Graph): boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Serializes a `ChangeImpactCache` to JSON and writes it to `cachePath`,
|
|
461
|
+
* creating parent directories as needed.
|
|
462
|
+
*
|
|
463
|
+
* @param cache - The cache to persist.
|
|
464
|
+
* @param cachePath - Absolute path to write the JSON file.
|
|
465
|
+
*/
|
|
466
|
+
declare function saveChangeImpactCache(cache: ChangeImpactCache, cachePath: string): void;
|
|
467
|
+
/**
|
|
468
|
+
* Reads and deserializes a `ChangeImpactCache` from disk.
|
|
469
|
+
* Returns `null` when the file does not exist or cannot be parsed.
|
|
470
|
+
*
|
|
471
|
+
* @param cachePath - Absolute path to the JSON file written by `saveChangeImpactCache`.
|
|
472
|
+
* @returns The deserialized cache, or `null` on failure.
|
|
473
|
+
*/
|
|
474
|
+
declare function loadChangeImpactCache(cachePath: string): ChangeImpactCache | null;
|
|
475
|
+
|
|
476
|
+
/** Controls how aggressively `detectFeatures` promotes files to features. */
|
|
477
|
+
interface FeatureDetectionOptions {
|
|
478
|
+
/**
|
|
479
|
+
* Minimum number of internal imports a file must have before it is
|
|
480
|
+
* considered a feature. Lower values surface more candidates;
|
|
481
|
+
* higher values keep the list focused on true feature aggregators.
|
|
482
|
+
* @default 5
|
|
483
|
+
*/
|
|
484
|
+
minOutDegree?: number;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* A file identified as a feature hub — a non-test file with high out-degree
|
|
488
|
+
* (imports many internal modules), acting as an orchestrator or aggregator.
|
|
489
|
+
*/
|
|
490
|
+
interface FeatureInfo {
|
|
491
|
+
/** Absolute (or project-relative) path of the feature file. */
|
|
492
|
+
path: string;
|
|
493
|
+
/** How many internal files this file imports (its out-degree in the dep graph). */
|
|
494
|
+
outDegree: number;
|
|
495
|
+
/** Auto-generated tag of the form `feature:<basename>`, used for queries and reports. */
|
|
496
|
+
tag: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @description Scans the dependency graph and promotes non-test, non-barrel files with many
|
|
500
|
+
* imports to "feature hubs". Uses a two-pass approach: first count out-degrees, then filter
|
|
501
|
+
* and annotate. The result maps file path → `FeatureInfo` for tag generation or graph annotation.
|
|
502
|
+
* @param {Map<string, FileNode>} nodes - All file nodes in the dependency graph, keyed by file path.
|
|
503
|
+
* @param {FeatureDetectionOptions} [options] - Tuning knobs; currently just `minOutDegree` (default 5).
|
|
504
|
+
* @returns {Map<string, FeatureInfo>} Map of detected feature files; empty if none qualify.
|
|
505
|
+
*/
|
|
506
|
+
declare function detectFeatures(nodes: Map<string, FileNode>, options?: FeatureDetectionOptions): Map<string, FeatureInfo>;
|
|
507
|
+
|
|
508
|
+
/** Builds a FeatureGraph grouping graph nodes into feature domains under their respective hub files. */
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* A group of files that a single feature hub transitively imports.
|
|
512
|
+
* The hub itself is the high-out-degree orchestrator; `files` are its dependencies.
|
|
513
|
+
*/
|
|
514
|
+
interface FeatureDomain {
|
|
515
|
+
/** Project-relative path of the feature hub file. */
|
|
516
|
+
hub: string;
|
|
517
|
+
/** Number of internal imports the hub has (its out-degree). */
|
|
518
|
+
outDegree: number;
|
|
519
|
+
/** All files transitively imported by the hub, excluding the hub itself. */
|
|
520
|
+
files: string[];
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Domain-clustered view of the import graph.
|
|
524
|
+
* Provides a token-efficient way to answer "what files are in domain X?"
|
|
525
|
+
* without traversing the full graph.
|
|
526
|
+
*/
|
|
527
|
+
interface FeatureGraph {
|
|
528
|
+
/** Map from feature name (e.g. `"parser"`) to its domain info. */
|
|
529
|
+
features: Map<string, FeatureDomain>;
|
|
530
|
+
/**
|
|
531
|
+
* Files not reachable from any feature hub — shared utilities, top-level
|
|
532
|
+
* entry points, or files below the out-degree threshold.
|
|
533
|
+
*/
|
|
534
|
+
unassigned: string[];
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Options for `buildFeatureGraph`. Extends `FeatureDetectionOptions` so callers
|
|
538
|
+
* can pass `{ minOutDegree }` without needing to know this type explicitly.
|
|
539
|
+
*/
|
|
540
|
+
interface FeatureGraphOptions extends FeatureDetectionOptions {
|
|
541
|
+
/**
|
|
542
|
+
* Comparator used to pick the "best" hub when a file is reachable from
|
|
543
|
+
* multiple hubs. Return a negative number when `left` should win over `right`.
|
|
544
|
+
* @default ascending out-degree (most-specific hub wins)
|
|
545
|
+
*/
|
|
546
|
+
hubComparator?: (left: FeatureInfo, right: FeatureInfo) => number;
|
|
547
|
+
/**
|
|
548
|
+
* Override the hub-detection function. Defaults to `detectFeatures`.
|
|
549
|
+
* Inject a custom implementation for testing or alternative hub strategies.
|
|
550
|
+
*/
|
|
551
|
+
detectFn?: (nodes: Map<string, FileNode>, options?: FeatureDetectionOptions) => Map<string, FeatureInfo>;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Builds a domain-clustered view of the import graph by grouping files under
|
|
555
|
+
* the most specific feature hub that can reach them.
|
|
556
|
+
*
|
|
557
|
+
* Assignment rule: each file is assigned to the hub with the lowest out-degree
|
|
558
|
+
* that can transitively reach it (overridable via `options.hubComparator`).
|
|
559
|
+
*
|
|
560
|
+
* @param graph - The import graph to cluster.
|
|
561
|
+
* @param options - Controls hub detection threshold, assignment comparator, and detectFn override.
|
|
562
|
+
* @returns A `FeatureGraph` with one domain per hub and an `unassigned` list.
|
|
563
|
+
*/
|
|
564
|
+
declare function buildFeatureGraph(graph: Graph, options?: FeatureGraphOptions): FeatureGraph;
|
|
565
|
+
|
|
566
|
+
/** Public types for the responsibility-graph subsystem. Kept separate to avoid circular imports between infer-role.ts and index.ts. */
|
|
567
|
+
/**
|
|
568
|
+
* Semantic role of a module derived from its file path and category.
|
|
569
|
+
* Roles are intentionally generic so they apply across any project layout.
|
|
570
|
+
*/
|
|
571
|
+
type ModuleRole = "test" | "config" | "types" | "model" | "service" | "controller" | "middleware" | "router" | "component" | "store" | "util" | "handler" | "cli" | "api" | "parser" | "builder" | "resolver" | "adapter" | "plugin" | "other";
|
|
572
|
+
/**
|
|
573
|
+
* What a single module is responsible for, derived purely from graph data.
|
|
574
|
+
* No inference or hallucination — only data already present in the `FileNode`.
|
|
575
|
+
*/
|
|
576
|
+
interface ModuleResponsibility {
|
|
577
|
+
/** Project-relative file path. */
|
|
578
|
+
path: string;
|
|
579
|
+
/** Coarse semantic role inferred from file path and category. */
|
|
580
|
+
role: ModuleRole;
|
|
581
|
+
/**
|
|
582
|
+
* Human-readable description extracted from the file's leading JSDoc comment.
|
|
583
|
+
* `undefined` when the file has no file-level JSDoc.
|
|
584
|
+
*/
|
|
585
|
+
description?: string;
|
|
586
|
+
/** Names of all exported symbols (functions, types, classes). */
|
|
587
|
+
exports: string[];
|
|
588
|
+
/**
|
|
589
|
+
* Name of the feature hub this file belongs to, if any.
|
|
590
|
+
* Derived from `buildFeatureGraph` with default threshold.
|
|
591
|
+
*/
|
|
592
|
+
featureHub?: string;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Map from project-relative path to its responsibility record.
|
|
596
|
+
* A token-efficient answer to "what does module X do?" across many files at once.
|
|
597
|
+
*/
|
|
598
|
+
type ResponsibilityGraph = Map<string, ModuleResponsibility>;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Builds a responsibility map for every file in the graph.
|
|
602
|
+
*
|
|
603
|
+
* Each entry is derived entirely from data already present in the `FileNode`:
|
|
604
|
+
* - `description` comes from the file's leading JSDoc (`FileNode.description`)
|
|
605
|
+
* - `exports` are the exported symbol names
|
|
606
|
+
* - `role` is inferred from file path and category via `inferRole`
|
|
607
|
+
* - `featureHub` is resolved via `buildFeatureGraph` with default options
|
|
608
|
+
*
|
|
609
|
+
* Test files are included with `role: "test"` so callers can filter them if needed.
|
|
610
|
+
*
|
|
611
|
+
* @param {Graph} graph - The import graph to derive responsibilities from.
|
|
612
|
+
* @param {FeatureDetectionOptions} [featureOptions] - Options forwarded to `buildFeatureGraph` (e.g. `minOutDegree`).
|
|
613
|
+
* @returns {ResponsibilityGraph} A map from each file path to its `ModuleResponsibility`.
|
|
614
|
+
*/
|
|
615
|
+
declare function buildResponsibilityGraph(graph: Graph, featureOptions?: FeatureDetectionOptions): ResponsibilityGraph;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* @description Tracks which exported symbols of each visited node are "affected" by a change.
|
|
619
|
+
*
|
|
620
|
+
* Enables symbol-level pruning during graph traversal: if a node only imports `foo` and `foo`
|
|
621
|
+
* was not among the changed symbols, that node is not considered affected and traversal stops there.
|
|
622
|
+
*/
|
|
623
|
+
declare class SymbolTraversalContext {
|
|
624
|
+
private affectedSymbols;
|
|
625
|
+
/**
|
|
626
|
+
* @param {string} startPath - Relative path of the changed file; seeded with the given affected symbols.
|
|
627
|
+
* @param {string[]} affectedSymbols - Symbol names that are considered changed. Pass `["*"]` to treat the whole file as changed.
|
|
628
|
+
*/
|
|
629
|
+
constructor(startPath: string, affectedSymbols: string[]);
|
|
630
|
+
/**
|
|
631
|
+
* @description Checks whether `visitedNode` imports any affected symbol from `childPath` and,
|
|
632
|
+
* if so, propagates the affected symbol set to `visitedNode` for the next traversal step.
|
|
633
|
+
*
|
|
634
|
+
* Both roles live in one method to avoid a second pass over the import edges — the check
|
|
635
|
+
* and the update read the same edge, so splitting them would duplicate work.
|
|
636
|
+
* @param {{ path: string; imports: ImportEdge[] }} visitedNode - The node currently being evaluated; its imports are inspected.
|
|
637
|
+
* @param {string} childPath - The path it was reached from; used to look up the current affected symbols.
|
|
638
|
+
* @returns {boolean} `true` if at least one imported symbol is affected and traversal should continue; `false` to prune.
|
|
639
|
+
*/
|
|
640
|
+
updateAffectedSymbols(visitedNode: {
|
|
641
|
+
path: string;
|
|
642
|
+
imports: ImportEdge[];
|
|
643
|
+
}, childPath: string): boolean;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** Structural kind of a type export. */
|
|
647
|
+
type TypeKind = "interface" | "class" | "enum" | "type";
|
|
648
|
+
/**
|
|
649
|
+
* A single type-like export extracted from a TypeScript source file.
|
|
650
|
+
* Only interfaces, classes, enums, and type aliases are included —
|
|
651
|
+
* plain functions and values are excluded.
|
|
652
|
+
*/
|
|
653
|
+
interface TypeNode {
|
|
654
|
+
/** Exported symbol name (e.g. `"FileNode"`). */
|
|
655
|
+
name: string;
|
|
656
|
+
/** Project-relative path of the file that exports this type. */
|
|
657
|
+
file: string;
|
|
658
|
+
/** Structural kind inferred from the export signature. */
|
|
659
|
+
kind: TypeKind;
|
|
660
|
+
/** JSDoc description attached to the export, if present. */
|
|
661
|
+
doc?: string;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* A directed edge representing that one file imports a specific type from another file.
|
|
665
|
+
*/
|
|
666
|
+
interface TypeEdge {
|
|
667
|
+
/** Project-relative path of the importing file. */
|
|
668
|
+
fromFile: string;
|
|
669
|
+
/** Name of the imported type. */
|
|
670
|
+
toType: string;
|
|
671
|
+
/** Project-relative path of the file that defines the type. */
|
|
672
|
+
toFile: string;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Type-level view of the import graph.
|
|
676
|
+
* Answers "what types depend on X?" and "what does type X depend on?"
|
|
677
|
+
* at a fraction of the cost of sending the full graph.
|
|
678
|
+
*/
|
|
679
|
+
interface TypeGraph {
|
|
680
|
+
/**
|
|
681
|
+
* All type-like exports in the graph.
|
|
682
|
+
* Key format: `"<file>::<typeName>"` (e.g. `"src/types/node.ts::FileNode"`).
|
|
683
|
+
*/
|
|
684
|
+
types: Map<string, TypeNode>;
|
|
685
|
+
/** All import edges where the imported symbol is a known type. */
|
|
686
|
+
edges: TypeEdge[];
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Result of a focused query for one named type.
|
|
690
|
+
* A token-efficient answer to "what types depend on X?" and "what does X use?"
|
|
691
|
+
*/
|
|
692
|
+
interface TypeQueryResult {
|
|
693
|
+
/** The type that was queried. */
|
|
694
|
+
type: TypeNode | null;
|
|
695
|
+
/** Project-relative paths of files that import this type. */
|
|
696
|
+
usedByFiles: string[];
|
|
697
|
+
/** Types that the defining file imports from other files. */
|
|
698
|
+
uses: TypeNode[];
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Builds a type-level view of the import graph by extracting all type-like exports
|
|
702
|
+
* and the import edges that connect them.
|
|
703
|
+
*
|
|
704
|
+
* Only TypeScript and JavaScript files are considered — other file types carry no
|
|
705
|
+
* type information usable for this graph.
|
|
706
|
+
*
|
|
707
|
+
* @param graph - The import graph to derive the type graph from.
|
|
708
|
+
* @returns A `TypeGraph` with all type nodes and their dependency edges.
|
|
709
|
+
*/
|
|
710
|
+
declare function buildTypeGraph(graph: Graph): TypeGraph;
|
|
711
|
+
/**
|
|
712
|
+
* Queries the type graph for a specific named type, returning its direct dependents
|
|
713
|
+
* (files that import it) and its direct dependencies (types it imports).
|
|
714
|
+
*
|
|
715
|
+
* When `typeName` is not found in the graph, `type` is `null` and both lists are empty.
|
|
716
|
+
*
|
|
717
|
+
* @param typeGraph - A previously built `TypeGraph`.
|
|
718
|
+
* @param typeName - Exact exported name of the type to look up (e.g. `"FileNode"`).
|
|
719
|
+
* @returns `TypeQueryResult` with the type node and its one-hop neighbours.
|
|
720
|
+
*/
|
|
721
|
+
declare function queryTypeGraph(typeGraph: TypeGraph, typeName: string): TypeQueryResult;
|
|
722
|
+
|
|
723
|
+
/** @description Metadata for a single package inside a monorepo workspace. */
|
|
724
|
+
interface WorkspacePackage {
|
|
725
|
+
/** Package name from `package.json`. */
|
|
726
|
+
name: string;
|
|
727
|
+
/** Absolute path to the package directory. */
|
|
728
|
+
root: string;
|
|
729
|
+
/** Path relative to the monorepo root (used as a stable key in node paths). */
|
|
730
|
+
relativeRoot: string;
|
|
731
|
+
/** Resolved entry point absolute paths, in priority order. */
|
|
732
|
+
entryPoints: string[];
|
|
733
|
+
}
|
|
734
|
+
/** @description Result returned by `detectMonorepo` describing the workspace layout. */
|
|
735
|
+
interface MonorepoLayout {
|
|
736
|
+
root: string;
|
|
737
|
+
/** Primary detected tool (first detector that fired), or `"none"`. */
|
|
738
|
+
type: string;
|
|
739
|
+
/** All tools detected in this repo (e.g. `["turborepo", "pnpm"]` for a Turborepo+pnpm repo). */
|
|
740
|
+
types: string[];
|
|
741
|
+
packages: WorkspacePackage[];
|
|
742
|
+
packageMap: Map<string, WorkspacePackage>;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/** Registry for MonorepoDetector plugins, allowing custom detectors to be added alongside the built-in ones. */
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* @description Contract for a tool-specific monorepo detector.
|
|
749
|
+
* Each detector knows how to recognise one package manager or build orchestrator
|
|
750
|
+
* and enumerate the packages it manages.
|
|
751
|
+
*/
|
|
752
|
+
interface MonorepoDetector {
|
|
753
|
+
/**
|
|
754
|
+
* Identifier for this tool (e.g. `"pnpm"`, `"nx"`).
|
|
755
|
+
* Included in `MonorepoLayout.types` when this detector fires.
|
|
756
|
+
*/
|
|
757
|
+
readonly type: string;
|
|
758
|
+
/**
|
|
759
|
+
* @description Inspects `rootDir` and returns the workspace packages it manages.
|
|
760
|
+
* Return `null` to signal "this tool is not present here" (detector does not fire).
|
|
761
|
+
* Return an empty array to signal "tool is present but manages no packages" (detector fires, contributes its type).
|
|
762
|
+
* @param {string} rootDir - Absolute path to the repository root to inspect.
|
|
763
|
+
* @returns {WorkspacePackage[] | null} Discovered packages, an empty array if the tool is present but empty, or `null` if the tool is absent.
|
|
764
|
+
*/
|
|
765
|
+
detect(rootDir: string): WorkspacePackage[] | null;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* @description Registers a monorepo detector. Detectors are run in registration order;
|
|
769
|
+
* register higher-priority tools first (e.g. Turborepo before pnpm).
|
|
770
|
+
* @param {MonorepoDetector} detector - The detector implementation to add to the registry.
|
|
771
|
+
*/
|
|
772
|
+
declare function registerMonorepoDetector(detector: MonorepoDetector): void;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* @description Runs all registered monorepo detectors against `rootDir` and merges
|
|
776
|
+
* their results into a single `MonorepoLayout`. All matching detectors contribute
|
|
777
|
+
* their `type` string and packages — so a Turborepo + pnpm repo will have
|
|
778
|
+
* `types: ["turborepo", "pnpm"]` and packages from the pnpm detector.
|
|
779
|
+
*
|
|
780
|
+
* Packages are deduplicated by name: the first detector to emit a package name wins.
|
|
781
|
+
* Returns `type: "none"` when no detector fires.
|
|
782
|
+
*/
|
|
783
|
+
declare function detectMonorepo(rootDir: string, detectors?: readonly MonorepoDetector[]): MonorepoLayout;
|
|
784
|
+
|
|
785
|
+
/** WorkspaceGraph holds one per-package Graph for a monorepo and exposes cross-package blast-radius queries. */
|
|
786
|
+
|
|
787
|
+
/** @description JSON-safe snapshot of a `WorkspaceGraph`, suitable for writing to disk and restoring via `WorkspaceGraph.deserialize`. */
|
|
788
|
+
interface SerializedWorkspaceGraph {
|
|
789
|
+
monorepoRoot: string;
|
|
790
|
+
type: string;
|
|
791
|
+
packages: Array<{
|
|
792
|
+
pkg: Omit<WorkspacePackage, "root">;
|
|
793
|
+
nodes: FileNode[];
|
|
794
|
+
}>;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* @description Holds one per-package `Graph` for each workspace package in a monorepo.
|
|
798
|
+
* Cross-package import edges are preserved inside each graph via `ImportEdge.isWorkspace`.
|
|
799
|
+
* The workspace graph does not merge all nodes into one flat namespace — each package graph
|
|
800
|
+
* is queried independently, with cross-package traversal handled by `getAffectedAcrossPackages`.
|
|
801
|
+
*/
|
|
802
|
+
declare class WorkspaceGraph {
|
|
803
|
+
readonly monorepoRoot: string;
|
|
804
|
+
readonly type: string;
|
|
805
|
+
readonly packages: Map<string, {
|
|
806
|
+
graph: Graph;
|
|
807
|
+
pkg: WorkspacePackage;
|
|
808
|
+
}>;
|
|
809
|
+
/**
|
|
810
|
+
* @param {string} monorepoRoot - Absolute path to the monorepo root directory.
|
|
811
|
+
* @param {string} type - Primary detected monorepo tool (e.g. `"turborepo"`, `"pnpm"`), or `"none"`.
|
|
812
|
+
*/
|
|
813
|
+
constructor(monorepoRoot: string, type: string);
|
|
814
|
+
/**
|
|
815
|
+
* @description Registers a package and its pre-built graph into this workspace.
|
|
816
|
+
* @param {WorkspacePackage} pkg - Package metadata including name, root, and entry points.
|
|
817
|
+
* @param {Graph} graph - The fully-built dependency graph for this package.
|
|
818
|
+
*/
|
|
819
|
+
addPackage(pkg: WorkspacePackage, graph: Graph): void;
|
|
820
|
+
/**
|
|
821
|
+
* @description Returns the workspace package whose `relativeRoot` is a path prefix of `relPath`.
|
|
822
|
+
* @param {string} relPath - A monorepo-root-relative file path to look up.
|
|
823
|
+
* @returns {WorkspacePackage | undefined} The owning package, or `undefined` if none matches.
|
|
824
|
+
*/
|
|
825
|
+
getPackageForFile(relPath: string): WorkspacePackage | undefined;
|
|
826
|
+
/**
|
|
827
|
+
* @description Returns a map of package-level dependencies derived from workspace import edges.
|
|
828
|
+
* Key: package name. Value: list of workspace package names it imports from.
|
|
829
|
+
* @returns {Map<string, string[]>} Map from package name to the list of workspace packages it depends on.
|
|
830
|
+
*/
|
|
831
|
+
getPackageDependencies(): Map<string, string[]>;
|
|
832
|
+
/**
|
|
833
|
+
* @description Cross-package blast-radius analysis. Returns every file (with its package name)
|
|
834
|
+
* that could be affected if the given monorepo-root-relative path changes.
|
|
835
|
+
* Step 1: traverses incoming edges within the owning package graph for intra-package dependents.
|
|
836
|
+
* Step 2: surfaces files in other packages that hold workspace import edges pointing at the owner.
|
|
837
|
+
* @param {string} relPath - Monorepo-root-relative path of the changed file.
|
|
838
|
+
* @returns {Array<{ file: string; package: string }>} Each affected file paired with its package name.
|
|
839
|
+
*/
|
|
840
|
+
getAffectedAcrossPackages(relPath: string): Array<{
|
|
841
|
+
file: string;
|
|
842
|
+
package: string;
|
|
843
|
+
}>;
|
|
844
|
+
/**
|
|
845
|
+
* @description Serializes the workspace graph to a plain JSON-safe object.
|
|
846
|
+
* `root` is omitted from package entries as it is not needed after build time.
|
|
847
|
+
* @returns {SerializedWorkspaceGraph} A JSON-serializable snapshot of the workspace graph.
|
|
848
|
+
*/
|
|
849
|
+
serialize(): SerializedWorkspaceGraph;
|
|
850
|
+
/**
|
|
851
|
+
* @description Reconstructs a `WorkspaceGraph` from a serialized snapshot.
|
|
852
|
+
* The `root` field on each package is set to an empty string — it is not persisted and not needed for graph traversal.
|
|
853
|
+
* @param {SerializedWorkspaceGraph} data - The plain object produced by `serialize`.
|
|
854
|
+
* @returns {WorkspaceGraph} A fully functional `WorkspaceGraph` instance.
|
|
855
|
+
*/
|
|
856
|
+
static deserialize(data: SerializedWorkspaceGraph): WorkspaceGraph;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* @description Contract for graph serializers. Implement this to add a new export format
|
|
861
|
+
* (e.g. Graphviz DOT, JSON, SVG) without touching the core graph model.
|
|
862
|
+
*/
|
|
863
|
+
interface GraphExporter {
|
|
864
|
+
/**
|
|
865
|
+
* @description Converts a dependency graph into a serialized string in the exporter's target format.
|
|
866
|
+
* @param graph - The fully-built dependency graph to serialize.
|
|
867
|
+
* @returns A string representation of the graph in the target format (e.g. Mermaid, DOT).
|
|
868
|
+
*/
|
|
869
|
+
serialize(graph: Graph): string;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** GraphExporter implementation that renders dependency graphs as Mermaid flowchart diagrams. */
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* @description GraphExporter implementation that renders dependency graphs as Mermaid diagrams.
|
|
876
|
+
* Use this directly or pass it anywhere a GraphExporter is accepted.
|
|
877
|
+
*/
|
|
878
|
+
declare const MermaidExporter: GraphExporter;
|
|
879
|
+
/**
|
|
880
|
+
* @description Convenience wrapper around MermaidExporter.serialize.
|
|
881
|
+
* @param graph - The dependency graph to render.
|
|
882
|
+
* @returns A Mermaid `graph TD` diagram string.
|
|
883
|
+
*/
|
|
884
|
+
declare function toMermaid(graph: Graph): string;
|
|
885
|
+
|
|
886
|
+
/** A config matcher: substring, regex, or predicate tested against the lowercase basename. */
|
|
887
|
+
type ConfigMatcher = string | RegExp | ((baseName: string) => boolean);
|
|
888
|
+
/**
|
|
889
|
+
* @description Registers a custom config-file matcher used when categorising nodes.
|
|
890
|
+
* Accepts a substring, regex, or predicate tested against the lowercase basename.
|
|
891
|
+
* Call this before running `createImportMap` — e.g. in a `mokosh.config.ts`.
|
|
892
|
+
* @param matcher - A substring, `RegExp`, or predicate function tested against the lowercase file basename.
|
|
893
|
+
* @example
|
|
894
|
+
* // Match any file whose basename contains ".myconfig."
|
|
895
|
+
* registerConfigMatcher(".myconfig.");
|
|
896
|
+
*
|
|
897
|
+
* // Match via regex
|
|
898
|
+
* registerConfigMatcher(/^vite\.config\./);
|
|
899
|
+
*
|
|
900
|
+
* // Match via predicate
|
|
901
|
+
* registerConfigMatcher((name) => name.startsWith("jest.config"));
|
|
902
|
+
*/
|
|
903
|
+
declare function registerConfigMatcher(matcher: ConfigMatcher): void;
|
|
904
|
+
/**
|
|
905
|
+
* @description Registers an additional basename substring that marks a file as a test.
|
|
906
|
+
* @param pattern - A substring matched against the file basename, e.g. `".unit."`.
|
|
907
|
+
*/
|
|
908
|
+
declare function registerTestPattern(pattern: string): void;
|
|
909
|
+
/**
|
|
910
|
+
* @description Registers an additional import specifier that indicates a test file.
|
|
911
|
+
* @param lib - An import specifier substring, e.g. `"@my-org/test-utils"`.
|
|
912
|
+
*/
|
|
913
|
+
declare function registerTestLibrary(lib: string): void;
|
|
914
|
+
|
|
915
|
+
interface RawCallEdge {
|
|
916
|
+
from: string;
|
|
917
|
+
to: string;
|
|
918
|
+
toSpecifier: string;
|
|
919
|
+
}
|
|
920
|
+
interface ParseResult {
|
|
921
|
+
imports: ImportEdge[];
|
|
922
|
+
exports: ExportedSymbol[];
|
|
923
|
+
tags: StructuredTag[];
|
|
924
|
+
category: NodeCategory;
|
|
925
|
+
rawCallEdges?: RawCallEdge[];
|
|
926
|
+
description?: string;
|
|
927
|
+
/** McCabe cyclomatic complexity of the file (base 1, undefined for non-TS/JS files). */
|
|
928
|
+
complexity?: number;
|
|
929
|
+
/** Cognitive complexity — nesting-aware difficulty score (undefined for non-TS/JS files). */
|
|
930
|
+
cognitiveComplexity?: number;
|
|
931
|
+
/** Per-function complexity breakdown (undefined for non-TS/JS files). */
|
|
932
|
+
functions?: FunctionComplexity[];
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/** Parser registry: maps FileType values to parser functions and provides lookup by file type. */
|
|
936
|
+
|
|
937
|
+
type ParserFunction = (filePath: string, content: string) => ParseResult | Promise<ParseResult>;
|
|
938
|
+
/**
|
|
939
|
+
* @description Registers a parser function for a given file type, overwriting any
|
|
940
|
+
* previously registered parser for that type.
|
|
941
|
+
* @param type - The `FileType` key this parser should handle.
|
|
942
|
+
* @param parser - The parsing function that extracts imports and tags from file content.
|
|
943
|
+
*/
|
|
944
|
+
declare function registerParser(type: FileType, parser: ParserFunction): void;
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Criteria for filtering nodes in a serialized graph.
|
|
948
|
+
*
|
|
949
|
+
* String fields support a `"!"` prefix for negation (e.g. `category: "!test"`).
|
|
950
|
+
* `tags` uses OR logic across positive entries; negated entries (`"!auth"`) act
|
|
951
|
+
* as mandatory exclusions and are evaluated independently.
|
|
952
|
+
*/
|
|
953
|
+
interface NodeQuery {
|
|
954
|
+
category?: string;
|
|
955
|
+
type?: string;
|
|
956
|
+
/** OR match across entries. Prefix with `"!"` to exclude that tag. */
|
|
957
|
+
tags?: string[];
|
|
958
|
+
/** AND match — all entries must be present (use `tag:a+b` syntax in query strings). */
|
|
959
|
+
allTags?: string[];
|
|
960
|
+
path?: string;
|
|
961
|
+
isExternal?: boolean;
|
|
962
|
+
/** Substring match on `imp.toPath` — node must import a file whose path contains this string. */
|
|
963
|
+
importsFile?: string;
|
|
964
|
+
/** Substring match on importer paths — node must be imported by a file whose path contains this string. */
|
|
965
|
+
importedBy?: string;
|
|
966
|
+
minImports?: number;
|
|
967
|
+
maxImports?: number;
|
|
968
|
+
minSize?: number;
|
|
969
|
+
maxSize?: number;
|
|
970
|
+
sort?: "size" | "imports" | "commitCount90d" | "exportUsage";
|
|
971
|
+
limit?: number;
|
|
972
|
+
hasDocstring?: boolean;
|
|
973
|
+
/** Minimum line-coverage percentage; nodes below this value are excluded. Nodes with no coverage data are excluded. */
|
|
974
|
+
minCoverage?: number;
|
|
975
|
+
/** Maximum line-coverage percentage; nodes above this value are excluded. Nodes with no coverage data are treated as 0%. */
|
|
976
|
+
maxCoverage?: number;
|
|
977
|
+
/** Minimum avgExportUsage (0–1); nodes below this value are excluded. Nodes with no data are excluded. */
|
|
978
|
+
minExportUsage?: number;
|
|
979
|
+
/** Maximum avgExportUsage (0–1); nodes above this value are excluded. Nodes with no data are treated as 0. */
|
|
980
|
+
maxExportUsage?: number;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/** Filters a graph by applying NodeQuery predicates: category, type, tag, path, imports, coverage, and more. */
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* @description Filters a serialized graph to only nodes matching all criteria in `query`,
|
|
987
|
+
* then trims each node's import list to edges whose target is also in the result set.
|
|
988
|
+
* Optionally sorts the result and applies a `limit`.
|
|
989
|
+
* @param {SerializedGraph} graph - The serialized graph to filter.
|
|
990
|
+
* @param {NodeQuery} query - Filter criteria; omitted fields are treated as wildcards.
|
|
991
|
+
* @returns {SerializedGraph} A new `SerializedGraph` containing only the matching subgraph.
|
|
992
|
+
*/
|
|
993
|
+
declare function filterGraph(graph: SerializedGraph, query: NodeQuery): SerializedGraph;
|
|
994
|
+
|
|
995
|
+
/** Parses a key:value query string into a structured NodeQuery for use with filterGraph. */
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* @description Parses a `"key:value,key:value"` query string into a structured `NodeQuery`.
|
|
999
|
+
* String values support `"!"` prefix for negation. The `tag`/`tags` key may appear multiple
|
|
1000
|
+
* times; values are OR-matched (negated entries act as exclusions). `tag:a+b` maps to `allTags`.
|
|
1001
|
+
* @param {string} queryString - Comma-separated `key:value` pairs, e.g. `"category:logic,tag:auth"`.
|
|
1002
|
+
* @returns {NodeQuery} The structured query object ready for use with `filterGraph` or `matchNode`.
|
|
1003
|
+
*/
|
|
1004
|
+
declare function parseQuery(queryString: string): NodeQuery;
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* @description Result for a single file processed by {@link applyTagsToFile}.
|
|
1008
|
+
*/
|
|
1009
|
+
interface ApplyTagsFileResult {
|
|
1010
|
+
/** Project-relative path of the test file. */
|
|
1011
|
+
path: string;
|
|
1012
|
+
/** `"updated"` when the file was rewritten, `"unchanged"` when tags already matched, `"error"` on I/O failure. */
|
|
1013
|
+
status: "updated" | "unchanged" | "error";
|
|
1014
|
+
/** Present only when status is `"error"`. */
|
|
1015
|
+
error?: string;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* @description Aggregate result returned by {@link applyTags} after processing all test nodes.
|
|
1019
|
+
*/
|
|
1020
|
+
interface ApplyTagsResult {
|
|
1021
|
+
/** Number of files that were written (or would have been written in dry-run mode). */
|
|
1022
|
+
updated: number;
|
|
1023
|
+
/** Number of files where the existing tags already matched the computed tags. */
|
|
1024
|
+
unchanged: number;
|
|
1025
|
+
/** Number of files that could not be read or written. */
|
|
1026
|
+
errors: number;
|
|
1027
|
+
/** Per-file breakdown. */
|
|
1028
|
+
files: ApplyTagsFileResult[];
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* @description Iterates every test node in the graph, extracts `"import"` kind tags that pass
|
|
1032
|
+
* a name validity check and generic-name blocklist, then delegates writing to the strategy
|
|
1033
|
+
* selected by `mokosh.config.*` (`tagApplier.framework`, default `"vitest"`). Non-test nodes
|
|
1034
|
+
* are skipped.
|
|
1035
|
+
* @param {Graph} graph - The fully-enriched dependency graph.
|
|
1036
|
+
* @param {string} rootDir - Absolute path to the project root.
|
|
1037
|
+
* @param {{ dryRun: boolean }} options - Pass `dryRun: true` to preview changes without disk writes.
|
|
1038
|
+
* @returns {Promise<ApplyTagsResult>} Aggregate result with per-file status breakdown.
|
|
1039
|
+
*/
|
|
1040
|
+
declare function applyTags(graph: Graph, rootDir: string, options: {
|
|
1041
|
+
dryRun: boolean;
|
|
1042
|
+
}): Promise<ApplyTagsResult>;
|
|
1043
|
+
|
|
1044
|
+
/** Strategy interface and default implementation for identifying test nodes in the graph. */
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* @description Strategy interface for determining whether a graph node represents a test file.
|
|
1048
|
+
*/
|
|
1049
|
+
interface TestNodeIdentifier {
|
|
1050
|
+
/**
|
|
1051
|
+
* @description Returns whether the given node should be treated as a test node.
|
|
1052
|
+
* @param {{ category: string; tags: StructuredTag[] }} node - A minimal node descriptor containing its category and structured tags.
|
|
1053
|
+
* @returns {boolean} `true` if the node is a test file.
|
|
1054
|
+
*/
|
|
1055
|
+
isTestNode(node: {
|
|
1056
|
+
category: string;
|
|
1057
|
+
tags: StructuredTag[];
|
|
1058
|
+
}): boolean;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/** Proposes semantic test tags and affected test files from git diff and the dependency graph. */
|
|
1062
|
+
|
|
1063
|
+
/** @description Options for `proposeTags` and `proposeAffectedTests`, allowing callers to override the test-node identifier and feature-detection behaviour. */
|
|
1064
|
+
interface ProposeTagsOptions {
|
|
1065
|
+
identifier?: TestNodeIdentifier;
|
|
1066
|
+
featureDetection?: FeatureDetectionOptions | false;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* @description Proposes Vitest tags to run based on which files changed.
|
|
1070
|
+
*
|
|
1071
|
+
* Traverses the incoming dependency graph from each changed file. Test nodes
|
|
1072
|
+
* that can reach the changed file contribute their tags. Feature hubs act as
|
|
1073
|
+
* boundaries: the hub's tag is emitted and traversal stops there, preventing
|
|
1074
|
+
* combinatorial blowup in large graphs.
|
|
1075
|
+
* @param {Graph} graph - The full project dependency graph.
|
|
1076
|
+
* @param {string[]} changedFiles - Relative paths of files that were modified (e.g. from git diff).
|
|
1077
|
+
* @param {ProposeTagsOptions} [options] - Optional: custom test identifier and feature-detection settings.
|
|
1078
|
+
* @returns {string[]} Deduplicated list of tag strings to pass to `vitest --grep`.
|
|
1079
|
+
*/
|
|
1080
|
+
declare function proposeTags(graph: Graph, changedFiles: string[], options?: ProposeTagsOptions): string[];
|
|
1081
|
+
/**
|
|
1082
|
+
* @description Returns the file paths of test files affected by the changed files.
|
|
1083
|
+
*
|
|
1084
|
+
* Traverses the incoming dependency graph from each changed file and collects
|
|
1085
|
+
* paths of reachable test nodes. Feature hubs act as traversal boundaries —
|
|
1086
|
+
* tests beyond a hub are excluded because the hub's own tag already covers
|
|
1087
|
+
* them when using `proposeTags`.
|
|
1088
|
+
*
|
|
1089
|
+
* The output is a plain list of relative paths suitable for piping directly
|
|
1090
|
+
* into Vitest: `vitest $(mokosh --affected-tests)`.
|
|
1091
|
+
* @param {Graph} graph - The full project dependency graph.
|
|
1092
|
+
* @param {string[]} changedFiles - Relative paths of files that were modified (e.g. from git diff).
|
|
1093
|
+
* @param {ProposeTagsOptions} [options] - Optional: custom test identifier and feature-detection settings.
|
|
1094
|
+
* @returns {string[]} Deduplicated list of relative test file paths.
|
|
1095
|
+
*/
|
|
1096
|
+
declare function proposeAffectedTests(graph: Graph, changedFiles: string[], options?: ProposeTagsOptions): string[];
|
|
1097
|
+
|
|
1098
|
+
/** Public library API: createImportMap, createWorkspaceGraph, and getAllProjectFiles. */
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* @description Builds a dependency graph from the given entry points, optionally reusing a
|
|
1102
|
+
* previously built graph for incremental updates.
|
|
1103
|
+
* @param rootDir - Absolute or relative path to the project root; resolved internally.
|
|
1104
|
+
* @param entryPoints - File paths (relative to `rootDir`) that seed the graph walk.
|
|
1105
|
+
* @param previousGraph - An earlier graph to diff against for incremental builds; pass `null` for a full build.
|
|
1106
|
+
* @param options - `silent` suppresses progress output; `gitStats` attaches git churn data; `coverageMap` maps file paths to line-coverage percentages.
|
|
1107
|
+
* @returns The fully-built Graph with all reachable nodes and import edges populated.
|
|
1108
|
+
*/
|
|
1109
|
+
declare function createImportMap(rootDir: string, entryPoints: string[], previousGraph?: Graph | null, options?: {
|
|
1110
|
+
silent?: boolean;
|
|
1111
|
+
gitStats?: boolean;
|
|
1112
|
+
coverageMap?: Map<string, number>;
|
|
1113
|
+
}): Promise<Graph>;
|
|
1114
|
+
/**
|
|
1115
|
+
* @description Auto-detects the monorepo layout under `rootDir` and builds a per-package
|
|
1116
|
+
* dependency graph, stitching them together into a single WorkspaceGraph.
|
|
1117
|
+
* @param rootDir - Absolute path to the monorepo root.
|
|
1118
|
+
* @param options - `packages` filters to a named subset of packages; `silent` suppresses progress; `gitStats` attaches git churn data per file.
|
|
1119
|
+
* @returns A WorkspaceGraph where each package has its own Graph and cross-package edges are resolved.
|
|
1120
|
+
*/
|
|
1121
|
+
declare function createWorkspaceGraph(rootDir: string, options?: {
|
|
1122
|
+
packages?: string[];
|
|
1123
|
+
silent?: boolean;
|
|
1124
|
+
gitStats?: boolean;
|
|
1125
|
+
}): Promise<WorkspaceGraph>;
|
|
1126
|
+
/**
|
|
1127
|
+
* @description Recursively walks `rootDir` and returns paths of every file whose extension
|
|
1128
|
+
* is in the allowed set, skipping ignored directories. Silently skips unreadable entries.
|
|
1129
|
+
* @param rootDir - Root directory to scan; returned paths are relative to this.
|
|
1130
|
+
* @param options - Override or extend the default ignore-dir and extension lists via ScanOptions.
|
|
1131
|
+
* @returns Relative file paths for all matching source files found under `rootDir`.
|
|
1132
|
+
*/
|
|
1133
|
+
declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
|
|
1134
|
+
|
|
1135
|
+
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, type CallEdge, type CalleeEntry, type CallerEntry, type ChangeImpactCache, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type ExportKind, type ExportedSymbol, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, type FileNode, type FileType, type FunctionCallInfo, Graph, type GraphExporter, type ImportEdge, type ImportType, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, type NodeCategory, type NodeQuery, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type StructuredTag, SymbolTraversalContext, type TagKind, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, getAllProjectFiles, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, toMermaid };
|