/**
 * Fuzzy matching utilities for the edit tool.
 *
 * Provides both character-level and line-level fuzzy matching with progressive
 * fallback strategies for finding text in files.
 */
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
import type { WritethroughCallback, WritethroughDeferredHandle } from "../../lsp/index.js";
import type { ToolSession } from "../../tools/index.js";
import type { EditToolDetails, LspBatchRequest } from "../renderer.js";
export interface FuzzyMatch {
    actualText: string;
    startIndex: number;
    startLine: number;
    confidence: number;
}
export interface MatchOutcome {
    match?: FuzzyMatch;
    closest?: FuzzyMatch;
    occurrences?: number;
    occurrenceLines?: number[];
    occurrencePreviews?: string[];
    fuzzyMatches?: number;
    dominantFuzzy?: boolean;
}
export type SequenceMatchStrategy = "exact" | "trim-trailing" | "trim" | "comment-prefix" | "unicode" | "prefix" | "substring" | "fuzzy" | "fuzzy-dominant" | "character";
export interface SequenceSearchResult {
    index: number | undefined;
    confidence: number;
    matchCount?: number;
    matchIndices?: number[];
    strategy?: SequenceMatchStrategy;
}
export type ContextMatchStrategy = "exact" | "trim" | "unicode" | "prefix" | "substring" | "fuzzy";
export interface ContextLineResult {
    index: number | undefined;
    confidence: number;
    matchCount?: number;
    matchIndices?: number[];
    strategy?: ContextMatchStrategy;
}
export declare class EditMatchError extends Error {
    readonly path: string;
    readonly searchText: string;
    readonly closest: FuzzyMatch | undefined;
    readonly options: {
        allowFuzzy: boolean;
        threshold: number;
        fuzzyMatches?: number;
    };
    constructor(path: string, searchText: string, closest: FuzzyMatch | undefined, options: {
        allowFuzzy: boolean;
        threshold: number;
        fuzzyMatches?: number;
    });
    static formatMessage(path: string, searchText: string, closest: FuzzyMatch | undefined, options: {
        allowFuzzy: boolean;
        threshold: number;
        fuzzyMatches?: number;
    }): string;
}
/** Default similarity threshold for fuzzy matching */
export declare const DEFAULT_FUZZY_THRESHOLD = 0.95;
/** Compute Levenshtein distance between two strings */
export declare function levenshteinDistance(a: string, b: string): number;
/** Compute similarity score between two strings (0 to 1) */
export declare function similarity(a: string, b: string): number;
/**
 * Find a match for target text within content.
 * Used primarily for replace-mode edits.
 */
export declare function findMatch(content: string, target: string, options: {
    allowFuzzy: boolean;
    threshold?: number;
}): MatchOutcome;
/**
 * Find a sequence of pattern lines within content lines.
 *
 * Attempts matches with decreasing strictness:
 * 1. Exact match
 * 2. Trailing whitespace ignored
 * 3. All whitespace trimmed
 * 4. Unicode punctuation normalized
 * 5. Prefix match (pattern is prefix of line)
 * 6. Substring match (pattern is substring of line)
 * 7. Fuzzy similarity match
 *
 * @param lines - The lines of the file content
 * @param pattern - The lines to search for
 * @param start - Starting index for the search
 * @param eof - If true, prefer matching at end of file first
 */
export declare function seekSequence(lines: string[], pattern: string[], start: number, eof: boolean, options?: {
    allowFuzzy?: boolean;
}): SequenceSearchResult;
export declare function findClosestSequenceMatch(lines: string[], pattern: string[], options?: {
    start?: number;
    eof?: boolean;
}): {
    index: number | undefined;
    confidence: number;
    strategy: SequenceMatchStrategy;
};
/**
 * Find a context line in the file using progressive matching strategies.
 *
 * @param lines - The lines of the file content
 * @param context - The context line to search for
 * @param startFrom - Starting index for the search
 */
export declare function findContextLine(lines: string[], context: string, startFrom: number, options?: {
    allowFuzzy?: boolean;
    skipFunctionFallback?: boolean;
}): ContextLineResult;
export declare const replaceEditEntrySchema: import("arktype/internal/variants/object.ts").ObjectType<{
    old_text: string;
    new_text: string;
    all?: boolean | undefined;
}, {}>;
export declare const replaceEditSchema: import("arktype/internal/variants/object.ts").ObjectType<{
    path: string;
    edits: {
        old_text: string;
        new_text: string;
        all?: boolean | undefined;
    }[];
}, {}>;
export type ReplaceEditEntry = typeof replaceEditEntrySchema.infer;
export type ReplaceParams = typeof replaceEditSchema.infer;
export interface ExecuteReplaceSingleOptions {
    session: ToolSession;
    path: string;
    params: ReplaceEditEntry;
    signal?: AbortSignal;
    batchRequest?: LspBatchRequest;
    allowFuzzy: boolean;
    fuzzyThreshold: number;
    writethrough: WritethroughCallback;
    beginDeferredDiagnosticsForPath: (path: string) => WritethroughDeferredHandle;
}
export declare function executeReplaceSingle(options: ExecuteReplaceSingleOptions): Promise<AgentToolResult<EditToolDetails, ReplaceEditEntry>>;
