agentic-qe 2.3.1 → 2.3.3

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +1 -1
  3. package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
  4. package/dist/agents/CoverageAnalyzerAgent.js +53 -27
  5. package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
  6. package/dist/agents/FlakyTestHunterAgent.d.ts +5 -0
  7. package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -1
  8. package/dist/agents/FlakyTestHunterAgent.js +20 -5
  9. package/dist/agents/FlakyTestHunterAgent.js.map +1 -1
  10. package/dist/agents/QualityGateAgent.js +44 -6
  11. package/dist/agents/QualityGateAgent.js.map +1 -1
  12. package/dist/cli/index.js +0 -0
  13. package/dist/cli/init/database-init.js +5 -0
  14. package/dist/cli/init/database-init.js.map +1 -1
  15. package/dist/core/memory/HNSWVectorMemory.js +1 -1
  16. package/dist/learning/PerformanceTracker.d.ts +9 -0
  17. package/dist/learning/PerformanceTracker.d.ts.map +1 -1
  18. package/dist/learning/PerformanceTracker.js +26 -2
  19. package/dist/learning/PerformanceTracker.js.map +1 -1
  20. package/dist/mcp/server-instructions.d.ts +1 -1
  21. package/dist/mcp/server-instructions.js +1 -1
  22. package/package.json +4 -2
  23. package/scripts/README.md +352 -0
  24. package/scripts/hooks/capture-task-learning.js +191 -0
  25. package/scripts/hooks/emit-task-complete.sh +35 -0
  26. package/scripts/hooks/emit-task-spawn.sh +27 -0
  27. package/.claude/agents/failing-agent.json +0 -9
  28. package/.claude/agents/test-agent.json +0 -9
  29. package/dist/App.d.ts +0 -5
  30. package/dist/App.d.ts.map +0 -1
  31. package/dist/App.js +0 -15
  32. package/dist/App.js.map +0 -1
  33. package/dist/cli/init/utils.d.ts +0 -183
  34. package/dist/cli/init/utils.d.ts.map +0 -1
  35. package/dist/cli/init/utils.js +0 -354
  36. package/dist/cli/init/utils.js.map +0 -1
  37. package/dist/components/Dashboard/Dashboard.d.ts +0 -4
  38. package/dist/components/Dashboard/Dashboard.d.ts.map +0 -1
  39. package/dist/components/Dashboard/Dashboard.js +0 -148
  40. package/dist/components/Dashboard/Dashboard.js.map +0 -1
  41. package/dist/components/Dashboard/DashboardHeader.d.ts +0 -4
  42. package/dist/components/Dashboard/DashboardHeader.d.ts.map +0 -1
  43. package/dist/components/Dashboard/DashboardHeader.js +0 -138
  44. package/dist/components/Dashboard/DashboardHeader.js.map +0 -1
  45. package/dist/contexts/DashboardContext.d.ts +0 -41
  46. package/dist/contexts/DashboardContext.d.ts.map +0 -1
  47. package/dist/contexts/DashboardContext.js +0 -187
  48. package/dist/contexts/DashboardContext.js.map +0 -1
  49. package/dist/core/transport/QUICTransport.d.ts +0 -320
  50. package/dist/core/transport/QUICTransport.d.ts.map +0 -1
  51. package/dist/core/transport/QUICTransport.js +0 -711
  52. package/dist/core/transport/QUICTransport.js.map +0 -1
  53. package/dist/learning/LearningPersistenceAdapter.d.ts +0 -84
  54. package/dist/learning/LearningPersistenceAdapter.d.ts.map +0 -1
  55. package/dist/learning/LearningPersistenceAdapter.js +0 -202
  56. package/dist/learning/LearningPersistenceAdapter.js.map +0 -1
  57. package/dist/learning/algorithms/QLearning.d.ts +0 -68
  58. package/dist/learning/algorithms/QLearning.d.ts.map +0 -1
  59. package/dist/learning/algorithms/QLearning.js +0 -116
  60. package/dist/learning/algorithms/QLearning.js.map +0 -1
  61. package/dist/mcp/handlers/advanced/requirements-generate-bdd.d.ts +0 -7
  62. package/dist/mcp/handlers/advanced/requirements-generate-bdd.d.ts.map +0 -1
  63. package/dist/mcp/handlers/advanced/requirements-generate-bdd.js +0 -267
  64. package/dist/mcp/handlers/advanced/requirements-generate-bdd.js.map +0 -1
  65. package/dist/mcp/handlers/advanced/requirements-validate.d.ts +0 -7
  66. package/dist/mcp/handlers/advanced/requirements-validate.d.ts.map +0 -1
  67. package/dist/mcp/handlers/advanced/requirements-validate.js +0 -175
  68. package/dist/mcp/handlers/advanced/requirements-validate.js.map +0 -1
  69. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.d.ts +0 -15
  70. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.d.ts.map +0 -1
  71. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.js +0 -43
  72. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.js.map +0 -1
  73. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.d.ts +0 -58
  74. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.d.ts.map +0 -1
  75. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.js +0 -188
  76. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.js.map +0 -1
  77. package/dist/mcp/handlers/optimize-tests.d.ts +0 -219
  78. package/dist/mcp/handlers/optimize-tests.d.ts.map +0 -1
  79. package/dist/mcp/handlers/optimize-tests.js +0 -533
  80. package/dist/mcp/handlers/optimize-tests.js.map +0 -1
  81. package/dist/mcp/handlers/predict-defects.d.ts +0 -194
  82. package/dist/mcp/handlers/predict-defects.d.ts.map +0 -1
  83. package/dist/mcp/handlers/predict-defects.js +0 -722
  84. package/dist/mcp/handlers/predict-defects.js.map +0 -1
  85. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts +0 -199
  86. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts.map +0 -1
  87. package/dist/mcp/handlers/prediction/regression-risk-analyze.js +0 -471
  88. package/dist/mcp/handlers/prediction/regression-risk-analyze.js.map +0 -1
  89. package/dist/mcp/handlers/quality/quality-decision-make.d.ts +0 -104
  90. package/dist/mcp/handlers/quality/quality-decision-make.d.ts.map +0 -1
  91. package/dist/mcp/handlers/quality/quality-decision-make.js +0 -408
  92. package/dist/mcp/handlers/quality/quality-decision-make.js.map +0 -1
  93. package/dist/mcp/handlers/quality/quality-gate-execute.d.ts +0 -160
  94. package/dist/mcp/handlers/quality/quality-gate-execute.d.ts.map +0 -1
  95. package/dist/mcp/handlers/quality/quality-gate-execute.js +0 -412
  96. package/dist/mcp/handlers/quality/quality-gate-execute.js.map +0 -1
  97. package/dist/mcp/handlers/quality/quality-policy-check.d.ts +0 -163
  98. package/dist/mcp/handlers/quality/quality-policy-check.d.ts.map +0 -1
  99. package/dist/mcp/handlers/quality/quality-policy-check.js +0 -455
  100. package/dist/mcp/handlers/quality/quality-policy-check.js.map +0 -1
  101. package/dist/mcp/handlers/quality/quality-risk-assess.d.ts +0 -123
  102. package/dist/mcp/handlers/quality/quality-risk-assess.d.ts.map +0 -1
  103. package/dist/mcp/handlers/quality/quality-risk-assess.js +0 -522
  104. package/dist/mcp/handlers/quality/quality-risk-assess.js.map +0 -1
  105. package/dist/mcp/handlers/quality/quality-validate-metrics.d.ts +0 -117
  106. package/dist/mcp/handlers/quality/quality-validate-metrics.d.ts.map +0 -1
  107. package/dist/mcp/handlers/quality/quality-validate-metrics.js +0 -288
  108. package/dist/mcp/handlers/quality/quality-validate-metrics.js.map +0 -1
  109. package/dist/mcp/handlers/quality-analyze.d.ts +0 -279
  110. package/dist/mcp/handlers/quality-analyze.d.ts.map +0 -1
  111. package/dist/mcp/handlers/quality-analyze.js +0 -720
  112. package/dist/mcp/handlers/quality-analyze.js.map +0 -1
  113. package/dist/mcp/handlers/security/check-authz.d.ts +0 -152
  114. package/dist/mcp/handlers/security/check-authz.d.ts.map +0 -1
  115. package/dist/mcp/handlers/security/check-authz.js +0 -434
  116. package/dist/mcp/handlers/security/check-authz.js.map +0 -1
  117. package/dist/mcp/handlers/security/scan-dependencies.d.ts +0 -148
  118. package/dist/mcp/handlers/security/scan-dependencies.d.ts.map +0 -1
  119. package/dist/mcp/handlers/security/scan-dependencies.js +0 -354
  120. package/dist/mcp/handlers/security/scan-dependencies.js.map +0 -1
  121. package/dist/mcp/handlers/security/validate-auth.d.ts +0 -128
  122. package/dist/mcp/handlers/security/validate-auth.d.ts.map +0 -1
  123. package/dist/mcp/handlers/security/validate-auth.js +0 -294
  124. package/dist/mcp/handlers/security/validate-auth.js.map +0 -1
  125. package/dist/mcp/handlers/test-generate.d.ts +0 -107
  126. package/dist/mcp/handlers/test-generate.d.ts.map +0 -1
  127. package/dist/mcp/handlers/test-generate.js +0 -454
  128. package/dist/mcp/handlers/test-generate.js.map +0 -1
@@ -1,720 +0,0 @@
1
- "use strict";
2
- /**
3
- * Quality Analysis Handler
4
- *
5
- * Handles comprehensive quality analysis and reporting.
6
- * Generates insights and recommendations for quality improvement.
7
- *
8
- * @version 1.0.0
9
- * @author Agentic QE Team
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.QualityAnalyzeHandler = void 0;
13
- const base_handler_js_1 = require("./base-handler.js");
14
- const SecureRandom_js_1 = require("../../utils/SecureRandom.js");
15
- class QualityAnalyzeHandler extends base_handler_js_1.BaseHandler {
16
- constructor(registry, hookExecutor) {
17
- super();
18
- this.analysisHistory = new Map();
19
- this.analyzers = new Map();
20
- this.registry = registry;
21
- this.hookExecutor = hookExecutor;
22
- this.initializeAnalyzers();
23
- }
24
- async handle(args) {
25
- const requestId = this.generateRequestId();
26
- this.log('info', 'Starting quality analysis', { requestId, params: args.params });
27
- let agentId;
28
- try {
29
- // Validate required parameters
30
- this.validateRequired(args, ['params']);
31
- this.validateQualityAnalysisParams(args.params);
32
- // Spawn or find quality-gate agent
33
- const spawnResult = await this.registry.spawnAgent('quality-gate', {
34
- name: 'quality-analyzer',
35
- description: `Quality analysis for ${args.params.scope}`
36
- });
37
- agentId = spawnResult.id;
38
- this.log('info', 'Quality-gate agent spawned', { agentId });
39
- // Execute pre-task hook
40
- await this.hookExecutor.executePreTask({
41
- description: `Analyzing quality: ${args.params.scope} with metrics: ${args.params.metrics.join(', ')}`,
42
- agentType: 'quality-gate',
43
- agentId,
44
- sessionId: requestId
45
- });
46
- // Execute quality analysis through agent
47
- const { result: qualityReport, executionTime } = await this.measureExecutionTime(async () => {
48
- // Ensure dataSource has a default context if missing
49
- const dataSourceWithContext = args.dataSource ? {
50
- ...args.dataSource,
51
- context: args.dataSource.context || {
52
- deploymentTarget: 'development',
53
- criticality: 'medium',
54
- environment: process.env.NODE_ENV || 'development',
55
- changes: []
56
- }
57
- } : {
58
- context: {
59
- deploymentTarget: 'development',
60
- criticality: 'medium',
61
- environment: process.env.NODE_ENV || 'development',
62
- changes: []
63
- }
64
- };
65
- const taskResult = await this.registry.executeTask(agentId, {
66
- taskType: 'analyze-quality',
67
- input: args.params,
68
- dataSource: dataSourceWithContext
69
- });
70
- // If agent returns a quality report, use it; otherwise, perform analysis locally
71
- if (taskResult.output && typeof taskResult.output === 'object' && 'id' in taskResult.output) {
72
- return taskResult.output;
73
- }
74
- // Fallback to local analysis if agent doesn't implement quality analysis yet
75
- this.log('info', 'Agent did not return quality report, performing local analysis');
76
- return await this.performQualityAnalysis(args.params, args.dataSource);
77
- });
78
- this.log('info', `Quality analysis completed in ${executionTime.toFixed(2)}ms`, {
79
- reportId: qualityReport.id,
80
- overallScore: qualityReport.score.overall,
81
- grade: qualityReport.score.grade
82
- });
83
- // Execute post-task hook with results
84
- await this.hookExecutor.executePostTask({
85
- taskId: agentId,
86
- agentType: 'quality-gate',
87
- agentId,
88
- sessionId: requestId,
89
- results: {
90
- reportId: qualityReport.id,
91
- scope: qualityReport.scope,
92
- score: qualityReport.score,
93
- thresholdsPassed: qualityReport.thresholds.passed,
94
- recommendations: qualityReport.recommendations.length,
95
- assessments: qualityReport.assessments.length
96
- }
97
- });
98
- return this.createSuccessResponse(qualityReport, requestId);
99
- }
100
- catch (error) {
101
- this.log('error', 'Quality analysis failed', { error: error instanceof Error ? error.message : String(error) });
102
- // Execute error notification hook if agent was spawned
103
- if (agentId) {
104
- await this.hookExecutor.notify({
105
- message: `Quality analysis failed: ${error instanceof Error ? error.message : String(error)}`,
106
- level: 'error'
107
- });
108
- }
109
- return this.createErrorResponse(error instanceof Error ? error.message : 'Quality analysis failed', requestId);
110
- }
111
- }
112
- initializeAnalyzers() {
113
- this.analyzers.set('code', {
114
- metrics: ['complexity', 'coverage', 'duplication', 'debt'],
115
- tools: ['sonarqube', 'eslint', 'complexity-analysis'],
116
- thresholds: {
117
- cyclomaticComplexity: 10,
118
- coverage: 80,
119
- duplication: 3
120
- }
121
- });
122
- this.analyzers.set('tests', {
123
- metrics: ['reliability', 'effectiveness', 'efficiency', 'coverage'],
124
- tools: ['mutation-testing', 'flaky-test-detection', 'test-metrics'],
125
- thresholds: {
126
- flakyRate: 2,
127
- mutationScore: 75,
128
- successRate: 98
129
- }
130
- });
131
- this.analyzers.set('performance', {
132
- metrics: ['responseTime', 'throughput', 'resources', 'bottlenecks'],
133
- tools: ['performance-profiler', 'load-testing', 'apm'],
134
- thresholds: {
135
- responseTime: 200,
136
- throughput: 1000,
137
- cpuUsage: 80
138
- }
139
- });
140
- this.analyzers.set('security', {
141
- metrics: ['vulnerabilities', 'compliance', 'dependencies'],
142
- tools: ['security-scanner', 'dependency-checker', 'compliance-validator'],
143
- thresholds: {
144
- criticalVulns: 0,
145
- highVulns: 2,
146
- complianceScore: 85
147
- }
148
- });
149
- }
150
- validateQualityAnalysisParams(params) {
151
- const validScopes = ['code', 'tests', 'performance', 'security', 'all'];
152
- if (!validScopes.includes(params.scope)) {
153
- throw new Error(`Invalid scope: ${params.scope}. Must be one of: ${validScopes.join(', ')}`);
154
- }
155
- if (!params.metrics || params.metrics.length === 0) {
156
- throw new Error('At least one metric must be specified');
157
- }
158
- }
159
- async performQualityAnalysis(params, dataSource) {
160
- const reportId = `quality-report-${Date.now()}-${SecureRandom_js_1.SecureRandom.generateId(3)}`;
161
- this.log('info', 'Performing quality analysis', { reportId, scope: params.scope });
162
- // Collect metrics based on scope
163
- const metrics = await this.collectMetrics(params, dataSource);
164
- // Perform assessments
165
- const assessments = await this.performAssessments(metrics, params);
166
- // Generate recommendations
167
- const recommendations = params.generateRecommendations
168
- ? await this.generateRecommendations(assessments, metrics)
169
- : [];
170
- // Analyze trends if historical comparison is enabled
171
- const trends = params.historicalComparison
172
- ? await this.analyzeTrends(reportId, metrics)
173
- : this.createEmptyTrends();
174
- // Evaluate thresholds
175
- const thresholds = await this.evaluateThresholds(metrics, params.thresholds);
176
- // Calculate composite score
177
- const score = this.calculateCompositeScore(assessments, thresholds);
178
- const qualityReport = {
179
- id: reportId,
180
- scope: params.scope,
181
- analysisType: 'comprehensive',
182
- generatedAt: new Date().toISOString(),
183
- metrics,
184
- assessments,
185
- recommendations,
186
- trends,
187
- thresholds,
188
- score
189
- };
190
- // Store report
191
- this.analysisHistory.set(reportId, qualityReport);
192
- return qualityReport;
193
- }
194
- async collectMetrics(params, dataSource) {
195
- const metrics = {
196
- code: await this.collectCodeMetrics(params, dataSource),
197
- test: await this.collectTestMetrics(params, dataSource),
198
- performance: await this.collectPerformanceMetrics(params, dataSource),
199
- security: await this.collectSecurityMetrics(params, dataSource),
200
- maintainability: await this.collectMaintainabilityMetrics(params, dataSource)
201
- };
202
- return metrics;
203
- }
204
- async collectCodeMetrics(params, dataSource) {
205
- // Simulate code quality metrics collection
206
- await new Promise(resolve => setTimeout(resolve, 100));
207
- return {
208
- complexity: {
209
- cyclomatic: SecureRandom_js_1.SecureRandom.randomFloat() * 15 + 5, // 5-20
210
- cognitive: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 10, // 10-30
211
- maintainabilityIndex: SecureRandom_js_1.SecureRandom.randomFloat() * 40 + 60 // 60-100
212
- },
213
- coverage: {
214
- line: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75, // 75-95%
215
- branch: SecureRandom_js_1.SecureRandom.randomFloat() * 25 + 70, // 70-95%
216
- function: SecureRandom_js_1.SecureRandom.randomFloat() * 15 + 80, // 80-95%
217
- statement: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75 // 75-95%
218
- },
219
- duplication: {
220
- percentage: SecureRandom_js_1.SecureRandom.randomFloat() * 8 + 2, // 2-10%
221
- lines: SecureRandom_js_1.SecureRandom.randomInt(50, 550), // 50-550
222
- blocks: SecureRandom_js_1.SecureRandom.randomInt(5, 25) // 5-25
223
- },
224
- technicalDebt: {
225
- ratio: SecureRandom_js_1.SecureRandom.randomFloat() * 0.3 + 0.1, // 10-40%
226
- estimatedHours: SecureRandom_js_1.SecureRandom.randomFloat() * 100 + 20, // 20-120 hours
227
- issues: this.generateTechnicalDebtIssues()
228
- }
229
- };
230
- }
231
- async collectTestMetrics(params, dataSource) {
232
- // Simulate test quality metrics collection
233
- await new Promise(resolve => setTimeout(resolve, 100));
234
- return {
235
- reliability: {
236
- flakyTests: SecureRandom_js_1.SecureRandom.randomInt(0, 5), // 0-5
237
- successRate: SecureRandom_js_1.SecureRandom.randomFloat() * 5 + 95, // 95-100%
238
- averageRetries: SecureRandom_js_1.SecureRandom.randomFloat() * 0.5 + 0.1 // 0.1-0.6
239
- },
240
- effectiveness: {
241
- mutationScore: SecureRandom_js_1.SecureRandom.randomFloat() * 25 + 70, // 70-95%
242
- defectDetectionRate: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75, // 75-95%
243
- falsePositiveRate: SecureRandom_js_1.SecureRandom.randomFloat() * 5 + 1 // 1-6%
244
- },
245
- efficiency: {
246
- executionTime: SecureRandom_js_1.SecureRandom.randomFloat() * 300 + 60, // 60-360 seconds
247
- parallelization: SecureRandom_js_1.SecureRandom.randomFloat() * 0.3 + 0.6, // 60-90%
248
- resourceUsage: SecureRandom_js_1.SecureRandom.randomFloat() * 30 + 40 // 40-70%
249
- },
250
- coverage: {
251
- achieved: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75, // 75-95%
252
- target: 80,
253
- gaps: this.generateCoverageGaps()
254
- }
255
- };
256
- }
257
- async collectPerformanceMetrics(params, dataSource) {
258
- // Simulate performance metrics collection
259
- await new Promise(resolve => setTimeout(resolve, 100));
260
- return {
261
- responseTime: {
262
- average: SecureRandom_js_1.SecureRandom.randomFloat() * 200 + 50, // 50-250ms
263
- p95: SecureRandom_js_1.SecureRandom.randomFloat() * 500 + 100, // 100-600ms
264
- p99: SecureRandom_js_1.SecureRandom.randomFloat() * 1000 + 200 // 200-1200ms
265
- },
266
- throughput: {
267
- requestsPerSecond: SecureRandom_js_1.SecureRandom.randomFloat() * 2000 + 500, // 500-2500 RPS
268
- concurrent: SecureRandom_js_1.SecureRandom.randomFloat() * 100 + 50 // 50-150 concurrent
269
- },
270
- resources: {
271
- cpu: SecureRandom_js_1.SecureRandom.randomFloat() * 40 + 30, // 30-70%
272
- memory: SecureRandom_js_1.SecureRandom.randomFloat() * 30 + 50, // 50-80%
273
- network: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 10 // 10-30%
274
- },
275
- bottlenecks: this.generatePerformanceBottlenecks()
276
- };
277
- }
278
- async collectSecurityMetrics(params, dataSource) {
279
- // Simulate security metrics collection
280
- await new Promise(resolve => setTimeout(resolve, 100));
281
- return {
282
- vulnerabilities: {
283
- critical: SecureRandom_js_1.SecureRandom.randomInt(0, 2), // 0-1
284
- high: SecureRandom_js_1.SecureRandom.randomInt(0, 5), // 0-4
285
- medium: SecureRandom_js_1.SecureRandom.randomInt(2, 12), // 2-12
286
- low: SecureRandom_js_1.SecureRandom.randomInt(5, 25) // 5-25
287
- },
288
- compliance: {
289
- owasp: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75, // 75-95%
290
- score: SecureRandom_js_1.SecureRandom.randomFloat() * 25 + 70, // 70-95
291
- issues: this.generateSecurityIssues()
292
- },
293
- dependencies: {
294
- outdated: SecureRandom_js_1.SecureRandom.randomInt(2, 12), // 2-12
295
- vulnerable: SecureRandom_js_1.SecureRandom.randomInt(0, 3), // 0-2
296
- licenses: this.generateLicenseIssues()
297
- }
298
- };
299
- }
300
- async collectMaintainabilityMetrics(params, dataSource) {
301
- // Simulate maintainability metrics collection
302
- await new Promise(resolve => setTimeout(resolve, 50));
303
- return {
304
- readability: SecureRandom_js_1.SecureRandom.randomFloat() * 25 + 70, // 70-95
305
- documentation: SecureRandom_js_1.SecureRandom.randomFloat() * 30 + 60, // 60-90
306
- testability: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75, // 75-95
307
- modularity: SecureRandom_js_1.SecureRandom.randomFloat() * 25 + 70, // 70-95
308
- changeability: SecureRandom_js_1.SecureRandom.randomFloat() * 30 + 65 // 65-95
309
- };
310
- }
311
- async performAssessments(metrics, params) {
312
- const assessments = [];
313
- if (params.scope === 'all' || params.scope === 'code') {
314
- assessments.push(...this.assessCodeQuality(metrics.code));
315
- }
316
- if (params.scope === 'all' || params.scope === 'tests') {
317
- assessments.push(...this.assessTestQuality(metrics.test));
318
- }
319
- if (params.scope === 'all' || params.scope === 'performance') {
320
- assessments.push(...this.assessPerformanceQuality(metrics.performance));
321
- }
322
- if (params.scope === 'all' || params.scope === 'security') {
323
- assessments.push(...this.assessSecurityQuality(metrics.security));
324
- }
325
- return assessments;
326
- }
327
- assessCodeQuality(metrics) {
328
- return [
329
- {
330
- category: 'code-complexity',
331
- score: this.normalizeScore(20 - metrics.complexity.cyclomatic, 0, 20) * 100,
332
- status: metrics.complexity.cyclomatic < 10 ? 'good' : metrics.complexity.cyclomatic < 15 ? 'fair' : 'poor',
333
- details: `Cyclomatic complexity: ${metrics.complexity.cyclomatic.toFixed(1)}`,
334
- evidence: ['complexity-analysis', 'static-analysis'],
335
- impact: metrics.complexity.cyclomatic > 15 ? 'high' : 'medium'
336
- },
337
- {
338
- category: 'code-coverage',
339
- score: metrics.coverage.line,
340
- status: metrics.coverage.line > 85 ? 'excellent' : metrics.coverage.line > 75 ? 'good' : 'fair',
341
- details: `Line coverage: ${metrics.coverage.line.toFixed(1)}%`,
342
- evidence: ['coverage-report', 'test-execution'],
343
- impact: metrics.coverage.line < 70 ? 'high' : 'medium'
344
- }
345
- ];
346
- }
347
- assessTestQuality(metrics) {
348
- return [
349
- {
350
- category: 'test-reliability',
351
- score: metrics.reliability.successRate,
352
- status: metrics.reliability.successRate > 98 ? 'excellent' : metrics.reliability.successRate > 95 ? 'good' : 'fair',
353
- details: `Test success rate: ${metrics.reliability.successRate.toFixed(1)}%, Flaky tests: ${metrics.reliability.flakyTests}`,
354
- evidence: ['test-execution-history', 'flaky-test-detection'],
355
- impact: metrics.reliability.successRate < 95 ? 'high' : 'medium'
356
- },
357
- {
358
- category: 'test-effectiveness',
359
- score: metrics.effectiveness.mutationScore,
360
- status: metrics.effectiveness.mutationScore > 80 ? 'excellent' : metrics.effectiveness.mutationScore > 70 ? 'good' : 'fair',
361
- details: `Mutation score: ${metrics.effectiveness.mutationScore.toFixed(1)}%`,
362
- evidence: ['mutation-testing', 'defect-analysis'],
363
- impact: metrics.effectiveness.mutationScore < 70 ? 'high' : 'medium'
364
- }
365
- ];
366
- }
367
- assessPerformanceQuality(metrics) {
368
- return [
369
- {
370
- category: 'response-time',
371
- score: this.normalizeScore(500 - metrics.responseTime.p95, 0, 500) * 100,
372
- status: metrics.responseTime.p95 < 200 ? 'excellent' : metrics.responseTime.p95 < 500 ? 'good' : 'fair',
373
- details: `P95 response time: ${metrics.responseTime.p95.toFixed(0)}ms`,
374
- evidence: ['performance-testing', 'apm-monitoring'],
375
- impact: metrics.responseTime.p95 > 500 ? 'high' : 'medium'
376
- }
377
- ];
378
- }
379
- assessSecurityQuality(metrics) {
380
- return [
381
- {
382
- category: 'security-vulnerabilities',
383
- score: this.calculateSecurityScore(metrics.vulnerabilities),
384
- status: metrics.vulnerabilities.critical === 0 && metrics.vulnerabilities.high < 2 ? 'good' : 'poor',
385
- details: `Critical: ${metrics.vulnerabilities.critical}, High: ${metrics.vulnerabilities.high}`,
386
- evidence: ['security-scanning', 'vulnerability-assessment'],
387
- impact: metrics.vulnerabilities.critical > 0 ? 'critical' : metrics.vulnerabilities.high > 3 ? 'high' : 'medium'
388
- }
389
- ];
390
- }
391
- async generateRecommendations(assessments, metrics) {
392
- const recommendations = [];
393
- // Generate recommendations based on assessments
394
- for (const assessment of assessments) {
395
- if (assessment.score < 70 || assessment.status === 'poor' || assessment.status === 'critical') {
396
- const recommendation = this.createRecommendationForAssessment(assessment);
397
- recommendations.push(recommendation);
398
- }
399
- }
400
- // Add proactive recommendations
401
- recommendations.push(...this.generateProactiveRecommendations(metrics));
402
- return recommendations;
403
- }
404
- createRecommendationForAssessment(assessment) {
405
- const recommendationMap = {
406
- 'code-complexity': {
407
- title: 'Reduce Code Complexity',
408
- description: 'Break down complex functions and classes to improve maintainability',
409
- effort: 'medium',
410
- impact: 'high',
411
- actions: [
412
- {
413
- type: 'code',
414
- description: 'Extract methods from complex functions',
415
- automated: false
416
- }
417
- ]
418
- },
419
- 'code-coverage': {
420
- title: 'Improve Test Coverage',
421
- description: 'Add tests for uncovered code paths',
422
- effort: 'medium',
423
- impact: 'high',
424
- actions: [
425
- {
426
- type: 'test',
427
- description: 'Generate tests for uncovered functions',
428
- automated: true
429
- }
430
- ]
431
- },
432
- 'test-reliability': {
433
- title: 'Fix Flaky Tests',
434
- description: 'Identify and fix unreliable tests',
435
- effort: 'high',
436
- impact: 'high',
437
- actions: [
438
- {
439
- type: 'test',
440
- description: 'Analyze and fix flaky test patterns',
441
- automated: false
442
- }
443
- ]
444
- }
445
- };
446
- const template = recommendationMap[assessment.category] || {
447
- title: 'Improve Quality',
448
- description: 'Address quality issues in this category',
449
- effort: 'medium',
450
- impact: 'medium',
451
- actions: []
452
- };
453
- return {
454
- id: `rec-${Date.now()}-${SecureRandom_js_1.SecureRandom.generateId(2)}`,
455
- category: assessment.category,
456
- priority: assessment.impact === 'critical' ? 'critical' : assessment.impact === 'high' ? 'high' : 'medium',
457
- title: template.title,
458
- description: template.description,
459
- effort: template.effort,
460
- impact: template.impact,
461
- actions: template.actions,
462
- estimatedHours: this.estimateHours(template.effort, template.impact)
463
- };
464
- }
465
- generateProactiveRecommendations(metrics) {
466
- const recommendations = [];
467
- // Add proactive recommendations based on trends and best practices
468
- if (metrics.maintainability.documentation < 80) {
469
- recommendations.push({
470
- id: `rec-proactive-${Date.now()}`,
471
- category: 'documentation',
472
- priority: 'medium',
473
- title: 'Improve Documentation',
474
- description: 'Enhance code documentation to improve maintainability',
475
- effort: 'low',
476
- impact: 'medium',
477
- actions: [
478
- {
479
- type: 'code',
480
- description: 'Add JSDoc comments to functions',
481
- automated: true
482
- }
483
- ],
484
- estimatedHours: 8
485
- });
486
- }
487
- return recommendations;
488
- }
489
- async analyzeTrends(reportId, metrics) {
490
- // Simulate trend analysis
491
- return {
492
- direction: SecureRandom_js_1.SecureRandom.randomFloat() > 0.5 ? 'improving' : SecureRandom_js_1.SecureRandom.randomFloat() > 0.5 ? 'stable' : 'declining',
493
- velocity: SecureRandom_js_1.SecureRandom.randomFloat() * 10 - 5, // -5 to +5
494
- predictions: [
495
- {
496
- metric: 'overall-quality',
497
- predictedValue: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 75, // 75-95
498
- confidence: SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 70, // 70-90%
499
- timeframe: '30 days'
500
- }
501
- ],
502
- historical: this.generateHistoricalData()
503
- };
504
- }
505
- createEmptyTrends() {
506
- return {
507
- direction: 'stable',
508
- velocity: 0,
509
- predictions: [],
510
- historical: []
511
- };
512
- }
513
- async evaluateThresholds(metrics, thresholds) {
514
- const failed = [];
515
- const warnings = [];
516
- // Evaluate each threshold
517
- for (const [metric, threshold] of Object.entries(thresholds)) {
518
- const actual = this.getMetricValue(metrics, metric);
519
- if (actual !== undefined) {
520
- if (actual < threshold) {
521
- failed.push({
522
- metric,
523
- actual,
524
- threshold,
525
- severity: actual < threshold * 0.8 ? 'critical' : actual < threshold * 0.9 ? 'error' : 'warning'
526
- });
527
- }
528
- else if (actual < threshold * 1.1) {
529
- warnings.push({
530
- metric,
531
- actual,
532
- threshold,
533
- message: `${metric} is close to threshold`
534
- });
535
- }
536
- }
537
- }
538
- return {
539
- passed: failed.length === 0,
540
- failed,
541
- warnings
542
- };
543
- }
544
- calculateCompositeScore(assessments, thresholds) {
545
- // Calculate weighted average of assessment scores
546
- const totalScore = assessments.reduce((sum, assessment) => sum + assessment.score, 0);
547
- const averageScore = assessments.length > 0 ? totalScore / assessments.length : 0;
548
- // Apply threshold penalties
549
- const thresholdPenalty = thresholds.failed.length * 5; // 5 points per failed threshold
550
- const finalScore = Math.max(0, averageScore - thresholdPenalty);
551
- // Calculate breakdown by category
552
- const breakdown = {};
553
- for (const assessment of assessments) {
554
- breakdown[assessment.category] = assessment.score;
555
- }
556
- // Determine grade
557
- let grade;
558
- if (finalScore >= 95)
559
- grade = 'A+';
560
- else if (finalScore >= 90)
561
- grade = 'A';
562
- else if (finalScore >= 85)
563
- grade = 'B+';
564
- else if (finalScore >= 80)
565
- grade = 'B';
566
- else if (finalScore >= 75)
567
- grade = 'C+';
568
- else if (finalScore >= 70)
569
- grade = 'C';
570
- else if (finalScore >= 60)
571
- grade = 'D';
572
- else
573
- grade = 'F';
574
- return {
575
- overall: Math.round(finalScore * 100) / 100,
576
- breakdown,
577
- grade,
578
- interpretation: this.interpretScore(finalScore, grade)
579
- };
580
- }
581
- // Helper methods
582
- normalizeScore(value, min, max) {
583
- return Math.max(0, Math.min(1, (value - min) / (max - min)));
584
- }
585
- calculateSecurityScore(vulnerabilities) {
586
- const weights = { critical: 50, high: 20, medium: 5, low: 1 };
587
- const totalDeduction = vulnerabilities.critical * weights.critical +
588
- vulnerabilities.high * weights.high +
589
- vulnerabilities.medium * weights.medium +
590
- vulnerabilities.low * weights.low;
591
- return Math.max(0, 100 - totalDeduction);
592
- }
593
- estimateHours(effort, impact) {
594
- const effortMultiplier = { low: 1, medium: 2, high: 4 };
595
- const impactMultiplier = { low: 1, medium: 1.5, high: 2 };
596
- return Math.round(4 * // Base hours
597
- (effortMultiplier[effort] || 2) *
598
- (impactMultiplier[impact] || 1.5));
599
- }
600
- getMetricValue(metrics, metricPath) {
601
- // Simple path resolution for nested metrics
602
- const paths = {
603
- 'coverage': metrics.code.coverage.line,
604
- 'complexity': metrics.code.complexity.cyclomatic,
605
- 'duplication': metrics.code.duplication.percentage,
606
- 'success-rate': metrics.test.reliability.successRate,
607
- 'mutation-score': metrics.test.effectiveness.mutationScore,
608
- 'response-time': metrics.performance.responseTime.p95
609
- };
610
- return paths[metricPath];
611
- }
612
- interpretScore(score, grade) {
613
- if (score >= 90)
614
- return 'Excellent quality with minimal issues';
615
- if (score >= 80)
616
- return 'Good quality with some areas for improvement';
617
- if (score >= 70)
618
- return 'Acceptable quality but needs attention';
619
- if (score >= 60)
620
- return 'Below average quality requiring significant improvement';
621
- return 'Poor quality requiring immediate attention';
622
- }
623
- generateTechnicalDebtIssues() {
624
- return [
625
- {
626
- file: 'src/complex-function.js',
627
- line: 45,
628
- type: 'complexity',
629
- severity: 'high',
630
- estimatedHours: 4,
631
- description: 'Function has high cyclomatic complexity'
632
- },
633
- {
634
- file: 'src/duplicate-code.js',
635
- line: 12,
636
- type: 'duplication',
637
- severity: 'medium',
638
- estimatedHours: 2,
639
- description: 'Code block is duplicated across multiple files'
640
- }
641
- ];
642
- }
643
- generateCoverageGaps() {
644
- return [
645
- {
646
- file: 'src/uncovered.js',
647
- lines: [23, 24, 25, 35],
648
- functions: ['errorHandler', 'cleanup'],
649
- priority: 'high'
650
- }
651
- ];
652
- }
653
- generatePerformanceBottlenecks() {
654
- return [
655
- {
656
- type: 'database-query',
657
- location: 'UserService.findAll()',
658
- impact: 0.4,
659
- recommendation: 'Add database index on user.email'
660
- },
661
- {
662
- type: 'memory-leak',
663
- location: 'EventHandler.subscribe()',
664
- impact: 0.2,
665
- recommendation: 'Implement proper cleanup in event handlers'
666
- }
667
- ];
668
- }
669
- generateSecurityIssues() {
670
- return [
671
- {
672
- type: 'sql-injection',
673
- severity: 'high',
674
- description: 'Potential SQL injection vulnerability',
675
- location: 'UserController.search()',
676
- cwe: 'CWE-89'
677
- }
678
- ];
679
- }
680
- generateLicenseIssues() {
681
- return [
682
- {
683
- dependency: 'some-package',
684
- license: 'GPL-3.0',
685
- compatibility: 'incompatible',
686
- risk: 'high'
687
- }
688
- ];
689
- }
690
- generateHistoricalData() {
691
- const data = [];
692
- const now = new Date();
693
- for (let i = 30; i >= 0; i--) {
694
- const date = new Date(now.getTime() - i * 24 * 60 * 60 * 1000);
695
- data.push({
696
- date: date.toISOString().split('T')[0],
697
- metrics: {
698
- 'overall-quality': SecureRandom_js_1.SecureRandom.randomFloat() * 20 + 70 + i * 0.5, // Improving trend
699
- 'coverage': SecureRandom_js_1.SecureRandom.randomFloat() * 10 + 75 + i * 0.3,
700
- 'complexity': SecureRandom_js_1.SecureRandom.randomFloat() * 5 + 8 - i * 0.1
701
- }
702
- });
703
- }
704
- return data;
705
- }
706
- /**
707
- * Get quality report by ID
708
- */
709
- getReport(reportId) {
710
- return this.analysisHistory.get(reportId);
711
- }
712
- /**
713
- * List all quality reports
714
- */
715
- listReports() {
716
- return Array.from(this.analysisHistory.values());
717
- }
718
- }
719
- exports.QualityAnalyzeHandler = QualityAnalyzeHandler;
720
- //# sourceMappingURL=quality-analyze.js.map