monomind 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/.claude/scheduled_tasks.lock +1 -1
- package/package.json +1 -1
- package/packages/@monomind/cli/dist/src/mcp-client.js +7 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.js +347 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/coherence-check.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/coherence-check.js +206 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.js +303 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.js +266 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.js +406 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.js +293 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +277 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.js +159 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence-tools.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence-tools.js +25 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.d.ts +163 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/chaos-resilience/chaos-inject.js +414 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.d.ts +128 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/analyze-coverage.js +375 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +161 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +423 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/track-trends.d.ts +165 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/track-trends.js +395 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.d.ts +165 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/defect-intelligence/analyze-root-cause.js +508 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.d.ts +147 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/defect-intelligence/find-similar-defects.js +391 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.d.ts +147 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/defect-intelligence/predict-defects.js +422 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.d.ts +185 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/quality-assessment/assess-readiness.js +437 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.d.ts +166 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/quality-assessment/calculate-risk.js +410 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.d.ts +201 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/quality-assessment/evaluate-quality-gate.js +363 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/audit-compliance.d.ts +166 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/audit-compliance.js +394 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +129 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js +383 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/security-scan.d.ts +171 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/security-scan.js +476 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/generate-tests.d.ts +147 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/generate-tests.js +400 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/suggest-tests.d.ts +145 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/suggest-tests.js +328 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/tdd-cycle.d.ts +126 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/tdd-cycle.js +348 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.js +308 -0
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +4 -124
- package/packages/@monomind/cli/package.json +1 -1
|
@@ -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,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
|