/** * Smart Imports Tool * * Analyzes TypeScript/JavaScript import statements with intelligent caching. * Provides import optimization suggestions, unused import detection, and circular dependency analysis. * * Token Reduction: 75-85% through summarization of import analysis */ import { CacheEngine } from '../../core/cache-engine.js'; import { MetricsCollector } from '../../core/metrics.js'; import { TokenCounter } from '../../core/token-counter.js'; /** * Import statement information */ export interface ImportInfo { /** Type of import: import, require, dynamic */ type: 'import' | 'require' | 'dynamic'; /** Module being imported */ module: string; /** Imported symbols and their aliases */ imports: Array<{ name: string; alias?: string; isDefault?: boolean; isNamespace?: boolean; }>; /** Location in source file */ location: { line: number; column: number; }; /** Whether import is used in the file */ used: boolean; /** Specific imports that are unused */ unusedImports?: string[]; } /** * Import optimization suggestion */ export interface ImportOptimization { /** Type of optimization */ type: 'remove-unused' | 'combine-imports' | 'reorder-imports' | 'convert-require' | 'add-missing'; /** Severity level */ severity: 'info' | 'warning' | 'error'; /** Human-readable message */ message: string; /** Specific suggestion */ suggestion: string; /** Location in source file */ location?: { line: number; column: number; }; /** Code example */ codeExample?: { before: string; after: string; }; /** Impact analysis */ impact?: { readability?: 'low' | 'medium' | 'high'; maintainability?: 'low' | 'medium' | 'high'; bundleSize?: 'low' | 'medium' | 'high'; }; } /** * Circular dependency information */ export interface CircularDependency { /** Files involved in the cycle */ cycle: string[]; /** Severity level */ severity: 'warning' | 'error'; /** Human-readable message */ message: string; } /** * Missing import suggestion */ export interface MissingImport { /** Symbol that appears to be missing */ symbol: string; /** Suggested modules where it might be found */ suggestedModules: string[]; /** Location where it's used */ location: { line: number; column: number; }; } /** * Smart imports analysis result */ export interface SmartImportsResult { /** All import statements found */ imports: ImportInfo[]; /** Unused imports detected */ unusedImports: ImportInfo[]; /** Missing imports detected */ missingImports: MissingImport[]; /** Optimization suggestions */ optimizations: ImportOptimization[]; /** Circular dependencies detected */ circularDependencies: CircularDependency[]; /** Summary statistics */ summary: { totalImports: number; unusedCount: number; missingCount: number; optimizationCount: number; circularCount: number; }; /** Cache metadata */ cached: boolean; cacheAge?: number; } /** * Options for smart imports analysis */ export interface SmartImportsOptions { /** File path to analyze */ filePath?: string; /** File content (if not reading from disk) */ fileContent?: string; /** Project root directory */ projectRoot?: string; /** Force analysis even if cached */ force?: boolean; /** Maximum cache age in seconds */ maxCacheAge?: number; /** Check for circular dependencies */ checkCircular?: boolean; /** Suggest missing imports */ suggestMissing?: boolean; } /** * Smart Imports Tool * Analyzes import statements with caching */ export declare class SmartImportsTool { private cache; private metrics; private tokenCounter; private cacheNamespace; private projectRoot; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string); /** * Run smart imports analysis */ run(options?: SmartImportsOptions): Promise; /** * Extract import statements from source file */ private extractImports; /** * Detect unused imports */ private detectUnusedImports; /** * Collect all symbols used in the file */ private collectUsedSymbols; /** * Detect missing imports */ private detectMissingImports; /** * Find location of a symbol in source file */ private findSymbolLocation; /** * Generate optimization suggestions */ private generateOptimizations; /** * Check if imports need reordering */ private checkImportOrder; /** * Get import type (external, internal, relative) */ private getImportType; /** * Detect circular dependencies */ private detectCircularDependencies; /** * Get imports for a file */ private getImportsForFile; /** * Resolve import path to absolute file path */ private resolveImportPath; /** * Generate cache key */ private generateCacheKey; /** * Get cached result */ private getCachedResult; /** * Cache result */ private cacheResult; /** * Compact result for token efficiency */ private compactResult; } /** * Factory function for dependency injection */ export declare function getSmartImportsTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string): SmartImportsTool; /** * Standalone function for CLI usage */ export declare function runSmartImports(options: SmartImportsOptions): Promise; /** * MCP Tool Definition */ export declare const SMART_IMPORTS_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; }; force: { type: string; description: string; default: boolean; }; maxCacheAge: { type: string; description: string; default: number; }; checkCircular: { type: string; description: string; default: boolean; }; suggestMissing: { type: string; description: string; default: boolean; }; }; }; }; //# sourceMappingURL=smart-imports.d.ts.map