Documentation
¶
Overview ¶
Package searchsession provides a cancellable, streaming search: unlike the grep/glob tools (which block until ripgrep finishes and return everything at once), search_start spawns ripgrep as a background job and returns immediately with a job_id - job_output (offset/tail-capable, see internal/tools/bash) paginates through matches as they accumulate, job_kill cancels a search that's taking too long or targeting too much, and task_list shows what's running. This reuses the existing bash background-task infrastructure wholesale (a ripgrep search is just another subprocess) rather than building a parallel job-tracking system.
It also covers a gap ripgrep can't: .docx/.xlsx are zipped XML, invisible to a line-oriented text search tool. search_start additionally searches the *extracted* text of any Office files under the search path (via internal/officetext, the same native reader read_file uses) and returns those matches immediately in its own response - a literal substring scan, not regex, both because it's fast enough for the modest number of Office files a typical search path has and to avoid a hostile pattern causing catastrophic backtracking against document text.
Index ¶
- Constants
- type Tool
- func (t *Tool) BackfillInput(_ context.Context, input map[string]any) map[string]any
- func (t *Tool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)
- func (t *Tool) CheckPermissions(_ context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
- func (t *Tool) Definition() tool.Definition
- func (t *Tool) Description(_ context.Context) (string, error)
- func (t *Tool) FormatResult(data any) string
- func (t *Tool) IsConcurrencySafe(_ map[string]any) bool
- func (t *Tool) IsEnabled() bool
- func (t *Tool) IsReadOnly(_ map[string]any) bool
- func (t *Tool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)
Constants ¶
const ( // ToolName is the name of the streaming search tool. ToolName = "search_start" // SearchHint is a hint for tool search functionality. SearchHint = "start a cancellable background content search over a large directory tree" // ToolDescription is the description of the search_start tool. ToolDescription = "Start a content search as a background job instead of blocking until it finishes - use this instead of Grep for a search that might be slow (huge directory, expensive regex) or where you want to see partial results / cancel early.\n\n" + "## When to use\n\n" + "- Large repositories or directory trees where a Grep call might take a while\n" + "- You want to start a search, do something else, and check back on it later\n" + "- You want to search inside .docx/.xlsx file contents too — Grep can't (they're zipped XML, not plain text), search_start extracts and searches their text natively\n\n" + "## When NOT to use\n\n" + "- A quick, targeted search in a small area — Grep is simpler and returns results directly\n\n" + "## Workflow\n\n" + "1. search_start returns a job_id immediately, plus any Office-document (.docx/.xlsx) matches found right away (a fast, separate pass).\n" + "2. job_output(job_id) reads ripgrep's matches as they accumulate — offset works the same as FileRead (negative = tail, i.e. last N matches).\n" + "3. job_kill(job_id) cancels the search early once you have enough, or if it's taking too long.\n" + "4. task_list shows all running searches (and other background jobs).\n" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool implements search_start.
func (*Tool) BackfillInput ¶
func (*Tool) Call ¶
func (t *Tool) Call( ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn, ) (tool.CallResult, error)
func (*Tool) CheckPermissions ¶
func (t *Tool) CheckPermissions(_ context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
func (*Tool) Definition ¶
func (t *Tool) Definition() tool.Definition