@omfalos/mokosh 0.1.7 → 0.1.9

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/dist/index.d.mts CHANGED
@@ -143,6 +143,14 @@ interface MokoshConfig {
143
143
  testPatterns?: string[];
144
144
  /** Additional import specifiers that indicate a test file (e.g. `"@my-org/test-utils"`). */
145
145
  testLibraries?: string[];
146
+ /**
147
+ * Explicit path-alias map for import resolution, same shape as tsconfig's
148
+ * `compilerOptions.paths` (e.g. `{ "@app/*": ["src/app/*"] }`). Takes precedence over
149
+ * any aliases declared in `tsconfig.json`. Useful for JS-only projects without a
150
+ * tsconfig, or to mirror Vite/webpack alias configs. Substitution paths are resolved
151
+ * relative to the project root.
152
+ */
153
+ pathAliases?: Record<string, string[]>;
146
154
  /** Ratio of export-statements to total statements required for `"barrel"` classification. Default: `0.8`. */
147
155
  barrelThreshold?: number;
148
156
  /** When true, enriches each node with `commitCount90d` and `lastAuthor` via git log. Only fetched for new/modified files. */
@@ -204,6 +212,20 @@ declare function loadMokoshConfig(rootDirOrPath: string, { allowJs, isExplicitPa
204
212
  * @param {MokoshConfig} config - The loaded config whose matchers, patterns, libraries, and thresholds are registered.
205
213
  */
206
214
  declare function applyConfig(config: MokoshConfig): void;
215
+ /**
216
+ * @description Extracts the subset of `MokoshConfig` fields that affect graph
217
+ * construction (`gitStats`, `parallelParsing`, `pathAliases`) into a plain options
218
+ * object, ready to spread into `createImportMap`/`createWorkspaceGraph` calls. Single
219
+ * source of truth for this mapping so every graph-building call site — CLI, MCP,
220
+ * and secondary command-level rebuilds — stays in sync as new config fields are added.
221
+ * @param config - The loaded config, or `undefined` when none has been loaded yet.
222
+ * @returns Graph-build options with defaults applied (`gitStats` defaults to `false`).
223
+ */
224
+ declare function configToGraphOptions(config: MokoshConfig | undefined): {
225
+ gitStats: boolean;
226
+ parallelParsing: ParallelParsingOption | undefined;
227
+ pathAliases: Record<string, string[]> | undefined;
228
+ };
207
229
 
208
230
  declare const DEFAULT_IGNORE_DIRS: readonly string[];
209
231
  declare const DEFAULT_EXTENSIONS: readonly string[];
@@ -1174,7 +1196,7 @@ declare function proposeAffectedTests(graph: Graph, changedFiles: string[], opti
1174
1196
  * @param rootDir - Absolute or relative path to the project root; resolved internally.
1175
1197
  * @param entryPoints - File paths (relative to `rootDir`) that seed the graph walk.
1176
1198
  * @param previousGraph - An earlier graph to diff against for incremental builds; pass `null` for a full build.
1177
- * @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}).
1199
+ * @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}); `pathAliases` overrides/extends tsconfig path-alias resolution (see `MokoshConfig.pathAliases`).
1178
1200
  * @returns The fully-built Graph with all reachable nodes and import edges populated.
1179
1201
  */
1180
1202
  declare function createImportMap(rootDir: string, entryPoints: string[], previousGraph?: Graph | null, options?: {
@@ -1182,12 +1204,13 @@ declare function createImportMap(rootDir: string, entryPoints: string[], previou
1182
1204
  gitStats?: boolean;
1183
1205
  coverageMap?: Map<string, number>;
1184
1206
  parallelParsing?: ParallelParsingOption | undefined;
1207
+ pathAliases?: Record<string, string[]> | undefined;
1185
1208
  }): Promise<Graph>;
1186
1209
  /**
1187
1210
  * @description Auto-detects the monorepo layout under `rootDir` and builds a per-package
1188
1211
  * dependency graph, stitching them together into a single WorkspaceGraph.
1189
1212
  * @param rootDir - Absolute path to the monorepo root.
1190
- * @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}).
1213
+ * @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}); `pathAliases` overrides/extends tsconfig path-alias resolution for every package (see `MokoshConfig.pathAliases`).
1191
1214
  * @returns A WorkspaceGraph where each package has its own Graph and cross-package edges are resolved.
1192
1215
  */
1193
1216
  declare function createWorkspaceGraph(rootDir: string, options?: {
@@ -1195,6 +1218,7 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1195
1218
  silent?: boolean;
1196
1219
  gitStats?: boolean;
1197
1220
  parallelParsing?: ParallelParsingOption | undefined;
1221
+ pathAliases?: Record<string, string[]> | undefined;
1198
1222
  }): Promise<WorkspaceGraph>;
1199
1223
  /**
1200
1224
  * @description Recursively walks `rootDir` and returns paths of every file whose extension
@@ -1205,4 +1229,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1205
1229
  */
1206
1230
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1207
1231
 
1208
- 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 };
1232
+ 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, configToGraphOptions, 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 };
package/dist/index.d.ts CHANGED
@@ -143,6 +143,14 @@ interface MokoshConfig {
143
143
  testPatterns?: string[];
144
144
  /** Additional import specifiers that indicate a test file (e.g. `"@my-org/test-utils"`). */
145
145
  testLibraries?: string[];
146
+ /**
147
+ * Explicit path-alias map for import resolution, same shape as tsconfig's
148
+ * `compilerOptions.paths` (e.g. `{ "@app/*": ["src/app/*"] }`). Takes precedence over
149
+ * any aliases declared in `tsconfig.json`. Useful for JS-only projects without a
150
+ * tsconfig, or to mirror Vite/webpack alias configs. Substitution paths are resolved
151
+ * relative to the project root.
152
+ */
153
+ pathAliases?: Record<string, string[]>;
146
154
  /** Ratio of export-statements to total statements required for `"barrel"` classification. Default: `0.8`. */
147
155
  barrelThreshold?: number;
148
156
  /** When true, enriches each node with `commitCount90d` and `lastAuthor` via git log. Only fetched for new/modified files. */
@@ -204,6 +212,20 @@ declare function loadMokoshConfig(rootDirOrPath: string, { allowJs, isExplicitPa
204
212
  * @param {MokoshConfig} config - The loaded config whose matchers, patterns, libraries, and thresholds are registered.
205
213
  */
206
214
  declare function applyConfig(config: MokoshConfig): void;
215
+ /**
216
+ * @description Extracts the subset of `MokoshConfig` fields that affect graph
217
+ * construction (`gitStats`, `parallelParsing`, `pathAliases`) into a plain options
218
+ * object, ready to spread into `createImportMap`/`createWorkspaceGraph` calls. Single
219
+ * source of truth for this mapping so every graph-building call site — CLI, MCP,
220
+ * and secondary command-level rebuilds — stays in sync as new config fields are added.
221
+ * @param config - The loaded config, or `undefined` when none has been loaded yet.
222
+ * @returns Graph-build options with defaults applied (`gitStats` defaults to `false`).
223
+ */
224
+ declare function configToGraphOptions(config: MokoshConfig | undefined): {
225
+ gitStats: boolean;
226
+ parallelParsing: ParallelParsingOption | undefined;
227
+ pathAliases: Record<string, string[]> | undefined;
228
+ };
207
229
 
208
230
  declare const DEFAULT_IGNORE_DIRS: readonly string[];
209
231
  declare const DEFAULT_EXTENSIONS: readonly string[];
@@ -1174,7 +1196,7 @@ declare function proposeAffectedTests(graph: Graph, changedFiles: string[], opti
1174
1196
  * @param rootDir - Absolute or relative path to the project root; resolved internally.
1175
1197
  * @param entryPoints - File paths (relative to `rootDir`) that seed the graph walk.
1176
1198
  * @param previousGraph - An earlier graph to diff against for incremental builds; pass `null` for a full build.
1177
- * @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}).
1199
+ * @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}); `pathAliases` overrides/extends tsconfig path-alias resolution (see `MokoshConfig.pathAliases`).
1178
1200
  * @returns The fully-built Graph with all reachable nodes and import edges populated.
1179
1201
  */
1180
1202
  declare function createImportMap(rootDir: string, entryPoints: string[], previousGraph?: Graph | null, options?: {
@@ -1182,12 +1204,13 @@ declare function createImportMap(rootDir: string, entryPoints: string[], previou
1182
1204
  gitStats?: boolean;
1183
1205
  coverageMap?: Map<string, number>;
1184
1206
  parallelParsing?: ParallelParsingOption | undefined;
1207
+ pathAliases?: Record<string, string[]> | undefined;
1185
1208
  }): Promise<Graph>;
1186
1209
  /**
1187
1210
  * @description Auto-detects the monorepo layout under `rootDir` and builds a per-package
1188
1211
  * dependency graph, stitching them together into a single WorkspaceGraph.
1189
1212
  * @param rootDir - Absolute path to the monorepo root.
1190
- * @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}).
1213
+ * @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}); `pathAliases` overrides/extends tsconfig path-alias resolution for every package (see `MokoshConfig.pathAliases`).
1191
1214
  * @returns A WorkspaceGraph where each package has its own Graph and cross-package edges are resolved.
1192
1215
  */
1193
1216
  declare function createWorkspaceGraph(rootDir: string, options?: {
@@ -1195,6 +1218,7 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1195
1218
  silent?: boolean;
1196
1219
  gitStats?: boolean;
1197
1220
  parallelParsing?: ParallelParsingOption | undefined;
1221
+ pathAliases?: Record<string, string[]> | undefined;
1198
1222
  }): Promise<WorkspaceGraph>;
1199
1223
  /**
1200
1224
  * @description Recursively walks `rootDir` and returns paths of every file whose extension
@@ -1205,4 +1229,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1205
1229
  */
1206
1230
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1207
1231
 
1208
- 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 };
1232
+ 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, configToGraphOptions, 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 };