@monoes/monomindcli 1.15.3 → 1.15.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/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +7 -0
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/coherence/causal-infer.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/causal-infer.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/causal-infer.js +347 -0
- package/dist/src/mcp-tools/coherence/causal-infer.js.map +1 -0
- package/dist/src/mcp-tools/coherence/coherence-check.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/coherence-check.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/coherence-check.js +206 -0
- package/dist/src/mcp-tools/coherence/coherence-check.js.map +1 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.js +303 -0
- package/dist/src/mcp-tools/coherence/consensus-verify.js.map +1 -0
- package/dist/src/mcp-tools/coherence/memory-gate.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/memory-gate.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/memory-gate.js +266 -0
- package/dist/src/mcp-tools/coherence/memory-gate.js.map +1 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.js +406 -0
- package/dist/src/mcp-tools/coherence/quantum-topology.js.map +1 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +15 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.js +293 -0
- package/dist/src/mcp-tools/coherence/spectral-analyze.js.map +1 -0
- package/dist/src/mcp-tools/coherence/types.d.ts +277 -0
- package/dist/src/mcp-tools/coherence/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence/types.js +159 -0
- package/dist/src/mcp-tools/coherence/types.js.map +1 -0
- package/dist/src/mcp-tools/coherence-tools.d.ts +9 -0
- package/dist/src/mcp-tools/coherence-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/coherence-tools.js +25 -0
- package/dist/src/mcp-tools/coherence-tools.js.map +1 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.d.ts +163 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.js +414 -0
- package/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.js.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.d.ts +128 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.js +375 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.js.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +161 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +423 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.d.ts +165 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.js +395 -0
- package/dist/src/mcp-tools/quality/coverage-analysis/track-trends.js.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.d.ts +165 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.js +508 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.js.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.d.ts +147 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.js +391 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.js.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.d.ts +147 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.js +422 -0
- package/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.js.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.d.ts +185 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.js +437 -0
- package/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.js.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.d.ts +166 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.js +410 -0
- package/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.js.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.d.ts +201 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.js +363 -0
- package/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.js.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.d.ts +166 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.js +394 -0
- package/dist/src/mcp-tools/quality/security-compliance/audit-compliance.js.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +129 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js +383 -0
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.d.ts +171 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.js +476 -0
- package/dist/src/mcp-tools/quality/security-compliance/security-scan.js.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.d.ts +147 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.js +400 -0
- package/dist/src/mcp-tools/quality/test-generation/generate-tests.js.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.d.ts +145 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.js +328 -0
- package/dist/src/mcp-tools/quality/test-generation/suggest-tests.js.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.d.ts +126 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.js +348 -0
- package/dist/src/mcp-tools/quality/test-generation/tdd-cycle.js.map +1 -0
- package/dist/src/mcp-tools/quality-tools.d.ts +9 -0
- package/dist/src/mcp-tools/quality-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/quality-tools.js +308 -0
- package/dist/src/mcp-tools/quality-tools.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calculate-risk.ts - Quality risk calculation MCP tool handler
|
|
3
|
+
*
|
|
4
|
+
* Calculates quality risk scores based on code complexity, test coverage,
|
|
5
|
+
* change frequency, defect history, and other factors.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// Input schema for calculate-risk tool
|
|
9
|
+
export const CalculateRiskInputSchema = z.object({
|
|
10
|
+
targetPath: z.string().describe('Path to file/directory to analyze'),
|
|
11
|
+
factors: z
|
|
12
|
+
.array(z.enum([
|
|
13
|
+
'complexity',
|
|
14
|
+
'coverage',
|
|
15
|
+
'change-frequency',
|
|
16
|
+
'defect-density',
|
|
17
|
+
'age',
|
|
18
|
+
'coupling',
|
|
19
|
+
'size',
|
|
20
|
+
'team-experience',
|
|
21
|
+
'documentation',
|
|
22
|
+
]))
|
|
23
|
+
.default(['complexity', 'coverage', 'change-frequency', 'defect-density'])
|
|
24
|
+
.describe('Risk factors to consider'),
|
|
25
|
+
weights: z
|
|
26
|
+
.object({
|
|
27
|
+
complexity: z.number().min(0).max(1).default(0.2),
|
|
28
|
+
coverage: z.number().min(0).max(1).default(0.25),
|
|
29
|
+
changeFrequency: z.number().min(0).max(1).default(0.2),
|
|
30
|
+
defectDensity: z.number().min(0).max(1).default(0.15),
|
|
31
|
+
age: z.number().min(0).max(1).default(0.05),
|
|
32
|
+
coupling: z.number().min(0).max(1).default(0.05),
|
|
33
|
+
size: z.number().min(0).max(1).default(0.05),
|
|
34
|
+
teamExperience: z.number().min(0).max(1).default(0.025),
|
|
35
|
+
documentation: z.number().min(0).max(1).default(0.025),
|
|
36
|
+
})
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Custom weights for risk factors'),
|
|
39
|
+
granularity: z
|
|
40
|
+
.enum(['file', 'module', 'function', 'project'])
|
|
41
|
+
.default('file')
|
|
42
|
+
.describe('Level of granularity for analysis'),
|
|
43
|
+
riskThresholds: z
|
|
44
|
+
.object({
|
|
45
|
+
low: z.number().default(30),
|
|
46
|
+
medium: z.number().default(60),
|
|
47
|
+
high: z.number().default(80),
|
|
48
|
+
})
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('Thresholds for risk categorization'),
|
|
51
|
+
includeRecommendations: z.boolean().default(true).describe('Include mitigation recommendations'),
|
|
52
|
+
});
|
|
53
|
+
// Default weights
|
|
54
|
+
const DEFAULT_WEIGHTS = {
|
|
55
|
+
complexity: 0.2,
|
|
56
|
+
coverage: 0.25,
|
|
57
|
+
changeFrequency: 0.2,
|
|
58
|
+
defectDensity: 0.15,
|
|
59
|
+
age: 0.05,
|
|
60
|
+
coupling: 0.05,
|
|
61
|
+
size: 0.05,
|
|
62
|
+
teamExperience: 0.025,
|
|
63
|
+
documentation: 0.025,
|
|
64
|
+
};
|
|
65
|
+
// Default thresholds
|
|
66
|
+
const DEFAULT_THRESHOLDS = { low: 30, medium: 60, high: 80 };
|
|
67
|
+
/**
|
|
68
|
+
* MCP Tool Handler for calculate-risk
|
|
69
|
+
*/
|
|
70
|
+
export async function handler(input, context) {
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
try {
|
|
73
|
+
// Validate input
|
|
74
|
+
const validatedInput = CalculateRiskInputSchema.parse(input);
|
|
75
|
+
// Get memory bridge for historical data
|
|
76
|
+
const bridge = context.get('aqe.bridge');
|
|
77
|
+
// Merge weights
|
|
78
|
+
const weights = { ...DEFAULT_WEIGHTS, ...validatedInput.weights };
|
|
79
|
+
const thresholds = { ...DEFAULT_THRESHOLDS, ...validatedInput.riskThresholds };
|
|
80
|
+
// Analyze components
|
|
81
|
+
const componentRisks = await analyzeComponents(validatedInput.targetPath, validatedInput.granularity, validatedInput.factors, weights);
|
|
82
|
+
// Calculate factor contributions
|
|
83
|
+
const factorContributions = calculateFactorContributions(componentRisks, validatedInput.factors, weights);
|
|
84
|
+
// Calculate overall risk
|
|
85
|
+
const overallRisk = calculateOverallRisk(componentRisks, thresholds);
|
|
86
|
+
// Identify hotspots
|
|
87
|
+
const hotspots = identifyHotspots(componentRisks, thresholds);
|
|
88
|
+
// Generate recommendations
|
|
89
|
+
const recommendations = validatedInput.includeRecommendations
|
|
90
|
+
? generateRecommendations(factorContributions, hotspots)
|
|
91
|
+
: [];
|
|
92
|
+
// Analyze trends
|
|
93
|
+
const trendAnalysis = await analyzeTrends(validatedInput.targetPath, bridge);
|
|
94
|
+
// Build result
|
|
95
|
+
const result = {
|
|
96
|
+
success: true,
|
|
97
|
+
overallRisk,
|
|
98
|
+
componentRisks,
|
|
99
|
+
factorContributions,
|
|
100
|
+
hotspots,
|
|
101
|
+
recommendations,
|
|
102
|
+
trendAnalysis,
|
|
103
|
+
metadata: {
|
|
104
|
+
calculatedAt: new Date().toISOString(),
|
|
105
|
+
durationMs: Date.now() - startTime,
|
|
106
|
+
targetPath: validatedInput.targetPath,
|
|
107
|
+
componentsAnalyzed: componentRisks.length,
|
|
108
|
+
factorsUsed: validatedInput.factors,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: 'text',
|
|
115
|
+
text: JSON.stringify(result, null, 2),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: 'text',
|
|
126
|
+
text: JSON.stringify({
|
|
127
|
+
success: false,
|
|
128
|
+
error: errorMessage,
|
|
129
|
+
metadata: {
|
|
130
|
+
calculatedAt: new Date().toISOString(),
|
|
131
|
+
durationMs: Date.now() - startTime,
|
|
132
|
+
},
|
|
133
|
+
}, null, 2),
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function analyzeComponents(targetPath, granularity, factors, weights) {
|
|
140
|
+
// Simulated component analysis
|
|
141
|
+
// In real implementation, would parse code and calculate metrics
|
|
142
|
+
const components = generateSimulatedComponents(targetPath, granularity);
|
|
143
|
+
return components.map((component) => {
|
|
144
|
+
const factorScores = {};
|
|
145
|
+
let weightedSum = 0;
|
|
146
|
+
let totalWeight = 0;
|
|
147
|
+
for (const factor of factors) {
|
|
148
|
+
const score = calculateFactorScore(factor, component);
|
|
149
|
+
factorScores[factor] = score;
|
|
150
|
+
const weightKey = factor.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
151
|
+
const weight = weights[weightKey] || 0.1;
|
|
152
|
+
weightedSum += score * weight;
|
|
153
|
+
totalWeight += weight;
|
|
154
|
+
}
|
|
155
|
+
const riskScore = totalWeight > 0 ? Math.round((weightedSum / totalWeight) * 100) / 100 : 0;
|
|
156
|
+
const riskLevel = scoreToLevel(riskScore * 100);
|
|
157
|
+
return {
|
|
158
|
+
path: component.path,
|
|
159
|
+
type: granularity,
|
|
160
|
+
riskScore,
|
|
161
|
+
riskLevel,
|
|
162
|
+
factors: factorScores,
|
|
163
|
+
topIssues: identifyTopIssues(factorScores),
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function generateSimulatedComponents(targetPath, granularity) {
|
|
168
|
+
const basePath = targetPath.replace(/\.[^.]+$/, '');
|
|
169
|
+
if (granularity === 'function') {
|
|
170
|
+
return [
|
|
171
|
+
{ path: `${basePath}::processInput`, lines: 25, complexity: 8, coverage: 85, changes: 5, defects: 1, age: 90 },
|
|
172
|
+
{ path: `${basePath}::validateConfig`, lines: 40, complexity: 12, coverage: 60, changes: 8, defects: 3, age: 180 },
|
|
173
|
+
{ path: `${basePath}::handleError`, lines: 15, complexity: 4, coverage: 45, changes: 2, defects: 0, age: 120 },
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
return [
|
|
177
|
+
{ path: `${basePath}/core.ts`, lines: 350, complexity: 45, coverage: 78, changes: 15, defects: 4, age: 365 },
|
|
178
|
+
{ path: `${basePath}/utils.ts`, lines: 150, complexity: 18, coverage: 92, changes: 8, defects: 1, age: 180 },
|
|
179
|
+
{ path: `${basePath}/handlers.ts`, lines: 280, complexity: 32, coverage: 65, changes: 22, defects: 6, age: 90 },
|
|
180
|
+
{ path: `${basePath}/validators.ts`, lines: 120, complexity: 15, coverage: 88, changes: 5, defects: 0, age: 120 },
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
function calculateFactorScore(factor, component) {
|
|
184
|
+
switch (factor) {
|
|
185
|
+
case 'complexity':
|
|
186
|
+
// Higher complexity = higher risk
|
|
187
|
+
return Math.min(component.complexity / 50, 1);
|
|
188
|
+
case 'coverage':
|
|
189
|
+
// Lower coverage = higher risk
|
|
190
|
+
return Math.max(0, 1 - component.coverage / 100);
|
|
191
|
+
case 'change-frequency':
|
|
192
|
+
// More changes = higher risk
|
|
193
|
+
return Math.min(component.changes / 20, 1);
|
|
194
|
+
case 'defect-density':
|
|
195
|
+
// More defects per line = higher risk
|
|
196
|
+
const density = component.defects / (component.lines / 100);
|
|
197
|
+
return Math.min(density / 5, 1);
|
|
198
|
+
case 'age':
|
|
199
|
+
// Older code = higher risk (if not maintained)
|
|
200
|
+
return Math.min(component.age / 365, 1);
|
|
201
|
+
case 'coupling':
|
|
202
|
+
// Simulated coupling score
|
|
203
|
+
return Math.random() * 0.5 + 0.2;
|
|
204
|
+
case 'size':
|
|
205
|
+
// Larger files = higher risk
|
|
206
|
+
return Math.min(component.lines / 500, 1);
|
|
207
|
+
case 'team-experience':
|
|
208
|
+
// Simulated team experience
|
|
209
|
+
return 1 - (Math.random() * 0.3 + 0.5);
|
|
210
|
+
case 'documentation':
|
|
211
|
+
// Simulated documentation score
|
|
212
|
+
return 1 - (Math.random() * 0.4 + 0.4);
|
|
213
|
+
default:
|
|
214
|
+
return 0.5;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function scoreToLevel(score) {
|
|
218
|
+
if (score >= 80)
|
|
219
|
+
return 'critical';
|
|
220
|
+
if (score >= 60)
|
|
221
|
+
return 'high';
|
|
222
|
+
if (score >= 30)
|
|
223
|
+
return 'medium';
|
|
224
|
+
return 'low';
|
|
225
|
+
}
|
|
226
|
+
function identifyTopIssues(factors) {
|
|
227
|
+
const issues = [];
|
|
228
|
+
const sortedFactors = Object.entries(factors).sort(([, a], [, b]) => b - a);
|
|
229
|
+
for (const [factor, score] of sortedFactors.slice(0, 3)) {
|
|
230
|
+
if (score > 0.5) {
|
|
231
|
+
const issueMap = {
|
|
232
|
+
complexity: 'High cyclomatic complexity',
|
|
233
|
+
coverage: 'Insufficient test coverage',
|
|
234
|
+
'change-frequency': 'Frequently modified code',
|
|
235
|
+
'defect-density': 'High defect density',
|
|
236
|
+
age: 'Legacy code requiring attention',
|
|
237
|
+
coupling: 'High coupling to other modules',
|
|
238
|
+
size: 'Large component size',
|
|
239
|
+
'team-experience': 'Limited team familiarity',
|
|
240
|
+
documentation: 'Inadequate documentation',
|
|
241
|
+
};
|
|
242
|
+
issues.push(issueMap[factor] || `High ${factor} risk`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return issues;
|
|
246
|
+
}
|
|
247
|
+
function calculateFactorContributions(componentRisks, factors, weights) {
|
|
248
|
+
const contributions = [];
|
|
249
|
+
for (const factor of factors) {
|
|
250
|
+
const avgRawScore = componentRisks.reduce((sum, c) => sum + (c.factors[factor] || 0), 0) / componentRisks.length;
|
|
251
|
+
const weightKey = factor.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
252
|
+
const weight = weights[weightKey] || 0.1;
|
|
253
|
+
const weightedScore = avgRawScore * weight;
|
|
254
|
+
contributions.push({
|
|
255
|
+
factor,
|
|
256
|
+
weight,
|
|
257
|
+
rawScore: Math.round(avgRawScore * 100) / 100,
|
|
258
|
+
weightedScore: Math.round(weightedScore * 100) / 100,
|
|
259
|
+
percentageContribution: 0, // Will be calculated after
|
|
260
|
+
details: generateFactorDetails(factor, avgRawScore),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
// Calculate percentage contributions
|
|
264
|
+
const totalWeighted = contributions.reduce((sum, c) => sum + c.weightedScore, 0);
|
|
265
|
+
for (const contrib of contributions) {
|
|
266
|
+
contrib.percentageContribution = totalWeighted > 0
|
|
267
|
+
? Math.round((contrib.weightedScore / totalWeighted) * 100)
|
|
268
|
+
: 0;
|
|
269
|
+
}
|
|
270
|
+
return contributions.sort((a, b) => b.weightedScore - a.weightedScore);
|
|
271
|
+
}
|
|
272
|
+
function generateFactorDetails(factor, score) {
|
|
273
|
+
const detailsMap = {
|
|
274
|
+
complexity: `Average complexity score: ${Math.round(score * 50)}`,
|
|
275
|
+
coverage: `Coverage gap: ${Math.round(score * 100)}%`,
|
|
276
|
+
'change-frequency': `Change rate: ${Math.round(score * 20)} changes/quarter`,
|
|
277
|
+
'defect-density': `Defect density: ${Math.round(score * 5)} per 100 LOC`,
|
|
278
|
+
age: `Average age: ${Math.round(score * 365)} days`,
|
|
279
|
+
coupling: `Coupling factor: ${Math.round(score * 100)}%`,
|
|
280
|
+
size: `Average size: ${Math.round(score * 500)} lines`,
|
|
281
|
+
'team-experience': `Team familiarity: ${Math.round((1 - score) * 100)}%`,
|
|
282
|
+
documentation: `Documentation coverage: ${Math.round((1 - score) * 100)}%`,
|
|
283
|
+
};
|
|
284
|
+
return detailsMap[factor] || `Score: ${Math.round(score * 100)}%`;
|
|
285
|
+
}
|
|
286
|
+
function calculateOverallRisk(componentRisks, thresholds) {
|
|
287
|
+
if (componentRisks.length === 0) {
|
|
288
|
+
return {
|
|
289
|
+
score: 0,
|
|
290
|
+
level: 'low',
|
|
291
|
+
confidence: 0,
|
|
292
|
+
breakdown: {},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
// Weighted average based on component risk
|
|
296
|
+
const totalScore = componentRisks.reduce((sum, c) => sum + c.riskScore, 0);
|
|
297
|
+
const avgScore = (totalScore / componentRisks.length) * 100;
|
|
298
|
+
// Calculate breakdown by risk level
|
|
299
|
+
const breakdown = {
|
|
300
|
+
low: componentRisks.filter((c) => c.riskLevel === 'low').length,
|
|
301
|
+
medium: componentRisks.filter((c) => c.riskLevel === 'medium').length,
|
|
302
|
+
high: componentRisks.filter((c) => c.riskLevel === 'high').length,
|
|
303
|
+
critical: componentRisks.filter((c) => c.riskLevel === 'critical').length,
|
|
304
|
+
};
|
|
305
|
+
// Confidence based on number of components analyzed
|
|
306
|
+
const confidence = Math.min(componentRisks.length / 10, 1);
|
|
307
|
+
return {
|
|
308
|
+
score: Math.round(avgScore * 10) / 10,
|
|
309
|
+
level: scoreToLevel(avgScore),
|
|
310
|
+
confidence: Math.round(confidence * 100) / 100,
|
|
311
|
+
breakdown,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function identifyHotspots(componentRisks, thresholds) {
|
|
315
|
+
return componentRisks
|
|
316
|
+
.filter((c) => c.riskScore * 100 >= thresholds.medium)
|
|
317
|
+
.sort((a, b) => b.riskScore - a.riskScore)
|
|
318
|
+
.slice(0, 5)
|
|
319
|
+
.map((c) => {
|
|
320
|
+
const topFactor = Object.entries(c.factors).sort(([, a], [, b]) => b - a)[0];
|
|
321
|
+
return {
|
|
322
|
+
path: c.path,
|
|
323
|
+
riskScore: Math.round(c.riskScore * 100),
|
|
324
|
+
primaryFactor: topFactor[0],
|
|
325
|
+
description: c.topIssues[0] || 'Multiple risk factors',
|
|
326
|
+
urgency: c.riskLevel === 'critical' ? 'immediate' : c.riskLevel === 'high' ? 'short-term' : 'long-term',
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function generateRecommendations(factorContributions, hotspots) {
|
|
331
|
+
const recommendations = [];
|
|
332
|
+
let priority = 1;
|
|
333
|
+
// Recommendations based on top contributing factors
|
|
334
|
+
for (const contrib of factorContributions.slice(0, 3)) {
|
|
335
|
+
const recommendationMap = {
|
|
336
|
+
complexity: {
|
|
337
|
+
action: 'Refactor complex functions into smaller, more manageable units',
|
|
338
|
+
impact: 'Reduced cognitive load and easier testing',
|
|
339
|
+
effort: 'medium',
|
|
340
|
+
},
|
|
341
|
+
coverage: {
|
|
342
|
+
action: 'Add unit tests targeting uncovered code paths',
|
|
343
|
+
impact: 'Improved defect detection and regression prevention',
|
|
344
|
+
effort: 'medium',
|
|
345
|
+
},
|
|
346
|
+
'change-frequency': {
|
|
347
|
+
action: 'Stabilize frequently changing components with better abstractions',
|
|
348
|
+
impact: 'Reduced change risk and improved maintainability',
|
|
349
|
+
effort: 'high',
|
|
350
|
+
},
|
|
351
|
+
'defect-density': {
|
|
352
|
+
action: 'Conduct focused code review and add defensive coding practices',
|
|
353
|
+
impact: 'Lower defect rate and improved reliability',
|
|
354
|
+
effort: 'medium',
|
|
355
|
+
},
|
|
356
|
+
age: {
|
|
357
|
+
action: 'Modernize legacy code with incremental refactoring',
|
|
358
|
+
impact: 'Improved maintainability and reduced technical debt',
|
|
359
|
+
effort: 'high',
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
const rec = recommendationMap[contrib.factor];
|
|
363
|
+
if (rec && contrib.rawScore > 0.4) {
|
|
364
|
+
recommendations.push({
|
|
365
|
+
priority: priority++,
|
|
366
|
+
factor: contrib.factor,
|
|
367
|
+
action: rec.action,
|
|
368
|
+
expectedImpact: rec.impact,
|
|
369
|
+
effort: rec.effort,
|
|
370
|
+
affectedComponents: hotspots
|
|
371
|
+
.filter((h) => h.primaryFactor === contrib.factor)
|
|
372
|
+
.map((h) => h.path),
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return recommendations;
|
|
377
|
+
}
|
|
378
|
+
async function analyzeTrends(targetPath, bridge) {
|
|
379
|
+
// Simulated historical data
|
|
380
|
+
const historicalScores = [
|
|
381
|
+
{ date: '2026-01-01', score: 55 },
|
|
382
|
+
{ date: '2026-01-08', score: 52 },
|
|
383
|
+
{ date: '2026-01-15', score: 48 },
|
|
384
|
+
{ date: '2026-01-22', score: 45 },
|
|
385
|
+
];
|
|
386
|
+
const first = historicalScores[0].score;
|
|
387
|
+
const last = historicalScores[historicalScores.length - 1].score;
|
|
388
|
+
const change = last - first;
|
|
389
|
+
const changePercent = (change / first) * 100;
|
|
390
|
+
// Project future score
|
|
391
|
+
const trend = (last - first) / historicalScores.length;
|
|
392
|
+
const projection = Math.max(0, Math.min(100, last + trend * 4));
|
|
393
|
+
return {
|
|
394
|
+
direction: changePercent < -5 ? 'improving' : changePercent > 5 ? 'worsening' : 'stable',
|
|
395
|
+
changePercent: Math.round(changePercent * 10) / 10,
|
|
396
|
+
historicalScores,
|
|
397
|
+
projection: Math.round(projection),
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
// Export tool definition for MCP registration
|
|
401
|
+
export const toolDefinition = {
|
|
402
|
+
name: 'aqe/calculate-risk',
|
|
403
|
+
description: 'Calculate quality risk scores based on multiple weighted factors',
|
|
404
|
+
category: 'quality-assessment',
|
|
405
|
+
version: '3.2.3',
|
|
406
|
+
inputSchema: CalculateRiskInputSchema,
|
|
407
|
+
handler,
|
|
408
|
+
};
|
|
409
|
+
export default toolDefinition;
|
|
410
|
+
//# sourceMappingURL=calculate-risk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-risk.js","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/quality-assessment/calculate-risk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACpE,OAAO,EAAE,CAAC;SACP,KAAK,CACJ,CAAC,CAAC,IAAI,CAAC;QACL,YAAY;QACZ,UAAU;QACV,kBAAkB;QAClB,gBAAgB;QAChB,KAAK;QACL,UAAU;QACV,MAAM;QACN,iBAAiB;QACj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C,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ;QACxF,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,EAAE,CAAC,GAAG,EAAE;QAClD,gBAAgB;QAChB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;KACnC,CAAC;AACJ,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,kEAAkE;IAC/E,QAAQ,EAAE,oBAAoB;IAC9B,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,wBAAwB;IACrC,OAAO;CACR,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evaluate-quality-gate.ts - Quality gate evaluation MCP tool handler
|
|
3
|
+
*
|
|
4
|
+
* Evaluates quality gates against defined thresholds to determine
|
|
5
|
+
* release readiness. Supports multiple metrics and custom gate configurations.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export declare const EvaluateQualityGateInputSchema: z.ZodObject<{
|
|
9
|
+
gates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
10
|
+
metric: z.ZodString;
|
|
11
|
+
operator: z.ZodEnum<{
|
|
12
|
+
">": ">";
|
|
13
|
+
"<": "<";
|
|
14
|
+
">=": ">=";
|
|
15
|
+
"<=": "<=";
|
|
16
|
+
"==": "==";
|
|
17
|
+
}>;
|
|
18
|
+
threshold: z.ZodNumber;
|
|
19
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
blocking: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
+
}, z.core.$strip>>>;
|
|
22
|
+
defaults: z.ZodDefault<z.ZodEnum<{
|
|
23
|
+
minimal: "minimal";
|
|
24
|
+
standard: "standard";
|
|
25
|
+
strict: "strict";
|
|
26
|
+
}>>;
|
|
27
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
28
|
+
includeMetrics: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
29
|
+
security: "security";
|
|
30
|
+
coverage: "coverage";
|
|
31
|
+
complexity: "complexity";
|
|
32
|
+
bugs: "bugs";
|
|
33
|
+
vulnerabilities: "vulnerabilities";
|
|
34
|
+
"code-smells": "code-smells";
|
|
35
|
+
duplications: "duplications";
|
|
36
|
+
"technical-debt": "technical-debt";
|
|
37
|
+
reliability: "reliability";
|
|
38
|
+
maintainability: "maintainability";
|
|
39
|
+
}>>>;
|
|
40
|
+
failFast: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
generateReport: z.ZodDefault<z.ZodBoolean>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type EvaluateQualityGateInput = z.infer<typeof EvaluateQualityGateInputSchema>;
|
|
44
|
+
export interface EvaluateQualityGateOutput {
|
|
45
|
+
success: boolean;
|
|
46
|
+
passed: boolean;
|
|
47
|
+
overallScore: number;
|
|
48
|
+
gateResults: GateResult[];
|
|
49
|
+
metrics: CollectedMetrics;
|
|
50
|
+
blockers: GateResult[];
|
|
51
|
+
warnings: GateResult[];
|
|
52
|
+
report: QualityReport | null;
|
|
53
|
+
metadata: QualityGateMetadata;
|
|
54
|
+
}
|
|
55
|
+
export interface GateResult {
|
|
56
|
+
metric: string;
|
|
57
|
+
operator: string;
|
|
58
|
+
threshold: number;
|
|
59
|
+
actual: number;
|
|
60
|
+
passed: boolean;
|
|
61
|
+
blocking: boolean;
|
|
62
|
+
weight: number;
|
|
63
|
+
deviation: number;
|
|
64
|
+
message: string;
|
|
65
|
+
}
|
|
66
|
+
export interface CollectedMetrics {
|
|
67
|
+
coverage: CoverageMetrics;
|
|
68
|
+
bugs: BugMetrics;
|
|
69
|
+
vulnerabilities: VulnerabilityMetrics;
|
|
70
|
+
codeSmells: CodeSmellMetrics;
|
|
71
|
+
duplications: DuplicationMetrics;
|
|
72
|
+
complexity: ComplexityMetrics;
|
|
73
|
+
technicalDebt: TechnicalDebtMetrics;
|
|
74
|
+
ratings: QualityRatings;
|
|
75
|
+
}
|
|
76
|
+
export interface CoverageMetrics {
|
|
77
|
+
line: number;
|
|
78
|
+
branch: number;
|
|
79
|
+
function: number;
|
|
80
|
+
overall: number;
|
|
81
|
+
}
|
|
82
|
+
export interface BugMetrics {
|
|
83
|
+
total: number;
|
|
84
|
+
critical: number;
|
|
85
|
+
major: number;
|
|
86
|
+
minor: number;
|
|
87
|
+
}
|
|
88
|
+
export interface VulnerabilityMetrics {
|
|
89
|
+
total: number;
|
|
90
|
+
critical: number;
|
|
91
|
+
high: number;
|
|
92
|
+
medium: number;
|
|
93
|
+
low: number;
|
|
94
|
+
}
|
|
95
|
+
export interface CodeSmellMetrics {
|
|
96
|
+
total: number;
|
|
97
|
+
debt: string;
|
|
98
|
+
ratio: number;
|
|
99
|
+
}
|
|
100
|
+
export interface DuplicationMetrics {
|
|
101
|
+
lines: number;
|
|
102
|
+
blocks: number;
|
|
103
|
+
percentage: number;
|
|
104
|
+
}
|
|
105
|
+
export interface ComplexityMetrics {
|
|
106
|
+
cyclomatic: number;
|
|
107
|
+
cognitive: number;
|
|
108
|
+
avgPerFunction: number;
|
|
109
|
+
}
|
|
110
|
+
export interface TechnicalDebtMetrics {
|
|
111
|
+
total: string;
|
|
112
|
+
ratio: number;
|
|
113
|
+
rating: 'A' | 'B' | 'C' | 'D' | 'E';
|
|
114
|
+
}
|
|
115
|
+
export interface QualityRatings {
|
|
116
|
+
reliability: 'A' | 'B' | 'C' | 'D' | 'E';
|
|
117
|
+
security: 'A' | 'B' | 'C' | 'D' | 'E';
|
|
118
|
+
maintainability: 'A' | 'B' | 'C' | 'D' | 'E';
|
|
119
|
+
}
|
|
120
|
+
export interface QualityReport {
|
|
121
|
+
summary: string;
|
|
122
|
+
recommendations: string[];
|
|
123
|
+
trends: TrendComparison[];
|
|
124
|
+
riskAreas: RiskArea[];
|
|
125
|
+
}
|
|
126
|
+
export interface TrendComparison {
|
|
127
|
+
metric: string;
|
|
128
|
+
previous: number;
|
|
129
|
+
current: number;
|
|
130
|
+
trend: 'improving' | 'stable' | 'declining';
|
|
131
|
+
}
|
|
132
|
+
export interface RiskArea {
|
|
133
|
+
name: string;
|
|
134
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
135
|
+
description: string;
|
|
136
|
+
files: string[];
|
|
137
|
+
}
|
|
138
|
+
export interface QualityGateMetadata {
|
|
139
|
+
evaluatedAt: string;
|
|
140
|
+
durationMs: number;
|
|
141
|
+
preset: string;
|
|
142
|
+
totalGates: number;
|
|
143
|
+
passedGates: number;
|
|
144
|
+
failedGates: number;
|
|
145
|
+
}
|
|
146
|
+
export interface ToolContext {
|
|
147
|
+
get<T>(key: string): T | undefined;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* MCP Tool Handler for evaluate-quality-gate
|
|
151
|
+
*/
|
|
152
|
+
export declare function handler(input: EvaluateQualityGateInput, context: ToolContext): Promise<{
|
|
153
|
+
content: Array<{
|
|
154
|
+
type: 'text';
|
|
155
|
+
text: string;
|
|
156
|
+
}>;
|
|
157
|
+
}>;
|
|
158
|
+
export declare const toolDefinition: {
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
category: string;
|
|
162
|
+
version: string;
|
|
163
|
+
inputSchema: z.ZodObject<{
|
|
164
|
+
gates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
165
|
+
metric: z.ZodString;
|
|
166
|
+
operator: z.ZodEnum<{
|
|
167
|
+
">": ">";
|
|
168
|
+
"<": "<";
|
|
169
|
+
">=": ">=";
|
|
170
|
+
"<=": "<=";
|
|
171
|
+
"==": "==";
|
|
172
|
+
}>;
|
|
173
|
+
threshold: z.ZodNumber;
|
|
174
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
175
|
+
blocking: z.ZodDefault<z.ZodBoolean>;
|
|
176
|
+
}, z.core.$strip>>>;
|
|
177
|
+
defaults: z.ZodDefault<z.ZodEnum<{
|
|
178
|
+
minimal: "minimal";
|
|
179
|
+
standard: "standard";
|
|
180
|
+
strict: "strict";
|
|
181
|
+
}>>;
|
|
182
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
183
|
+
includeMetrics: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
184
|
+
security: "security";
|
|
185
|
+
coverage: "coverage";
|
|
186
|
+
complexity: "complexity";
|
|
187
|
+
bugs: "bugs";
|
|
188
|
+
vulnerabilities: "vulnerabilities";
|
|
189
|
+
"code-smells": "code-smells";
|
|
190
|
+
duplications: "duplications";
|
|
191
|
+
"technical-debt": "technical-debt";
|
|
192
|
+
reliability: "reliability";
|
|
193
|
+
maintainability: "maintainability";
|
|
194
|
+
}>>>;
|
|
195
|
+
failFast: z.ZodDefault<z.ZodBoolean>;
|
|
196
|
+
generateReport: z.ZodDefault<z.ZodBoolean>;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
handler: typeof handler;
|
|
199
|
+
};
|
|
200
|
+
export default toolDefinition;
|
|
201
|
+
//# sourceMappingURL=evaluate-quality-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-quality-gate.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAGtF,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,Y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