/** * Shared diff computation utilities for the edit tool. * Used by both edit.ts (for execution) and tool-execution.ts (for preview rendering). */ export declare function detectLineEnding(content: string): "\r\n" | "\n"; export declare function normalizeToLF(text: string): string; export declare function digestNormalizedEditSource(content: string): string; export declare function restoreLineEndings(text: string, ending: "\r\n" | "\n"): string; /** * Normalize text for fuzzy matching. Applies progressive transformations: * - Strip trailing whitespace from each line * - Normalize smart quotes to ASCII equivalents * - Normalize Unicode dashes/hyphens to ASCII hyphen * - Normalize special Unicode spaces to regular space */ export declare function normalizeForFuzzyMatch(text: string): string; export interface FuzzyMatchResult { /** Whether a match was found */ found: boolean; /** The index where the match starts (in the content that should be used for replacement) */ index: number; /** Length of the matched text */ matchLength: number; /** Whether fuzzy matching was used (false = exact match) */ usedFuzzyMatch: boolean; /** The original content replacements should be applied to. */ contentForReplacement: string; } export interface Edit { oldText: string; newText: string; /** Inclusive 1-based line bounds from the read that supplied oldText. */ range?: EditRange; } export interface EditRange { startLine: number; endLine: number; } interface PlannedEdit { editIndex: number; matchIndex: number; matchLength: number; newText: string; expectedText: string; } export interface EditMatchPlan { /** Length of the LF-normalized source against which this plan was validated. */ baseLength: number; editCount: number; /** Compact, source-ordered replacement spans; the source body is not retained. */ edits: readonly PlannedEdit[]; } export interface AppliedEditsResult { baseContent: string; newContent: string; } /** * Find oldText in content, trying exact match first, then fuzzy match. * Fuzzy matching searches normalized text, but returned spans still refer to * the original content so replacement does not normalize unrelated text. */ export declare function fuzzyFindText(content: string, oldText: string): FuzzyMatchResult; /** Strip UTF-8 BOM if present, return both the BOM (if any) and the text without it */ export declare function stripBom(content: string): { bom: string; text: string; }; /** * Match and validate one or more replacements against LF-normalized content. * * The returned plan retains only the validated spans and their replacement * text. Exact matching uses native substring search, bounded by optional line * ranges, while uniqueness is still proven across the whole source. */ export declare function planEditsToNormalizedContent(normalizedContent: string, edits: Edit[], path: string): EditMatchPlan; /** Apply a validated match plan to the same LF-normalized source in one linear join. */ export declare function applyEditMatchPlan(normalizedContent: string, plan: EditMatchPlan, path: string): AppliedEditsResult; export declare function applyEditsToNormalizedContent(normalizedContent: string, edits: Edit[], path: string): AppliedEditsResult; /** Generate a standard unified patch. */ export declare function generateUnifiedPatch(path: string, oldContent: string, newContent: string, contextLines?: number): string; /** * Generate a display-oriented diff string with line numbers and context. * Returns both the diff string and the first changed line number (in the new file). */ export declare function generateDiffString(oldContent: string, newContent: string, contextLines?: number): { diff: string; firstChangedLine: number | undefined; }; export interface EditDiffResult { diff: string; firstChangedLine: number | undefined; } export interface EditDiffError { error: string; } export interface EditPlannedDiffResult extends EditDiffResult { plan: EditMatchPlan; sourceDigest: string; } /** * Compute the diff for one or more edit operations without applying them. * Used for preview rendering in the TUI before the tool executes. */ export declare function computeEditsPlannedDiff(path: string, edits: Edit[], cwd: string): Promise; export declare function computeEditsDiff(path: string, edits: Edit[], cwd: string): Promise; /** * Compute the diff for a single edit operation without applying it. * Kept as a convenience wrapper for single-edit callers. */ export declare function computeEditDiff(path: string, oldText: string, newText: string, cwd: string): Promise; export {}; //# sourceMappingURL=edit-diff.d.ts.map