agentic-qe 2.6.5 → 2.6.6
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/CHANGELOG.md +52 -0
- package/README.md +1 -1
- package/dist/agents/CoverageAnalyzerAgent.d.ts +31 -0
- package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/CoverageAnalyzerAgent.js +159 -0
- package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
- package/dist/agents/FleetCommanderAgent.d.ts +36 -0
- package/dist/agents/FleetCommanderAgent.d.ts.map +1 -1
- package/dist/agents/FleetCommanderAgent.js +226 -0
- package/dist/agents/FleetCommanderAgent.js.map +1 -1
- package/dist/cli/commands/kg/mincut.d.ts +50 -0
- package/dist/cli/commands/kg/mincut.d.ts.map +1 -0
- package/dist/cli/commands/kg/mincut.js +372 -0
- package/dist/cli/commands/kg/mincut.js.map +1 -0
- package/dist/cli/index.js +91 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/claude-config.js +2 -2
- package/dist/code-intelligence/analysis/mincut/CircularDependencyDetector.d.ts +148 -0
- package/dist/code-intelligence/analysis/mincut/CircularDependencyDetector.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/CircularDependencyDetector.js +393 -0
- package/dist/code-intelligence/analysis/mincut/CircularDependencyDetector.js.map +1 -0
- package/dist/code-intelligence/analysis/mincut/GraphAdapter.d.ts +169 -0
- package/dist/code-intelligence/analysis/mincut/GraphAdapter.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/GraphAdapter.js +335 -0
- package/dist/code-intelligence/analysis/mincut/GraphAdapter.js.map +1 -0
- package/dist/code-intelligence/analysis/mincut/JsMinCut.d.ts +55 -0
- package/dist/code-intelligence/analysis/mincut/JsMinCut.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/JsMinCut.js +265 -0
- package/dist/code-intelligence/analysis/mincut/JsMinCut.js.map +1 -0
- package/dist/code-intelligence/analysis/mincut/MinCutAnalyzer.d.ts +92 -0
- package/dist/code-intelligence/analysis/mincut/MinCutAnalyzer.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/MinCutAnalyzer.js +200 -0
- package/dist/code-intelligence/analysis/mincut/MinCutAnalyzer.js.map +1 -0
- package/dist/code-intelligence/analysis/mincut/ModuleCouplingAnalyzer.d.ts +157 -0
- package/dist/code-intelligence/analysis/mincut/ModuleCouplingAnalyzer.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/ModuleCouplingAnalyzer.js +434 -0
- package/dist/code-intelligence/analysis/mincut/ModuleCouplingAnalyzer.js.map +1 -0
- package/dist/code-intelligence/analysis/mincut/index.d.ts +12 -0
- package/dist/code-intelligence/analysis/mincut/index.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/index.js +20 -0
- package/dist/code-intelligence/analysis/mincut/index.js.map +1 -0
- package/dist/code-intelligence/analysis/mincut/types.d.ts +145 -0
- package/dist/code-intelligence/analysis/mincut/types.d.ts.map +1 -0
- package/dist/code-intelligence/analysis/mincut/types.js +16 -0
- package/dist/code-intelligence/analysis/mincut/types.js.map +1 -0
- package/dist/code-intelligence/chunking/ASTChunker.d.ts +1 -1
- package/dist/code-intelligence/chunking/ASTChunker.d.ts.map +1 -1
- package/dist/code-intelligence/chunking/ASTChunker.js +4 -4
- package/dist/code-intelligence/chunking/ASTChunker.js.map +1 -1
- package/dist/code-intelligence/graph/GraphBuilder.d.ts +120 -0
- package/dist/code-intelligence/graph/GraphBuilder.d.ts.map +1 -1
- package/dist/code-intelligence/graph/GraphBuilder.js +517 -0
- package/dist/code-intelligence/graph/GraphBuilder.js.map +1 -1
- package/dist/code-intelligence/orchestrator/CodeIntelligenceOrchestrator.d.ts.map +1 -1
- package/dist/code-intelligence/orchestrator/CodeIntelligenceOrchestrator.js +3 -3
- package/dist/code-intelligence/orchestrator/CodeIntelligenceOrchestrator.js.map +1 -1
- package/dist/code-intelligence/parser/{TreeSitterParser.d.ts → WebTreeSitterParser.d.ts} +45 -10
- package/dist/code-intelligence/parser/WebTreeSitterParser.d.ts.map +1 -0
- package/dist/code-intelligence/parser/{TreeSitterParser.js → WebTreeSitterParser.js} +147 -54
- package/dist/code-intelligence/parser/WebTreeSitterParser.js.map +1 -0
- package/dist/code-intelligence/parser/extractors/BaseExtractor.d.ts +12 -10
- package/dist/code-intelligence/parser/extractors/BaseExtractor.d.ts.map +1 -1
- package/dist/code-intelligence/parser/extractors/BaseExtractor.js +7 -3
- package/dist/code-intelligence/parser/extractors/BaseExtractor.js.map +1 -1
- package/dist/code-intelligence/parser/extractors/GoExtractor.d.ts +7 -5
- package/dist/code-intelligence/parser/extractors/GoExtractor.d.ts.map +1 -1
- package/dist/code-intelligence/parser/extractors/GoExtractor.js +2 -2
- package/dist/code-intelligence/parser/extractors/GoExtractor.js.map +1 -1
- package/dist/code-intelligence/parser/extractors/JavaScriptExtractor.d.ts +7 -5
- package/dist/code-intelligence/parser/extractors/JavaScriptExtractor.d.ts.map +1 -1
- package/dist/code-intelligence/parser/extractors/JavaScriptExtractor.js +2 -2
- package/dist/code-intelligence/parser/extractors/JavaScriptExtractor.js.map +1 -1
- package/dist/code-intelligence/parser/extractors/PythonExtractor.d.ts +7 -5
- package/dist/code-intelligence/parser/extractors/PythonExtractor.d.ts.map +1 -1
- package/dist/code-intelligence/parser/extractors/PythonExtractor.js +2 -2
- package/dist/code-intelligence/parser/extractors/PythonExtractor.js.map +1 -1
- package/dist/code-intelligence/parser/extractors/RustExtractor.d.ts +7 -5
- package/dist/code-intelligence/parser/extractors/RustExtractor.d.ts.map +1 -1
- package/dist/code-intelligence/parser/extractors/RustExtractor.js +2 -2
- package/dist/code-intelligence/parser/extractors/RustExtractor.js.map +1 -1
- package/dist/code-intelligence/parser/extractors/TypeScriptExtractor.d.ts +7 -5
- package/dist/code-intelligence/parser/extractors/TypeScriptExtractor.d.ts.map +1 -1
- package/dist/code-intelligence/parser/extractors/TypeScriptExtractor.js +2 -2
- package/dist/code-intelligence/parser/extractors/TypeScriptExtractor.js.map +1 -1
- package/dist/code-intelligence/parser/index.d.ts +7 -1
- package/dist/code-intelligence/parser/index.d.ts.map +1 -1
- package/dist/code-intelligence/parser/index.js +11 -3
- package/dist/code-intelligence/parser/index.js.map +1 -1
- package/dist/code-intelligence/service/CodeIntelligenceService.d.ts.map +1 -1
- package/dist/code-intelligence/service/CodeIntelligenceService.js +7 -5
- package/dist/code-intelligence/service/CodeIntelligenceService.js.map +1 -1
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/coverage/CriticalPathDetector.d.ts +240 -0
- package/dist/coverage/CriticalPathDetector.d.ts.map +1 -0
- package/dist/coverage/CriticalPathDetector.js +388 -0
- package/dist/coverage/CriticalPathDetector.js.map +1 -0
- package/dist/coverage/index.d.ts +13 -0
- package/dist/coverage/index.d.ts.map +1 -0
- package/dist/coverage/index.js +16 -0
- package/dist/coverage/index.js.map +1 -0
- package/dist/fleet/topology/SPOFMonitor.d.ts +181 -0
- package/dist/fleet/topology/SPOFMonitor.d.ts.map +1 -0
- package/dist/fleet/topology/SPOFMonitor.js +286 -0
- package/dist/fleet/topology/SPOFMonitor.js.map +1 -0
- package/dist/fleet/topology/TopologyMinCutAnalyzer.d.ts +87 -0
- package/dist/fleet/topology/TopologyMinCutAnalyzer.d.ts.map +1 -0
- package/dist/fleet/topology/TopologyMinCutAnalyzer.js +472 -0
- package/dist/fleet/topology/TopologyMinCutAnalyzer.js.map +1 -0
- package/dist/fleet/topology/index.d.ts +13 -0
- package/dist/fleet/topology/index.d.ts.map +1 -0
- package/dist/fleet/topology/index.js +20 -0
- package/dist/fleet/topology/index.js.map +1 -0
- package/dist/fleet/topology/types.d.ts +139 -0
- package/dist/fleet/topology/types.d.ts.map +1 -0
- package/dist/fleet/topology/types.js +19 -0
- package/dist/fleet/topology/types.js.map +1 -0
- package/dist/mcp/handlers/test/test-execute-parallel.d.ts +34 -3
- package/dist/mcp/handlers/test/test-execute-parallel.d.ts.map +1 -1
- package/dist/mcp/handlers/test/test-execute-parallel.js +120 -5
- package/dist/mcp/handlers/test/test-execute-parallel.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +2 -2
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +2 -2
- package/dist/test/partition/MinCutPartitioner.d.ts +97 -0
- package/dist/test/partition/MinCutPartitioner.d.ts.map +1 -0
- package/dist/test/partition/MinCutPartitioner.js +459 -0
- package/dist/test/partition/MinCutPartitioner.js.map +1 -0
- package/dist/test/partition/RealTestExecutor.d.ts +86 -0
- package/dist/test/partition/RealTestExecutor.d.ts.map +1 -0
- package/dist/test/partition/RealTestExecutor.js +279 -0
- package/dist/test/partition/RealTestExecutor.js.map +1 -0
- package/dist/test/partition/TestDependencyAnalyzer.d.ts +75 -0
- package/dist/test/partition/TestDependencyAnalyzer.d.ts.map +1 -0
- package/dist/test/partition/TestDependencyAnalyzer.js +297 -0
- package/dist/test/partition/TestDependencyAnalyzer.js.map +1 -0
- package/dist/test/partition/index.d.ts +10 -0
- package/dist/test/partition/index.d.ts.map +1 -0
- package/dist/test/partition/index.js +26 -0
- package/dist/test/partition/index.js.map +1 -0
- package/dist/test/partition/types.d.ts +120 -0
- package/dist/test/partition/types.d.ts.map +1 -0
- package/dist/test/partition/types.js +21 -0
- package/dist/test/partition/types.js.map +1 -0
- package/package.json +4 -7
- package/dist/code-intelligence/parser/TreeSitterParser.d.ts.map +0 -1
- package/dist/code-intelligence/parser/TreeSitterParser.js.map +0 -1
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Module Coupling Analyzer
|
|
4
|
+
*
|
|
5
|
+
* High-level analyzer for module coupling that provides actionable insights
|
|
6
|
+
* for code quality improvement. Uses MinCut analysis to identify optimal
|
|
7
|
+
* module boundaries and coupling reduction points.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const graph = graphBuilder.exportGraph();
|
|
12
|
+
* const analyzer = new ModuleCouplingAnalyzer(graph, {
|
|
13
|
+
* moduleGrouping: 'directory',
|
|
14
|
+
* minCouplingThreshold: 0.1
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Analyze coupling between two modules
|
|
18
|
+
* const result = await analyzer.analyzeCoupling('src/auth', 'src/user');
|
|
19
|
+
* console.log('Coupling strength:', result.couplingStrength);
|
|
20
|
+
* console.log('Recommendations:', result.recommendations);
|
|
21
|
+
*
|
|
22
|
+
* // Find all highly coupled module pairs
|
|
23
|
+
* const coupled = await analyzer.findHighlyCoupledModules(0.7);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.ModuleCouplingAnalyzer = void 0;
|
|
28
|
+
const MinCutAnalyzer_js_1 = require("./MinCutAnalyzer.js");
|
|
29
|
+
const GraphAdapter_js_1 = require("./GraphAdapter.js");
|
|
30
|
+
const Logger_js_1 = require("../../../utils/Logger.js");
|
|
31
|
+
const logger = Logger_js_1.Logger.getInstance();
|
|
32
|
+
/**
|
|
33
|
+
* ModuleCouplingAnalyzer - High-level analyzer for module coupling
|
|
34
|
+
*
|
|
35
|
+
* Provides actionable insights about module coupling and recommendations
|
|
36
|
+
* for improving code quality through better module boundaries.
|
|
37
|
+
*/
|
|
38
|
+
class ModuleCouplingAnalyzer {
|
|
39
|
+
/**
|
|
40
|
+
* Create a new ModuleCouplingAnalyzer
|
|
41
|
+
*
|
|
42
|
+
* @param graph - Code graph to analyze (from GraphBuilder.exportGraph())
|
|
43
|
+
* @param options - Analysis options
|
|
44
|
+
*/
|
|
45
|
+
constructor(graph, options = {}) {
|
|
46
|
+
this.graph = graph;
|
|
47
|
+
this.analyzer = new MinCutAnalyzer_js_1.MinCutAnalyzer(options.minCutConfig);
|
|
48
|
+
this.options = {
|
|
49
|
+
minCutConfig: options.minCutConfig || {},
|
|
50
|
+
moduleGrouping: options.moduleGrouping || 'directory',
|
|
51
|
+
customModuleExtractor: options.customModuleExtractor || this.defaultModuleExtractor.bind(this),
|
|
52
|
+
minCouplingThreshold: options.minCouplingThreshold || 0.1,
|
|
53
|
+
};
|
|
54
|
+
logger.info('ModuleCouplingAnalyzer initialized', {
|
|
55
|
+
nodeCount: graph.nodes.size,
|
|
56
|
+
edgeCount: graph.edges.size,
|
|
57
|
+
moduleGrouping: this.options.moduleGrouping,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Analyze coupling between two specific modules
|
|
62
|
+
*
|
|
63
|
+
* @param module1Path - Path to first module
|
|
64
|
+
* @param module2Path - Path to second module
|
|
65
|
+
* @returns Promise resolving to coupling analysis result
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const result = await analyzer.analyzeCoupling('src/auth', 'src/user');
|
|
70
|
+
* if (result.couplingStrength > 0.7) {
|
|
71
|
+
* console.log('High coupling detected!');
|
|
72
|
+
* console.log('Recommendations:', result.recommendations);
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
async analyzeCoupling(module1Path, module2Path) {
|
|
77
|
+
logger.debug('Analyzing coupling', { module1Path, module2Path });
|
|
78
|
+
// 1. Extract nodes for both modules
|
|
79
|
+
const module1Nodes = this.getModuleNodes(module1Path);
|
|
80
|
+
const module2Nodes = this.getModuleNodes(module2Path);
|
|
81
|
+
if (module1Nodes.length === 0 || module2Nodes.length === 0) {
|
|
82
|
+
logger.warn('One or both modules have no nodes', {
|
|
83
|
+
module1Count: module1Nodes.length,
|
|
84
|
+
module2Count: module2Nodes.length,
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
module1: module1Path,
|
|
88
|
+
module2: module2Path,
|
|
89
|
+
couplingStrength: 0,
|
|
90
|
+
sharedDependencies: [],
|
|
91
|
+
circularDependency: false,
|
|
92
|
+
cutEdges: [],
|
|
93
|
+
recommendations: ['One or both modules not found in the code graph'],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// 2. Build subgraph containing only these modules
|
|
97
|
+
const subgraph = this.extractModuleSubgraph(module1Nodes, module2Nodes);
|
|
98
|
+
// 3. Run MinCut analysis
|
|
99
|
+
const minCutInput = GraphAdapter_js_1.GraphAdapter.toMinCutFormat(subgraph, {
|
|
100
|
+
normalizeWeights: true,
|
|
101
|
+
directed: false,
|
|
102
|
+
});
|
|
103
|
+
let result;
|
|
104
|
+
try {
|
|
105
|
+
result = await this.analyzer.computeMinCut(minCutInput);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger.error('MinCut computation failed', { error });
|
|
109
|
+
return {
|
|
110
|
+
module1: module1Path,
|
|
111
|
+
module2: module2Path,
|
|
112
|
+
couplingStrength: 0,
|
|
113
|
+
sharedDependencies: [],
|
|
114
|
+
circularDependency: false,
|
|
115
|
+
cutEdges: [],
|
|
116
|
+
recommendations: ['Failed to compute minimum cut - graph may be too large or disconnected'],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// 4. Calculate coupling strength
|
|
120
|
+
const couplingStrength = this.calculateCouplingStrength(result, subgraph);
|
|
121
|
+
// 5. Check for circular dependency
|
|
122
|
+
const circular = this.hasCircularDependency(module1Nodes, module2Nodes);
|
|
123
|
+
// 6. Find shared dependencies
|
|
124
|
+
const shared = this.findSharedDependencies(module1Nodes, module2Nodes);
|
|
125
|
+
// 7. Generate recommendations
|
|
126
|
+
const recommendations = this.generateRecommendations(couplingStrength, circular, result.cutEdges);
|
|
127
|
+
logger.debug('Coupling analysis complete', {
|
|
128
|
+
module1Path,
|
|
129
|
+
module2Path,
|
|
130
|
+
couplingStrength,
|
|
131
|
+
circularDependency: circular,
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
module1: module1Path,
|
|
135
|
+
module2: module2Path,
|
|
136
|
+
couplingStrength,
|
|
137
|
+
sharedDependencies: shared,
|
|
138
|
+
circularDependency: circular,
|
|
139
|
+
cutEdges: result.cutEdges,
|
|
140
|
+
recommendations,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Find all highly coupled module pairs
|
|
145
|
+
*
|
|
146
|
+
* @param threshold - Minimum coupling strength to include (0-1, default 0.7)
|
|
147
|
+
* @returns Promise resolving to array of coupling results, sorted by strength
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const coupled = await analyzer.findHighlyCoupledModules(0.7);
|
|
152
|
+
* for (const pair of coupled) {
|
|
153
|
+
* console.log(`${pair.module1} <-> ${pair.module2}: ${pair.couplingStrength}`);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
async findHighlyCoupledModules(threshold = 0.7) {
|
|
158
|
+
const modules = this.getUniqueModules();
|
|
159
|
+
const results = [];
|
|
160
|
+
logger.info('Finding highly coupled modules', {
|
|
161
|
+
moduleCount: modules.length,
|
|
162
|
+
threshold,
|
|
163
|
+
});
|
|
164
|
+
// Analyze all module pairs
|
|
165
|
+
for (let i = 0; i < modules.length; i++) {
|
|
166
|
+
for (let j = i + 1; j < modules.length; j++) {
|
|
167
|
+
const result = await this.analyzeCoupling(modules[i], modules[j]);
|
|
168
|
+
// Only include if above minimum threshold AND above requested threshold
|
|
169
|
+
if (result.couplingStrength >= this.options.minCouplingThreshold &&
|
|
170
|
+
result.couplingStrength >= threshold) {
|
|
171
|
+
results.push(result);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Sort by coupling strength (highest first)
|
|
176
|
+
results.sort((a, b) => b.couplingStrength - a.couplingStrength);
|
|
177
|
+
logger.info('Found highly coupled modules', { count: results.length });
|
|
178
|
+
return results;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get a coupling summary for the entire codebase
|
|
182
|
+
*
|
|
183
|
+
* @returns Promise resolving to overall coupling statistics and recommendations
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const overview = await analyzer.getCouplingOverview();
|
|
188
|
+
* console.log('Average coupling:', overview.averageCoupling);
|
|
189
|
+
* console.log('Recommendations:', overview.recommendations);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
async getCouplingOverview() {
|
|
193
|
+
logger.info('Computing coupling overview');
|
|
194
|
+
// Analyze all module pairs (no threshold filter)
|
|
195
|
+
const allResults = await this.findHighlyCoupledModules(0);
|
|
196
|
+
if (allResults.length === 0) {
|
|
197
|
+
return {
|
|
198
|
+
averageCoupling: 0,
|
|
199
|
+
maxCoupling: 0,
|
|
200
|
+
highlyCoupledPairs: 0,
|
|
201
|
+
circularDependencies: 0,
|
|
202
|
+
recommendations: ['No module coupling found - graph may be disconnected or too small'],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const average = allResults.reduce((sum, r) => sum + r.couplingStrength, 0) / allResults.length;
|
|
206
|
+
const max = Math.max(...allResults.map(r => r.couplingStrength));
|
|
207
|
+
const highlyPaired = allResults.filter(r => r.couplingStrength > 0.7).length;
|
|
208
|
+
const circular = allResults.filter(r => r.circularDependency).length;
|
|
209
|
+
const recommendations = [];
|
|
210
|
+
if (average > 0.5) {
|
|
211
|
+
recommendations.push('Consider breaking up large modules into smaller, focused units');
|
|
212
|
+
}
|
|
213
|
+
if (circular > 0) {
|
|
214
|
+
recommendations.push(`Found ${circular} circular dependencies - consider introducing abstraction layers`);
|
|
215
|
+
}
|
|
216
|
+
if (highlyPaired > 0) {
|
|
217
|
+
recommendations.push(`Found ${highlyPaired} highly coupled module pairs - review for potential merging or refactoring`);
|
|
218
|
+
}
|
|
219
|
+
if (average < 0.3 && highlyPaired === 0) {
|
|
220
|
+
recommendations.push('Module coupling is low - good separation of concerns');
|
|
221
|
+
}
|
|
222
|
+
logger.info('Coupling overview complete', {
|
|
223
|
+
averageCoupling: average,
|
|
224
|
+
maxCoupling: max,
|
|
225
|
+
highlyCoupledPairs: highlyPaired,
|
|
226
|
+
circularDependencies: circular,
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
averageCoupling: average,
|
|
230
|
+
maxCoupling: max,
|
|
231
|
+
highlyCoupledPairs: highlyPaired,
|
|
232
|
+
circularDependencies: circular,
|
|
233
|
+
recommendations,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get all nodes belonging to a module
|
|
238
|
+
*/
|
|
239
|
+
getModuleNodes(modulePath) {
|
|
240
|
+
const nodes = [];
|
|
241
|
+
for (const node of this.graph.nodes.values()) {
|
|
242
|
+
const nodeModule = this.extractModulePath(node.filePath);
|
|
243
|
+
if (nodeModule === modulePath) {
|
|
244
|
+
nodes.push(node);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return nodes;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Extract module subgraph containing only specified nodes
|
|
251
|
+
*/
|
|
252
|
+
extractModuleSubgraph(nodes1, nodes2) {
|
|
253
|
+
const allNodes = [...nodes1, ...nodes2];
|
|
254
|
+
const nodeIdSet = new Set(allNodes.map(n => n.id));
|
|
255
|
+
// Filter edges to only those connecting nodes in the subgraph
|
|
256
|
+
const edges = [];
|
|
257
|
+
for (const edge of this.graph.edges.values()) {
|
|
258
|
+
if (nodeIdSet.has(edge.source) && nodeIdSet.has(edge.target)) {
|
|
259
|
+
edges.push(edge);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return { nodes: allNodes, edges };
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Calculate coupling strength from MinCut result
|
|
266
|
+
*
|
|
267
|
+
* Coupling strength is calculated as:
|
|
268
|
+
* - If cutValue is 0: coupling = 0 (no connection)
|
|
269
|
+
* - Otherwise: coupling = normalized based on cut edges and graph structure
|
|
270
|
+
*/
|
|
271
|
+
calculateCouplingStrength(result, graph) {
|
|
272
|
+
if (result.cutValue === 0 || graph.edges.length === 0) {
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
// Calculate total possible weight (all edges)
|
|
276
|
+
const totalWeight = graph.edges.reduce((sum, e) => sum + e.weight, 0);
|
|
277
|
+
if (totalWeight === 0) {
|
|
278
|
+
return 0;
|
|
279
|
+
}
|
|
280
|
+
// Coupling strength is the ratio of cut value to total weight
|
|
281
|
+
// Cut edges represent the coupling between modules
|
|
282
|
+
const rawStrength = result.cutValue / totalWeight;
|
|
283
|
+
// Cap at 1.0 and ensure it's in [0, 1] range
|
|
284
|
+
return Math.min(1.0, Math.max(0, rawStrength));
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Check if there's a circular dependency between module nodes
|
|
288
|
+
*/
|
|
289
|
+
hasCircularDependency(nodes1, nodes2) {
|
|
290
|
+
const nodeIds1 = new Set(nodes1.map(n => n.id));
|
|
291
|
+
const nodeIds2 = new Set(nodes2.map(n => n.id));
|
|
292
|
+
// Check if there are edges in both directions
|
|
293
|
+
let hasForward = false;
|
|
294
|
+
let hasBackward = false;
|
|
295
|
+
for (const edge of this.graph.edges.values()) {
|
|
296
|
+
// Forward: module1 -> module2
|
|
297
|
+
if (nodeIds1.has(edge.source) && nodeIds2.has(edge.target)) {
|
|
298
|
+
hasForward = true;
|
|
299
|
+
}
|
|
300
|
+
// Backward: module2 -> module1
|
|
301
|
+
if (nodeIds2.has(edge.source) && nodeIds1.has(edge.target)) {
|
|
302
|
+
hasBackward = true;
|
|
303
|
+
}
|
|
304
|
+
if (hasForward && hasBackward) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Find dependencies shared by both modules
|
|
312
|
+
*/
|
|
313
|
+
findSharedDependencies(nodes1, nodes2) {
|
|
314
|
+
const nodeIds1 = new Set(nodes1.map(n => n.id));
|
|
315
|
+
const nodeIds2 = new Set(nodes2.map(n => n.id));
|
|
316
|
+
// Find external dependencies for each module
|
|
317
|
+
const deps1 = new Set();
|
|
318
|
+
const deps2 = new Set();
|
|
319
|
+
for (const edge of this.graph.edges.values()) {
|
|
320
|
+
// Dependencies of module 1 (exclude internal and module 2)
|
|
321
|
+
if (nodeIds1.has(edge.source) &&
|
|
322
|
+
!nodeIds1.has(edge.target) &&
|
|
323
|
+
!nodeIds2.has(edge.target)) {
|
|
324
|
+
deps1.add(edge.target);
|
|
325
|
+
}
|
|
326
|
+
// Dependencies of module 2 (exclude internal and module 1)
|
|
327
|
+
if (nodeIds2.has(edge.source) &&
|
|
328
|
+
!nodeIds2.has(edge.target) &&
|
|
329
|
+
!nodeIds1.has(edge.target)) {
|
|
330
|
+
deps2.add(edge.target);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Find intersection
|
|
334
|
+
const shared = [];
|
|
335
|
+
for (const dep of deps1) {
|
|
336
|
+
if (deps2.has(dep)) {
|
|
337
|
+
shared.push(dep);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return shared;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Generate actionable recommendations based on coupling analysis
|
|
344
|
+
*/
|
|
345
|
+
generateRecommendations(strength, circular, edges) {
|
|
346
|
+
const recommendations = [];
|
|
347
|
+
// Recommendations based on coupling strength
|
|
348
|
+
if (strength > 0.8) {
|
|
349
|
+
recommendations.push('Very high coupling detected - strongly consider merging these modules');
|
|
350
|
+
recommendations.push('If merging is not appropriate, extract shared functionality to a separate module');
|
|
351
|
+
}
|
|
352
|
+
else if (strength > 0.6) {
|
|
353
|
+
recommendations.push('High coupling detected - review for potential refactoring');
|
|
354
|
+
recommendations.push('Consider extracting shared functionality to reduce interdependence');
|
|
355
|
+
}
|
|
356
|
+
else if (strength > 0.4) {
|
|
357
|
+
recommendations.push('Moderate coupling - acceptable for closely related modules');
|
|
358
|
+
recommendations.push('Monitor for further increases in coupling');
|
|
359
|
+
}
|
|
360
|
+
else if (strength < 0.2) {
|
|
361
|
+
recommendations.push('Low coupling - modules are well-isolated');
|
|
362
|
+
recommendations.push('No immediate action needed');
|
|
363
|
+
}
|
|
364
|
+
// Recommendations for circular dependencies
|
|
365
|
+
if (circular) {
|
|
366
|
+
recommendations.push('⚠️ Circular dependency detected - this should be resolved');
|
|
367
|
+
recommendations.push('Break the cycle by:');
|
|
368
|
+
recommendations.push(' 1. Introducing an interface/abstraction layer');
|
|
369
|
+
recommendations.push(' 2. Moving shared code to a third module');
|
|
370
|
+
recommendations.push(' 3. Using dependency injection');
|
|
371
|
+
recommendations.push(' 4. Applying the Dependency Inversion Principle');
|
|
372
|
+
}
|
|
373
|
+
// Recommendations for specific edges to break
|
|
374
|
+
if (edges.length > 0 && edges.length <= 5) {
|
|
375
|
+
recommendations.push(`Consider breaking these ${edges.length} key dependencies:`);
|
|
376
|
+
for (const edge of edges.slice(0, 5)) {
|
|
377
|
+
recommendations.push(` - ${edge.source} -> ${edge.target}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else if (edges.length > 5) {
|
|
381
|
+
recommendations.push(`Many dependencies found (${edges.length} total)`);
|
|
382
|
+
recommendations.push('Review the top dependencies and extract common patterns');
|
|
383
|
+
}
|
|
384
|
+
return recommendations;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Get unique module identifiers from the graph
|
|
388
|
+
*/
|
|
389
|
+
getUniqueModules() {
|
|
390
|
+
const modules = new Set();
|
|
391
|
+
for (const node of this.graph.nodes.values()) {
|
|
392
|
+
const modulePath = this.extractModulePath(node.filePath);
|
|
393
|
+
modules.add(modulePath);
|
|
394
|
+
}
|
|
395
|
+
return Array.from(modules).sort();
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Extract module path from file path based on grouping strategy
|
|
399
|
+
*/
|
|
400
|
+
extractModulePath(filePath) {
|
|
401
|
+
if (this.options.moduleGrouping === 'custom') {
|
|
402
|
+
return this.options.customModuleExtractor(filePath);
|
|
403
|
+
}
|
|
404
|
+
if (this.options.moduleGrouping === 'file') {
|
|
405
|
+
return filePath;
|
|
406
|
+
}
|
|
407
|
+
// 'directory' mode - extract directory path
|
|
408
|
+
return this.defaultModuleExtractor(filePath);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Default module extractor - extracts directory path
|
|
412
|
+
*/
|
|
413
|
+
defaultModuleExtractor(filePath) {
|
|
414
|
+
const parts = filePath.split('/');
|
|
415
|
+
// Remove filename
|
|
416
|
+
parts.pop();
|
|
417
|
+
// Return directory path, or filename if no directory
|
|
418
|
+
return parts.length > 0 ? parts.join('/') : filePath;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Get current analysis options
|
|
422
|
+
*/
|
|
423
|
+
getOptions() {
|
|
424
|
+
return { ...this.options };
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Get the underlying graph
|
|
428
|
+
*/
|
|
429
|
+
getGraph() {
|
|
430
|
+
return this.graph;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
exports.ModuleCouplingAnalyzer = ModuleCouplingAnalyzer;
|
|
434
|
+
//# sourceMappingURL=ModuleCouplingAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleCouplingAnalyzer.js","sourceRoot":"","sources":["../../../../src/code-intelligence/analysis/mincut/ModuleCouplingAnalyzer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,2DAAqD;AACrD,uDAAiD;AAGjD,wDAAkD;AAElD,MAAM,MAAM,GAAG,kBAAM,CAAC,WAAW,EAAE,CAAC;AAmBpC;;;;;GAKG;AACH,MAAa,sBAAsB;IAKjC;;;;;OAKG;IACH,YAAY,KAAgB,EAAE,UAAiC,EAAE;QAC/D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,kCAAc,CAAC,OAAO,CAAC,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C/C,CAAC;IAED;;OAEG;IACK,sBAAsB,CAAC,QAAgB;QAC7C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,kBAAkB;QAClB,KAAK,CAAC,GAAG,EAAE,CAAC;QAEZ,qDAAqD;QACrD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA/eD,wDA+eC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MinCut Analysis Module
|
|
3
|
+
*
|
|
4
|
+
* Provides minimum cut analysis for code dependency graphs.
|
|
5
|
+
* Used to identify optimal module boundaries and coupling reduction points.
|
|
6
|
+
*/
|
|
7
|
+
export { GraphAdapter, GraphAdapterOptions } from './GraphAdapter.js';
|
|
8
|
+
export { MinCutAnalyzer } from './MinCutAnalyzer.js';
|
|
9
|
+
export { CircularDependencyDetector } from './CircularDependencyDetector.js';
|
|
10
|
+
export { ModuleCouplingAnalyzer, ModuleCouplingOptions } from './ModuleCouplingAnalyzer.js';
|
|
11
|
+
export { MinCutGraphInput, MinCutResult, MinCutConfig, DEFAULT_MINCUT_CONFIG, CutEdge, CircularDependencyResult, BreakPoint, ModuleCouplingResult, } from './types.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/code-intelligence/analysis/mincut/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,OAAO,EACP,wBAAwB,EACxB,UAAU,EACV,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MinCut Analysis Module
|
|
4
|
+
*
|
|
5
|
+
* Provides minimum cut analysis for code dependency graphs.
|
|
6
|
+
* Used to identify optimal module boundaries and coupling reduction points.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_MINCUT_CONFIG = exports.ModuleCouplingAnalyzer = exports.CircularDependencyDetector = exports.MinCutAnalyzer = exports.GraphAdapter = void 0;
|
|
10
|
+
var GraphAdapter_js_1 = require("./GraphAdapter.js");
|
|
11
|
+
Object.defineProperty(exports, "GraphAdapter", { enumerable: true, get: function () { return GraphAdapter_js_1.GraphAdapter; } });
|
|
12
|
+
var MinCutAnalyzer_js_1 = require("./MinCutAnalyzer.js");
|
|
13
|
+
Object.defineProperty(exports, "MinCutAnalyzer", { enumerable: true, get: function () { return MinCutAnalyzer_js_1.MinCutAnalyzer; } });
|
|
14
|
+
var CircularDependencyDetector_js_1 = require("./CircularDependencyDetector.js");
|
|
15
|
+
Object.defineProperty(exports, "CircularDependencyDetector", { enumerable: true, get: function () { return CircularDependencyDetector_js_1.CircularDependencyDetector; } });
|
|
16
|
+
var ModuleCouplingAnalyzer_js_1 = require("./ModuleCouplingAnalyzer.js");
|
|
17
|
+
Object.defineProperty(exports, "ModuleCouplingAnalyzer", { enumerable: true, get: function () { return ModuleCouplingAnalyzer_js_1.ModuleCouplingAnalyzer; } });
|
|
18
|
+
var types_js_1 = require("./types.js");
|
|
19
|
+
Object.defineProperty(exports, "DEFAULT_MINCUT_CONFIG", { enumerable: true, get: function () { return types_js_1.DEFAULT_MINCUT_CONFIG; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/code-intelligence/analysis/mincut/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qDAAsE;AAA7D,+GAAA,YAAY,OAAA;AACrB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,iFAA6E;AAApE,2IAAA,0BAA0B,OAAA;AACnC,yEAA4F;AAAnF,mIAAA,sBAAsB,OAAA;AAC/B,uCASoB;AALlB,iHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { EdgeType } from '../../graph/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of a minimum cut computation
|
|
4
|
+
*/
|
|
5
|
+
export interface MinCutResult {
|
|
6
|
+
/** The value (total weight) of the minimum cut */
|
|
7
|
+
cutValue: number;
|
|
8
|
+
/** Node IDs in the first partition */
|
|
9
|
+
partition1: string[];
|
|
10
|
+
/** Node IDs in the second partition */
|
|
11
|
+
partition2: string[];
|
|
12
|
+
/** Edges that were cut to separate the partitions */
|
|
13
|
+
cutEdges: CutEdge[];
|
|
14
|
+
/** Algorithm used for computation (currently only stoer-wagner is implemented) */
|
|
15
|
+
algorithmUsed: 'stoer-wagner';
|
|
16
|
+
/** Time taken to compute the cut in milliseconds */
|
|
17
|
+
computationTimeMs: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An edge that crosses the minimum cut
|
|
21
|
+
*/
|
|
22
|
+
export interface CutEdge {
|
|
23
|
+
/** Source node ID */
|
|
24
|
+
source: string;
|
|
25
|
+
/** Target node ID */
|
|
26
|
+
target: string;
|
|
27
|
+
/** Edge weight */
|
|
28
|
+
weight: number;
|
|
29
|
+
/** Optional edge type from the knowledge graph */
|
|
30
|
+
edgeType?: EdgeType;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Input graph format for MinCut computation
|
|
34
|
+
*/
|
|
35
|
+
export interface MinCutGraphInput {
|
|
36
|
+
/** Graph nodes */
|
|
37
|
+
nodes: Array<{
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
properties?: Record<string, unknown>;
|
|
41
|
+
}>;
|
|
42
|
+
/** Graph edges with weights */
|
|
43
|
+
edges: Array<{
|
|
44
|
+
source: string;
|
|
45
|
+
target: string;
|
|
46
|
+
weight: number;
|
|
47
|
+
edgeType?: EdgeType;
|
|
48
|
+
}>;
|
|
49
|
+
/** Whether the graph is directed (MinCut works on undirected graphs) */
|
|
50
|
+
directed: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Configuration for MinCut analyzer
|
|
54
|
+
*/
|
|
55
|
+
export interface MinCutConfig {
|
|
56
|
+
/**
|
|
57
|
+
* Algorithm selection.
|
|
58
|
+
* Currently only 'stoer-wagner' is supported (pure JavaScript implementation).
|
|
59
|
+
* The 'auto' option is kept for backwards compatibility but uses stoer-wagner.
|
|
60
|
+
*/
|
|
61
|
+
algorithm: 'stoer-wagner' | 'auto';
|
|
62
|
+
/** Maximum number of nodes before rejecting the graph (recommended: 500 for performance) */
|
|
63
|
+
maxNodes: number;
|
|
64
|
+
/** Timeout in milliseconds for computation */
|
|
65
|
+
timeout: number;
|
|
66
|
+
/** Whether to normalize edge weights to [0, 1] */
|
|
67
|
+
normalizeWeights: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Default configuration for MinCut analyzer
|
|
71
|
+
*
|
|
72
|
+
* Uses Stoer-Wagner algorithm with a 10,000 node limit and 30 second timeout.
|
|
73
|
+
* For optimal performance, graphs should have < 500 nodes.
|
|
74
|
+
*/
|
|
75
|
+
export declare const DEFAULT_MINCUT_CONFIG: MinCutConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Internal representation of the graph for MinCut algorithms
|
|
78
|
+
*/
|
|
79
|
+
export interface MinCutGraph {
|
|
80
|
+
/** Adjacency list: nodeId -> { neighborId: weight } */
|
|
81
|
+
adjacency: Map<string, Map<string, number>>;
|
|
82
|
+
/** All node IDs */
|
|
83
|
+
nodes: string[];
|
|
84
|
+
/** Total number of nodes */
|
|
85
|
+
nodeCount: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Result of a single phase in the Stoer-Wagner algorithm
|
|
89
|
+
*/
|
|
90
|
+
export interface StoerWagnerPhase {
|
|
91
|
+
/** The s-t cut value from this phase */
|
|
92
|
+
cutValue: number;
|
|
93
|
+
/** The node that was merged (t) */
|
|
94
|
+
mergedNode: string;
|
|
95
|
+
/** The node it was merged into (s) */
|
|
96
|
+
targetNode: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Result of module coupling analysis
|
|
100
|
+
*/
|
|
101
|
+
export interface ModuleCouplingResult {
|
|
102
|
+
/** First module (file or directory path) */
|
|
103
|
+
module1: string;
|
|
104
|
+
/** Second module (file or directory path) */
|
|
105
|
+
module2: string;
|
|
106
|
+
/** Coupling strength (0-1, higher = more coupled) */
|
|
107
|
+
couplingStrength: number;
|
|
108
|
+
/** Shared dependencies between modules */
|
|
109
|
+
sharedDependencies: string[];
|
|
110
|
+
/** Whether a circular dependency exists */
|
|
111
|
+
circularDependency: boolean;
|
|
112
|
+
/** Edges that were cut */
|
|
113
|
+
cutEdges: CutEdge[];
|
|
114
|
+
/** Actionable recommendations for reducing coupling */
|
|
115
|
+
recommendations: string[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Result of circular dependency detection
|
|
119
|
+
*/
|
|
120
|
+
export interface CircularDependencyResult {
|
|
121
|
+
/** Files involved in the circular dependency */
|
|
122
|
+
cycle: string[];
|
|
123
|
+
/** Suggested break points to resolve the cycle */
|
|
124
|
+
breakPoints: BreakPoint[];
|
|
125
|
+
/** Severity of the circular dependency */
|
|
126
|
+
severity: 'low' | 'medium' | 'high';
|
|
127
|
+
/** Recommendations for fixing the cycle */
|
|
128
|
+
recommendations: string[];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A suggested point to break a circular dependency
|
|
132
|
+
*/
|
|
133
|
+
export interface BreakPoint {
|
|
134
|
+
/** Source file/entity in the dependency */
|
|
135
|
+
source: string;
|
|
136
|
+
/** Target file/entity in the dependency */
|
|
137
|
+
target: string;
|
|
138
|
+
/** Type of edge that should be broken */
|
|
139
|
+
edgeType: string;
|
|
140
|
+
/** Estimated effort to break this dependency */
|
|
141
|
+
effort: 'low' | 'medium' | 'high';
|
|
142
|
+
/** Specific suggestion for how to break the dependency */
|
|
143
|
+
suggestion: string;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/code-intelligence/analysis/mincut/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,uCAAuC;IACvC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,qDAAqD;IACrD,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,kFAAkF;IAClF,aAAa,EAAE,cAAc,CAAC;IAC9B,oDAAoD;IACpD,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;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AC;IACnB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,2CAA2C;IAC3C,kBAAkB,EAAE,OAAO,CAAC;IAC5B,0BAA0B;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,uDAAuD;IACvD,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,gDAAgD;IAChD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kDAAkD;IAClD,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,0CAA0C;IAC1C,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,2CAA2C;IAC3C,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAClC,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_MINCUT_CONFIG = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default configuration for MinCut analyzer
|
|
6
|
+
*
|
|
7
|
+
* Uses Stoer-Wagner algorithm with a 10,000 node limit and 30 second timeout.
|
|
8
|
+
* For optimal performance, graphs should have < 500 nodes.
|
|
9
|
+
*/
|
|
10
|
+
exports.DEFAULT_MINCUT_CONFIG = {
|
|
11
|
+
algorithm: 'stoer-wagner',
|
|
12
|
+
maxNodes: 10000,
|
|
13
|
+
timeout: 30000,
|
|
14
|
+
normalizeWeights: true,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/code-intelligence/analysis/mincut/types.ts"],"names":[],"mappings":";;;AAyEA;;;;;GAKG;AACU,QAAA,qBAAqB,GAAiB;IACjD,SAAS,EAAE,cAAc;IACzB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,gBAAgB,EAAE,IAAI;CACvB,CAAC"}
|