aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
217 lines • 5.12 kB
TypeScript
/**
* @file metrics-collector.ts
* @description Metrics collection and aggregation system
*
* Implements F-010/UC-010: Metrics Collection
* - Code quality metrics (complexity, duplication, coverage)
* - Performance metrics (build time, test time, response time)
* - Team metrics (velocity, throughput, lead time)
* - Trend analysis and visualization
* - Metric export (CSV, JSON, Prometheus)
*
* @implements NFR-METRICS-001: Collection overhead <5%
* @implements NFR-METRICS-002: Real-time dashboard updates <1s
* @implements NFR-METRICS-003: Retention 90 days minimum
*/
export interface MetricPoint {
timestamp: Date;
value: number;
labels?: Record<string, string>;
}
export interface MetricSeries {
name: string;
type: 'counter' | 'gauge' | 'histogram' | 'summary';
unit?: string;
description?: string;
points: MetricPoint[];
}
export interface CodeQualityMetrics {
complexity: number;
duplication: number;
coverage: number;
linesOfCode: number;
technicalDebt: number;
codeSmells: number;
bugs: number;
vulnerabilities: number;
}
export interface PerformanceMetrics {
buildTime: number;
testTime: number;
deployTime: number;
responseTime: number;
throughput: number;
errorRate: number;
}
export interface TeamMetrics {
velocity: number;
throughput: number;
leadTime: number;
cycleTime: number;
deployFrequency: number;
changeFailureRate: number;
meanTimeToRecovery: number;
}
export interface MetricsSnapshot {
timestamp: Date;
codeQuality: CodeQualityMetrics;
performance: PerformanceMetrics;
team: TeamMetrics;
}
export interface MetricsCollectorConfig {
projectPath: string;
retentionDays?: number;
collectInterval?: number;
exportFormats?: Array<'json' | 'csv' | 'prometheus'>;
storePath?: string;
}
export declare class MetricsCollector {
private config;
private metrics;
private snapshots;
private collectionTimer?;
constructor(config: MetricsCollectorConfig);
/**
* Start automatic metric collection
*/
startCollection(): Promise<void>;
/**
* Stop automatic collection
*/
stopCollection(): void;
/**
* Collect all metrics
*/
collect(): Promise<MetricsSnapshot>;
/**
* Collect code quality metrics
*/
private collectCodeQuality;
/**
* Collect performance metrics
*/
private collectPerformance;
/**
* Collect team metrics
*/
private collectTeamMetrics;
/**
* Measure cyclomatic complexity
*/
private measureComplexity;
/**
* Measure code duplication
*/
private measureDuplication;
/**
* Measure test coverage
*/
private measureCoverage;
/**
* Count lines of code
*/
private countLinesOfCode;
/**
* Check if file is source code
*/
private isSourceFile;
/**
* Estimate technical debt
*/
private estimateTechnicalDebt;
/**
* Measure build time
*/
private measureBuildTime;
/**
* Measure test time
*/
private measureTestTime;
/**
* Calculate team velocity
*/
private calculateVelocity;
/**
* Calculate throughput
*/
private calculateThroughput;
/**
* Calculate lead time
*/
private calculateLeadTime;
/**
* Calculate cycle time
*/
private calculateCycleTime;
/**
* Record a metric point
*/
recordMetric(name: string, value: number, labels?: Record<string, string>): void;
/**
* Get metric series
*/
getMetric(name: string): MetricSeries | undefined;
/**
* Get all metrics
*/
getAllMetrics(): MetricSeries[];
/**
* Get recent snapshots
*/
getSnapshots(count?: number): MetricsSnapshot[];
/**
* Get latest snapshot
*/
getLatestSnapshot(): MetricsSnapshot | undefined;
/**
* Calculate metric trend
*/
calculateTrend(metricName: string, windowSize?: number): 'increasing' | 'decreasing' | 'stable';
/**
* Get metric statistics
*/
getStatistics(metricName: string): {
min: number;
max: number;
avg: number;
median: number;
stdDev: number;
} | null;
/**
* Export metrics to JSON
*/
exportJSON(): string;
/**
* Export metrics to CSV
*/
exportCSV(): string;
/**
* Export metrics in Prometheus format
*/
exportPrometheus(): string;
/**
* Export to file
*/
exportToFile(format: 'json' | 'csv' | 'prometheus', filePath: string): Promise<void>;
/**
* Save metrics to disk
*/
private persist;
/**
* Load metrics from disk
*/
load(): Promise<void>;
/**
* Prune old snapshots (NFR-METRICS-003: 90 days retention)
*/
private pruneOldSnapshots;
/**
* Prune old metric points
*/
private pruneOldPoints;
/**
* Clear all metrics
*/
clear(): void;
}
//# sourceMappingURL=metrics-collector.d.ts.map