/** * Hashline-style anchor recovery for the edit tool. * * When exact and whitespace-fuzzy matching both fail (the file drifted since * the model read it: lines edited, shifted, or partially rewritten), we anchor * each line of oldText by a short content hash and look for the window of the * file with the highest anchor hit rate. The replacement is only applied when * the best window is unambiguous (clear margin over the runner-up). */ export interface AnchorRecoveryResult { found: boolean; /** Start line (0-based) of the recovered window in the content */ startLine: number; /** End line (0-based, exclusive) of the recovered window */ endLine: number; /** * Similarity of the window with oldText (0-1): matched non-empty lines divided by * the larger of the oldText and window non-empty line counts, so it bounds both the * share of oldText found and the share of the window the model has seen. */ score: number; /** True when two windows score too close to pick safely */ ambiguous: boolean; /** * Non-empty lines of the window that match no oldText line: content the model * never saw and that the replacement overwrites. Callers must report it. */ unmatchedWindowLines: number; } /** Short content hash of one normalized line (trailing whitespace stripped). */ export declare function lineAnchor(line: string): string; /** Map of hash -> line numbers for a document. */ export declare function computeAnchors(content: string): Map; /** Minimum anchor hit rate for a recovery to be considered. */ export declare const RECOVERY_THRESHOLD = 0.6; /** Minimum relative margin between best and second-best window. */ export declare const AMBIGUITY_MARGIN = 0.15; /** * Recover the position of oldText in content by line anchors. * oldText must span at least 2 non-empty lines; single-line recovery is left * to the exact/fuzzy matchers (single short lines are too ambiguous). * * Safety rules: the first and last non-empty lines of oldText must both match the * boundaries of the window (so the replacement can neither slide past the region * the model saw nor swallow neighbouring lines), leading/trailing blank lines of * oldText must be blank in the file too, and the window may not grow or shrink by * more than the tolerated drift. */ export declare function recoverByAnchors(content: string, oldText: string): AnchorRecoveryResult; /** * Replace the recovered window [startLine, endLine) of content with newText. * Returns the new content. Callers must have validated recovery.found first. */ export declare function applyRecoveredWindow(content: string, recovery: AnchorRecoveryResult, newText: string): string; //# sourceMappingURL=edit-hashline.d.ts.map