/** * Smart TypeScript Tool - 83% Token Reduction * * Incremental TypeScript compilation with intelligent caching: * - Tracks file dependencies (import/export graph) * - Only recompiles changed files and their dependents * - Caches compilation results and type information * - <5s cache invalidation on file changes * - Provides actionable type error summaries */ import { CacheEngine } from '../../core/cache-engine.js'; import { MetricsCollector } from '../../core/metrics.js'; import { TokenCounter } from '../../core/token-counter.js'; interface SmartTypeScriptOptions { /** * Force full compilation (ignore cache) */ force?: boolean; /** * Project root directory */ projectRoot?: string; /** * TypeScript config file */ tsconfig?: string; /** * Maximum cache age in seconds (default: 300 = 5 minutes) */ maxCacheAge?: number; /** * Files to specifically check (incremental mode) */ files?: string[]; /** * Include type information in output */ includeTypeInfo?: boolean; } interface SmartTypeScriptOutput { /** * Compilation summary */ summary: { success: boolean; errorCount: number; warningCount: number; filesCompiled: number; filesFromCache: number; duration: number; fromCache: boolean; incrementalMode: boolean; }; /** * Categorized diagnostics (errors and warnings) */ diagnosticsByCategory: Array<{ category: string; severity: 'error' | 'warning' | 'info'; count: number; items: Array<{ file: string; location: string; code: number; message: string; }>; }>; /** * File dependency information */ dependencies?: { totalFiles: number; changedFiles: string[]; affectedFiles: string[]; dependencyGraph: Record; }; /** * Type information for exported symbols */ typeInfo?: Array<{ file: string; exports: Array<{ name: string; type: string; kind: string; }>; }>; /** * Optimization suggestions */ suggestions: Array<{ type: 'fix' | 'refactor' | 'config' | 'performance'; priority: number; message: string; impact: string; }>; /** * Token reduction metrics */ metrics: { originalTokens: number; compactedTokens: number; reductionPercentage: number; }; } export declare class SmartTypeScript { private cache; private metrics; private cacheNamespace; private projectRoot; private program?; private fileRegistry; private dependencyGraph; private reverseDependencyGraph; constructor(cache: CacheEngine, _tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string); /** * Run TypeScript compilation with intelligent caching and incremental mode */ run(options?: SmartTypeScriptOptions): Promise; /** * Build dependency graph from TypeScript program */ private buildDependencyGraph; /** * Extract imported file paths from a source file */ private extractImports; /** * Resolve import path to absolute file path */ private resolveImport; /** * Get all files affected by changes to specific files */ private getAffectedFiles; /** * Compile TypeScript files */ private compile; /** * Extract type information from a source file */ private extractTypeInfo; /** * Transform compilation result to smart output */ private transformOutput; /** * Categorize TypeScript diagnostic */ private categorizeDiagnostic; /** * Generate optimization suggestions */ private generateSuggestions; /** * Generate cache key based on tsconfig and file hashes */ private generateCacheKey; /** * Generate hash for a single file */ private generateFileHash; /** * Get cached result if available and fresh */ private getCachedResult; /** * Cache compilation result */ private cacheResult; /** * Estimate original output size (full diagnostic messages) */ private estimateOriginalOutputSize; /** * Estimate compact output size */ private estimateCompactSize; /** * Close cache and cleanup */ close(): void; } /** * Factory function to create SmartTypeScript with dependency injection */ export declare function getSmartTypeScriptTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string): SmartTypeScript; /** * CLI-friendly function for running smart TypeScript compilation */ export declare function runSmartTypescript(options?: SmartTypeScriptOptions): Promise; export declare const SMART_TYPESCRIPT_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { force: { type: string; description: string; default: boolean; }; projectRoot: { type: string; description: string; }; tsconfig: { type: string; description: string; default: string; }; maxCacheAge: { type: string; description: string; default: number; }; files: { type: string; description: string; items: { type: string; }; }; includeTypeInfo: { type: string; description: string; default: boolean; }; }; }; }; export {}; //# sourceMappingURL=smart-typescript.d.ts.map