@omfalos/mokosh 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -3
- package/dist/cli.js +75 -26
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +76 -27
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +245 -196
- package/dist/index.d.ts +245 -196
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -17
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +19 -17
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +19 -17
- package/dist/mcp.mjs.map +1 -1
- package/dist/parse-worker.d.mts +10 -0
- package/dist/parse-worker.d.ts +10 -0
- package/dist/parse-worker.js +2 -0
- package/dist/parse-worker.js.map +1 -0
- package/dist/parse-worker.mjs +2 -0
- package/dist/parse-worker.mjs.map +1 -0
- package/dist/types-C9fLCS45.d.mts +99 -0
- package/dist/types-C9fLCS45.d.ts +99 -0
- package/package.json +7 -3
- package/templates/config/mokosh.config.js +19 -0
- package/templates/skill/SKILL.md +122 -0
- package/templates/skill/mokosh.md +117 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,174 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
}
|
|
1
|
+
import { F as FileNode, C as CallEdge, I as ImportEdge, a as FileType, P as ParseResult, S as StructuredTag } from './types-C9fLCS45.js';
|
|
2
|
+
export { E as ExportedSymbol, b as ImportType, N as NodeCategory, T as TagKind } from './types-C9fLCS45.js';
|
|
172
3
|
|
|
173
4
|
interface SerializedGraph {
|
|
174
5
|
nodes: FileNode[];
|
|
@@ -283,6 +114,121 @@ declare class Graph {
|
|
|
283
114
|
findCycles(): string[][];
|
|
284
115
|
}
|
|
285
116
|
|
|
117
|
+
/** Configures whether/how `parseFile` calls are offloaded to a `piscina` worker pool. `false` always parses in-process. */
|
|
118
|
+
type ParallelParsingOption = boolean | {
|
|
119
|
+
minFiles?: number;
|
|
120
|
+
maxThreads?: number;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** Tag applier strategy interface — one implementation per testing framework. */
|
|
124
|
+
type TagFramework = "vitest" | "playwright" | "cypress" | "jest";
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @description Top-level configuration for mokosh. All fields are optional; unset fields
|
|
128
|
+
* fall back to built-in defaults. Load this object via `loadMokoshConfig`, then activate
|
|
129
|
+
* it with `applyConfig` before calling `createImportMap`.
|
|
130
|
+
*/
|
|
131
|
+
interface MokoshConfig {
|
|
132
|
+
/** Additional directories to skip when scanning (merged with built-in defaults). */
|
|
133
|
+
ignoreDirs?: string[];
|
|
134
|
+
/** Additional file extensions to scan (merged with built-in defaults). */
|
|
135
|
+
extensions?: string[];
|
|
136
|
+
/** Override the default cache path (`mokosh-cache/graph.json`). */
|
|
137
|
+
cachePath?: string;
|
|
138
|
+
/** Default entry points used when none are provided on the CLI. */
|
|
139
|
+
entryPoints?: string[];
|
|
140
|
+
/** Additional basename substrings that mark a file as `"config"` category. */
|
|
141
|
+
configMatchers?: string[];
|
|
142
|
+
/** Additional basename substrings that mark a file as `"test"` category (e.g. `".unit."`). */
|
|
143
|
+
testPatterns?: string[];
|
|
144
|
+
/** Additional import specifiers that indicate a test file (e.g. `"@my-org/test-utils"`). */
|
|
145
|
+
testLibraries?: string[];
|
|
146
|
+
/** Ratio of export-statements to total statements required for `"barrel"` classification. Default: `0.8`. */
|
|
147
|
+
barrelThreshold?: number;
|
|
148
|
+
/** When true, enriches each node with `commitCount90d` and `lastAuthor` via git log. Only fetched for new/modified files. */
|
|
149
|
+
gitStats?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Tag-applier configuration for `--apply-tags`. Controls which format is written into
|
|
152
|
+
* test files. Defaults to `{ framework: "vitest" }` when unset.
|
|
153
|
+
*/
|
|
154
|
+
tagApplier?: {
|
|
155
|
+
/**
|
|
156
|
+
* Fallback test framework whose tag format to use for TS/JS files. Each file's actual
|
|
157
|
+
* framework is auto-detected from its imports (`@playwright/test`, `cypress`,
|
|
158
|
+
* `@jest/globals`, `vitest`), so a single repo can mix frameworks and each file is tagged
|
|
159
|
+
* in its own native format. This value is only used when a file has no detectable
|
|
160
|
+
* framework import (e.g. `globals: true` configs with no explicit import).
|
|
161
|
+
* - `"vitest"` — injects `{ tags: [...] }` in describe/test/it options (default)
|
|
162
|
+
* - `"playwright"` — injects `{ tag: ["@name"] }` with `@` prefix convention
|
|
163
|
+
* - `"cypress"` — injects `{ tags: ["@name"] }` for use with `@cypress/grep`
|
|
164
|
+
* - `"jest"` — writes a `/** @group name *\/` docblock for use with `jest-runner-groups`
|
|
165
|
+
*/
|
|
166
|
+
framework?: TagFramework;
|
|
167
|
+
/**
|
|
168
|
+
* Path-glob pattern (project-relative, e.g. `"tests/e2e/**"`) to fallback framework. Checked
|
|
169
|
+
* in object key order, first match wins, before falling back further to `framework`. Only
|
|
170
|
+
* consulted when a file's own imports don't reveal a framework — lets different directories
|
|
171
|
+
* default to different frameworks (e.g. e2e tests using Playwright globals, unit tests using
|
|
172
|
+
* Jest globals) instead of sharing one project-wide default.
|
|
173
|
+
*/
|
|
174
|
+
frameworkOverrides?: Record<string, TagFramework>;
|
|
175
|
+
};
|
|
176
|
+
/** 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. */
|
|
177
|
+
coverageReportPath?: string;
|
|
178
|
+
/** Default line-coverage threshold (0–100) used by `find_uncovered`. Defaults to `80` when not specified. */
|
|
179
|
+
coverageThreshold?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Controls worker-pool offloading of file parsing (see docs/adr-010-parallel-parsing.md).
|
|
182
|
+
* `true`/unset (default) enables it once a cheap pre-scan finds at least `minFiles`
|
|
183
|
+
* (default 20) files; parsing a file is fast enough in most repos that the pool's
|
|
184
|
+
* per-thread startup cost only pays off past roughly 600-700 files, so small/typical
|
|
185
|
+
* repos may see slightly slower builds under the default — set `false` to always parse
|
|
186
|
+
* in-process, or pass `{ minFiles, maxThreads }` to raise the threshold instead.
|
|
187
|
+
*/
|
|
188
|
+
parallelParsing?: ParallelParsingOption;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @description Loads a mokosh config file, probing standard filenames in `rootDirOrPath` or reading an explicit path when `isExplicitPath` is true.
|
|
192
|
+
* JS/CJS configs may export a plain object or a factory function; the MCP server passes `allowJs: false` to prevent arbitrary code execution.
|
|
193
|
+
* @param {string} rootDirOrPath - Directory to probe for standard config filenames, or absolute path to the config file when `isExplicitPath` is true.
|
|
194
|
+
* @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.
|
|
195
|
+
* @returns {MokoshConfig} The parsed config, or an empty object when no config file is found.
|
|
196
|
+
*/
|
|
197
|
+
declare function loadMokoshConfig(rootDirOrPath: string, { allowJs, isExplicitPath }?: {
|
|
198
|
+
allowJs?: boolean;
|
|
199
|
+
isExplicitPath?: boolean;
|
|
200
|
+
}): MokoshConfig;
|
|
201
|
+
/**
|
|
202
|
+
* @description Applies a `MokoshConfig` to the global registries that control classification and scanning.
|
|
203
|
+
* Call this after `loadMokoshConfig` and before `createImportMap`.
|
|
204
|
+
* @param {MokoshConfig} config - The loaded config whose matchers, patterns, libraries, and thresholds are registered.
|
|
205
|
+
*/
|
|
206
|
+
declare function applyConfig(config: MokoshConfig): void;
|
|
207
|
+
|
|
208
|
+
declare const DEFAULT_IGNORE_DIRS: readonly string[];
|
|
209
|
+
declare const DEFAULT_EXTENSIONS: readonly string[];
|
|
210
|
+
interface ScanOptions {
|
|
211
|
+
/** Replaces the default ignore-dir list. Use `additionalIgnoreDirs` to extend instead. */
|
|
212
|
+
ignoreDirs?: string[];
|
|
213
|
+
/** Replaces the default extension list. Use `additionalExtensions` to extend instead. */
|
|
214
|
+
extensions?: string[];
|
|
215
|
+
/** Merged with `DEFAULT_IGNORE_DIRS` (additive). */
|
|
216
|
+
additionalIgnoreDirs?: string[];
|
|
217
|
+
/** Merged with `DEFAULT_EXTENSIONS` (additive). */
|
|
218
|
+
additionalExtensions?: string[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @description Reads an Istanbul/v8 `coverage-summary.json` file and returns a map of
|
|
223
|
+
* project-relative file paths to their line-coverage percentage (0–100).
|
|
224
|
+
* Returns an empty map when the file is missing, unreadable, or malformed — the
|
|
225
|
+
* caller can always proceed safely with no coverage data.
|
|
226
|
+
* @param rootDir - Absolute path to the project root; used to make paths relative.
|
|
227
|
+
* @param reportPath - Path to the coverage summary JSON, relative to `rootDir`.
|
|
228
|
+
* @returns A map of `relativePath → lineCoveragePct`.
|
|
229
|
+
*/
|
|
230
|
+
declare function loadCoverageMap(rootDir: string, reportPath: string): Map<string, number>;
|
|
231
|
+
|
|
286
232
|
/**
|
|
287
233
|
* Coarse kind of a public export derived from its type signature prefix.
|
|
288
234
|
* Used to distinguish runtime values from type-only exports without parsing the full signature.
|
|
@@ -348,7 +294,7 @@ declare function buildApiSurface(graph: Graph, entryPoints: string[]): ApiSurfac
|
|
|
348
294
|
|
|
349
295
|
/** Public types for the call-graph subsystem. */
|
|
350
296
|
/** A file and function name that calls the target function. */
|
|
351
|
-
interface CallerEntry {
|
|
297
|
+
interface CallerEntry$1 {
|
|
352
298
|
/** Project-relative path of the file containing the caller. */
|
|
353
299
|
file: string;
|
|
354
300
|
/** Name of the function that makes the call. */
|
|
@@ -375,7 +321,7 @@ interface FunctionCallInfo {
|
|
|
375
321
|
*/
|
|
376
322
|
definedIn: string | null;
|
|
377
323
|
/** Files and functions that call this function. */
|
|
378
|
-
callers: CallerEntry[];
|
|
324
|
+
callers: CallerEntry$1[];
|
|
379
325
|
/** Files and functions that this function calls. */
|
|
380
326
|
callees: CalleeEntry[];
|
|
381
327
|
}
|
|
@@ -883,6 +829,127 @@ declare const MermaidExporter: GraphExporter;
|
|
|
883
829
|
*/
|
|
884
830
|
declare function toMermaid(graph: Graph): string;
|
|
885
831
|
|
|
832
|
+
/** Pure graph query/shaping functions shared by the MCP handlers and the CLI, so both surfaces return identical JSON shapes. */
|
|
833
|
+
|
|
834
|
+
interface PathWithSymbols {
|
|
835
|
+
path: string;
|
|
836
|
+
symbols?: string[];
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* @description Outgoing traversal from `file` — all files it imports, up to `depth` hops.
|
|
840
|
+
* @param graph - The graph to traverse.
|
|
841
|
+
* @param file - Project-relative path of the starting node.
|
|
842
|
+
* @param depth - Max traversal depth (default 1 = immediate imports only).
|
|
843
|
+
* @returns Reachable imported paths, each with the symbols imported from it when known.
|
|
844
|
+
*/
|
|
845
|
+
declare function getDependencies(graph: Graph, file: string, depth?: number): PathWithSymbols[];
|
|
846
|
+
/**
|
|
847
|
+
* @description Incoming one-hop traversal — files that directly import `file`.
|
|
848
|
+
* @param graph - The graph to traverse.
|
|
849
|
+
* @param file - Project-relative path of the target node.
|
|
850
|
+
* @returns Direct importers, each with the symbols they import from `file` when known.
|
|
851
|
+
*/
|
|
852
|
+
declare function getDependents(graph: Graph, file: string): PathWithSymbols[];
|
|
853
|
+
interface GetAffectedOptions {
|
|
854
|
+
testsOnly?: boolean | undefined;
|
|
855
|
+
changedSymbols?: string[] | undefined;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* @description Full incoming traversal from `file` upward — every file transitively affected if `file` changes.
|
|
859
|
+
* @param graph - The graph to traverse.
|
|
860
|
+
* @param file - Project-relative path of the changed node.
|
|
861
|
+
* @param options - `testsOnly` restricts results to test/spec files; `changedSymbols` restricts propagation to files that actually import those symbols.
|
|
862
|
+
* @returns Project-relative paths of all transitively impacted files.
|
|
863
|
+
*/
|
|
864
|
+
declare function getAffected(graph: Graph, file: string, options?: GetAffectedOptions): string[];
|
|
865
|
+
interface CallerEntry {
|
|
866
|
+
file: string;
|
|
867
|
+
edges?: Array<{
|
|
868
|
+
from: string;
|
|
869
|
+
to: string;
|
|
870
|
+
}>;
|
|
871
|
+
}
|
|
872
|
+
interface GetCallersOptions {
|
|
873
|
+
depth?: number | undefined;
|
|
874
|
+
withEdgeDetail?: boolean | undefined;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* @description Incoming call-edge traversal — files whose exported functions call into `file`.
|
|
878
|
+
* More precise than `getAffected` because it follows runtime call edges rather than all import edges.
|
|
879
|
+
* @param graph - The graph to traverse.
|
|
880
|
+
* @param file - Project-relative path of the target node.
|
|
881
|
+
* @param options - `depth` caps traversal hops (default 1); `withEdgeDetail` adds from/to function names per edge.
|
|
882
|
+
* @returns Callers, each optionally including edge detail.
|
|
883
|
+
*/
|
|
884
|
+
declare function getCallers(graph: Graph, file: string, options?: GetCallersOptions): CallerEntry[];
|
|
885
|
+
interface ComplexFunctionEntry {
|
|
886
|
+
file: string;
|
|
887
|
+
name: string;
|
|
888
|
+
line: number;
|
|
889
|
+
complexity: number;
|
|
890
|
+
cognitiveComplexity: number;
|
|
891
|
+
}
|
|
892
|
+
interface FindComplexFunctionsOptions {
|
|
893
|
+
metric?: "cognitiveComplexity" | "complexity" | undefined;
|
|
894
|
+
threshold?: number | undefined;
|
|
895
|
+
limit?: number | undefined;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* @description Scans every file's per-function complexity breakdown and returns functions/methods
|
|
899
|
+
* at or above the given threshold, sorted worst-first. TypeScript/JavaScript only.
|
|
900
|
+
* @param graph - The graph to scan.
|
|
901
|
+
* @param options - `metric` picks which score to threshold/sort on (default `cognitiveComplexity`); `threshold` is the minimum score to include (default 10); `limit` caps the results (default 20).
|
|
902
|
+
* @returns Matching functions, sorted worst-first.
|
|
903
|
+
*/
|
|
904
|
+
declare function findComplexFunctions(graph: Graph, options?: FindComplexFunctionsOptions): ComplexFunctionEntry[];
|
|
905
|
+
interface SlimNode {
|
|
906
|
+
path: string;
|
|
907
|
+
type: FileNode["type"];
|
|
908
|
+
category: FileNode["category"];
|
|
909
|
+
exports: string[];
|
|
910
|
+
tags: string[];
|
|
911
|
+
importsFiles: string[];
|
|
912
|
+
description?: string;
|
|
913
|
+
testedBy?: string[];
|
|
914
|
+
coveragePct?: number;
|
|
915
|
+
avgExportUsage?: number;
|
|
916
|
+
maxExportUsage?: number;
|
|
917
|
+
}
|
|
918
|
+
interface SlimSerializedGraph {
|
|
919
|
+
nodes: SlimNode[];
|
|
920
|
+
cycles: string[][] | undefined;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* @description Strips a serialized graph down to a compact response: export names, meaningful tags,
|
|
924
|
+
* and a flat importsFiles path list — no edge objects, no mtime/size.
|
|
925
|
+
* @param filtered - A `SerializedGraph` (typically the output of `filterGraph`) to compact.
|
|
926
|
+
* @returns The slim node list plus cycle info.
|
|
927
|
+
*/
|
|
928
|
+
declare function slimSerialize(filtered: SerializedGraph): SlimSerializedGraph;
|
|
929
|
+
interface WorkspacePackageSummary {
|
|
930
|
+
name: string;
|
|
931
|
+
relativeRoot: string;
|
|
932
|
+
nodeCount: number;
|
|
933
|
+
dependsOn: string[];
|
|
934
|
+
}
|
|
935
|
+
interface WorkspacePackagesSummary {
|
|
936
|
+
monorepoType: string;
|
|
937
|
+
packageCount: number;
|
|
938
|
+
packages: WorkspacePackageSummary[];
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* @description Summarizes every package in a workspace graph: node counts and cross-package dependencies.
|
|
942
|
+
* @param wg - The workspace graph to summarize.
|
|
943
|
+
* @returns Monorepo type, package count, and per-package details.
|
|
944
|
+
*/
|
|
945
|
+
declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackagesSummary;
|
|
946
|
+
/**
|
|
947
|
+
* @description Returns `true` if at least one node in the graph has coverage data loaded.
|
|
948
|
+
* @param graph - The graph to check.
|
|
949
|
+
* @returns Whether any node has a defined `coveragePct`.
|
|
950
|
+
*/
|
|
951
|
+
declare function hasCoverageData(graph: Graph): boolean;
|
|
952
|
+
|
|
886
953
|
/** A config matcher: substring, regex, or predicate tested against the lowercase basename. */
|
|
887
954
|
type ConfigMatcher = string | RegExp | ((baseName: string) => boolean);
|
|
888
955
|
/**
|
|
@@ -912,26 +979,6 @@ declare function registerTestPattern(pattern: string): void;
|
|
|
912
979
|
*/
|
|
913
980
|
declare function registerTestLibrary(lib: string): void;
|
|
914
981
|
|
|
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
982
|
/** Parser registry: maps FileType values to parser functions and provides lookup by file type. */
|
|
936
983
|
|
|
937
984
|
type ParserFunction = (filePath: string, content: string) => ParseResult | Promise<ParseResult>;
|
|
@@ -1103,25 +1150,27 @@ declare function proposeAffectedTests(graph: Graph, changedFiles: string[], opti
|
|
|
1103
1150
|
* @param rootDir - Absolute or relative path to the project root; resolved internally.
|
|
1104
1151
|
* @param entryPoints - File paths (relative to `rootDir`) that seed the graph walk.
|
|
1105
1152
|
* @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.
|
|
1153
|
+
* @param options - `silent` suppresses progress output; `gitStats` attaches git churn data; `coverageMap` maps file paths to line-coverage percentages; `parallelParsing` controls worker-pool offloading of file parsing (see {@link ParallelParsingOption}).
|
|
1107
1154
|
* @returns The fully-built Graph with all reachable nodes and import edges populated.
|
|
1108
1155
|
*/
|
|
1109
1156
|
declare function createImportMap(rootDir: string, entryPoints: string[], previousGraph?: Graph | null, options?: {
|
|
1110
1157
|
silent?: boolean;
|
|
1111
1158
|
gitStats?: boolean;
|
|
1112
1159
|
coverageMap?: Map<string, number>;
|
|
1160
|
+
parallelParsing?: ParallelParsingOption | undefined;
|
|
1113
1161
|
}): Promise<Graph>;
|
|
1114
1162
|
/**
|
|
1115
1163
|
* @description Auto-detects the monorepo layout under `rootDir` and builds a per-package
|
|
1116
1164
|
* dependency graph, stitching them together into a single WorkspaceGraph.
|
|
1117
1165
|
* @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.
|
|
1166
|
+
* @param options - `packages` filters to a named subset of packages; `silent` suppresses progress; `gitStats` attaches git churn data per file; `parallelParsing` controls worker-pool offloading of file parsing per package (see {@link ParallelParsingOption}).
|
|
1119
1167
|
* @returns A WorkspaceGraph where each package has its own Graph and cross-package edges are resolved.
|
|
1120
1168
|
*/
|
|
1121
1169
|
declare function createWorkspaceGraph(rootDir: string, options?: {
|
|
1122
1170
|
packages?: string[];
|
|
1123
1171
|
silent?: boolean;
|
|
1124
1172
|
gitStats?: boolean;
|
|
1173
|
+
parallelParsing?: ParallelParsingOption | undefined;
|
|
1125
1174
|
}): Promise<WorkspaceGraph>;
|
|
1126
1175
|
/**
|
|
1127
1176
|
* @description Recursively walks `rootDir` and returns paths of every file whose extension
|
|
@@ -1132,4 +1181,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
|
|
|
1132
1181
|
*/
|
|
1133
1182
|
declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
|
|
1134
1183
|
|
|
1135
|
-
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult,
|
|
1184
|
+
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, ImportEdge, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, SymbolTraversalContext, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, type WorkspacePackageSummary, type WorkspacePackagesSummary, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, findComplexFunctions, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, slimSerialize, summarizeWorkspacePackages, toMermaid };
|