@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
47 lines • 1.35 kB
TypeScript
/**
* Syntax-aware utilities for smart truncation and chunking
*/
export interface ChunkResult {
chunks: string[];
metadata: ChunkMetadata[];
totalSize: number;
}
export interface ChunkMetadata {
index: number;
startLine: number;
endLine: number;
size: number;
type: 'code' | 'comment' | 'import' | 'export' | 'function' | 'class' | 'other';
}
export interface TruncationResult {
truncated: string;
original: string;
removed: number;
kept: number;
compressionRatio: number;
}
/**
* Detect file type from extension
*/
export declare function detectFileType(filePath: string): string;
/**
* Smart chunking based on syntax boundaries
*/
export declare function chunkBySyntax(content: string, maxChunkSize?: number): ChunkResult;
/**
* Truncate file content intelligently, keeping important parts
*/
export declare function truncateContent(content: string, maxSize: number, options?: {
keepTop?: number;
keepBottom?: number;
preserveStructure?: boolean;
}): TruncationResult;
/**
* Extract only changed sections from content
*/
export declare function extractChangedSections(content: string, lineNumbers: number[]): string;
/**
* Check if content is minified/compressed
*/
export declare function isMinified(content: string): boolean;
//# sourceMappingURL=syntax-utils.d.ts.map