/** * Preprocessor for reducing AI token usage * * Provides functions to compress code snippets before sending to LLM: * - Remove comments (single-line and multi-line) * - Collapse multiple blank lines * - Extract only changed functions/classes * - Summarize unchanged context */ import type { FileSnippet } from '../parsers/file-reader.js'; export interface PreprocessOptions { /** Strip single-line (//) and multi-line (block) comments */ removeComments: boolean; /** Collapse multiple consecutive blank lines into one */ removeBlankLines: boolean; /** Only include lines within changed functions/classes */ extractChangedOnly: boolean; /** Replace large unchanged blocks with summaries */ summarizeContext: boolean; /** Minimum lines to trigger summarization */ summarizeThreshold: number; } export declare const DEFAULT_PREPROCESS_OPTIONS: PreprocessOptions; /** * Remove single-line comments (//) from code */ export declare function removeSingleLineComments(content: string): string; /** * Remove multi-line block comments from code */ export declare function removeMultiLineComments(content: string): string; /** * Collapse multiple consecutive blank lines into a single blank line */ export declare function collapseBlankLines(content: string): string; /** * Remove leading/trailing whitespace from each line while preserving indentation structure */ export declare function trimTrailingWhitespace(content: string): string; /** * Summarize a block of code by showing first/last lines and a count */ export declare function summarizeBlock(lines: string[], maxPreview?: number): string; /** * Extract the function or class containing specific line numbers */ export declare function extractContainingScope(content: string, changedLines: number[]): string; /** * Preprocess a code snippet to reduce token count */ export declare function preprocessSnippet(snippet: FileSnippet, options?: Partial): FileSnippet; /** * Preprocess multiple snippets */ export declare function preprocessSnippets(snippets: FileSnippet[], options?: Partial): FileSnippet[]; /** * Estimate token count for a string (rough approximation) * Uses ~4 characters per token as a heuristic */ export declare function estimateTokens(content: string): number; /** * Calculate token savings from preprocessing */ export declare function calculateSavings(original: string, preprocessed: string): { originalTokens: number; newTokens: number; savedTokens: number; savingsPercent: number; }; //# sourceMappingURL=preprocessor.d.ts.map