Expand description
Task-driven context packs.
Given a natural-language task and a token budget, greplm assembles the most
relevant slice of the codebase an agent needs to act — ranked by lexical
relevance, call-graph centrality, and (when built with the semantic
feature) meaning — and packs it to fit the budget. This is the “give me
exactly the code for this task” surface that keeps agents off the
grep-then-read-whole-files treadmill.
The ranking helpers here are pure; crate::search::Searcher::context_pack
drives them over the index.
Structs§
- Context
Pack - A budget-bounded bundle of context for a task.
- Pack
Item - One unit of packed context: a symbol, its signature, and a code snippet.
- Score
Scratch - Reusable buffers for
lexical_score_with.
Constants§
- CHARS_
PER_ TOKEN - Conservative chars-per-token estimate (matches the savings accounting).
Functions§
- est_
tokens - Estimate the token cost of a string.
- lexical_
score - Lexical relevance of a symbol to the task terms.
- lexical_
score_ with - Lexical relevance of a symbol, given its document’s precomputed
path_term_bonus. Allocation-free oncescratch’s buffers are warm. - path_
term_ bonus - The path component of a symbol’s lexical score:
2.0per task term that appears in the path. This depends only on the document, socontext_packcomputes it once per file rather than once per symbol. - split_
identifier - Split an identifier into lowercase tokens on camelCase and snake/kebab.
- tokenize
- Tokenize a free-form task into lowercased search terms: split on non-identifier characters, then split camelCase/snake_case, dropping stopwords and 1-character noise.