search

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package search ranks tools for code mode's searchTools() and the tool_search tool with BM25.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RankDocuments

func RankDocuments(query string, documents []Document, limit int) []string

RankDocuments is Okapi BM25 (k1 1.2, b 0.75) over the text, with the name and the namespace as separate fields: the names of the best matches, best first; ties keep document order.

  • A tool that matches more of the query's terms, in any field, ranks above one that matches fewer, whatever their scores: for `screenshot window`, a tool whose description has both words beats `window`, whose name has one.
  • A query term in the name scores more than any number of mentions in the text.
  • A tool whose whole local name (after the last `__`) is in the query gets a bonus worth one more match of every query term, so among tools matching as many terms, `peekaboo app` finds `mcp__peekaboo__app` over tools that only mention the words.
  • A query that is exactly a tool's name, or its name after a `__`, ranks that tool first, before coverage.

Only the text is length-normalized, so a long name or long namespace instructions do not lower a tool's score.

Types

type Document

type Document struct {
	Name string
	// Text is the description and the parameters' names and descriptions, not the name.
	Text string
	// NamespaceText is the name, description and instructions of the tool's namespace.
	NamespaceText string
}

Document is a tool as the ranker sees it: its name, its text and the text of its namespace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL