query

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package query provides a tool for embedding-based code search.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inputs

type Inputs struct {
	// Query is the search query for semantic similarity.
	Query string `json:"query" jsonschema:"required,description=Search query for semantic similarity" validate:"required"`
	// K is the number of results to return (default: from config).
	K int `json:"k,omitempty" jsonschema:"description=Number of results to return (default from config)"`
	// FullContent returns chunk content in results when true.
	FullContent bool `json:"full_content,omitempty" jsonschema:"description=Return chunk content in results (default false)"`
	// Reranking enables the reranking pass. Nil/omitted = true (default on).
	Reranking *bool `json:"reranking,omitempty" jsonschema:"description=Include reranking pass (default true)"`
}

Inputs defines the parameters for the Query tool.

type Result

type Result struct {
	Path      string `json:"path"`
	StartLine int    `json:"start_line"`
	EndLine   int    `json:"end_line"`
	Content   string `json:"content,omitempty"`
}

Result represents a single search result for JSON output.

type Tool

type Tool struct {
	tool.Base

	// Cfg is the full config — needed because this tool creates sub-agents
	// via agent.New(), which requires access to agents, providers, modes,
	// and the full BuildAgent pipeline. Also uses Home (embedding cache path)
	// and Features.Estimation (token estimator).
	Cfg    config.Config
	Paths  config.Paths
	Rt     *config.Runtime
	Events chan<- ui.Event
}

Tool implements embedding-based code search.

func New

func New(cfg config.Config, paths config.Paths, rt *config.Runtime) *Tool

New creates a Query tool with the given configuration.

func (*Tool) Available

func (t *Tool) Available() bool

Available checks if the embeddings agent is configured.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, args map[string]any) (string, error)

Execute indexes the codebase and searches for similar content.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool's identifier.

func (*Tool) Sandboxable

func (t *Tool) Sandboxable() bool

Sandboxable returns false because the tool accesses the filesystem and network.

func (*Tool) Schema

func (t *Tool) Schema() tool.Schema

Schema returns the provider-agnostic tool definition.

Jump to

Keyboard shortcuts

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