@omfalos/mokosh 0.1.3 → 0.1.5

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
@@ -348,7 +348,7 @@ declare function buildApiSurface(graph: Graph, entryPoints: string[]): ApiSurfac
348
348
 
349
349
  /** Public types for the call-graph subsystem. */
350
350
  /** A file and function name that calls the target function. */
351
- interface CallerEntry {
351
+ interface CallerEntry$1 {
352
352
  /** Project-relative path of the file containing the caller. */
353
353
  file: string;
354
354
  /** Name of the function that makes the call. */
@@ -375,7 +375,7 @@ interface FunctionCallInfo {
375
375
  */
376
376
  definedIn: string | null;
377
377
  /** Files and functions that call this function. */
378
- callers: CallerEntry[];
378
+ callers: CallerEntry$1[];
379
379
  /** Files and functions that this function calls. */
380
380
  callees: CalleeEntry[];
381
381
  }
@@ -883,6 +883,127 @@ declare const MermaidExporter: GraphExporter;
883
883
  */
884
884
  declare function toMermaid(graph: Graph): string;
885
885
 
886
+ /** Pure graph query/shaping functions shared by the MCP handlers and the CLI, so both surfaces return identical JSON shapes. */
887
+
888
+ interface PathWithSymbols {
889
+ path: string;
890
+ symbols?: string[];
891
+ }
892
+ /**
893
+ * @description Outgoing traversal from `file` — all files it imports, up to `depth` hops.
894
+ * @param graph - The graph to traverse.
895
+ * @param file - Project-relative path of the starting node.
896
+ * @param depth - Max traversal depth (default 1 = immediate imports only).
897
+ * @returns Reachable imported paths, each with the symbols imported from it when known.
898
+ */
899
+ declare function getDependencies(graph: Graph, file: string, depth?: number): PathWithSymbols[];
900
+ /**
901
+ * @description Incoming one-hop traversal — files that directly import `file`.
902
+ * @param graph - The graph to traverse.
903
+ * @param file - Project-relative path of the target node.
904
+ * @returns Direct importers, each with the symbols they import from `file` when known.
905
+ */
906
+ declare function getDependents(graph: Graph, file: string): PathWithSymbols[];
907
+ interface GetAffectedOptions {
908
+ testsOnly?: boolean | undefined;
909
+ changedSymbols?: string[] | undefined;
910
+ }
911
+ /**
912
+ * @description Full incoming traversal from `file` upward — every file transitively affected if `file` changes.
913
+ * @param graph - The graph to traverse.
914
+ * @param file - Project-relative path of the changed node.
915
+ * @param options - `testsOnly` restricts results to test/spec files; `changedSymbols` restricts propagation to files that actually import those symbols.
916
+ * @returns Project-relative paths of all transitively impacted files.
917
+ */
918
+ declare function getAffected(graph: Graph, file: string, options?: GetAffectedOptions): string[];
919
+ interface CallerEntry {
920
+ file: string;
921
+ edges?: Array<{
922
+ from: string;
923
+ to: string;
924
+ }>;
925
+ }
926
+ interface GetCallersOptions {
927
+ depth?: number | undefined;
928
+ withEdgeDetail?: boolean | undefined;
929
+ }
930
+ /**
931
+ * @description Incoming call-edge traversal — files whose exported functions call into `file`.
932
+ * More precise than `getAffected` because it follows runtime call edges rather than all import edges.
933
+ * @param graph - The graph to traverse.
934
+ * @param file - Project-relative path of the target node.
935
+ * @param options - `depth` caps traversal hops (default 1); `withEdgeDetail` adds from/to function names per edge.
936
+ * @returns Callers, each optionally including edge detail.
937
+ */
938
+ declare function getCallers(graph: Graph, file: string, options?: GetCallersOptions): CallerEntry[];
939
+ interface ComplexFunctionEntry {
940
+ file: string;
941
+ name: string;
942
+ line: number;
943
+ complexity: number;
944
+ cognitiveComplexity: number;
945
+ }
946
+ interface FindComplexFunctionsOptions {
947
+ metric?: "cognitiveComplexity" | "complexity" | undefined;
948
+ threshold?: number | undefined;
949
+ limit?: number | undefined;
950
+ }
951
+ /**
952
+ * @description Scans every file's per-function complexity breakdown and returns functions/methods
953
+ * at or above the given threshold, sorted worst-first. TypeScript/JavaScript only.
954
+ * @param graph - The graph to scan.
955
+ * @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).
956
+ * @returns Matching functions, sorted worst-first.
957
+ */
958
+ declare function findComplexFunctions(graph: Graph, options?: FindComplexFunctionsOptions): ComplexFunctionEntry[];
959
+ interface SlimNode {
960
+ path: string;
961
+ type: FileNode["type"];
962
+ category: FileNode["category"];
963
+ exports: string[];
964
+ tags: string[];
965
+ importsFiles: string[];
966
+ description?: string;
967
+ testedBy?: string[];
968
+ coveragePct?: number;
969
+ avgExportUsage?: number;
970
+ maxExportUsage?: number;
971
+ }
972
+ interface SlimSerializedGraph {
973
+ nodes: SlimNode[];
974
+ cycles: string[][] | undefined;
975
+ }
976
+ /**
977
+ * @description Strips a serialized graph down to a compact response: export names, meaningful tags,
978
+ * and a flat importsFiles path list — no edge objects, no mtime/size.
979
+ * @param filtered - A `SerializedGraph` (typically the output of `filterGraph`) to compact.
980
+ * @returns The slim node list plus cycle info.
981
+ */
982
+ declare function slimSerialize(filtered: SerializedGraph): SlimSerializedGraph;
983
+ interface WorkspacePackageSummary {
984
+ name: string;
985
+ relativeRoot: string;
986
+ nodeCount: number;
987
+ dependsOn: string[];
988
+ }
989
+ interface WorkspacePackagesSummary {
990
+ monorepoType: string;
991
+ packageCount: number;
992
+ packages: WorkspacePackageSummary[];
993
+ }
994
+ /**
995
+ * @description Summarizes every package in a workspace graph: node counts and cross-package dependencies.
996
+ * @param wg - The workspace graph to summarize.
997
+ * @returns Monorepo type, package count, and per-package details.
998
+ */
999
+ declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackagesSummary;
1000
+ /**
1001
+ * @description Returns `true` if at least one node in the graph has coverage data loaded.
1002
+ * @param graph - The graph to check.
1003
+ * @returns Whether any node has a defined `coveragePct`.
1004
+ */
1005
+ declare function hasCoverageData(graph: Graph): boolean;
1006
+
886
1007
  /** A config matcher: substring, regex, or predicate tested against the lowercase basename. */
887
1008
  type ConfigMatcher = string | RegExp | ((baseName: string) => boolean);
888
1009
  /**
@@ -1132,4 +1253,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1132
1253
  */
1133
1254
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1134
1255
 
1135
- export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, type CallEdge, type CalleeEntry, type CallerEntry, type ChangeImpactCache, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type ExportKind, type ExportedSymbol, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, type FileNode, type FileType, type FunctionCallInfo, Graph, type GraphExporter, type ImportEdge, type ImportType, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, type NodeCategory, type NodeQuery, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type StructuredTag, SymbolTraversalContext, type TagKind, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, getAllProjectFiles, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, toMermaid };
1256
+ export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, type CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type ExportKind, type ExportedSymbol, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, type FileNode, type FileType, type FindComplexFunctionsOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, type ImportEdge, type ImportType, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, type NodeCategory, type NodeQuery, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, type StructuredTag, SymbolTraversalContext, type TagKind, 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 };
package/dist/index.d.ts CHANGED
@@ -348,7 +348,7 @@ declare function buildApiSurface(graph: Graph, entryPoints: string[]): ApiSurfac
348
348
 
349
349
  /** Public types for the call-graph subsystem. */
350
350
  /** A file and function name that calls the target function. */
351
- interface CallerEntry {
351
+ interface CallerEntry$1 {
352
352
  /** Project-relative path of the file containing the caller. */
353
353
  file: string;
354
354
  /** Name of the function that makes the call. */
@@ -375,7 +375,7 @@ interface FunctionCallInfo {
375
375
  */
376
376
  definedIn: string | null;
377
377
  /** Files and functions that call this function. */
378
- callers: CallerEntry[];
378
+ callers: CallerEntry$1[];
379
379
  /** Files and functions that this function calls. */
380
380
  callees: CalleeEntry[];
381
381
  }
@@ -883,6 +883,127 @@ declare const MermaidExporter: GraphExporter;
883
883
  */
884
884
  declare function toMermaid(graph: Graph): string;
885
885
 
886
+ /** Pure graph query/shaping functions shared by the MCP handlers and the CLI, so both surfaces return identical JSON shapes. */
887
+
888
+ interface PathWithSymbols {
889
+ path: string;
890
+ symbols?: string[];
891
+ }
892
+ /**
893
+ * @description Outgoing traversal from `file` — all files it imports, up to `depth` hops.
894
+ * @param graph - The graph to traverse.
895
+ * @param file - Project-relative path of the starting node.
896
+ * @param depth - Max traversal depth (default 1 = immediate imports only).
897
+ * @returns Reachable imported paths, each with the symbols imported from it when known.
898
+ */
899
+ declare function getDependencies(graph: Graph, file: string, depth?: number): PathWithSymbols[];
900
+ /**
901
+ * @description Incoming one-hop traversal — files that directly import `file`.
902
+ * @param graph - The graph to traverse.
903
+ * @param file - Project-relative path of the target node.
904
+ * @returns Direct importers, each with the symbols they import from `file` when known.
905
+ */
906
+ declare function getDependents(graph: Graph, file: string): PathWithSymbols[];
907
+ interface GetAffectedOptions {
908
+ testsOnly?: boolean | undefined;
909
+ changedSymbols?: string[] | undefined;
910
+ }
911
+ /**
912
+ * @description Full incoming traversal from `file` upward — every file transitively affected if `file` changes.
913
+ * @param graph - The graph to traverse.
914
+ * @param file - Project-relative path of the changed node.
915
+ * @param options - `testsOnly` restricts results to test/spec files; `changedSymbols` restricts propagation to files that actually import those symbols.
916
+ * @returns Project-relative paths of all transitively impacted files.
917
+ */
918
+ declare function getAffected(graph: Graph, file: string, options?: GetAffectedOptions): string[];
919
+ interface CallerEntry {
920
+ file: string;
921
+ edges?: Array<{
922
+ from: string;
923
+ to: string;
924
+ }>;
925
+ }
926
+ interface GetCallersOptions {
927
+ depth?: number | undefined;
928
+ withEdgeDetail?: boolean | undefined;
929
+ }
930
+ /**
931
+ * @description Incoming call-edge traversal — files whose exported functions call into `file`.
932
+ * More precise than `getAffected` because it follows runtime call edges rather than all import edges.
933
+ * @param graph - The graph to traverse.
934
+ * @param file - Project-relative path of the target node.
935
+ * @param options - `depth` caps traversal hops (default 1); `withEdgeDetail` adds from/to function names per edge.
936
+ * @returns Callers, each optionally including edge detail.
937
+ */
938
+ declare function getCallers(graph: Graph, file: string, options?: GetCallersOptions): CallerEntry[];
939
+ interface ComplexFunctionEntry {
940
+ file: string;
941
+ name: string;
942
+ line: number;
943
+ complexity: number;
944
+ cognitiveComplexity: number;
945
+ }
946
+ interface FindComplexFunctionsOptions {
947
+ metric?: "cognitiveComplexity" | "complexity" | undefined;
948
+ threshold?: number | undefined;
949
+ limit?: number | undefined;
950
+ }
951
+ /**
952
+ * @description Scans every file's per-function complexity breakdown and returns functions/methods
953
+ * at or above the given threshold, sorted worst-first. TypeScript/JavaScript only.
954
+ * @param graph - The graph to scan.
955
+ * @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).
956
+ * @returns Matching functions, sorted worst-first.
957
+ */
958
+ declare function findComplexFunctions(graph: Graph, options?: FindComplexFunctionsOptions): ComplexFunctionEntry[];
959
+ interface SlimNode {
960
+ path: string;
961
+ type: FileNode["type"];
962
+ category: FileNode["category"];
963
+ exports: string[];
964
+ tags: string[];
965
+ importsFiles: string[];
966
+ description?: string;
967
+ testedBy?: string[];
968
+ coveragePct?: number;
969
+ avgExportUsage?: number;
970
+ maxExportUsage?: number;
971
+ }
972
+ interface SlimSerializedGraph {
973
+ nodes: SlimNode[];
974
+ cycles: string[][] | undefined;
975
+ }
976
+ /**
977
+ * @description Strips a serialized graph down to a compact response: export names, meaningful tags,
978
+ * and a flat importsFiles path list — no edge objects, no mtime/size.
979
+ * @param filtered - A `SerializedGraph` (typically the output of `filterGraph`) to compact.
980
+ * @returns The slim node list plus cycle info.
981
+ */
982
+ declare function slimSerialize(filtered: SerializedGraph): SlimSerializedGraph;
983
+ interface WorkspacePackageSummary {
984
+ name: string;
985
+ relativeRoot: string;
986
+ nodeCount: number;
987
+ dependsOn: string[];
988
+ }
989
+ interface WorkspacePackagesSummary {
990
+ monorepoType: string;
991
+ packageCount: number;
992
+ packages: WorkspacePackageSummary[];
993
+ }
994
+ /**
995
+ * @description Summarizes every package in a workspace graph: node counts and cross-package dependencies.
996
+ * @param wg - The workspace graph to summarize.
997
+ * @returns Monorepo type, package count, and per-package details.
998
+ */
999
+ declare function summarizeWorkspacePackages(wg: WorkspaceGraph): WorkspacePackagesSummary;
1000
+ /**
1001
+ * @description Returns `true` if at least one node in the graph has coverage data loaded.
1002
+ * @param graph - The graph to check.
1003
+ * @returns Whether any node has a defined `coveragePct`.
1004
+ */
1005
+ declare function hasCoverageData(graph: Graph): boolean;
1006
+
886
1007
  /** A config matcher: substring, regex, or predicate tested against the lowercase basename. */
887
1008
  type ConfigMatcher = string | RegExp | ((baseName: string) => boolean);
888
1009
  /**
@@ -1132,4 +1253,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
1132
1253
  */
1133
1254
  declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
1134
1255
 
1135
- export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, type CallEdge, type CalleeEntry, type CallerEntry, type ChangeImpactCache, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type ExportKind, type ExportedSymbol, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, type FileNode, type FileType, type FunctionCallInfo, Graph, type GraphExporter, type ImportEdge, type ImportType, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, type NodeCategory, type NodeQuery, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type StructuredTag, SymbolTraversalContext, type TagKind, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, getAllProjectFiles, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, toMermaid };
1256
+ export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, type CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type ExportKind, type ExportedSymbol, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, type FileNode, type FileType, type FindComplexFunctionsOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, type ImportEdge, type ImportType, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, type NodeCategory, type NodeQuery, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, type StructuredTag, SymbolTraversalContext, type TagKind, 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 };