Skip to main content

Module search

Module search 

Source
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:

  1. Fast path: exact name match (case-insensitive) returns immediately. Handles the select:<tool_name> style where the model passes a bare tool name.
  2. 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§

KeywordSearchEngine
The default search engine: keyword + CamelCase + searchHint weighted scoring, as described in fake-cc’s src/tools/ToolSearchTool/ToolSearchTool.ts:186-302.

Constants§

DEFAULT_MAX_RESULTS
Default number of results returned when the caller doesn’t specify a max_results value.
MAX_RESULTS_CAP
Hard cap on the number of results, regardless of caller request.

Traits§

ToolSearchEngine
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§

SpecWithHint
A (spec, search_hint) pair, as produced by ToolRegistry::partition_by_eagerness. The hint is local metadata; the spec is the wire shape sent to the model.