Documentation
¶
Overview ¶
Package query implements semantic search from a caller's perspective.
Querier wraps an embedder and a store: its Querier.Search and Querier.SearchWithOptions methods embed the query string and run hybrid KNN + BM25 search over the store. Result is a separate type from store.SearchResult so query controls its own public surface independently of storage internals.
Querier.Map generates a token-budget-aware repo map by listing all named symbols from the store, grouping them by package, and rendering a compact directory of types and functions.
Index ¶
- func PackageFromPath(projectRoot, filePath string) string
- type MapOptions
- type Querier
- func (q *Querier) InvalidateMapCache()
- func (q *Querier) Map(ctx context.Context, opts MapOptions) (string, error)
- func (q *Querier) Search(ctx context.Context, text string, limit int) (SearchResults, error)
- func (q *Querier) SearchWithOptions(ctx context.Context, text string, opts SearchOptions) (SearchResults, error)
- type Result
- type SearchOptions
- type SearchResults
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackageFromPath ¶
PackageFromPath derives a Go-style package path from a file path relative to projectRoot. Returns "." for files directly in the project root.
Types ¶
type MapOptions ¶
type MapOptions struct {
MaxTokens int // token budget; 0 means no limit
CodeOnly bool // exclude languages listed in NonCodeLanguages
NonCodeLanguages []string // language names excluded when CodeOnly is true
ShowSummary bool // add per-file kind count summary in file headers
ShowVisibility bool // prefix symbols with + (exported) or - (internal)
}
MapOptions configures a Querier.Map call.
type Querier ¶
type Querier struct {
// contains filtered or unexported fields
}
Querier runs semantic search over an indexed store.
func (*Querier) InvalidateMapCache ¶
func (q *Querier) InvalidateMapCache()
InvalidateMapCache bumps the generation counter so the next Map call rebuilds the cached output from the store.
func (*Querier) Map ¶
Map generates a token-budget-aware repository map by listing all named symbols from the store, grouping them by package, and rendering a compact directory. Packages with more symbols appear first. Results are cached by generation counter; call Querier.InvalidateMapCache after indexing new content to force a rebuild. The cache stores unfiltered data; all MapOptions filtering is applied at render time.
func (*Querier) Search ¶
Search embeds text and returns the top limit most similar records from the store.
func (*Querier) SearchWithOptions ¶
func (q *Querier) SearchWithOptions(ctx context.Context, text string, opts SearchOptions) (SearchResults, error)
SearchWithOptions is like Search but also accepts offset, language, path, package, and token-budget filters via SearchOptions.
type Result ¶
type Result struct {
FilePath string
Language string
Content string
NodeKind string
Name string
Parent string
StartLine int
EndLine int
Score float32
}
Result is a matching code chunk returned by Querier.Search or Querier.SearchWithOptions, with a relevance Score.
type SearchOptions ¶
type SearchOptions struct {
Limit int // maximum number of results to return
Offset int // number of results to skip (pagination)
Languages []string // filter by language name; nil means all
Paths []string // glob patterns for file path filtering
MaxTokens int // token budget; 0 means no limit
Package string // filter to a package (e.g. "store"); resolved to a Paths glob
Names []string // filter by symbol name; nil means all
NodeKinds []string // filter by node kind; nil means all
MetadataOnly bool // when true, return metadata only (no content)
}
SearchOptions configures a Querier.SearchWithOptions call.
type SearchResults ¶
type SearchResults struct {
Results []Result // matching chunks in relevance order
Truncated bool // true when MaxTokens budget caused results to be dropped
}
SearchResults wraps a slice of results with a truncation flag indicating whether the token budget caused some results to be dropped.