/** * 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; 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; }>; }>; /** * Of the files the caller named, the ones the program does not contain. * * Absent when every named file was checked. Present and non-empty means this * report is about fewer files than were asked about, which a caller cannot * work out from a count that only ever named successes. */ notTypeChecked?: string[]; /** * Optimization suggestions */ suggestions: Array<{ type: 'fix' | 'refactor' | 'config' | 'performance'; priority: number; message: string; impact: string; }>; } 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); /** * A path the CALLER wrote, resolved against the project root. * * `join(this.projectRoot, file)` was used directly, and on an absolute * argument that produces a path which exists nowhere: joining the root * `C:/p/fixtures` to `C:/p/fixtures/a.ts` appends the second whole path to * the first, drive letter included. Every consequence of it was silent. The * program had no source file under that name, so compile() skipped it and * reported zero diagnostics as `Status: Success`; getAffectedFiles joined * the root on a second time, so the report named a path doubled twice; and * generateCacheKey's existsSync failed, so the file's content never entered * the cache key and two different versions of a file shared one entry. * * `files` is documented as taking paths, not names, and the MCP dispatch * hands over whatever the caller sent. So absolute is the ordinary case * here, not the exception. */ private resolveFromRoot; /** * 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) */ /** * 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 { SMART_TYPESCRIPT_TOOL_DEFINITION } from './analysis-tool-definitions.js'; //# sourceMappingURL=smart-typescript.d.ts.map