/** * File Read Tracker - Enforces "Read Before Edit" pattern * * This module tracks file reads to ensure the AI has fresh content * before attempting edits. This prevents "old_string not found" errors * caused by using stale content from memory. */ export interface FileReadRecord { /** When the file was last read */ timestamp: number; /** Hash of the content at read time (for staleness detection) */ contentHash: string; /** Line range that was read (null = full file) */ lineRange: { start: number; end: number; } | null; } export interface ReadValidationResult { /** Whether the read is valid for editing */ valid: boolean; /** Type of issue if not valid */ issue?: 'not_read' | 'stale' | 'content_changed'; /** Error message for display */ errorMessage?: string; /** Whether auto-refresh can resolve the issue */ canAutoRefresh?: boolean; } /** * Simple content hash for staleness detection */ export declare function hashContent(content: string): string; /** * Record that a file was read */ export declare function recordFileRead(filePath: string, content: string, lineRange?: { start: number; end: number; }): void; /** * Check if a file has been read recently enough for editing */ export declare function wasFileReadRecently(filePath: string): boolean; /** * Get the read record for a file */ export declare function getFileReadRecord(filePath: string): FileReadRecord | null; /** * Validate that a file read is valid for the edit being attempted * Returns null if valid, or an error message if not */ export declare function validateReadForEdit(filePath: string, _oldString: string, currentContent: string): string | null; /** * Enhanced validation that returns structured result for auto-refresh support. * Returns detailed info about validation state instead of just an error message. */ export declare function validateReadForEditEx(filePath: string, _oldString: string, currentContent: string): ReadValidationResult; /** * Clear all read records (for testing or session reset) */ export declare function clearFileReadRecords(): void; /** * Get stats for debugging */ export declare function getReadTrackerStats(): { trackedFiles: number; oldestReadAge: number | null; }; //# sourceMappingURL=fileReadTracker.d.ts.map