@omfalos/mokosh 0.4.2 → 0.4.4

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
@@ -211,7 +211,12 @@ declare function loadMokoshConfig(rootDirOrPath: string, { allowJs, isExplicitPa
211
211
  }): MokoshConfig;
212
212
  /**
213
213
  * @description Applies a `MokoshConfig` to the global registries that control classification and scanning.
214
- * Call this after `loadMokoshConfig` and before `createImportMap`.
214
+ * Call this after `loadMokoshConfig` and before `createImportMap`. Resets those registries
215
+ * first, so each call fully replaces the previously active config instead of accumulating on
216
+ * top of it — otherwise a project's matchers/patterns/libraries would permanently leak into
217
+ * every later `applyConfig` call in the same process (e.g. a different root analyzed in the
218
+ * same long-running MCP server session), and a config narrowed or emptied on disk could never
219
+ * actually shrink what was registered.
215
220
  * @param {MokoshConfig} config - The loaded config whose matchers, patterns, libraries, and thresholds are registered.
216
221
  */
217
222
  declare function applyConfig(config: MokoshConfig): void;
@@ -1181,6 +1186,50 @@ declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackag
1181
1186
  * @returns Whether any node has a defined `coveragePct`.
1182
1187
  */
1183
1188
  declare function hasCoverageData(graph: Graph): boolean;
1189
+ /**
1190
+ * @description Returns `true` if at least one node in the graph has git churn data loaded.
1191
+ * @param graph - The graph to check.
1192
+ * @returns Whether any node has a defined `commitCount90d`.
1193
+ */
1194
+ declare function hasChurnData(graph: Graph): boolean;
1195
+ interface RiskHotspotEntry {
1196
+ file: string;
1197
+ name: string;
1198
+ line: number;
1199
+ complexity: number;
1200
+ cognitiveComplexity: number;
1201
+ coveragePct: number;
1202
+ commitCount90d?: number;
1203
+ }
1204
+ interface FindRiskHotspotsOptions {
1205
+ metric?: "cognitiveComplexity" | "complexity" | undefined;
1206
+ minComplexity?: number | undefined;
1207
+ maxCoveragePct?: number | undefined;
1208
+ minChurn?: number | undefined;
1209
+ limit?: number | undefined;
1210
+ }
1211
+ interface RiskHotspotsResult {
1212
+ hotspots: RiskHotspotEntry[];
1213
+ count: number;
1214
+ churnDataAvailable: boolean;
1215
+ }
1216
+ /**
1217
+ * @description Finds functions that are complex, in a poorly-covered file, and — when git churn
1218
+ * data is loaded — in a frequently-changed file. Coverage and churn are file-level (the
1219
+ * containing file's `coveragePct`/`commitCount90d`), joined against each per-function
1220
+ * complexity entry, since neither is tracked per-function. Callers should check
1221
+ * `hasCoverageData` first and surface an explicit error if it's false, the same way
1222
+ * `find_uncovered` does — this function doesn't self-guard.
1223
+ * @param graph - The graph to scan. Coverage data should already be loaded for useful results.
1224
+ * @param options - `metric` picks which per-function score to filter/sort on (default
1225
+ * `cognitiveComplexity`); `minComplexity` is the minimum score to include (default 10);
1226
+ * `maxCoveragePct` is the maximum containing-file coverage to include (default 50);
1227
+ * `minChurn` is the minimum containing-file 90-day commit count to include (default 0),
1228
+ * ignored entirely when no node has churn data loaded; `limit` caps the results (default 20).
1229
+ * @returns Matching functions sorted worst-first by `metric`, plus whether churn data was
1230
+ * available (and therefore whether `minChurn` was actually applied).
1231
+ */
1232
+ declare function findRiskHotspots(graph: Graph, options?: FindRiskHotspotsOptions): RiskHotspotsResult;
1184
1233
 
1185
1234
  /** Symbol-name lookup across the whole graph — generalizes queryCallGraph beyond TS/JS functions. */
1186
1235
 
@@ -1244,6 +1293,22 @@ declare function registerTestPattern(pattern: string): void;
1244
1293
  * @param lib - An import specifier substring, e.g. `"@my-org/test-utils"`.
1245
1294
  */
1246
1295
  declare function registerTestLibrary(lib: string): void;
1296
+ /**
1297
+ * @description Clears every user-registered config matcher, test pattern, and test library,
1298
+ * and resets the barrel threshold to its default. These registries are process-global —
1299
+ * not scoped per project root — so without a reset between projects, one root's
1300
+ * `mokosh.config.json` settings would permanently leak into every other root analyzed
1301
+ * afterward in the same long-running process (e.g. an MCP server session), and a config
1302
+ * later narrowed or emptied could never actually shrink what's registered. `applyConfig`
1303
+ * calls this before registering the new config's values so each call fully replaces the
1304
+ * active registry state rather than accumulating on top of it, matching the documented
1305
+ * contract that unset `MokoshConfig` fields fall back to built-in defaults.
1306
+ *
1307
+ * Not safe to call while another `applyConfig` + graph build for a different root is
1308
+ * still in flight — these registries have no per-root isolation, so overlapping builds
1309
+ * were already able to observe each other's state before this function existed.
1310
+ */
1311
+ declare function resetClassifyRegistries(): void;
1247
1312
 
1248
1313
  /** Parser registry: maps FileType values to parser functions and provides lookup by file type. */
1249
1314
 
@@ -1473,4 +1538,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1473
1538
  */
1474
1539
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1475
1540
 
1476
- export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, type CachedFileTokens, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_CACHE_DIR, DEFAULT_DUPLICATION_TOKEN_CACHE_FILE, DEFAULT_EXTENSIONS, DEFAULT_GRAPH_CACHE_FILE, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, type DuplicationTokenCache, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FindDuplicatesResult, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, 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, findDuplicates, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, loadTokenCacheFromDisk, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };
1541
+ export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, type CachedFileTokens, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_CACHE_DIR, DEFAULT_DUPLICATION_TOKEN_CACHE_FILE, DEFAULT_EXTENSIONS, DEFAULT_GRAPH_CACHE_FILE, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, type DuplicationTokenCache, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FindDuplicatesResult, type FindRiskHotspotsOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type RiskHotspotEntry, type RiskHotspotsResult, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, 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, findDuplicates, findRiskHotspots, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasChurnData, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, loadTokenCacheFromDisk, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, resetClassifyRegistries, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };
package/dist/index.d.ts CHANGED
@@ -211,7 +211,12 @@ declare function loadMokoshConfig(rootDirOrPath: string, { allowJs, isExplicitPa
211
211
  }): MokoshConfig;
212
212
  /**
213
213
  * @description Applies a `MokoshConfig` to the global registries that control classification and scanning.
214
- * Call this after `loadMokoshConfig` and before `createImportMap`.
214
+ * Call this after `loadMokoshConfig` and before `createImportMap`. Resets those registries
215
+ * first, so each call fully replaces the previously active config instead of accumulating on
216
+ * top of it — otherwise a project's matchers/patterns/libraries would permanently leak into
217
+ * every later `applyConfig` call in the same process (e.g. a different root analyzed in the
218
+ * same long-running MCP server session), and a config narrowed or emptied on disk could never
219
+ * actually shrink what was registered.
215
220
  * @param {MokoshConfig} config - The loaded config whose matchers, patterns, libraries, and thresholds are registered.
216
221
  */
217
222
  declare function applyConfig(config: MokoshConfig): void;
@@ -1181,6 +1186,50 @@ declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackag
1181
1186
  * @returns Whether any node has a defined `coveragePct`.
1182
1187
  */
1183
1188
  declare function hasCoverageData(graph: Graph): boolean;
1189
+ /**
1190
+ * @description Returns `true` if at least one node in the graph has git churn data loaded.
1191
+ * @param graph - The graph to check.
1192
+ * @returns Whether any node has a defined `commitCount90d`.
1193
+ */
1194
+ declare function hasChurnData(graph: Graph): boolean;
1195
+ interface RiskHotspotEntry {
1196
+ file: string;
1197
+ name: string;
1198
+ line: number;
1199
+ complexity: number;
1200
+ cognitiveComplexity: number;
1201
+ coveragePct: number;
1202
+ commitCount90d?: number;
1203
+ }
1204
+ interface FindRiskHotspotsOptions {
1205
+ metric?: "cognitiveComplexity" | "complexity" | undefined;
1206
+ minComplexity?: number | undefined;
1207
+ maxCoveragePct?: number | undefined;
1208
+ minChurn?: number | undefined;
1209
+ limit?: number | undefined;
1210
+ }
1211
+ interface RiskHotspotsResult {
1212
+ hotspots: RiskHotspotEntry[];
1213
+ count: number;
1214
+ churnDataAvailable: boolean;
1215
+ }
1216
+ /**
1217
+ * @description Finds functions that are complex, in a poorly-covered file, and — when git churn
1218
+ * data is loaded — in a frequently-changed file. Coverage and churn are file-level (the
1219
+ * containing file's `coveragePct`/`commitCount90d`), joined against each per-function
1220
+ * complexity entry, since neither is tracked per-function. Callers should check
1221
+ * `hasCoverageData` first and surface an explicit error if it's false, the same way
1222
+ * `find_uncovered` does — this function doesn't self-guard.
1223
+ * @param graph - The graph to scan. Coverage data should already be loaded for useful results.
1224
+ * @param options - `metric` picks which per-function score to filter/sort on (default
1225
+ * `cognitiveComplexity`); `minComplexity` is the minimum score to include (default 10);
1226
+ * `maxCoveragePct` is the maximum containing-file coverage to include (default 50);
1227
+ * `minChurn` is the minimum containing-file 90-day commit count to include (default 0),
1228
+ * ignored entirely when no node has churn data loaded; `limit` caps the results (default 20).
1229
+ * @returns Matching functions sorted worst-first by `metric`, plus whether churn data was
1230
+ * available (and therefore whether `minChurn` was actually applied).
1231
+ */
1232
+ declare function findRiskHotspots(graph: Graph, options?: FindRiskHotspotsOptions): RiskHotspotsResult;
1184
1233
 
1185
1234
  /** Symbol-name lookup across the whole graph — generalizes queryCallGraph beyond TS/JS functions. */
1186
1235
 
@@ -1244,6 +1293,22 @@ declare function registerTestPattern(pattern: string): void;
1244
1293
  * @param lib - An import specifier substring, e.g. `"@my-org/test-utils"`.
1245
1294
  */
1246
1295
  declare function registerTestLibrary(lib: string): void;
1296
+ /**
1297
+ * @description Clears every user-registered config matcher, test pattern, and test library,
1298
+ * and resets the barrel threshold to its default. These registries are process-global —
1299
+ * not scoped per project root — so without a reset between projects, one root's
1300
+ * `mokosh.config.json` settings would permanently leak into every other root analyzed
1301
+ * afterward in the same long-running process (e.g. an MCP server session), and a config
1302
+ * later narrowed or emptied could never actually shrink what's registered. `applyConfig`
1303
+ * calls this before registering the new config's values so each call fully replaces the
1304
+ * active registry state rather than accumulating on top of it, matching the documented
1305
+ * contract that unset `MokoshConfig` fields fall back to built-in defaults.
1306
+ *
1307
+ * Not safe to call while another `applyConfig` + graph build for a different root is
1308
+ * still in flight — these registries have no per-root isolation, so overlapping builds
1309
+ * were already able to observe each other's state before this function existed.
1310
+ */
1311
+ declare function resetClassifyRegistries(): void;
1247
1312
 
1248
1313
  /** Parser registry: maps FileType values to parser functions and provides lookup by file type. */
1249
1314
 
@@ -1473,4 +1538,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1473
1538
  */
1474
1539
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1475
1540
 
1476
- export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, type CachedFileTokens, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_CACHE_DIR, DEFAULT_DUPLICATION_TOKEN_CACHE_FILE, DEFAULT_EXTENSIONS, DEFAULT_GRAPH_CACHE_FILE, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, type DuplicationTokenCache, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FindDuplicatesResult, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, 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, findDuplicates, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, loadTokenCacheFromDisk, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };
1541
+ export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, type CachedFileTokens, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_CACHE_DIR, DEFAULT_DUPLICATION_TOKEN_CACHE_FILE, DEFAULT_EXTENSIONS, DEFAULT_GRAPH_CACHE_FILE, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, type DuplicationTokenCache, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FindDuplicatesResult, type FindRiskHotspotsOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type RiskHotspotEntry, type RiskHotspotsResult, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, 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, findDuplicates, findRiskHotspots, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasChurnData, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, loadTokenCacheFromDisk, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, resetClassifyRegistries, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };