/** * Smart Complexity Analysis Tool * * Analyzes code complexity metrics with intelligent caching * Calculates cyclomatic, cognitive, and Halstead metrics * Target: 70-80% token reduction through metric summarization */ import { CacheEngine } from '../../core/cache-engine.js'; import { MetricsCollector } from '../../core/metrics.js'; import { TokenCounter } from '../../core/token-counter.js'; export interface SmartComplexityOptions { filePath?: string; fileContent?: string; projectRoot?: string; includeHalstead?: boolean; includeMaintainability?: boolean; threshold?: { cyclomatic?: number; cognitive?: number; }; force?: boolean; maxCacheAge?: number; } export interface ComplexityMetrics { cyclomatic: number; cognitive: number; halstead?: HalsteadMetrics; maintainabilityIndex?: number; linesOfCode: number; logicalLinesOfCode: number; } export interface HalsteadMetrics { distinctOperators: number; distinctOperands: number; totalOperators: number; totalOperands: number; vocabulary: number; length: number; calculatedLength: number; volume: number; difficulty: number; effort: number; time: number; bugs: number; } export interface FunctionComplexity { name: string; location: { line: number; column: number; }; complexity: ComplexityMetrics; aboveThreshold: boolean; } export interface SmartComplexityResult { summary: { file: string; totalComplexity: ComplexityMetrics; averageComplexity: number; maxComplexity: number; functionsAboveThreshold: number; totalFunctions: number; riskLevel: 'low' | 'medium' | 'high' | 'critical'; fromCache: boolean; duration: number; }; functions: FunctionComplexity[]; fileMetrics: ComplexityMetrics; recommendations: string[]; metrics: { originalTokens: number; compactedTokens: number; reductionPercentage: number; }; } export declare class SmartComplexityTool { private cache; private metrics; private tokenCounter; private cacheNamespace; private projectRoot; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string); run(options?: SmartComplexityOptions): Promise; private analyzeFunctions; private getFunctionName; private calculateComplexity; private calculateCyclomaticComplexity; private calculateCognitiveComplexity; private calculateHalsteadMetrics; private calculateMaintainabilityIndex; private countLines; private calculateFileMetrics; private generateRecommendations; private calculateRiskLevel; private compactResult; private generateCacheKey; private getCachedResult; private cacheResult; } export declare function getSmartComplexityTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector): SmartComplexityTool; export declare function runSmartComplexity(options: SmartComplexityOptions, cache?: CacheEngine, tokenCounter?: TokenCounter, metrics?: MetricsCollector): Promise; export declare const SMART_COMPLEXITY_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { filePath: { type: string; description: string; }; fileContent: { type: string; description: string; }; projectRoot: { type: string; description: string; }; includeHalstead: { type: string; description: string; default: boolean; }; includeMaintainability: { type: string; description: string; default: boolean; }; threshold: { type: string; description: string; properties: { cyclomatic: { type: string; default: number; }; cognitive: { type: string; default: number; }; }; }; force: { type: string; description: string; default: boolean; }; maxCacheAge: { type: string; description: string; default: number; }; }; }; }; //# sourceMappingURL=smart-complexity.d.ts.map