fix(tools): rank natural-language tool search#260
Conversation
Tokenize tool names and descriptions so nb__search can match multi-term queries like "todo task create" across hyphenated source names, tool names, and descriptions. Reuse the ranked search for invalid-tool suggestions and add regressions for todo-board discovery. Fixes NimbleBrainInc#33
|
Thanks for picking this up! The tokenization + multi-term matching is the right shape for the bug, and the new tests cover the three motivating queries from the issue cleanly. Two small things I'd want to address before merging — both are narrow fixes, not asking for a rework. 1. Single-word prefix queries regress. The old substring filter matched if (matchedTerms === 0 && !name.includes(normalizedQuery) && !description.includes(normalizedQuery)) continue;Worth a regression test ( 2. The system-tools handler is uncapped. Tests, typecheck, and lint all pass locally. Nice clean module separation — having |
Summary
Fixes #33.
nb__searchpreviously used literal substring matching over the full query, so natural-language queries liketodo task createfailed unless that exact phrase appeared contiguously in a tool name or description.This PR adds deterministic tokenized ranking for tool discovery:
-,_, and spaces.This allows queries like
todo task createandtodo boardto discoversynapse-todo-board__create_board_task.Testing
bun test test/unit/system-tools.test.tsbun run checkbun run format:checkbun run lint