XNews

Context.dev Releases sgrep, a Rust Local Semantic Code Search CLI

Context.dev Releases sgrep, a Rust Local Semantic Code Search CLI

Context.dev has open-sourced sgrep, a Rust-written local semantic code and document search CLI that runs a roughly 32MB CPU model fully offline after the first search, keeping code and queries on the machine. The tool combines ripgrep-based file enumeration, Tree-sitter syntax-aware chunking, static embeddings from MinishLab's model2vec-style Potion models, and hybrid scoring of 75% semantic plus 25% BM25 with exact identifier matches ranked first. On SWE-bench Verified with GPT-6 across 50 tasks run twice, sgrep in pipeline mode cut LLM API costs by 21.3% versus ripgrep while solving 70 of 100 tasks against 68 of 100.

Event version 4.

Key insights

Cost and task results on SWE-bench Verified

In pipeline mode on SWE-bench Verified with GPT-6 across 50 tasks run twice, sgrep saved 21.3% in LLM API costs compared with ripgrep and solved 70 of 100 tasks versus 68 of 100. The result reflects fewer retrieval rounds and cheaper context for slightly better outcomes.

Retrieval quality across benchmarks

sgrep leads on RepoQA for full-function retrieval, while CK's semantic mode is stronger on CoSQA for code snippet retrieval. The author states this limitation directly.

Trade-offs of static embeddings

Averaging token vectors discards token order information and cannot capture deep contextual semantics. Hybrid scoring with BM25 and exact identifier matching is used to correct directional errors in the semantic signal.

Positioning against existing search approaches

ripgrep suits known names, exact text, and regex but returns heavy noise for intent-based queries, while cloud semantic search such as mgrep requires an account, network access, and syncing source code off-machine. sgrep targets privacy and offline scenarios.

Source posts