/** * Smart Exports Tool * * Analyzes TypeScript/JavaScript export statements with intelligent caching. * Provides export tracking, unused export detection, and optimization suggestions. * * Token Reduction: 75-85% through summarization of export analysis */ import { CacheEngine } from '../../core/cache-engine.js'; import { MetricsCollector } from '../../core/metrics.js'; import { TokenCounter } from '../../core/token-counter.js'; /** * Export statement information */ export interface ExportInfo { /** Type of export: named, default, namespace, reexport */ type: 'named' | 'default' | 'namespace' | 'reexport'; /** Name of the exported symbol */ name: string; /** Original name if aliased */ originalName?: string; /** Module being re-exported from (for re-exports) */ fromModule?: string; /** Location in source file */ location: { line: number; column: number; }; /** Symbol kind (variable, function, class, etc.) */ kind?: string; /** Whether export is used (imported elsewhere) */ used?: boolean; /** TypeScript type information */ typeInfo?: string; } /** * Export optimization suggestion */ export interface ExportOptimization { /** Type of optimization */ type: 'remove-unused' | 'consolidate-exports' | 'barrel-file' | 'export-organization'; /** 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'; treeShaking?: 'low' | 'medium' | 'high'; }; } /** * Export dependency information */ export interface ExportDependency { /** File that imports this export */ importingFile: string; /** Exported symbol being imported */ symbol: string; /** How it's imported (named, default, namespace) */ importType: 'named' | 'default' | 'namespace'; } /** * Smart exports analysis result */ export interface SmartExportsResult { /** All exports found */ exports: ExportInfo[]; /** Unused exports detected */ unusedExports: ExportInfo[]; /** Export dependencies (what imports these exports) */ dependencies: ExportDependency[]; /** Optimization suggestions */ optimizations: ExportOptimization[]; /** Summary statistics */ summary: { totalExports: number; namedExports: number; defaultExports: number; reexports: number; unusedCount: number; dependencyCount: number; }; /** Cache metadata */ cached: boolean; cacheAge?: number; } /** * Options for smart exports analysis */ export interface SmartExportsOptions { /** 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 usage across project */ checkUsage?: boolean; /** Scan depth for checking usage (number of directories) */ scanDepth?: number; } /** * Smart Exports Tool * Analyzes export statements with caching */ export declare class SmartExportsTool { private cache; private metrics; private tokenCounter; private cacheNamespace; private projectRoot; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string); /** * Run smart exports analysis */ run(options?: SmartExportsOptions): Promise; /** * Extract export statements from source file */ private extractExports; /** * Find files that import these exports */ private findExportDependencies; /** * Scan project files up to specified depth */ private scanProjectFiles; /** * Extract imports from a file that might import from our target file */ private extractImportsFromFile; /** * Resolve import path to check if it matches target file */ private resolveImportPath; /** * Detect unused exports */ private detectUnusedExports; /** * Generate optimization suggestions */ private generateOptimizations; /** * 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 getSmartExportsTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string): SmartExportsTool; /** * Standalone function for CLI usage */ export declare function runSmartExports(options: SmartExportsOptions): Promise; /** * MCP Tool Definition */ export declare const SMART_EXPORTS_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; }; checkUsage: { type: string; description: string; default: boolean; }; scanDepth: { type: string; description: string; default: number; }; }; }; }; //# sourceMappingURL=smart-exports.d.ts.map