gptme-warpgrep
Natural-language code search for gptme using Morph's warp-grep model. Ask "where are JWT tokens validated?" and get back the relevant code snippets with line numbers, instead of guessing regex patterns.
Status: experimental. Requires an API key for Morph (a third-party hosted service).
How it works
warp-grep is a small search agent. For each query it explores your repository over up to 4 turns. The Morph model decides what to run; the plugin executes those operations locally against your checkout:
grepsearches for a regex, withgit grepin a git repository or ripgrep (rg) otherwise,readreads a file or line range,analyselists directory structure (git-tracked files only in a git repository),finishreturns the final file and line ranges.
In a git repository only tracked files are searched, so .gitignore applies. Outside git, version-control directories, dependency folders (node_modules, .venv, vendor), caches, build output and lock files are excluded. File contents the model asks to see are sent to Morph's API (api.morphllm.com) as part of the search, so don't use it on code you can't share with that service.
Use it for conceptual or exploratory questions in unfamiliar codebases. For exact-symbol lookups, plain grep/rg or gptme-lsp are faster and free.
Install
-
To search directories that are not git repositories, install ripgrep so
rgis onPATH(git repositories only needgit). -
Point gptme at the plugin in
gptme.toml(project) or~/.config/gptme/config.toml(user):[plugins] paths = ["/path/to/gptme-contrib/plugins/gptme-warpgrep"] enabled = ["gptme_warp_grep"]
The plugin uses
httpx, which must be importable in gptme's environment. -
Set your Morph API key (get one here), either as an environment variable or in the
[env]table of your gptme config:export MORPH_API_KEY="your-api-key"
Quickstart
gptme "use warp_grep to find where database connection errors are handled"
The tool exposes one function, which the agent calls from a Python block:
warp_grep("Find authentication middleware")
warp_grep("Find all API endpoints", "/path/to/project") # search another repo
It returns Markdown with one fenced, syntax-highlighted snippet per matching file, or No relevant code found for the query.
As a library
from gptme_warp_grep.tools.warp_grep import warp_grep_search
results = warp_grep_search(
query="Find where JWT tokens are validated",
repo_root="/path/to/project",
# api_key="...", # defaults to MORPH_API_KEY
)
for f in results: # list of ResolvedFile(path, content)
print(f"=== {f.path} ===")
print(f.content)
Agent lesson
lessons/tools/warp-grep-usage.md is a keyword-triggered lesson that teaches an agent when to reach for warp-grep. Copy it into your agent's lessons directory if you use the gptme lesson system.
Development
cd plugins/gptme-warpgrep
make test # uv run pytest tests/ -v
make typecheck # uv run mypy src/ --ignore-missing-imports
License
MIT