Expand description
Tool search engine: keyword-based discovery of deferred tools.
Ported from claude-code/src/tools/ToolSearchTool/ToolSearchTool.ts
(searchToolsWithKeywords, lines 186-302). The pure-function
resolve(query, specs) -> Vec<String> design is preserved so the
algorithm is straightforward to test in isolation.
Two phases:
- Fast path: exact name match (case-insensitive) returns
immediately. Handles the
select:<tool_name>style where the model passes a bare tool name. - Scored keyword search: split the query into terms, score
each candidate tool by name parts,
search_hint, and description word boundaries, return the top N by score.
The + prefix on a term marks it as required (must appear in
name or description); the remaining terms are ranked.
Structs§
- Keyword
Search Engine - The default search engine: keyword + CamelCase +
searchHintweighted scoring, as described in fake-cc’ssrc/tools/ToolSearchTool/ToolSearchTool.ts:186-302.
Constants§
- DEFAULT_
MAX_ RESULTS - Default number of results returned when the caller doesn’t
specify a
max_resultsvalue. - MAX_
RESULTS_ CAP - Hard cap on the number of results, regardless of caller request.
Traits§
- Tool
Search Engine - Resolves a free-text query into a ranked list of deferred tool names. Implementations are pure functions of their inputs — no I/O, no async — so they are easy to unit-test.
Type Aliases§
- Spec
With Hint - A
(spec, search_hint)pair, as produced byToolRegistry::partition_by_eagerness. The hint is local metadata; the spec is the wire shape sent to the model.