@omfalos/mokosh 0.4.2 → 0.4.3

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
@@ -1181,6 +1181,50 @@ declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackag
1181
1181
  * @returns Whether any node has a defined `coveragePct`.
1182
1182
  */
1183
1183
  declare function hasCoverageData(graph: Graph): boolean;
1184
+ /**
1185
+ * @description Returns `true` if at least one node in the graph has git churn data loaded.
1186
+ * @param graph - The graph to check.
1187
+ * @returns Whether any node has a defined `commitCount90d`.
1188
+ */
1189
+ declare function hasChurnData(graph: Graph): boolean;
1190
+ interface RiskHotspotEntry {
1191
+ file: string;
1192
+ name: string;
1193
+ line: number;
1194
+ complexity: number;
1195
+ cognitiveComplexity: number;
1196
+ coveragePct: number;
1197
+ commitCount90d?: number;
1198
+ }
1199
+ interface FindRiskHotspotsOptions {
1200
+ metric?: "cognitiveComplexity" | "complexity" | undefined;
1201
+ minComplexity?: number | undefined;
1202
+ maxCoveragePct?: number | undefined;
1203
+ minChurn?: number | undefined;
1204
+ limit?: number | undefined;
1205
+ }
1206
+ interface RiskHotspotsResult {
1207
+ hotspots: RiskHotspotEntry[];
1208
+ count: number;
1209
+ churnDataAvailable: boolean;
1210
+ }
1211
+ /**
1212
+ * @description Finds functions that are complex, in a poorly-covered file, and — when git churn
1213
+ * data is loaded — in a frequently-changed file. Coverage and churn are file-level (the
1214
+ * containing file's `coveragePct`/`commitCount90d`), joined against each per-function
1215
+ * complexity entry, since neither is tracked per-function. Callers should check
1216
+ * `hasCoverageData` first and surface an explicit error if it's false, the same way
1217
+ * `find_uncovered` does — this function doesn't self-guard.
1218
+ * @param graph - The graph to scan. Coverage data should already be loaded for useful results.
1219
+ * @param options - `metric` picks which per-function score to filter/sort on (default
1220
+ * `cognitiveComplexity`); `minComplexity` is the minimum score to include (default 10);
1221
+ * `maxCoveragePct` is the maximum containing-file coverage to include (default 50);
1222
+ * `minChurn` is the minimum containing-file 90-day commit count to include (default 0),
1223
+ * ignored entirely when no node has churn data loaded; `limit` caps the results (default 20).
1224
+ * @returns Matching functions sorted worst-first by `metric`, plus whether churn data was
1225
+ * available (and therefore whether `minChurn` was actually applied).
1226
+ */
1227
+ declare function findRiskHotspots(graph: Graph, options?: FindRiskHotspotsOptions): RiskHotspotsResult;
1184
1228
 
1185
1229
  /** Symbol-name lookup across the whole graph — generalizes queryCallGraph beyond TS/JS functions. */
1186
1230
 
@@ -1473,4 +1517,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1473
1517
  */
1474
1518
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1475
1519
 
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 };
1520
+ 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, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };
package/dist/index.d.ts CHANGED
@@ -1181,6 +1181,50 @@ declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackag
1181
1181
  * @returns Whether any node has a defined `coveragePct`.
1182
1182
  */
1183
1183
  declare function hasCoverageData(graph: Graph): boolean;
1184
+ /**
1185
+ * @description Returns `true` if at least one node in the graph has git churn data loaded.
1186
+ * @param graph - The graph to check.
1187
+ * @returns Whether any node has a defined `commitCount90d`.
1188
+ */
1189
+ declare function hasChurnData(graph: Graph): boolean;
1190
+ interface RiskHotspotEntry {
1191
+ file: string;
1192
+ name: string;
1193
+ line: number;
1194
+ complexity: number;
1195
+ cognitiveComplexity: number;
1196
+ coveragePct: number;
1197
+ commitCount90d?: number;
1198
+ }
1199
+ interface FindRiskHotspotsOptions {
1200
+ metric?: "cognitiveComplexity" | "complexity" | undefined;
1201
+ minComplexity?: number | undefined;
1202
+ maxCoveragePct?: number | undefined;
1203
+ minChurn?: number | undefined;
1204
+ limit?: number | undefined;
1205
+ }
1206
+ interface RiskHotspotsResult {
1207
+ hotspots: RiskHotspotEntry[];
1208
+ count: number;
1209
+ churnDataAvailable: boolean;
1210
+ }
1211
+ /**
1212
+ * @description Finds functions that are complex, in a poorly-covered file, and — when git churn
1213
+ * data is loaded — in a frequently-changed file. Coverage and churn are file-level (the
1214
+ * containing file's `coveragePct`/`commitCount90d`), joined against each per-function
1215
+ * complexity entry, since neither is tracked per-function. Callers should check
1216
+ * `hasCoverageData` first and surface an explicit error if it's false, the same way
1217
+ * `find_uncovered` does — this function doesn't self-guard.
1218
+ * @param graph - The graph to scan. Coverage data should already be loaded for useful results.
1219
+ * @param options - `metric` picks which per-function score to filter/sort on (default
1220
+ * `cognitiveComplexity`); `minComplexity` is the minimum score to include (default 10);
1221
+ * `maxCoveragePct` is the maximum containing-file coverage to include (default 50);
1222
+ * `minChurn` is the minimum containing-file 90-day commit count to include (default 0),
1223
+ * ignored entirely when no node has churn data loaded; `limit` caps the results (default 20).
1224
+ * @returns Matching functions sorted worst-first by `metric`, plus whether churn data was
1225
+ * available (and therefore whether `minChurn` was actually applied).
1226
+ */
1227
+ declare function findRiskHotspots(graph: Graph, options?: FindRiskHotspotsOptions): RiskHotspotsResult;
1184
1228
 
1185
1229
  /** Symbol-name lookup across the whole graph — generalizes queryCallGraph beyond TS/JS functions. */
1186
1230
 
@@ -1473,4 +1517,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1473
1517
  */
1474
1518
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1475
1519
 
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 };
1520
+ 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, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };