/** * Type definitions for discovery and fuzzy matching helpers * * Provides types for fuzzy-matching functionality used to suggest corrections * when tools, prompts, or resources are not found in discovery caches. * * @module @wavespec/kit/discovery/types */ /** * Result of a fuzzy match operation * * Contains the matched value along with distance and similarity metrics * that indicate how close the match is to the input string. * * @example * ```typescript * // Searching for "reead_file" against ["read_file", "write_file"] * const matches = findClosestMatches("reead_file", ["read_file", "write_file"]); * // Returns: * // { * // value: "read_file", // The matched string * // distance: 1, // One character different * // similarity: 0.89 // 89% similar * // } * ``` */ export interface FuzzyMatchResult { /** The matched string (original case preserved) */ value: string; /** * Levenshtein distance between input and candidate * * Represents the minimum number of single-character edits (insertions, * deletions, substitutions) required to transform input into candidate. * Lower values indicate better matches. * * @example * - distance: 0 → exact match * - distance: 1 → one character different * - distance: 2 → two characters different */ distance: number; /** * Similarity score from 0 to 1 * * Calculated as: `1 - (distance / max_string_length)` * * Higher values indicate better matches: * - similarity: 1.0 → exact match * - similarity: 0.9 → very similar * - similarity: 0.5 → somewhat similar * - similarity: 0.0 → completely different */ similarity: number; } /** * Options for fuzzy matching behavior * * Controls how closely strings are matched and how many results are returned. * * @example * ```typescript * // Get top 5 matches with lower threshold for typos * const matches = findClosestMatches("ressource", candidates, { * maxResults: 5, * minSimilarity: 0.3, // Allow more typos * caseSensitive: false // Ignore case differences * }); * ``` */ export interface FuzzyMatchOptions { /** * Maximum number of results to return * * @default 3 */ maxResults?: number; /** * Minimum similarity threshold (0 to 1) * * Filters out matches below this threshold. A value of 0.4 means * the match must be at least 40% similar to the input. * * Common thresholds: * - 0.4 → Default, good for finding typos and similar names * - 0.5 → Stricter, better when looking for close matches * - 0.6 → Very strict, only very similar matches * - 0.3 → Lenient, includes more suggestions for very different names * * @default 0.4 */ minSimilarity?: number; /** * Whether matching should be case-sensitive * * When false (default), "ReadFile" matches "read_file" equally well. * When true, case differences are counted as edits. * * @default false */ caseSensitive?: boolean; } //# sourceMappingURL=types.d.ts.map