@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,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* suggest-tests.ts - Coverage gap test suggestions MCP tool handler
|
|
3
|
+
*
|
|
4
|
+
* Analyzes existing code and coverage data to suggest tests that would
|
|
5
|
+
* improve coverage in areas that matter most based on risk and complexity.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// Input schema for suggest-tests tool
|
|
9
|
+
export const SuggestTestsInputSchema = z.object({
|
|
10
|
+
targetPath: z.string().describe('Path to file/directory to analyze'),
|
|
11
|
+
coverageReport: z.string().optional().describe('Path to existing coverage report (lcov/json)'),
|
|
12
|
+
focusAreas: z
|
|
13
|
+
.array(z.enum(['branches', 'functions', 'lines', 'edge-cases', 'error-handling', 'boundaries']))
|
|
14
|
+
.default(['branches', 'functions'])
|
|
15
|
+
.describe('Areas to focus suggestions on'),
|
|
16
|
+
maxSuggestions: z.number().min(1).max(50).default(10).describe('Maximum suggestions to return'),
|
|
17
|
+
priorityBy: z
|
|
18
|
+
.enum(['risk', 'complexity', 'coverage-impact', 'change-frequency'])
|
|
19
|
+
.default('risk')
|
|
20
|
+
.describe('How to prioritize suggestions'),
|
|
21
|
+
includeCode: z.boolean().default(true).describe('Include generated test code in suggestions'),
|
|
22
|
+
framework: z
|
|
23
|
+
.enum(['vitest', 'jest', 'mocha', 'pytest', 'junit'])
|
|
24
|
+
.default('vitest')
|
|
25
|
+
.describe('Test framework for generated code'),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* MCP Tool Handler for suggest-tests
|
|
29
|
+
*/
|
|
30
|
+
export async function handler(input, context) {
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
try {
|
|
33
|
+
// Validate input
|
|
34
|
+
const validatedInput = SuggestTestsInputSchema.parse(input);
|
|
35
|
+
// Get bridge for pattern search
|
|
36
|
+
const bridge = context.get('aqe.bridge');
|
|
37
|
+
// Analyze coverage gaps
|
|
38
|
+
const coverageAnalysis = await analyzeCoverageGaps(validatedInput.targetPath, validatedInput.coverageReport, validatedInput.focusAreas);
|
|
39
|
+
// Generate prioritized suggestions
|
|
40
|
+
const suggestions = await generateSuggestions(coverageAnalysis, validatedInput.priorityBy, validatedInput.maxSuggestions, validatedInput.includeCode, validatedInput.framework, bridge);
|
|
41
|
+
// Calculate prioritization info
|
|
42
|
+
const prioritization = calculatePrioritization(validatedInput.priorityBy, coverageAnalysis);
|
|
43
|
+
// Build result
|
|
44
|
+
const result = {
|
|
45
|
+
success: true,
|
|
46
|
+
suggestions,
|
|
47
|
+
coverageAnalysis: {
|
|
48
|
+
currentCoverage: coverageAnalysis.current,
|
|
49
|
+
projectedCoverage: calculateProjectedCoverage(coverageAnalysis.current, suggestions),
|
|
50
|
+
uncoveredAreas: coverageAnalysis.uncovered,
|
|
51
|
+
},
|
|
52
|
+
prioritization,
|
|
53
|
+
metadata: {
|
|
54
|
+
generatedAt: new Date().toISOString(),
|
|
55
|
+
analysisTimeMs: Date.now() - startTime,
|
|
56
|
+
filesAnalyzed: coverageAnalysis.filesAnalyzed,
|
|
57
|
+
totalUncoveredLines: coverageAnalysis.uncoveredLines,
|
|
58
|
+
totalUncoveredBranches: coverageAnalysis.uncoveredBranches,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{
|
|
64
|
+
type: 'text',
|
|
65
|
+
text: JSON.stringify(result, null, 2),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
72
|
+
return {
|
|
73
|
+
content: [
|
|
74
|
+
{
|
|
75
|
+
type: 'text',
|
|
76
|
+
text: JSON.stringify({
|
|
77
|
+
success: false,
|
|
78
|
+
error: errorMessage,
|
|
79
|
+
suggestions: [],
|
|
80
|
+
metadata: {
|
|
81
|
+
generatedAt: new Date().toISOString(),
|
|
82
|
+
analysisTimeMs: Date.now() - startTime,
|
|
83
|
+
},
|
|
84
|
+
}, null, 2),
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function analyzeCoverageGaps(targetPath, coverageReport, focusAreas) {
|
|
91
|
+
// Simulated coverage analysis
|
|
92
|
+
// In real implementation, would parse coverage report and analyze code
|
|
93
|
+
const uncoveredAreas = [];
|
|
94
|
+
// Analyze based on focus areas
|
|
95
|
+
if (focusAreas.includes('branches')) {
|
|
96
|
+
uncoveredAreas.push({
|
|
97
|
+
type: 'branch',
|
|
98
|
+
location: {
|
|
99
|
+
file: targetPath,
|
|
100
|
+
startLine: 25,
|
|
101
|
+
endLine: 30,
|
|
102
|
+
functionName: 'processInput',
|
|
103
|
+
},
|
|
104
|
+
risk: 'high',
|
|
105
|
+
reason: 'Error handling branch never executed',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (focusAreas.includes('functions')) {
|
|
109
|
+
uncoveredAreas.push({
|
|
110
|
+
type: 'function',
|
|
111
|
+
location: {
|
|
112
|
+
file: targetPath,
|
|
113
|
+
startLine: 50,
|
|
114
|
+
endLine: 65,
|
|
115
|
+
functionName: 'validateConfig',
|
|
116
|
+
},
|
|
117
|
+
risk: 'medium',
|
|
118
|
+
reason: 'Validation function not covered',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (focusAreas.includes('edge-cases')) {
|
|
122
|
+
uncoveredAreas.push({
|
|
123
|
+
type: 'edge-case',
|
|
124
|
+
location: {
|
|
125
|
+
file: targetPath,
|
|
126
|
+
startLine: 80,
|
|
127
|
+
endLine: 85,
|
|
128
|
+
functionName: 'handleEmptyInput',
|
|
129
|
+
},
|
|
130
|
+
risk: 'high',
|
|
131
|
+
reason: 'Empty input handling not tested',
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (focusAreas.includes('error-handling')) {
|
|
135
|
+
uncoveredAreas.push({
|
|
136
|
+
type: 'error',
|
|
137
|
+
location: {
|
|
138
|
+
file: targetPath,
|
|
139
|
+
startLine: 100,
|
|
140
|
+
endLine: 110,
|
|
141
|
+
functionName: 'handleError',
|
|
142
|
+
},
|
|
143
|
+
risk: 'critical',
|
|
144
|
+
reason: 'Error handling code path not tested',
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
current: {
|
|
149
|
+
lines: 72,
|
|
150
|
+
branches: 58,
|
|
151
|
+
functions: 80,
|
|
152
|
+
statements: 75,
|
|
153
|
+
},
|
|
154
|
+
uncovered: uncoveredAreas,
|
|
155
|
+
filesAnalyzed: 1,
|
|
156
|
+
uncoveredLines: 45,
|
|
157
|
+
uncoveredBranches: 12,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async function generateSuggestions(analysis, priorityBy, maxSuggestions, includeCode, framework, bridge) {
|
|
161
|
+
const suggestions = [];
|
|
162
|
+
// Sort uncovered areas by priority strategy
|
|
163
|
+
const sortedAreas = sortByPriority(analysis.uncovered, priorityBy);
|
|
164
|
+
for (const area of sortedAreas.slice(0, maxSuggestions)) {
|
|
165
|
+
const suggestion = {
|
|
166
|
+
id: `sug-${Date.now()}-${suggestions.length}`,
|
|
167
|
+
type: mapAreaType(area.type),
|
|
168
|
+
priority: area.risk,
|
|
169
|
+
title: generateSuggestionTitle(area),
|
|
170
|
+
description: generateSuggestionDescription(area),
|
|
171
|
+
targetLocation: area.location,
|
|
172
|
+
rationale: area.reason,
|
|
173
|
+
estimatedCoverageGain: calculateCoverageGain(area),
|
|
174
|
+
complexity: assessComplexity(area),
|
|
175
|
+
};
|
|
176
|
+
if (includeCode) {
|
|
177
|
+
suggestion.testCode = await generateTestCode(area, framework, bridge);
|
|
178
|
+
}
|
|
179
|
+
suggestions.push(suggestion);
|
|
180
|
+
}
|
|
181
|
+
return suggestions;
|
|
182
|
+
}
|
|
183
|
+
function sortByPriority(areas, strategy) {
|
|
184
|
+
const riskOrder = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
185
|
+
switch (strategy) {
|
|
186
|
+
case 'risk':
|
|
187
|
+
return [...areas].sort((a, b) => riskOrder[a.risk] - riskOrder[b.risk]);
|
|
188
|
+
case 'complexity':
|
|
189
|
+
return [...areas].sort((a, b) => (a.location.endLine - a.location.startLine) - (b.location.endLine - b.location.startLine));
|
|
190
|
+
case 'coverage-impact':
|
|
191
|
+
return [...areas].sort((a, b) => (b.location.endLine - b.location.startLine) - (a.location.endLine - a.location.startLine));
|
|
192
|
+
default:
|
|
193
|
+
return areas;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function mapAreaType(type) {
|
|
197
|
+
const typeMap = {
|
|
198
|
+
branch: 'branch',
|
|
199
|
+
function: 'function',
|
|
200
|
+
line: 'line',
|
|
201
|
+
'edge-case': 'edge-case',
|
|
202
|
+
error: 'error-handling',
|
|
203
|
+
boundary: 'boundary',
|
|
204
|
+
};
|
|
205
|
+
return typeMap[type] || 'line';
|
|
206
|
+
}
|
|
207
|
+
function generateSuggestionTitle(area) {
|
|
208
|
+
const templates = {
|
|
209
|
+
branch: `Test branch coverage in ${area.location.functionName || 'code block'}`,
|
|
210
|
+
function: `Add tests for ${area.location.functionName || 'function'}`,
|
|
211
|
+
line: `Cover lines ${area.location.startLine}-${area.location.endLine}`,
|
|
212
|
+
'edge-case': `Test edge case: ${area.reason}`,
|
|
213
|
+
error: `Test error handling in ${area.location.functionName || 'code block'}`,
|
|
214
|
+
};
|
|
215
|
+
return templates[area.type] || `Test ${area.type} at line ${area.location.startLine}`;
|
|
216
|
+
}
|
|
217
|
+
function generateSuggestionDescription(area) {
|
|
218
|
+
return `Add test coverage for ${area.type} at ${area.location.file}:${area.location.startLine}. ${area.reason}`;
|
|
219
|
+
}
|
|
220
|
+
function calculateCoverageGain(area) {
|
|
221
|
+
const lineCount = area.location.endLine - area.location.startLine + 1;
|
|
222
|
+
// Estimate coverage gain based on line count and type
|
|
223
|
+
const baseGain = Math.min(lineCount * 0.5, 5);
|
|
224
|
+
const typeMultiplier = {
|
|
225
|
+
branch: 1.5,
|
|
226
|
+
function: 2,
|
|
227
|
+
error: 1.2,
|
|
228
|
+
};
|
|
229
|
+
return Math.round((baseGain * (typeMultiplier[area.type] || 1)) * 10) / 10;
|
|
230
|
+
}
|
|
231
|
+
function assessComplexity(area) {
|
|
232
|
+
const lineCount = area.location.endLine - area.location.startLine + 1;
|
|
233
|
+
if (lineCount <= 5)
|
|
234
|
+
return 'simple';
|
|
235
|
+
if (lineCount <= 15)
|
|
236
|
+
return 'moderate';
|
|
237
|
+
return 'complex';
|
|
238
|
+
}
|
|
239
|
+
async function generateTestCode(area, framework, bridge) {
|
|
240
|
+
// Search for similar patterns if bridge available
|
|
241
|
+
if (bridge) {
|
|
242
|
+
try {
|
|
243
|
+
await bridge.searchSimilarPatterns(`test ${area.type} ${area.location.functionName}`, 3);
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
// Continue without patterns
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const templates = {
|
|
250
|
+
vitest: `import { describe, it, expect } from 'vitest';
|
|
251
|
+
import { ${area.location.functionName || 'targetFunction'} } from './${area.location.file.replace(/\.[^.]+$/, '')}';
|
|
252
|
+
|
|
253
|
+
describe('${area.location.functionName || 'Target'}', () => {
|
|
254
|
+
it('should ${area.reason.toLowerCase()}', () => {
|
|
255
|
+
// Arrange
|
|
256
|
+
const input = /* test input for ${area.type} */;
|
|
257
|
+
|
|
258
|
+
// Act
|
|
259
|
+
const result = ${area.location.functionName || 'targetFunction'}(input);
|
|
260
|
+
|
|
261
|
+
// Assert
|
|
262
|
+
expect(result).toBeDefined();
|
|
263
|
+
// Add specific assertions for ${area.type}
|
|
264
|
+
});
|
|
265
|
+
});`,
|
|
266
|
+
jest: `describe('${area.location.functionName || 'Target'}', () => {
|
|
267
|
+
it('should ${area.reason.toLowerCase()}', () => {
|
|
268
|
+
// Arrange
|
|
269
|
+
const input = /* test input for ${area.type} */;
|
|
270
|
+
|
|
271
|
+
// Act
|
|
272
|
+
const result = ${area.location.functionName || 'targetFunction'}(input);
|
|
273
|
+
|
|
274
|
+
// Assert
|
|
275
|
+
expect(result).toBeDefined();
|
|
276
|
+
});
|
|
277
|
+
});`,
|
|
278
|
+
};
|
|
279
|
+
return templates[framework] || templates.vitest;
|
|
280
|
+
}
|
|
281
|
+
function calculatePrioritization(strategy, analysis) {
|
|
282
|
+
const factors = [
|
|
283
|
+
{
|
|
284
|
+
name: 'Risk Level',
|
|
285
|
+
weight: strategy === 'risk' ? 0.5 : 0.2,
|
|
286
|
+
value: analysis.uncovered.filter((a) => a.risk === 'critical' || a.risk === 'high').length / analysis.uncovered.length,
|
|
287
|
+
description: 'Proportion of high-risk uncovered areas',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'Coverage Gap',
|
|
291
|
+
weight: strategy === 'coverage-impact' ? 0.5 : 0.3,
|
|
292
|
+
value: (100 - analysis.current.branches) / 100,
|
|
293
|
+
description: 'Current branch coverage gap',
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: 'Complexity',
|
|
297
|
+
weight: strategy === 'complexity' ? 0.5 : 0.2,
|
|
298
|
+
value: analysis.uncovered.reduce((sum, a) => sum + (a.location.endLine - a.location.startLine), 0) / 100,
|
|
299
|
+
description: 'Relative complexity of uncovered areas',
|
|
300
|
+
},
|
|
301
|
+
];
|
|
302
|
+
const riskScore = factors.reduce((sum, f) => sum + f.weight * f.value, 0);
|
|
303
|
+
return {
|
|
304
|
+
strategy,
|
|
305
|
+
factors,
|
|
306
|
+
riskScore: Math.round(riskScore * 100) / 100,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function calculateProjectedCoverage(current, suggestions) {
|
|
310
|
+
const totalGain = suggestions.reduce((sum, s) => sum + s.estimatedCoverageGain, 0);
|
|
311
|
+
return {
|
|
312
|
+
lines: Math.min(current.lines + totalGain, 100),
|
|
313
|
+
branches: Math.min(current.branches + totalGain * 0.8, 100),
|
|
314
|
+
functions: Math.min(current.functions + totalGain * 0.5, 100),
|
|
315
|
+
statements: Math.min(current.statements + totalGain * 0.9, 100),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
// Export tool definition for MCP registration
|
|
319
|
+
export const toolDefinition = {
|
|
320
|
+
name: 'aqe/suggest-tests',
|
|
321
|
+
description: 'Suggest tests based on coverage gaps with risk-based prioritization',
|
|
322
|
+
category: 'test-generation',
|
|
323
|
+
version: '3.2.3',
|
|
324
|
+
inputSchema: SuggestTestsInputSchema,
|
|
325
|
+
handler,
|
|
326
|
+
};
|
|
327
|
+
export default toolDefinition;
|
|
328
|
+
//# sourceMappingURL=suggest-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest-tests.js","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/test-generation/suggest-tests.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sCAAsC;AACtC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACpE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IAC9F,UAAU,EAAE,CAAC;SACV,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC;SAC/F,OAAO,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;SAClC,QAAQ,CAAC,+BAA+B,CA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,CAAC,SAAS,GAAG,SAAS,GAAG,GAAG,EAAE,GAAG,CAAC;QAC7D,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,GAAG,SAAS,GAAG,GAAG,EAAE,GAAG,CAAC;KAChE,CAAC;AACJ,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,qEAAqE;IAClF,QAAQ,EAAE,iBAAiB;IAC3B,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,uBAAuB;IACpC,OAAO;CACR,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdd-cycle.ts - TDD red-green-refactor orchestration MCP tool handler
|
|
3
|
+
*
|
|
4
|
+
* Executes TDD cycles with 7 specialized subagents:
|
|
5
|
+
* 1. requirement-analyzer - Analyzes requirements
|
|
6
|
+
* 2. test-designer - Designs test cases
|
|
7
|
+
* 3. red-phase-executor - Writes failing tests
|
|
8
|
+
* 4. green-phase-implementer - Implements to pass tests
|
|
9
|
+
* 5. refactor-advisor - Suggests refactoring improvements
|
|
10
|
+
* 6. coverage-verifier - Verifies coverage targets
|
|
11
|
+
* 7. cycle-coordinator - Orchestrates the cycle
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
export declare const TDDCycleInputSchema: z.ZodObject<{
|
|
15
|
+
requirement: z.ZodString;
|
|
16
|
+
targetPath: z.ZodString;
|
|
17
|
+
style: z.ZodDefault<z.ZodEnum<{
|
|
18
|
+
london: "london";
|
|
19
|
+
chicago: "chicago";
|
|
20
|
+
}>>;
|
|
21
|
+
maxCycles: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
framework: z.ZodDefault<z.ZodEnum<{
|
|
23
|
+
vitest: "vitest";
|
|
24
|
+
jest: "jest";
|
|
25
|
+
mocha: "mocha";
|
|
26
|
+
pytest: "pytest";
|
|
27
|
+
junit: "junit";
|
|
28
|
+
}>>;
|
|
29
|
+
coverageTarget: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
autoRefactor: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
stopOnGreen: z.ZodDefault<z.ZodBoolean>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type TDDCycleInput = z.infer<typeof TDDCycleInputSchema>;
|
|
34
|
+
export type TDDPhase = 'red' | 'green' | 'refactor' | 'complete';
|
|
35
|
+
export interface TDDCycleOutput {
|
|
36
|
+
success: boolean;
|
|
37
|
+
cycles: TDDCycleResult[];
|
|
38
|
+
finalCoverage: number;
|
|
39
|
+
totalCycles: number;
|
|
40
|
+
implementation: ImplementationSummary;
|
|
41
|
+
agents: AgentContribution[];
|
|
42
|
+
metadata: TDDMetadata;
|
|
43
|
+
}
|
|
44
|
+
export interface TDDCycleResult {
|
|
45
|
+
cycleNumber: number;
|
|
46
|
+
phase: TDDPhase;
|
|
47
|
+
test: TestCase | null;
|
|
48
|
+
implementation: string | null;
|
|
49
|
+
refactoring: RefactoringSuggestion[];
|
|
50
|
+
passed: boolean;
|
|
51
|
+
coverage: number;
|
|
52
|
+
durationMs: number;
|
|
53
|
+
}
|
|
54
|
+
export interface TestCase {
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
code: string;
|
|
58
|
+
assertions: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface RefactoringSuggestion {
|
|
61
|
+
type: 'extract-method' | 'rename' | 'simplify' | 'inline' | 'extract-class' | 'other';
|
|
62
|
+
description: string;
|
|
63
|
+
location: string;
|
|
64
|
+
applied: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface ImplementationSummary {
|
|
67
|
+
filesCreated: string[];
|
|
68
|
+
filesModified: string[];
|
|
69
|
+
linesOfCode: number;
|
|
70
|
+
testCount: number;
|
|
71
|
+
coverage: number;
|
|
72
|
+
}
|
|
73
|
+
export interface AgentContribution {
|
|
74
|
+
agentId: string;
|
|
75
|
+
agentType: string;
|
|
76
|
+
tasksCompleted: number;
|
|
77
|
+
contributions: string[];
|
|
78
|
+
}
|
|
79
|
+
export interface TDDMetadata {
|
|
80
|
+
startedAt: string;
|
|
81
|
+
completedAt: string;
|
|
82
|
+
totalDurationMs: number;
|
|
83
|
+
style: 'london' | 'chicago';
|
|
84
|
+
framework: string;
|
|
85
|
+
requirement: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ToolContext {
|
|
88
|
+
get<T>(key: string): T | undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* MCP Tool Handler for tdd-cycle
|
|
92
|
+
*/
|
|
93
|
+
export declare function handler(input: TDDCycleInput, context: ToolContext): Promise<{
|
|
94
|
+
content: Array<{
|
|
95
|
+
type: 'text';
|
|
96
|
+
text: string;
|
|
97
|
+
}>;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const toolDefinition: {
|
|
100
|
+
name: string;
|
|
101
|
+
description: string;
|
|
102
|
+
category: string;
|
|
103
|
+
version: string;
|
|
104
|
+
inputSchema: z.ZodObject<{
|
|
105
|
+
requirement: z.ZodString;
|
|
106
|
+
targetPath: z.ZodString;
|
|
107
|
+
style: z.ZodDefault<z.ZodEnum<{
|
|
108
|
+
london: "london";
|
|
109
|
+
chicago: "chicago";
|
|
110
|
+
}>>;
|
|
111
|
+
maxCycles: z.ZodDefault<z.ZodNumber>;
|
|
112
|
+
framework: z.ZodDefault<z.ZodEnum<{
|
|
113
|
+
vitest: "vitest";
|
|
114
|
+
jest: "jest";
|
|
115
|
+
mocha: "mocha";
|
|
116
|
+
pytest: "pytest";
|
|
117
|
+
junit: "junit";
|
|
118
|
+
}>>;
|
|
119
|
+
coverageTarget: z.ZodDefault<z.ZodNumber>;
|
|
120
|
+
autoRefactor: z.ZodDefault<z.ZodBoolean>;
|
|
121
|
+
stopOnGreen: z.ZodDefault<z.ZodBoolean>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
handler: typeof handler;
|
|
124
|
+
};
|
|
125
|
+
export default toolDefinition;
|
|
126
|
+
//# sourceMappingURL=tdd-cycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tdd-cycle.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/test-generation/tdd-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;iBAkB9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGhE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AAGjE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,qBAAqB,CAAC;IACtC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,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