
semantic grep, powered by Jev

semantic grep, powered by Jev
sgrep is a command line tool that enables users to ask questions about their codebase in plain English, functioning as a semantic alternative to traditional grep. Instead of matching keywords or building a vector index with embeddings, sgrep divides a repository into chunks at the function or class level and sends each chunk to Jev, a lightweight model from TypeSafe, with a single typed question: whether the chunk matches the query. The results are then ranked by a calibrated confidence score. Each Jev call uses approximately 150 tokens and takes roughly 100 milliseconds, with output provided at no additional cost, making it feasible to scan an entire repository for pennies and integrate into continuous integration workflows on every pull request. The tool handles chunking intelligently based on file type. For Python files it uses the standard library AST parser, while JavaScript, TypeScript, and Java files are parsed via tree-sitter to capture components, arrow functions, and export wrapped declarations. Other file types fall back to line based windows. When a repository contains more chunks than the specified top k limit, sgrep first applies a local offline pre filter using Model2Vec static embeddings and forwards only the top candidates to Jev, reducing the number of HTTPS calls from potentially hundreds to a manageable few dozen. The pre filter is semantic by design to avoid dropping code that keyword filters would miss, such as verify_jwt for an authentication query. sgrep supports several power user features to accelerate repeated or batch queries. Batch mode accepts up to three queries in a single run with the q flag, and all discovery, parsing, and embedding computations are shared across queries. A warm daemon mode keeps the Python process and the embedding model resident in memory, eliminating startup overhead for subsequent scans. Combined, batch mode with a warm daemon can process three queries in roughly 5.5 seconds, a 2.7 times speedup compared to separate cold runs. The daemon is fail safe, silently falling back to an in process scan if no daemon is running. Technical requirements include Python 3.10 or later. On first run, sgrep downloads a small local embedding model of approximately 7 megabytes. Provider API keys (for auto, vercel, typesafe, or mock) are read from a local .env file, which is gitignored. The tool is distributed as a Python package and can be built with python m build and published via twine. In benchmarking on a Claude agent tracing real flows through a distributed application, sgrep with batch mode and warm daemon reduced total token usage by roughly 40 percent and code read into context by 66 percent while maintaining equal answer quality and improving wall clock speed.