/** * File State Cache — LRU 文件状态缓存 * * 设计: * 使用路径归一化 + 大小驱逐的 LRU 缓存, * 避免 AI 工具重复读取同一文件。 * * 核心设计: * 1. 路径归一化(resolve + normalize)确保一致的缓存键 * 2. 双限制驱逐:条目数上限 + 字节大小上限 * 3. 支持部分内容缓存(offset + limit) * 4. write/edit 后自动更新缓存 */ /** 默认缓存条目数上限 */ export declare const DEFAULT_MAX_ENTRIES = 100; /** 默认缓存字节数上限(25MB) */ export declare const DEFAULT_MAX_SIZE_BYTES: number; /** 缓存的文件状态 */ export interface FileState { /** 文件内容 */ content: string; /** 缓存时间戳 */ timestamp: number; /** 读取偏移(如果是部分读取) */ offset?: number; /** 读取限制(如果是部分读取) */ limit?: number; /** 是否是部分内容 */ isPartialView?: boolean; } /** * LRU 文件状态缓存 * * 使用双向链表维护访问顺序,Map 存储内容。 * 同时由条目数和总字节数两个维度控制缓存大小。 */ export declare class FileStateCache { private cache; private accessOrder; private totalBytes; private maxEntries; private maxSizeBytes; constructor(maxEntries?: number, maxSizeBytes?: number); /** * 归一化文件路径 */ private normalizePath; /** * 计算内容字节数 */ private contentBytes; /** * 获取缓存的文件状态 */ get(filePath: string): FileState | undefined; /** * 设置文件状态缓存 */ set(filePath: string, state: FileState): void; /** * 删除指定文件的缓存 */ delete(filePath: string): boolean; /** * 检查是否有缓存 */ has(filePath: string): boolean; /** * 清空全部缓存 */ clear(): void; /** 当前缓存条目数 */ get size(): number; /** 当前缓存总字节数 */ get bytes(): number; private touchAccessOrder; private evictIfNeeded; private evictLRU; } //# sourceMappingURL=file-state-cache.d.ts.map