@monoes/monomindcli 1.15.4 → 1.15.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/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/src/plugins/store/discovery.d.ts.map +1 -1
- package/dist/src/plugins/store/discovery.js +4 -124
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/publish-registry.ts +0 -2
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* predict-defects.ts - ML-based defect prediction MCP tool handler
|
|
3
|
+
*
|
|
4
|
+
* Predicts potential defects using machine learning analysis of code
|
|
5
|
+
* complexity, historical patterns, and semantic similarity to known defects.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// Input schema for predict-defects tool
|
|
9
|
+
export const PredictDefectsInputSchema = z.object({
|
|
10
|
+
targetPath: z.string().describe('Path to file/directory to analyze'),
|
|
11
|
+
depth: z
|
|
12
|
+
.enum(['shallow', 'medium', 'deep'])
|
|
13
|
+
.default('medium')
|
|
14
|
+
.describe('Analysis depth - deeper finds more but takes longer'),
|
|
15
|
+
includeRootCause: z.boolean().default(true).describe('Include root cause analysis'),
|
|
16
|
+
minConfidence: z
|
|
17
|
+
.number()
|
|
18
|
+
.min(0)
|
|
19
|
+
.max(1)
|
|
20
|
+
.default(0.6)
|
|
21
|
+
.describe('Minimum confidence threshold for predictions'),
|
|
22
|
+
categories: z
|
|
23
|
+
.array(z.enum([
|
|
24
|
+
'null-pointer',
|
|
25
|
+
'boundary',
|
|
26
|
+
'resource-leak',
|
|
27
|
+
'race-condition',
|
|
28
|
+
'logic-error',
|
|
29
|
+
'security',
|
|
30
|
+
'performance',
|
|
31
|
+
'type-error',
|
|
32
|
+
'exception-handling',
|
|
33
|
+
]))
|
|
34
|
+
.default(['null-pointer', 'boundary', 'logic-error', 'exception-handling'])
|
|
35
|
+
.describe('Defect categories to check'),
|
|
36
|
+
useSimilarPatterns: z.boolean().default(true).describe('Use historical pattern matching'),
|
|
37
|
+
maxPredictions: z.number().min(1).max(100).default(20).describe('Maximum predictions to return'),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* MCP Tool Handler for predict-defects
|
|
41
|
+
*/
|
|
42
|
+
export async function handler(input, context) {
|
|
43
|
+
const startTime = Date.now();
|
|
44
|
+
try {
|
|
45
|
+
// Validate input
|
|
46
|
+
const validatedInput = PredictDefectsInputSchema.parse(input);
|
|
47
|
+
// Get memory bridge for pattern matching
|
|
48
|
+
const bridge = context.get('aqe.bridge');
|
|
49
|
+
// Analyze code for potential defects
|
|
50
|
+
const predictions = await analyzeForDefects(validatedInput.targetPath, validatedInput.categories, validatedInput.depth, validatedInput.minConfidence, validatedInput.includeRootCause);
|
|
51
|
+
// Search for similar historical defects
|
|
52
|
+
const similarDefects = validatedInput.useSimilarPatterns
|
|
53
|
+
? await findSimilarDefects(predictions, bridge)
|
|
54
|
+
: [];
|
|
55
|
+
// Calculate risk summary
|
|
56
|
+
const riskSummary = calculateRiskSummary(predictions);
|
|
57
|
+
// Generate prevention strategies
|
|
58
|
+
const preventionStrategies = generatePreventionStrategies(predictions);
|
|
59
|
+
// Limit results
|
|
60
|
+
const limitedPredictions = predictions
|
|
61
|
+
.sort((a, b) => {
|
|
62
|
+
// Sort by severity then confidence
|
|
63
|
+
const severityOrder = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
64
|
+
const sevDiff = severityOrder[a.severity] - severityOrder[b.severity];
|
|
65
|
+
if (sevDiff !== 0)
|
|
66
|
+
return sevDiff;
|
|
67
|
+
return b.confidence - a.confidence;
|
|
68
|
+
})
|
|
69
|
+
.slice(0, validatedInput.maxPredictions);
|
|
70
|
+
// Build result
|
|
71
|
+
const result = {
|
|
72
|
+
success: true,
|
|
73
|
+
predictions: limitedPredictions,
|
|
74
|
+
riskSummary,
|
|
75
|
+
similarDefects,
|
|
76
|
+
preventionStrategies,
|
|
77
|
+
metadata: {
|
|
78
|
+
analyzedAt: new Date().toISOString(),
|
|
79
|
+
durationMs: Date.now() - startTime,
|
|
80
|
+
filesAnalyzed: 1,
|
|
81
|
+
linesAnalyzed: 500,
|
|
82
|
+
patternsMatched: similarDefects.length,
|
|
83
|
+
modelVersion: '3.2.3',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: 'text',
|
|
90
|
+
text: JSON.stringify(result, null, 2),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: 'text',
|
|
101
|
+
text: JSON.stringify({
|
|
102
|
+
success: false,
|
|
103
|
+
error: errorMessage,
|
|
104
|
+
predictions: [],
|
|
105
|
+
metadata: {
|
|
106
|
+
analyzedAt: new Date().toISOString(),
|
|
107
|
+
durationMs: Date.now() - startTime,
|
|
108
|
+
},
|
|
109
|
+
}, null, 2),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function analyzeForDefects(targetPath, categories, depth, minConfidence, includeRootCause) {
|
|
116
|
+
const predictions = [];
|
|
117
|
+
// Generate predictions based on categories
|
|
118
|
+
for (const category of categories) {
|
|
119
|
+
const categoryPredictions = generateCategoryPredictions(category, targetPath, depth, includeRootCause);
|
|
120
|
+
predictions.push(...categoryPredictions);
|
|
121
|
+
}
|
|
122
|
+
// Filter by confidence
|
|
123
|
+
return predictions.filter((p) => p.confidence >= minConfidence);
|
|
124
|
+
}
|
|
125
|
+
function generateCategoryPredictions(category, targetPath, depth, includeRootCause) {
|
|
126
|
+
const depthMultiplier = depth === 'deep' ? 3 : depth === 'medium' ? 2 : 1;
|
|
127
|
+
const categoryPatterns = {
|
|
128
|
+
'null-pointer': [
|
|
129
|
+
{
|
|
130
|
+
severity: 'high',
|
|
131
|
+
description: 'Potential null/undefined dereference without check',
|
|
132
|
+
suggestedFix: 'Add null check before accessing property',
|
|
133
|
+
rootCause: 'Missing null safety check',
|
|
134
|
+
pattern: 'Unchecked optional access',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
severity: 'medium',
|
|
138
|
+
description: 'Optional chaining not used for nullable object',
|
|
139
|
+
suggestedFix: 'Use optional chaining (?.) or nullish coalescing (??)',
|
|
140
|
+
rootCause: 'Inconsistent null handling',
|
|
141
|
+
pattern: 'Direct property access on nullable',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
boundary: [
|
|
145
|
+
{
|
|
146
|
+
severity: 'high',
|
|
147
|
+
description: 'Array index access without bounds check',
|
|
148
|
+
suggestedFix: 'Validate array index before access',
|
|
149
|
+
rootCause: 'Missing bounds validation',
|
|
150
|
+
pattern: 'Direct array indexing',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
severity: 'medium',
|
|
154
|
+
description: 'Potential off-by-one error in loop',
|
|
155
|
+
suggestedFix: 'Review loop bounds and use forEach/map when possible',
|
|
156
|
+
rootCause: 'Manual index management',
|
|
157
|
+
pattern: 'Loop boundary condition',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
'resource-leak': [
|
|
161
|
+
{
|
|
162
|
+
severity: 'critical',
|
|
163
|
+
description: 'Resource not properly closed in error path',
|
|
164
|
+
suggestedFix: 'Use try-finally or using/dispose pattern',
|
|
165
|
+
rootCause: 'Missing cleanup in error handling',
|
|
166
|
+
pattern: 'Unclosed resource in exception path',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
'race-condition': [
|
|
170
|
+
{
|
|
171
|
+
severity: 'high',
|
|
172
|
+
description: 'Shared state modified without synchronization',
|
|
173
|
+
suggestedFix: 'Add mutex/lock or use atomic operations',
|
|
174
|
+
rootCause: 'Unprotected shared state',
|
|
175
|
+
pattern: 'Concurrent access to mutable state',
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
'logic-error': [
|
|
179
|
+
{
|
|
180
|
+
severity: 'medium',
|
|
181
|
+
description: 'Conditional logic may not cover all cases',
|
|
182
|
+
suggestedFix: 'Add exhaustive case handling or default clause',
|
|
183
|
+
rootCause: 'Incomplete branching logic',
|
|
184
|
+
pattern: 'Non-exhaustive conditional',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
severity: 'low',
|
|
188
|
+
description: 'Redundant condition detected',
|
|
189
|
+
suggestedFix: 'Simplify conditional logic',
|
|
190
|
+
rootCause: 'Code complexity',
|
|
191
|
+
pattern: 'Duplicate or redundant check',
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
security: [
|
|
195
|
+
{
|
|
196
|
+
severity: 'critical',
|
|
197
|
+
description: 'User input used without sanitization',
|
|
198
|
+
suggestedFix: 'Sanitize and validate all user input',
|
|
199
|
+
rootCause: 'Missing input validation',
|
|
200
|
+
pattern: 'Unsanitized input flow',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
performance: [
|
|
204
|
+
{
|
|
205
|
+
severity: 'medium',
|
|
206
|
+
description: 'Nested loops with O(n^2) complexity',
|
|
207
|
+
suggestedFix: 'Consider using Map/Set for O(n) lookup',
|
|
208
|
+
rootCause: 'Inefficient algorithm',
|
|
209
|
+
pattern: 'Quadratic time complexity',
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
'type-error': [
|
|
213
|
+
{
|
|
214
|
+
severity: 'medium',
|
|
215
|
+
description: 'Type assertion without runtime check',
|
|
216
|
+
suggestedFix: 'Add type guard or runtime validation',
|
|
217
|
+
rootCause: 'Unsafe type cast',
|
|
218
|
+
pattern: 'Unguarded type assertion',
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
'exception-handling': [
|
|
222
|
+
{
|
|
223
|
+
severity: 'high',
|
|
224
|
+
description: 'Catch block swallows exception without logging',
|
|
225
|
+
suggestedFix: 'Log or rethrow exceptions appropriately',
|
|
226
|
+
rootCause: 'Silent failure pattern',
|
|
227
|
+
pattern: 'Empty catch block',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
severity: 'medium',
|
|
231
|
+
description: 'Generic exception catch may hide specific errors',
|
|
232
|
+
suggestedFix: 'Catch specific exception types',
|
|
233
|
+
rootCause: 'Over-broad exception handling',
|
|
234
|
+
pattern: 'Catch-all exception handler',
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
};
|
|
238
|
+
const patterns = categoryPatterns[category] || [];
|
|
239
|
+
const predictions = [];
|
|
240
|
+
let predictionId = 0;
|
|
241
|
+
const CONFIDENCE_BY_SEVERITY = {
|
|
242
|
+
critical: 0.90,
|
|
243
|
+
high: 0.80,
|
|
244
|
+
medium: 0.70,
|
|
245
|
+
low: 0.60,
|
|
246
|
+
};
|
|
247
|
+
for (const pattern of patterns.slice(0, depthMultiplier)) {
|
|
248
|
+
const confidence = CONFIDENCE_BY_SEVERITY[pattern.severity] ?? 0.70;
|
|
249
|
+
const prediction = {
|
|
250
|
+
id: `pred-${category}-${predictionId++}`,
|
|
251
|
+
category,
|
|
252
|
+
severity: pattern.severity,
|
|
253
|
+
confidence,
|
|
254
|
+
location: {
|
|
255
|
+
file: targetPath,
|
|
256
|
+
},
|
|
257
|
+
description: pattern.description,
|
|
258
|
+
suggestedFix: pattern.suggestedFix,
|
|
259
|
+
evidence: [
|
|
260
|
+
{
|
|
261
|
+
type: 'code-pattern',
|
|
262
|
+
description: pattern.pattern,
|
|
263
|
+
weight: 0.4,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
type: 'static-analysis',
|
|
267
|
+
description: `Static analysis flagged potential ${category}`,
|
|
268
|
+
weight: 0.3,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
type: 'complexity',
|
|
272
|
+
description: 'Function complexity contributes to defect likelihood',
|
|
273
|
+
weight: 0.2,
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
};
|
|
277
|
+
if (includeRootCause) {
|
|
278
|
+
prediction.rootCause = {
|
|
279
|
+
primaryCause: pattern.rootCause,
|
|
280
|
+
contributingFactors: [
|
|
281
|
+
'High code complexity',
|
|
282
|
+
'Insufficient test coverage',
|
|
283
|
+
'Time pressure during development',
|
|
284
|
+
],
|
|
285
|
+
codePattern: pattern.pattern,
|
|
286
|
+
historicalOccurrences: 0,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
predictions.push(prediction);
|
|
290
|
+
}
|
|
291
|
+
return predictions;
|
|
292
|
+
}
|
|
293
|
+
async function findSimilarDefects(predictions, bridge) {
|
|
294
|
+
const similarDefects = [];
|
|
295
|
+
// If bridge available, search for similar patterns
|
|
296
|
+
if (bridge) {
|
|
297
|
+
try {
|
|
298
|
+
for (const prediction of predictions.slice(0, 3)) {
|
|
299
|
+
const patterns = await bridge.searchSimilarPatterns(`defect ${prediction.category} ${prediction.description}`, 3);
|
|
300
|
+
for (let i = 0; i < patterns.length && i < 2; i++) {
|
|
301
|
+
similarDefects.push({
|
|
302
|
+
id: `sim-${prediction.id}-${i}`,
|
|
303
|
+
similarity: 0.75,
|
|
304
|
+
originalDefect: {
|
|
305
|
+
category: prediction.category,
|
|
306
|
+
description: `Historical ${prediction.category} defect`,
|
|
307
|
+
resolution: prediction.suggestedFix,
|
|
308
|
+
file: 'historical/similar-file.ts',
|
|
309
|
+
},
|
|
310
|
+
matchedPattern: prediction.rootCause?.codePattern || 'Unknown pattern',
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
// Continue without similar defects
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return similarDefects.sort((a, b) => b.similarity - a.similarity);
|
|
320
|
+
}
|
|
321
|
+
function calculateRiskSummary(predictions) {
|
|
322
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
323
|
+
for (const pred of predictions) {
|
|
324
|
+
counts[pred.severity]++;
|
|
325
|
+
}
|
|
326
|
+
const avgConfidence = predictions.length > 0
|
|
327
|
+
? predictions.reduce((sum, p) => sum + p.confidence, 0) / predictions.length
|
|
328
|
+
: 0;
|
|
329
|
+
// Identify high-risk areas (files with critical/high predictions)
|
|
330
|
+
const highRiskFiles = new Set();
|
|
331
|
+
for (const pred of predictions) {
|
|
332
|
+
if (pred.severity === 'critical' || pred.severity === 'high') {
|
|
333
|
+
highRiskFiles.add(pred.location.file);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
totalPredictions: predictions.length,
|
|
338
|
+
criticalCount: counts.critical,
|
|
339
|
+
highCount: counts.high,
|
|
340
|
+
mediumCount: counts.medium,
|
|
341
|
+
lowCount: counts.low,
|
|
342
|
+
avgConfidence: Math.round(avgConfidence * 100) / 100,
|
|
343
|
+
highRiskAreas: Array.from(highRiskFiles),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function generatePreventionStrategies(predictions) {
|
|
347
|
+
const categoryStrategies = {
|
|
348
|
+
'null-pointer': {
|
|
349
|
+
strategy: 'Implement strict null checking',
|
|
350
|
+
implementation: 'Enable TypeScript strict mode, use optional chaining, add null guards',
|
|
351
|
+
effectiveness: 0.85,
|
|
352
|
+
},
|
|
353
|
+
boundary: {
|
|
354
|
+
strategy: 'Use safe array access patterns',
|
|
355
|
+
implementation: 'Replace direct indexing with .at(), use forEach/map, add bounds validation',
|
|
356
|
+
effectiveness: 0.80,
|
|
357
|
+
},
|
|
358
|
+
'resource-leak': {
|
|
359
|
+
strategy: 'Implement resource management patterns',
|
|
360
|
+
implementation: 'Use try-finally, implement IDisposable pattern, add cleanup hooks',
|
|
361
|
+
effectiveness: 0.90,
|
|
362
|
+
},
|
|
363
|
+
'race-condition': {
|
|
364
|
+
strategy: 'Add concurrency controls',
|
|
365
|
+
implementation: 'Use mutex/semaphore, implement atomic operations, avoid shared state',
|
|
366
|
+
effectiveness: 0.75,
|
|
367
|
+
},
|
|
368
|
+
'logic-error': {
|
|
369
|
+
strategy: 'Improve code coverage and review',
|
|
370
|
+
implementation: 'Add unit tests for edge cases, implement exhaustive pattern matching',
|
|
371
|
+
effectiveness: 0.70,
|
|
372
|
+
},
|
|
373
|
+
security: {
|
|
374
|
+
strategy: 'Implement input validation layer',
|
|
375
|
+
implementation: 'Add input sanitization, use parameterized queries, implement CSP',
|
|
376
|
+
effectiveness: 0.95,
|
|
377
|
+
},
|
|
378
|
+
performance: {
|
|
379
|
+
strategy: 'Optimize algorithm complexity',
|
|
380
|
+
implementation: 'Use appropriate data structures, implement caching, profile hot paths',
|
|
381
|
+
effectiveness: 0.80,
|
|
382
|
+
},
|
|
383
|
+
'type-error': {
|
|
384
|
+
strategy: 'Strengthen type safety',
|
|
385
|
+
implementation: 'Add type guards, use branded types, implement runtime validation',
|
|
386
|
+
effectiveness: 0.85,
|
|
387
|
+
},
|
|
388
|
+
'exception-handling': {
|
|
389
|
+
strategy: 'Implement structured error handling',
|
|
390
|
+
implementation: 'Create error hierarchy, add logging, implement error boundaries',
|
|
391
|
+
effectiveness: 0.80,
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
const strategies = [];
|
|
395
|
+
const categoriesWithPredictions = new Set(predictions.map((p) => p.category));
|
|
396
|
+
for (const category of categoriesWithPredictions) {
|
|
397
|
+
const strategyInfo = categoryStrategies[category];
|
|
398
|
+
if (strategyInfo) {
|
|
399
|
+
strategies.push({
|
|
400
|
+
category,
|
|
401
|
+
strategy: strategyInfo.strategy,
|
|
402
|
+
implementation: strategyInfo.implementation,
|
|
403
|
+
effectiveness: strategyInfo.effectiveness,
|
|
404
|
+
affectedPredictions: predictions
|
|
405
|
+
.filter((p) => p.category === category)
|
|
406
|
+
.map((p) => p.id),
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return strategies.sort((a, b) => b.effectiveness - a.effectiveness);
|
|
411
|
+
}
|
|
412
|
+
// Export tool definition for MCP registration
|
|
413
|
+
export const toolDefinition = {
|
|
414
|
+
name: 'aqe/predict-defects',
|
|
415
|
+
description: 'Predict potential defects using ML-based analysis with root cause identification',
|
|
416
|
+
category: 'defect-intelligence',
|
|
417
|
+
version: '3.2.3',
|
|
418
|
+
inputSchema: PredictDefectsInputSchema,
|
|
419
|
+
handler,
|
|
420
|
+
};
|
|
421
|
+
export default toolDefinition;
|
|
422
|
+
//# sourceMappingURL=predict-defects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predict-defects.js","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/defect-intelligence/predict-defects.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wCAAwC;AACxC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACpE,KAAK,EAAE,CAAC;SACL,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;SACnC,OAAO,CAAC,QAAQ,CAAC;SACjB,QAAQ,CAAC,qDAAqD,CAAC;IAClE,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IACnF,aAAa,EAAE,CAAC;SACb,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,CAAC,CAAC;SACN,OAAO,CAAC,GAAG,CAAC;SACZ,QAAQ,CAAC,8CAA8C,CAAC;IAC3D,UAAU,EAAE,CAAC;SACV,KAAK,CACJ,CAAC,CAAC,IAAI,CAAC;QACL,cAAc;QACd,UAAU;QACV,eAAe;QACf,gBAAgB;QAChB,aAAa;QACb,UAAU;QACV,aAAa;QACb,YAAY;QACZ,oBAAoB;KACrB,CAAC,CACH;SACA,OAAO,CAAC,CAAC,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;SAC1E,QAAQ,CAAC,4BAA4B,CAAC;IACzC,kBAAkB,E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E,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;AACtE,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,kFAAkF;IAC/F,QAAQ,EAAE,qBAAqB;IAC/B,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,yBAAyB;IACtC,OAAO;CACR,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* assess-readiness.ts - Release readiness assessment MCP tool handler
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive release readiness assessment combining quality metrics,
|
|
5
|
+
* test results, risk factors, and stakeholder criteria.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export declare const AssessReadinessInputSchema: z.ZodObject<{
|
|
9
|
+
releaseType: z.ZodDefault<z.ZodEnum<{
|
|
10
|
+
minor: "minor";
|
|
11
|
+
major: "major";
|
|
12
|
+
patch: "patch";
|
|
13
|
+
hotfix: "hotfix";
|
|
14
|
+
}>>;
|
|
15
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
16
|
+
criteria: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
category: z.ZodEnum<{
|
|
19
|
+
security: "security";
|
|
20
|
+
performance: "performance";
|
|
21
|
+
documentation: "documentation";
|
|
22
|
+
testing: "testing";
|
|
23
|
+
quality: "quality";
|
|
24
|
+
compliance: "compliance";
|
|
25
|
+
}>;
|
|
26
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
27
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
includeChecks: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
30
|
+
dependencies: "dependencies";
|
|
31
|
+
documentation: "documentation";
|
|
32
|
+
"quality-gates": "quality-gates";
|
|
33
|
+
"test-results": "test-results";
|
|
34
|
+
"security-scan": "security-scan";
|
|
35
|
+
"performance-baseline": "performance-baseline";
|
|
36
|
+
"change-log": "change-log";
|
|
37
|
+
"rollback-plan": "rollback-plan";
|
|
38
|
+
}>>>;
|
|
39
|
+
compareToRelease: z.ZodOptional<z.ZodString>;
|
|
40
|
+
strictMode: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type AssessReadinessInput = z.infer<typeof AssessReadinessInputSchema>;
|
|
43
|
+
export interface AssessReadinessOutput {
|
|
44
|
+
success: boolean;
|
|
45
|
+
ready: boolean;
|
|
46
|
+
confidence: number;
|
|
47
|
+
verdict: ReadinessVerdict;
|
|
48
|
+
checkResults: CheckResult[];
|
|
49
|
+
riskAssessment: RiskAssessment;
|
|
50
|
+
blockers: Blocker[];
|
|
51
|
+
warnings: Warning[];
|
|
52
|
+
signOffRequired: SignOff[];
|
|
53
|
+
releaseNotes: ReleaseNotes;
|
|
54
|
+
metadata: ReadinessMetadata;
|
|
55
|
+
}
|
|
56
|
+
export interface ReadinessVerdict {
|
|
57
|
+
decision: 'go' | 'no-go' | 'conditional';
|
|
58
|
+
reason: string;
|
|
59
|
+
conditions?: string[];
|
|
60
|
+
}
|
|
61
|
+
export interface CheckResult {
|
|
62
|
+
name: string;
|
|
63
|
+
category: string;
|
|
64
|
+
status: 'passed' | 'failed' | 'warning' | 'skipped';
|
|
65
|
+
required: boolean;
|
|
66
|
+
score: number;
|
|
67
|
+
details: string;
|
|
68
|
+
evidence: Evidence[];
|
|
69
|
+
}
|
|
70
|
+
export interface Evidence {
|
|
71
|
+
type: string;
|
|
72
|
+
value: string;
|
|
73
|
+
link?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface RiskAssessment {
|
|
76
|
+
overallRisk: 'low' | 'medium' | 'high' | 'critical';
|
|
77
|
+
riskScore: number;
|
|
78
|
+
factors: RiskFactor[];
|
|
79
|
+
mitigations: Mitigation[];
|
|
80
|
+
}
|
|
81
|
+
export interface RiskFactor {
|
|
82
|
+
name: string;
|
|
83
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
84
|
+
likelihood: 'unlikely' | 'possible' | 'likely' | 'certain';
|
|
85
|
+
impact: string;
|
|
86
|
+
mitigation?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface Mitigation {
|
|
89
|
+
risk: string;
|
|
90
|
+
action: string;
|
|
91
|
+
owner: string;
|
|
92
|
+
status: 'planned' | 'in-progress' | 'complete';
|
|
93
|
+
}
|
|
94
|
+
export interface Blocker {
|
|
95
|
+
id: string;
|
|
96
|
+
severity: 'critical' | 'high';
|
|
97
|
+
description: string;
|
|
98
|
+
resolution: string;
|
|
99
|
+
owner?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface Warning {
|
|
102
|
+
id: string;
|
|
103
|
+
severity: 'medium' | 'low';
|
|
104
|
+
description: string;
|
|
105
|
+
recommendation: string;
|
|
106
|
+
}
|
|
107
|
+
export interface SignOff {
|
|
108
|
+
role: string;
|
|
109
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
110
|
+
approver?: string;
|
|
111
|
+
date?: string;
|
|
112
|
+
notes?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ReleaseNotes {
|
|
115
|
+
version: string;
|
|
116
|
+
date: string;
|
|
117
|
+
highlights: string[];
|
|
118
|
+
features: string[];
|
|
119
|
+
bugFixes: string[];
|
|
120
|
+
breakingChanges: string[];
|
|
121
|
+
knownIssues: string[];
|
|
122
|
+
}
|
|
123
|
+
export interface ReadinessMetadata {
|
|
124
|
+
assessedAt: string;
|
|
125
|
+
durationMs: number;
|
|
126
|
+
releaseType: string;
|
|
127
|
+
checksPerformed: number;
|
|
128
|
+
checksPassed: number;
|
|
129
|
+
comparedTo?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface ToolContext {
|
|
132
|
+
get<T>(key: string): T | undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* MCP Tool Handler for assess-readiness
|
|
136
|
+
*/
|
|
137
|
+
export declare function handler(input: AssessReadinessInput, context: ToolContext): Promise<{
|
|
138
|
+
content: Array<{
|
|
139
|
+
type: 'text';
|
|
140
|
+
text: string;
|
|
141
|
+
}>;
|
|
142
|
+
}>;
|
|
143
|
+
export declare const toolDefinition: {
|
|
144
|
+
name: string;
|
|
145
|
+
description: string;
|
|
146
|
+
category: string;
|
|
147
|
+
version: string;
|
|
148
|
+
inputSchema: z.ZodObject<{
|
|
149
|
+
releaseType: z.ZodDefault<z.ZodEnum<{
|
|
150
|
+
minor: "minor";
|
|
151
|
+
major: "major";
|
|
152
|
+
patch: "patch";
|
|
153
|
+
hotfix: "hotfix";
|
|
154
|
+
}>>;
|
|
155
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
156
|
+
criteria: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
category: z.ZodEnum<{
|
|
159
|
+
security: "security";
|
|
160
|
+
performance: "performance";
|
|
161
|
+
documentation: "documentation";
|
|
162
|
+
testing: "testing";
|
|
163
|
+
quality: "quality";
|
|
164
|
+
compliance: "compliance";
|
|
165
|
+
}>;
|
|
166
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
167
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
168
|
+
}, z.core.$strip>>>;
|
|
169
|
+
includeChecks: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
170
|
+
dependencies: "dependencies";
|
|
171
|
+
documentation: "documentation";
|
|
172
|
+
"quality-gates": "quality-gates";
|
|
173
|
+
"test-results": "test-results";
|
|
174
|
+
"security-scan": "security-scan";
|
|
175
|
+
"performance-baseline": "performance-baseline";
|
|
176
|
+
"change-log": "change-log";
|
|
177
|
+
"rollback-plan": "rollback-plan";
|
|
178
|
+
}>>>;
|
|
179
|
+
compareToRelease: z.ZodOptional<z.ZodString>;
|
|
180
|
+
strictMode: z.ZodDefault<z.ZodBoolean>;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
handler: typeof handler;
|
|
183
|
+
};
|
|
184
|
+
export default toolDefinition;
|
|
185
|
+
//# sourceMappingURL=assess-readiness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assess-readiness.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/quality-assessment/assess-readiness.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,IAAI,GAAG,OAAO,GAAG,aAAa,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,SA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