qa360 2.2.15 → 2.2.20

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 (46) hide show
  1. package/cli/dist/commands/ai.js +1 -1
  2. package/cli/dist/commands/ask.js +362 -36
  3. package/cli/dist/commands/coverage.js +1 -1
  4. package/cli/dist/commands/crawl.js +1 -1
  5. package/cli/dist/commands/doctor.js +2 -2
  6. package/cli/dist/commands/explain.js +2 -2
  7. package/cli/dist/commands/flakiness.js +1 -1
  8. package/cli/dist/commands/generate.js +1 -1
  9. package/cli/dist/commands/history.js +1 -1
  10. package/cli/dist/commands/monitor.js +3 -3
  11. package/cli/dist/commands/ollama.js +1 -1
  12. package/cli/dist/commands/pack.js +2 -2
  13. package/cli/dist/commands/regression.js +1 -1
  14. package/cli/dist/commands/repair.js +1 -1
  15. package/cli/dist/commands/retry.js +1 -1
  16. package/cli/dist/commands/run.d.ts +1 -1
  17. package/cli/dist/commands/run.js +2 -1
  18. package/cli/dist/commands/secrets.js +1 -1
  19. package/cli/dist/commands/serve.js +1 -1
  20. package/cli/dist/commands/slo.js +1 -1
  21. package/cli/dist/commands/verify.js +1 -1
  22. package/cli/dist/core/ai/ollama-provider.js +3 -15
  23. package/cli/dist/core/core/coverage/analyzer.d.ts +101 -0
  24. package/cli/dist/core/core/coverage/analyzer.js +415 -0
  25. package/cli/dist/core/core/coverage/collector.d.ts +74 -0
  26. package/cli/dist/core/core/coverage/collector.js +459 -0
  27. package/cli/dist/core/core/coverage/config.d.ts +37 -0
  28. package/cli/dist/core/core/coverage/config.js +156 -0
  29. package/cli/dist/core/core/coverage/index.d.ts +11 -0
  30. package/cli/dist/core/core/coverage/index.js +15 -0
  31. package/cli/dist/core/core/coverage/types.d.ts +267 -0
  32. package/cli/dist/core/core/coverage/types.js +6 -0
  33. package/cli/dist/core/core/coverage/vault.d.ts +95 -0
  34. package/cli/dist/core/core/coverage/vault.js +405 -0
  35. package/cli/dist/core/crawler/selector-generator.js +3 -72
  36. package/cli/dist/core/generation/crawler-pack-generator.d.ts +1 -1
  37. package/cli/dist/core/generation/crawler-pack-generator.js +143 -31
  38. package/cli/dist/core/pack/validator.js +2 -2
  39. package/cli/dist/core/pack-v2/migrator.d.ts +0 -5
  40. package/cli/dist/core/pack-v2/migrator.js +6 -81
  41. package/cli/dist/core/pack-v2/validator.js +3 -4
  42. package/cli/dist/core/runner/phase3-runner.js +1 -12
  43. package/cli/dist/utils/config.d.ts +1 -1
  44. package/cli/dist/utils/config.js +11 -5
  45. package/core/package.json +1 -1
  46. package/package.json +3 -2
@@ -6,7 +6,7 @@
6
6
  import { Command } from 'commander';
7
7
  import chalk from 'chalk';
8
8
  import Table from 'cli-table3';
9
- import { createSmartRetryEngine, RetryStrategy } from '../core/index.js';
9
+ import { createSmartRetryEngine, RetryStrategy } from 'qa360-core';
10
10
  /**
11
11
  * Display retry statistics in a formatted table
12
12
  */
@@ -6,7 +6,7 @@
6
6
  * qa360 run --output ./results
7
7
  * qa360 run --verbose
8
8
  */
9
- import { type Phase3RunResult, type PackConfigV1, type PackConfigV2 } from '../core/index.js';
9
+ import { type Phase3RunResult, type PackConfigV1, type PackConfigV2 } from 'qa360-core';
10
10
  /**
11
11
  * CLI options for run command
12
12
  */
@@ -9,7 +9,7 @@
9
9
  import { existsSync } from 'fs';
10
10
  import { join, resolve, dirname } from 'path';
11
11
  import chalk from 'chalk';
12
- import { Phase3Runner, PackLoaderV2 } from '../core/index.js';
12
+ import { Phase3Runner, PackLoaderV2 } from 'qa360-core';
13
13
  /**
14
14
  * Format gates for display (handles both v1 array and v2 object formats)
15
15
  */
@@ -150,6 +150,7 @@ export async function runCommand(packArg, options = {}) {
150
150
  pack,
151
151
  packDir, // Pass pack directory for resolving fixtures
152
152
  outputDir,
153
+ headed: options.headed,
153
154
  });
154
155
  const result = await runner.run();
155
156
  // Step 5: Display results
@@ -5,7 +5,7 @@
5
5
  import chalk from 'chalk';
6
6
  import ora from 'ora';
7
7
  import inquirer from 'inquirer';
8
- import { SecretsManager, SecretsCrypto } from '../core/index.js';
8
+ import { SecretsManager, SecretsCrypto } from 'qa360-core';
9
9
  export class QA360Secrets {
10
10
  manager;
11
11
  constructor() {
@@ -3,7 +3,7 @@
3
3
  * Démarre le serveur d'observabilité
4
4
  */
5
5
  import { Command } from 'commander';
6
- import { QA360Server } from '../core/index.js';
6
+ import { QA360Server } from 'qa360-core';
7
7
  export function createServeCommand() {
8
8
  return new Command('serve')
9
9
  .description('Start QA360 observability server')
@@ -4,7 +4,7 @@
4
4
  * CLI command for SLO/SLI management and reporting.
5
5
  */
6
6
  import { Command } from 'commander';
7
- import { SLOTracker, createDefaultSLOConfig, createStrictSLOConfig, createRelaxedSLOConfig, TimeWindows } from '../core/index.js';
7
+ import { SLOTracker, createDefaultSLOConfig, createStrictSLOConfig, createRelaxedSLOConfig, TimeWindows } from 'qa360-core';
8
8
  export const sloCommand = new Command('slo');
9
9
  sloCommand.description('Service Level Objectives and Indicators management');
10
10
  // List all SLOs
@@ -14,7 +14,7 @@ import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
14
14
  import { join, resolve, basename } from 'path';
15
15
  import chalk from 'chalk';
16
16
  // Import from core
17
- import { verifyProofFile, verifyPhase3Proof, VerificationCode, } from '../core/index.js';
17
+ import { verifyProofFile, verifyPhase3Proof, VerificationCode, } from 'qa360-core';
18
18
  /**
19
19
  * Verify a proof file with automatic format detection
20
20
  */
@@ -32,28 +32,16 @@ export class OllamaProvider {
32
32
  }
33
33
  async isAvailable() {
34
34
  try {
35
- // Use a longer timeout (15 seconds) to accommodate slower systems
36
- // Ollama can take time to respond, especially on first run or with many models
35
+ // Use timeout with AbortSignal - wrap for compatibility
37
36
  const controller = new AbortController();
38
- const timeoutId = setTimeout(() => controller.abort(), 15000);
37
+ const timeoutId = setTimeout(() => controller.abort(), 5000);
39
38
  const response = await fetch(`${this.baseUrl}/api/tags`, {
40
39
  signal: controller.signal,
41
40
  });
42
41
  clearTimeout(timeoutId);
43
42
  return response.ok;
44
43
  }
45
- catch (error) {
46
- // Log the error for debugging (will be visible in verbose mode)
47
- if (error instanceof Error) {
48
- if (error.name === 'AbortError') {
49
- // Timeout - Ollama is slow to respond
50
- console.debug(`[Ollama] Connection to ${this.baseUrl} timed out after 15s`);
51
- }
52
- else {
53
- // Other error (ECONNREFUSED, ENOTFOUND, etc.)
54
- console.debug(`[Ollama] Connection error: ${error.message}`);
55
- }
56
- }
44
+ catch {
57
45
  return false;
58
46
  }
59
47
  }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Coverage Analyzer
3
+ *
4
+ * Analyzes coverage data to provide insights, trends, and recommendations.
5
+ */
6
+ import type { FileCoverage, CoverageMetrics, CoverageResult, CoverageTrend, CoverageGap, CoverageComparison, CoverageThreshold, CoverageType, CoverageReport } from './types.js';
7
+ /**
8
+ * Historical coverage data point
9
+ */
10
+ interface HistoricalCoverage {
11
+ runId: string;
12
+ timestamp: number;
13
+ metrics: CoverageMetrics;
14
+ }
15
+ /**
16
+ * Coverage Analyzer class
17
+ */
18
+ export declare class CoverageAnalyzer {
19
+ private history;
20
+ /**
21
+ * Analyze coverage and generate insights
22
+ */
23
+ analyze(result: CoverageResult, threshold?: CoverageThreshold): CoverageReport;
24
+ /**
25
+ * Check if coverage meets thresholds
26
+ */
27
+ checkThresholds(metrics: CoverageMetrics, threshold?: CoverageThreshold): boolean;
28
+ /**
29
+ * Check if a single file meets thresholds
30
+ */
31
+ checkFileThresholds(file: FileCoverage, threshold?: CoverageThreshold): boolean;
32
+ /**
33
+ * Find coverage gaps
34
+ */
35
+ findGaps(files: Record<string, FileCoverage>, threshold?: CoverageThreshold): CoverageGap[];
36
+ /**
37
+ * Calculate priority for covering a file
38
+ */
39
+ private calculatePriority;
40
+ /**
41
+ * Estimate effort to cover a file
42
+ */
43
+ private estimateEffort;
44
+ /**
45
+ * Generate test suggestions for a file
46
+ */
47
+ private generateSuggestions;
48
+ /**
49
+ * Group consecutive numbers into ranges
50
+ */
51
+ private groupConsecutiveNumbers;
52
+ /**
53
+ * Get top and bottom files by coverage
54
+ */
55
+ getTopFiles(files: Record<string, FileCoverage>, limit?: number): Array<{
56
+ path: string;
57
+ coverage: number;
58
+ type: 'best' | 'worst';
59
+ }>;
60
+ /**
61
+ * Compare two coverage results
62
+ */
63
+ compare(baseResult: CoverageResult, compareResult: CoverageResult): CoverageComparison;
64
+ /**
65
+ * Add historical coverage data
66
+ */
67
+ addHistory(key: string, data: HistoricalCoverage): void;
68
+ /**
69
+ * Get coverage trends
70
+ */
71
+ getTrends(key: string, type?: CoverageType, limit?: number): CoverageTrend[];
72
+ /**
73
+ * Calculate trend direction
74
+ */
75
+ getTrendDirection(trends: CoverageTrend[]): 'improving' | 'stable' | 'declining';
76
+ /**
77
+ * Predict future coverage based on trends
78
+ */
79
+ predictCoverage(key: string, type: CoverageType | undefined, targetCoverage: number): {
80
+ predictedReach: number | null;
81
+ projectedCoverage: number;
82
+ confidence: 'high' | 'medium' | 'low';
83
+ };
84
+ /**
85
+ * Generate coverage summary text
86
+ */
87
+ generateSummary(metrics: CoverageMetrics): string;
88
+ /**
89
+ * Format coverage percentage with color indicator
90
+ */
91
+ formatCoverage(percentage: number, threshold?: number): string;
92
+ /**
93
+ * Clear history
94
+ */
95
+ clearHistory(key?: string): void;
96
+ }
97
+ /**
98
+ * Create a coverage analyzer
99
+ */
100
+ export declare function createCoverageAnalyzer(): CoverageAnalyzer;
101
+ export {};
@@ -0,0 +1,415 @@
1
+ /**
2
+ * Coverage Analyzer
3
+ *
4
+ * Analyzes coverage data to provide insights, trends, and recommendations.
5
+ */
6
+ /**
7
+ * Coverage Analyzer class
8
+ */
9
+ export class CoverageAnalyzer {
10
+ history = new Map();
11
+ /**
12
+ * Analyze coverage and generate insights
13
+ */
14
+ analyze(result, threshold) {
15
+ const thresholdsMet = this.checkThresholds(result.metrics, threshold);
16
+ const gaps = this.findGaps(result.files, threshold);
17
+ const topFiles = this.getTopFiles(result.files);
18
+ return {
19
+ runId: `run_${Date.now()}`,
20
+ timestamp: Date.now(),
21
+ metrics: result.metrics,
22
+ byGate: { [result.gate]: result.metrics },
23
+ topFiles,
24
+ gaps: gaps.slice(0, 10), // Top 10 gaps
25
+ thresholdsMet,
26
+ thresholdViolations: gaps.map(g => g.path)
27
+ };
28
+ }
29
+ /**
30
+ * Check if coverage meets thresholds
31
+ */
32
+ checkThresholds(metrics, threshold) {
33
+ if (!threshold) {
34
+ return true;
35
+ }
36
+ if (threshold.scope === 'per-file') {
37
+ // Per-file thresholds checked separately
38
+ return true;
39
+ }
40
+ if (threshold.line !== undefined && metrics.lineCoverage < threshold.line) {
41
+ return false;
42
+ }
43
+ if (threshold.branch !== undefined && metrics.branchCoverage < threshold.branch) {
44
+ return false;
45
+ }
46
+ if (threshold.function !== undefined && metrics.functionCoverage < threshold.function) {
47
+ return false;
48
+ }
49
+ if (threshold.statement !== undefined && metrics.statementCoverage < threshold.statement) {
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+ /**
55
+ * Check if a single file meets thresholds
56
+ */
57
+ checkFileThresholds(file, threshold) {
58
+ if (!threshold) {
59
+ return true;
60
+ }
61
+ if (threshold.line !== undefined && file.lineCoverage < threshold.line) {
62
+ return false;
63
+ }
64
+ if (threshold.branch !== undefined && file.branchCoverage < threshold.branch) {
65
+ return false;
66
+ }
67
+ if (threshold.function !== undefined && file.functionCoverage < threshold.function) {
68
+ return false;
69
+ }
70
+ if (threshold.statement !== undefined && file.statementCoverage < threshold.statement) {
71
+ return false;
72
+ }
73
+ return true;
74
+ }
75
+ /**
76
+ * Find coverage gaps
77
+ */
78
+ findGaps(files, threshold) {
79
+ const gaps = [];
80
+ const targetLine = threshold?.line ?? 80;
81
+ const targetBranch = threshold?.branch ?? 70;
82
+ const targetFunction = threshold?.function ?? 75;
83
+ for (const [path, file] of Object.entries(files)) {
84
+ const minTarget = Math.min(targetLine, targetBranch, targetFunction);
85
+ const avgCoverage = (file.lineCoverage + file.branchCoverage + file.functionCoverage) / 3;
86
+ if (avgCoverage < minTarget) {
87
+ gaps.push({
88
+ path,
89
+ currentCoverage: avgCoverage,
90
+ targetCoverage: minTarget,
91
+ gap: minTarget - avgCoverage,
92
+ priority: this.calculatePriority(file, minTarget),
93
+ effort: this.estimateEffort(file),
94
+ uncoveredCount: file.uncoveredLines.length,
95
+ suggestions: this.generateSuggestions(file)
96
+ });
97
+ }
98
+ }
99
+ // Sort by gap size, then priority
100
+ gaps.sort((a, b) => {
101
+ if (a.priority !== b.priority) {
102
+ const priorityOrder = { high: 0, medium: 1, low: 2 };
103
+ return priorityOrder[a.priority] - priorityOrder[b.priority];
104
+ }
105
+ return b.gap - a.gap;
106
+ });
107
+ return gaps;
108
+ }
109
+ /**
110
+ * Calculate priority for covering a file
111
+ */
112
+ calculatePriority(file, target) {
113
+ const gap = target - file.lineCoverage;
114
+ // High priority: large gap in important files
115
+ if (gap > 30) {
116
+ return 'high';
117
+ }
118
+ // Medium priority: moderate gap
119
+ if (gap > 10) {
120
+ return 'medium';
121
+ }
122
+ return 'low';
123
+ }
124
+ /**
125
+ * Estimate effort to cover a file
126
+ */
127
+ estimateEffort(file) {
128
+ const complexity = file.totalBranches + file.totalFunctions;
129
+ const uncoveredRatio = file.uncoveredLines.length / Math.max(file.totalLines, 1);
130
+ if (complexity > 100 || uncoveredRatio > 0.5) {
131
+ return 'high';
132
+ }
133
+ if (complexity > 30 || uncoveredRatio > 0.2) {
134
+ return 'medium';
135
+ }
136
+ return 'low';
137
+ }
138
+ /**
139
+ * Generate test suggestions for a file
140
+ */
141
+ generateSuggestions(file) {
142
+ const suggestions = [];
143
+ if (file.uncoveredLines.length > 0) {
144
+ const lineRanges = this.groupConsecutiveNumbers(file.uncoveredLines);
145
+ suggestions.push(`Add tests covering lines: ${lineRanges.slice(0, 3).join(', ')}`);
146
+ }
147
+ if (file.branchCoverage < file.lineCoverage) {
148
+ suggestions.push('Add tests for all branch conditions (true/false paths)');
149
+ }
150
+ if (file.functionCoverage < 100) {
151
+ suggestions.push('Add tests for uncovered functions');
152
+ }
153
+ if (file.totalFunctions === 0) {
154
+ suggestions.push('Consider splitting large functions into smaller, testable units');
155
+ }
156
+ return suggestions;
157
+ }
158
+ /**
159
+ * Group consecutive numbers into ranges
160
+ */
161
+ groupConsecutiveNumbers(numbers) {
162
+ if (numbers.length === 0)
163
+ return [];
164
+ const sorted = [...numbers].sort((a, b) => a - b);
165
+ const ranges = [];
166
+ let start = sorted[0];
167
+ let prev = sorted[0];
168
+ for (let i = 1; i < sorted.length; i++) {
169
+ if (sorted[i] === prev + 1) {
170
+ prev = sorted[i];
171
+ }
172
+ else {
173
+ ranges.push(start === prev ? `${start}` : `${start}-${prev}`);
174
+ start = sorted[i];
175
+ prev = sorted[i];
176
+ }
177
+ }
178
+ ranges.push(start === prev ? `${start}` : `${start}-${prev}`);
179
+ return ranges;
180
+ }
181
+ /**
182
+ * Get top and bottom files by coverage
183
+ */
184
+ getTopFiles(files, limit = 5) {
185
+ const fileArray = Object.entries(files).map(([path, file]) => ({
186
+ path,
187
+ coverage: file.lineCoverage,
188
+ type: 'best'
189
+ }));
190
+ // Sort by coverage
191
+ fileArray.sort((a, b) => b.coverage - a.coverage);
192
+ const result = [];
193
+ // Best files
194
+ for (let i = 0; i < Math.min(limit, fileArray.length); i++) {
195
+ result.push({ ...fileArray[i], type: 'best' });
196
+ }
197
+ // Worst files
198
+ for (let i = fileArray.length - 1; i >= Math.max(fileArray.length - limit, 0); i--) {
199
+ result.push({ path: fileArray[i].path, coverage: fileArray[i].coverage, type: 'worst' });
200
+ }
201
+ return result;
202
+ }
203
+ /**
204
+ * Compare two coverage results
205
+ */
206
+ compare(baseResult, compareResult) {
207
+ const baseFiles = baseResult.files;
208
+ const compareFiles = compareResult.files;
209
+ const improved = [];
210
+ const regressed = [];
211
+ const newFiles = [];
212
+ const removedFiles = [];
213
+ // Check all files in base
214
+ for (const [path, baseFile] of Object.entries(baseFiles)) {
215
+ const compareFile = compareFiles[path];
216
+ if (!compareFile) {
217
+ removedFiles.push(path);
218
+ continue;
219
+ }
220
+ const delta = compareFile.lineCoverage - baseFile.lineCoverage;
221
+ if (delta > 0.5) {
222
+ improved.push({
223
+ path,
224
+ before: baseFile.lineCoverage,
225
+ after: compareFile.lineCoverage,
226
+ delta
227
+ });
228
+ }
229
+ else if (delta < -0.5) {
230
+ regressed.push({
231
+ path,
232
+ before: baseFile.lineCoverage,
233
+ after: compareFile.lineCoverage,
234
+ delta
235
+ });
236
+ }
237
+ }
238
+ // Find new files
239
+ for (const path of Object.keys(compareFiles)) {
240
+ if (!baseFiles[path]) {
241
+ newFiles.push(path);
242
+ }
243
+ }
244
+ // Calculate overall change
245
+ const overallChange = compareResult.metrics.lineCoverage - baseResult.metrics.lineCoverage;
246
+ return {
247
+ baseRunId: `base_${baseResult.timestamp}`,
248
+ compareRunId: `compare_${compareResult.timestamp}`,
249
+ improved,
250
+ regressed,
251
+ newFiles,
252
+ removedFiles,
253
+ overallChange
254
+ };
255
+ }
256
+ /**
257
+ * Add historical coverage data
258
+ */
259
+ addHistory(key, data) {
260
+ if (!this.history.has(key)) {
261
+ this.history.set(key, []);
262
+ }
263
+ const history = this.history.get(key);
264
+ history.push(data);
265
+ // Keep only last 100 entries
266
+ if (history.length > 100) {
267
+ history.shift();
268
+ }
269
+ }
270
+ /**
271
+ * Get coverage trends
272
+ */
273
+ getTrends(key, type = 'line', limit = 30) {
274
+ const history = this.history.get(key) || [];
275
+ const sorted = history
276
+ .sort((a, b) => a.timestamp - b.timestamp)
277
+ .slice(-limit);
278
+ const trends = [];
279
+ let previousValue = 0;
280
+ for (const entry of sorted) {
281
+ let value;
282
+ switch (type) {
283
+ case 'line':
284
+ value = entry.metrics.lineCoverage;
285
+ break;
286
+ case 'branch':
287
+ value = entry.metrics.branchCoverage;
288
+ break;
289
+ case 'function':
290
+ value = entry.metrics.functionCoverage;
291
+ break;
292
+ case 'statement':
293
+ value = entry.metrics.statementCoverage;
294
+ break;
295
+ }
296
+ trends.push({
297
+ runId: entry.runId,
298
+ timestamp: entry.timestamp,
299
+ coverage: value,
300
+ type,
301
+ change: value - previousValue
302
+ });
303
+ previousValue = value;
304
+ }
305
+ return trends;
306
+ }
307
+ /**
308
+ * Calculate trend direction
309
+ */
310
+ getTrendDirection(trends) {
311
+ if (trends.length < 3) {
312
+ return 'stable';
313
+ }
314
+ const recent = trends.slice(-5);
315
+ const avgChange = recent.reduce((sum, t) => sum + t.change, 0) / recent.length;
316
+ if (avgChange > 1)
317
+ return 'improving';
318
+ if (avgChange < -1)
319
+ return 'declining';
320
+ return 'stable';
321
+ }
322
+ /**
323
+ * Predict future coverage based on trends
324
+ */
325
+ predictCoverage(key, type = 'line', targetCoverage) {
326
+ const trends = this.getTrends(key, type, 20);
327
+ if (trends.length < 5) {
328
+ return {
329
+ predictedReach: null,
330
+ projectedCoverage: trends[trends.length - 1]?.coverage || 0,
331
+ confidence: 'low'
332
+ };
333
+ }
334
+ // Simple linear regression
335
+ const n = trends.length;
336
+ let sumX = 0;
337
+ let sumY = 0;
338
+ let sumXY = 0;
339
+ let sumXX = 0;
340
+ for (let i = 0; i < n; i++) {
341
+ const x = i;
342
+ const y = trends[i].coverage;
343
+ sumX += x;
344
+ sumY += y;
345
+ sumXY += x * y;
346
+ sumXX += x * x;
347
+ }
348
+ const slope = (n * sumXY - sumX * sumY) / (n * sumXX - sumX * sumX);
349
+ const intercept = (sumY - slope * sumX) / n;
350
+ const currentCoverage = trends[n - 1].coverage;
351
+ const avgCoverage = sumY / n;
352
+ const variance = trends.reduce((sum, t) => sum + Math.pow(t.coverage - avgCoverage, 2), 0) / n;
353
+ // Determine confidence based on variance
354
+ let confidence;
355
+ if (variance < 25)
356
+ confidence = 'high';
357
+ else if (variance < 100)
358
+ confidence = 'medium';
359
+ else
360
+ confidence = 'low';
361
+ // Project coverage for next run
362
+ const projectedCoverage = currentCoverage + slope;
363
+ // Predict when target will be reached
364
+ let predictedReach = null;
365
+ if (slope > 0.1) {
366
+ const runsNeeded = (targetCoverage - currentCoverage) / slope;
367
+ if (runsNeeded > 0 && runsNeeded < 100) {
368
+ predictedReach = Date.now() + runsNeeded * 24 * 60 * 60 * 1000; // Assume daily runs
369
+ }
370
+ }
371
+ return { predictedReach, projectedCoverage, confidence };
372
+ }
373
+ /**
374
+ * Generate coverage summary text
375
+ */
376
+ generateSummary(metrics) {
377
+ const parts = [];
378
+ parts.push(`Line Coverage: ${metrics.lineCoverage.toFixed(1)}%`);
379
+ parts.push(`Branch Coverage: ${metrics.branchCoverage.toFixed(1)}%`);
380
+ parts.push(`Function Coverage: ${metrics.functionCoverage.toFixed(1)}%`);
381
+ if (metrics.totalFiles > 0) {
382
+ parts.push(`Files: ${metrics.filesWithCoverage}/${metrics.totalFiles}`);
383
+ }
384
+ return parts.join(' | ');
385
+ }
386
+ /**
387
+ * Format coverage percentage with color indicator
388
+ */
389
+ formatCoverage(percentage, threshold = 80) {
390
+ if (percentage >= threshold) {
391
+ return `✓ ${percentage.toFixed(1)}%`;
392
+ }
393
+ else if (percentage >= threshold - 10) {
394
+ return `⚠ ${percentage.toFixed(1)}%`;
395
+ }
396
+ return `✗ ${percentage.toFixed(1)}%`;
397
+ }
398
+ /**
399
+ * Clear history
400
+ */
401
+ clearHistory(key) {
402
+ if (key) {
403
+ this.history.delete(key);
404
+ }
405
+ else {
406
+ this.history.clear();
407
+ }
408
+ }
409
+ }
410
+ /**
411
+ * Create a coverage analyzer
412
+ */
413
+ export function createCoverageAnalyzer() {
414
+ return new CoverageAnalyzer();
415
+ }