This document defines how broad agentgrep queries should be interpreted without requiring embeddings.
The goal is not deep semantic understanding. The goal is to turn one broad user query into an internal multi-pass lexical search plan.
A query should normalize into a small structured object with:
- raw text
- normalized text
- likely subject
- likely relation/intent
- support terms
- mode (
grep,find,trace)
struct ParsedQuery {
raw: String,
normalized_text: String,
tokens: Vec<String>,
identifier_tokens: Vec<String>,
path_tokens: Vec<String>,
phrase_tokens: Vec<String>,
mode: QueryMode,
intent: QueryIntent,
subject: Option<String>,
relation: Option<RelationKind>,
support_terms: Vec<String>,
constraints: QueryConstraints,
}User wants exact lexical truth.
User wants files/paths.
User wants interpretation, multi-pass probing, fusion, and grouped output.
Examples:
where is AuthStatus definedwhat is build_auth_status_linefind the implementation of auth_status
Boost:
- definitions
- type declarations
- function definitions
- primary implementation files
Examples:
where is auth_status called fromwho calls check_selfdev_signals
Boost:
- call expressions
- executable references
- dispatch and entrypoint code
Penalize:
- definition lines
- imports/reexports
Examples:
where is compaction triggered fromwhat triggers reconnect_attempts
Boost:
- event loops
- dispatch logic
- callbacks
- scheduling/queueing code
Examples:
where is auth_status renderedwhere is the memory widget renderedwhere is header label drawn
Expand relation terms with:
- render
- draw
- widget
- view
- layout
- ui
- panel
- component
Boost:
- UI files/modules
- render-like functions
- widget/component construction
Examples:
where is remote_available_models populatedwhere is image_regions set
Expand relation terms with:
- populate
- set
- assign
- insert
- push
- append
- build
- init
- update
Boost:
- assignment expressions
- field writes
- builder assembly
- initialization code
Examples:
where does provider_name come fromwhere does width come from
Expand relation terms with:
- source
- load
- fetch
- read
- parse
- deserialize
- initialize
- derive
Boost:
- upstream providers
- config loading
- parsing/deserialization
- constructor paths
Examples:
what handles scroll eventswhere is paste handledwhat handles subscribe response
Expand relation terms with:
- handle
- handler
- dispatch
- route
- on_
- callback
- event
Boost:
handle_*functions- match/routing code
- callbacks
- event loop logic
The initial trace interface should prefer a small DSL:
subject:auth_status relation:rendered support:ui
Accepted forms should include key:value and key=value.
Required keys:
subjectrelation
Optional keys:
supportkindpath
Recommended values:
kind:codeto suppress docs-oriented resultskind:docsto focus on docspath:src/tuito bias toward a subtree
For a query like:
subject:auth_status relation:rendered support:ui
agentgrep should:
- keep the raw terms
- normalize them
- use
auth_statusas explicit subject - use
renderedas explicit relation - expand into lexical probes
- run internal searches for:
- subject matches
- relation-context matches
- file-role/path matches
- co-occurrence evidence
- rerank and group results
This design should work well for:
- identifier + relation queries
- mixed natural-language + symbol queries
- repo navigation questions with strong lexical anchors
It is not trying to fully solve weak-anchor conceptual queries in v1.