UNPKG

@ooples/token-optimizer-mcp

Version:

Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters

215 lines 5.26 kB
/** * Smart Lint Tool - 75% Token Reduction * * Wraps ESLint to provide: * - Cached lint results per file * - Show only new issues * - Auto-fix suggestions * - Ignore previously acknowledged issues */ import { CacheEngine } from '../../core/cache-engine.js'; import { TokenCounter } from '../../core/token-counter.js'; import { MetricsCollector } from '../../core/metrics.js'; interface SmartLintOptions { /** * Files or pattern to lint */ files?: string | string[]; /** * Force full lint (ignore cache) */ force?: boolean; /** * Auto-fix issues */ fix?: boolean; /** * Project root directory */ projectRoot?: string; /** * Show only new issues (since last run) */ onlyNew?: boolean; /** * Include previously ignored issues */ includeIgnored?: boolean; /** * Maximum cache age in seconds (default: 3600 = 1 hour) */ maxCacheAge?: number; } interface SmartLintOutput { /** * Lint summary */ summary: { totalFiles: number; errorCount: number; warningCount: number; fixableCount: number; newIssuesCount: number; fromCache: boolean; }; /** * Issues grouped by severity and rule */ issues: Array<{ severity: 'error' | 'warning'; ruleId: string; count: number; fixable: boolean; files: Array<{ path: string; locations: Array<{ line: number; column: number; message: string; }>; }>; }>; /** * Auto-fix suggestions */ autoFixSuggestions: Array<{ ruleId: string; count: number; impact: 'high' | 'medium' | 'low'; }>; /** * New issues since last run */ newIssues: Array<{ file: string; ruleId: string; message: string; location: string; }>; /** * Token reduction _metrics */ _metrics: { originalTokens: number; compactedTokens: number; reductionPercentage: number; }; } export declare class SmartLint { private cache; private cacheNamespace; private projectRoot; private ignoredIssuesKey; constructor(cache: CacheEngine, _tokenCounter: TokenCounter, _metrics: MetricsCollector, projectRoot?: string); /** * Run lint with smart caching and output reduction */ run(options?: SmartLintOptions): Promise<SmartLintOutput>; /** * Run ESLint and capture results */ private runEslint; /** * Generate cache key based on source files */ private generateCacheKey; /** * Get cached result if available and fresh */ private getCachedResult; /** * Cache lint result */ private cacheResult; /** * Get previously ignored issues */ private getIgnoredIssues; /** * Generate issue key for tracking */ private generateIssueKey; /** * Compare with previous run to detect new issues */ private detectNewIssues; /** * Transform full lint output to smart output */ private transformOutput; /** * Estimate fix impact */ private estimateFixImpact; /** * Format cached output */ private formatCachedOutput; /** * Estimate original output size (full eslint output) */ private estimateOriginalOutputSize; /** * Estimate compact output size */ private estimateCompactSize; /** * Close cache connection */ close(): void; } /** * Factory function for creating SmartLint with shared resources (for benchmarks) */ export declare function getSmartLintTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string): SmartLint; /** * CLI-friendly function for running smart lint */ export declare function runSmartLint(options?: SmartLintOptions): Promise<string>; export declare const SMART_LINT_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { files: { type: string[]; description: string; items: { type: string; }; }; force: { type: string; description: string; default: boolean; }; fix: { type: string; description: string; default: boolean; }; projectRoot: { type: string; description: string; }; onlyNew: { type: string; description: string; default: boolean; }; includeIgnored: { type: string; description: string; default: boolean; }; maxCacheAge: { type: string; description: string; default: number; }; }; }; }; export {}; //# sourceMappingURL=smart-lint.d.ts.map