/** * Fuzzy text matching based on Levenshtein distance. * * Ported from aaronsb/obsidian-mcp-plugin's `src/utils/fuzzy-match.ts`, but * adapted to work on raw strings instead of line-indexed content. Whereas * aaronsb's version returned line numbers (because the Obsidian editor wants * to highlight lines), this version returns character offsets so the caller * can perform in-place substring substitution. * * Two-stage approach: * 1. Direct substring search (case-insensitive). * 2. If no exact hit, sliding-window Levenshtein over word groups. */ export interface FuzzyMatch { /** Character offset where the match begins (inclusive). */ start: number; /** Character offset where the match ends (exclusive). */ end: number; /** The substring of `haystack` that matched. */ text: string; /** Similarity score in [0, 1]; 1 means exact (case-insensitive) match. */ score: number; } /** Similarity in [0,1]; 1 means identical (case-insensitive). */ export declare function similarity(a: string, b: string): number; /** * Locate fuzzy occurrences of `needle` inside `haystack`. * * Returns all matches at or above `threshold`, sorted by score descending. * The caller is expected to enforce uniqueness (e.g. 1 result = good, * >1 = ambiguous, 0 = missing). */ export declare function fuzzyFind(haystack: string, needle: string, threshold?: number): FuzzyMatch[];