Nearest tool name (short form) for unknown-tool suggestions.
(canonical: &str, defs: &[ToolDefinition])
| 457 | |
| 458 | /// Nearest tool name (short form) for unknown-tool suggestions. |
| 459 | pub(crate) fn nearest_tool_name(canonical: &str, defs: &[ToolDefinition]) -> Option<String> { |
| 460 | let target = short_tool_name(canonical); |
| 461 | nearest_by_edit_distance( |
| 462 | target, |
| 463 | defs.iter() |
| 464 | .map(|def| short_tool_name(&def.name).to_string()), |
| 465 | ) |
| 466 | } |
| 467 | |
| 468 | /// Classic two-row Levenshtein distance; property and tool names are short so |
| 469 | /// the quadratic cost is irrelevant. |