@claude-flow/cli 3.0.0-alpha.15 → 3.0.0-alpha.17
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/src/commands/analyze.d.ts +19 -0
- package/dist/src/commands/analyze.d.ts.map +1 -0
- package/dist/src/commands/analyze.js +1819 -0
- package/dist/src/commands/analyze.js.map +1 -0
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +325 -1
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +2 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +12 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp.js +3 -3
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/route.d.ts +16 -0
- package/dist/src/commands/route.d.ts.map +1 -0
- package/dist/src/commands/route.js +597 -0
- package/dist/src/commands/route.js.map +1 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +218 -362
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +2 -0
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +317 -0
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -0
- package/dist/src/mcp-tools/index.d.ts +2 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +2 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +277 -0
- package/dist/src/ruvector/ast-analyzer.js.map +1 -0
- package/dist/src/ruvector/coverage-router.d.ts +145 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +451 -0
- package/dist/src/ruvector/coverage-router.js.map +1 -0
- package/dist/src/ruvector/coverage-tools.d.ts +33 -0
- package/dist/src/ruvector/coverage-tools.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-tools.js +157 -0
- package/dist/src/ruvector/coverage-tools.js.map +1 -0
- package/dist/src/ruvector/diff-classifier.d.ts +154 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +508 -0
- package/dist/src/ruvector/diff-classifier.js.map +1 -0
- package/dist/src/ruvector/graph-analyzer.d.ts +174 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +878 -0
- package/dist/src/ruvector/graph-analyzer.js.map +1 -0
- package/dist/src/ruvector/index.d.ts +27 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +47 -0
- package/dist/src/ruvector/index.js.map +1 -0
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +681 -0
- package/dist/src/ruvector/q-learning-router.js.map +1 -0
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +243 -0
- package/dist/src/ruvector/vector-db.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Analyzer Module
|
|
3
|
+
*
|
|
4
|
+
* Provides code dependency graph analysis using ruvector's graph algorithms:
|
|
5
|
+
* - MinCut for code boundary detection (refactoring suggestions)
|
|
6
|
+
* - Louvain for module/community detection
|
|
7
|
+
* - Circular dependency detection
|
|
8
|
+
* - DOT format export for visualization
|
|
9
|
+
*
|
|
10
|
+
* Falls back to built-in implementations when @ruvector/wasm is not available.
|
|
11
|
+
*
|
|
12
|
+
* @module @claude-flow/cli/ruvector/graph-analyzer
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Node in the dependency graph
|
|
16
|
+
*/
|
|
17
|
+
export interface GraphNode {
|
|
18
|
+
id: string;
|
|
19
|
+
path: string;
|
|
20
|
+
name: string;
|
|
21
|
+
type: 'file' | 'module' | 'package';
|
|
22
|
+
imports: string[];
|
|
23
|
+
exports: string[];
|
|
24
|
+
size: number;
|
|
25
|
+
complexity?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Edge in the dependency graph
|
|
29
|
+
*/
|
|
30
|
+
export interface GraphEdge {
|
|
31
|
+
source: string;
|
|
32
|
+
target: string;
|
|
33
|
+
type: 'import' | 'require' | 'dynamic' | 're-export';
|
|
34
|
+
weight: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Dependency graph representation
|
|
38
|
+
*/
|
|
39
|
+
export interface DependencyGraph {
|
|
40
|
+
nodes: Map<string, GraphNode>;
|
|
41
|
+
edges: GraphEdge[];
|
|
42
|
+
metadata: {
|
|
43
|
+
rootDir: string;
|
|
44
|
+
totalFiles: number;
|
|
45
|
+
totalEdges: number;
|
|
46
|
+
buildTime: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MinCut result representing a natural boundary in the codebase
|
|
51
|
+
*/
|
|
52
|
+
export interface MinCutBoundary {
|
|
53
|
+
cutValue: number;
|
|
54
|
+
partition1: string[];
|
|
55
|
+
partition2: string[];
|
|
56
|
+
cutEdges: GraphEdge[];
|
|
57
|
+
suggestion: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Community/module detection result
|
|
61
|
+
*/
|
|
62
|
+
export interface ModuleCommunity {
|
|
63
|
+
id: number;
|
|
64
|
+
members: string[];
|
|
65
|
+
cohesion: number;
|
|
66
|
+
centralNode?: string;
|
|
67
|
+
suggestedName?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Circular dependency info
|
|
71
|
+
*/
|
|
72
|
+
export interface CircularDependency {
|
|
73
|
+
cycle: string[];
|
|
74
|
+
severity: 'low' | 'medium' | 'high';
|
|
75
|
+
suggestion: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Analysis result
|
|
79
|
+
*/
|
|
80
|
+
export interface GraphAnalysisResult {
|
|
81
|
+
graph: DependencyGraph;
|
|
82
|
+
boundaries?: MinCutBoundary[];
|
|
83
|
+
communities?: ModuleCommunity[];
|
|
84
|
+
circularDependencies: CircularDependency[];
|
|
85
|
+
statistics: {
|
|
86
|
+
nodeCount: number;
|
|
87
|
+
edgeCount: number;
|
|
88
|
+
avgDegree: number;
|
|
89
|
+
maxDegree: number;
|
|
90
|
+
density: number;
|
|
91
|
+
componentCount: number;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Interface for ruvector graph operations
|
|
96
|
+
*/
|
|
97
|
+
interface IRuVectorGraph {
|
|
98
|
+
mincut(nodes: string[], edges: Array<[string, string, number]>): {
|
|
99
|
+
cutValue: number;
|
|
100
|
+
partition1: string[];
|
|
101
|
+
partition2: string[];
|
|
102
|
+
cutEdges: Array<[string, string]>;
|
|
103
|
+
};
|
|
104
|
+
louvain(nodes: string[], edges: Array<[string, string, number]>): {
|
|
105
|
+
communities: Array<{
|
|
106
|
+
id: number;
|
|
107
|
+
members: string[];
|
|
108
|
+
}>;
|
|
109
|
+
modularity: number;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Attempt to load ruvector graph algorithms
|
|
114
|
+
*/
|
|
115
|
+
declare function loadRuVector(): Promise<IRuVectorGraph | null>;
|
|
116
|
+
/**
|
|
117
|
+
* Build dependency graph from source directory
|
|
118
|
+
*/
|
|
119
|
+
export declare function buildDependencyGraph(rootDir: string, options?: {
|
|
120
|
+
include?: string[];
|
|
121
|
+
exclude?: string[];
|
|
122
|
+
maxDepth?: number;
|
|
123
|
+
}): Promise<DependencyGraph>;
|
|
124
|
+
/**
|
|
125
|
+
* Stoer-Wagner MinCut algorithm (fallback when ruvector not available)
|
|
126
|
+
* Finds minimum cut with deterministic result
|
|
127
|
+
*/
|
|
128
|
+
declare function fallbackMinCut(nodes: string[], edges: Array<[string, string, number]>): {
|
|
129
|
+
cutValue: number;
|
|
130
|
+
partition1: string[];
|
|
131
|
+
partition2: string[];
|
|
132
|
+
cutEdges: Array<[string, string]>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Louvain community detection algorithm (fallback when ruvector not available)
|
|
136
|
+
* Greedy modularity optimization
|
|
137
|
+
*/
|
|
138
|
+
declare function fallbackLouvain(nodes: string[], edges: Array<[string, string, number]>): {
|
|
139
|
+
communities: Array<{
|
|
140
|
+
id: number;
|
|
141
|
+
members: string[];
|
|
142
|
+
}>;
|
|
143
|
+
modularity: number;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Detect circular dependencies using DFS
|
|
147
|
+
*/
|
|
148
|
+
export declare function detectCircularDependencies(graph: DependencyGraph): CircularDependency[];
|
|
149
|
+
/**
|
|
150
|
+
* Analyze graph boundaries using MinCut algorithm
|
|
151
|
+
*/
|
|
152
|
+
export declare function analyzeMinCutBoundaries(graph: DependencyGraph, numPartitions?: number): Promise<MinCutBoundary[]>;
|
|
153
|
+
/**
|
|
154
|
+
* Analyze module communities using Louvain algorithm
|
|
155
|
+
*/
|
|
156
|
+
export declare function analyzeModuleCommunities(graph: DependencyGraph): Promise<ModuleCommunity[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Full graph analysis
|
|
159
|
+
*/
|
|
160
|
+
export declare function analyzeGraph(rootDir: string, options?: {
|
|
161
|
+
includeBoundaries?: boolean;
|
|
162
|
+
includeModules?: boolean;
|
|
163
|
+
numPartitions?: number;
|
|
164
|
+
}): Promise<GraphAnalysisResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Export graph to DOT format for visualization
|
|
167
|
+
*/
|
|
168
|
+
export declare function exportToDot(result: GraphAnalysisResult, options?: {
|
|
169
|
+
includeLabels?: boolean;
|
|
170
|
+
colorByCommunity?: boolean;
|
|
171
|
+
highlightCycles?: boolean;
|
|
172
|
+
}): string;
|
|
173
|
+
export { loadRuVector, fallbackMinCut, fallbackLouvain, };
|
|
174
|
+
//# sourceMappingURL=graph-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-analyzer.d.ts","sourceRoot":"","sources":["../../../src/ruvector/graph-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;IACrD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QAC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