Grep-shaped CLI search powered by DSPy RLM
Project description
rlmgrep
Grep-shaped search powered by DSPy RLM. It accepts a natural-language query, scans the files you point at, and prints matching lines in a grep-like format.
Quickstart
uv tool install --python 3.11 .
# or from GitHub:
# uv tool install --python 3.11 git+https://github.com/halfprice06/rlmgrep.git
export OPENAI_API_KEY=... # or set keys in ~/.rlmgrep
rlmgrep "where are API keys read" rlmgrep/
Requirements
- Python 3.11+
- Deno runtime (DSPy RLM uses a Deno-based interpreter)
- API key for your chosen provider (OpenAI, Anthropic, Gemini, etc.)
Install Deno
DSPy requires the Deno runtime. Install it with the official scripts:
macOS/Linux:
curl -fsSL https://deno.land/install.sh | sh
Windows PowerShell:
irm https://deno.land/install.ps1 | iex
Verify it is on your PATH:
deno --version
Usage
rlmgrep [options] "query" [paths...]
Common options:
-nshow line numbers-Halways show filenames-C Ncontext lines before/after (grep-style)-A Ncontext lines after-B Ncontext lines before-m Nmax matching lines per file-g GLOBinclude files matching glob (repeatable, comma-separated)--type Tinclude file types (repeatable, comma-separated)--no-recursivedo not recurse directories-a,--texttreat binary files as text--model,--sub-modeloverride model names--api-key,--api-base,--model-typeoverride provider settings--max-iterations,--max-llm-callscap RLM search effort-v,--verboseshow verbose RLM output
Examples:
# Natural-language query over a repo
rlmgrep -n -C 2 "token parsing" rlmgrep/
# Restrict to Python files
rlmgrep "where config is read" --type py rlmgrep/
# Glob filters (repeatable or comma-separated)
rlmgrep "error handling" -g "**/*.py" -g "**/*.md" .
# Read from stdin (only when no paths are provided)
cat README.md | rlmgrep "install"
Input selection
- Directories are searched recursively by default. Use
--no-recursiveto stop recursion. --typeuses built-in type mappings (e.g.,py,js,md); unknown values are treated as file extensions.-g/--globmatches path globs against normalized paths (forward slashes).- Paths are printed relative to the current working directory when possible.
- If no paths are provided, rlmgrep reads from stdin and uses the synthetic path
<stdin>; if stdin is empty, it exits with code 2.
Output contract (stable for agents)
- Matches are written to stdout; warnings go to stderr.
- Output uses grep-like prefixes:
path:line:textfor match lines when both-Hand-nare enabled.path-line-textfor context lines (note the-separator).- If
-Hor-nare omitted, their parts are omitted.
- Line numbers are 1-based.
- When context ranges are disjoint, a
--line separates groups. - Exit codes:
0= at least one match1= no matches2= usage/config/error
Agent tip: use -n -H and no context for parse-friendly output, then key off exit codes.
Configuration
rlmgrep creates a default config automatically if missing. The config path is:
~/.rlmgrep/config.toml
Default config values (from rlmgrep/config.py):
model = "openai/gpt-5.2"
sub_model = "openai/gpt-5-mini"
api_base = "https://api.openai.com/v1"
model_type = "responses"
temperature = 1.0
max_tokens = 64000
max_iterations = 10
max_llm_calls = 20
# markitdown_enable_images = false
# markitdown_image_llm_model = "gpt-5-mini"
# markitdown_image_llm_provider = "openai"
# markitdown_image_llm_api_key = ""
# markitdown_image_llm_api_base = ""
# markitdown_image_llm_prompt = ""
# markitdown_enable_audio = false
# markitdown_audio_model = "gpt-4o-mini-transcribe"
# markitdown_audio_provider = "openai"
# markitdown_audio_api_key = ""
# markitdown_audio_api_base = ""
CLI flags override config values. Model keys are resolved as:
- CLI flags (
--api-key,--sub-api-key) - Config values (
api_key,sub_api_key) - Provider env vars inferred from the model name:
OPENAI_API_KEYANTHROPIC_API_KEYGEMINI_API_KEY
If more than one provider key is set and the model does not make the provider obvious, rlmgrep emits a warning and requires an explicit --api-key.
Non-text files (PDF, images, audio)
- PDF files are parsed with
pypdf. Each page gets a marker line===== Page N =====, and output lines include apage=Nsuffix. - Images and audio are converted via
markitdownwhen enabled in config. For image/audio conversion, anopenaiPython client is required. - Converted image/audio text is cached in sidecar files named
<original>.<ext>.mdnext to the original file and reused on subsequent runs. - Use
-a/--textto force binary files to be read as text (UTF-8 with replacement).
Agent usage notes
- Prefer narrow corpora (globs/types) to reduce token usage.
- Use
--max-llm-callsto cap costs; combine with small--max-iterationsfor safety. - Always read stderr for warnings (skipped files, config issues, ambiguous API keys).
- For reproducible parsing, use
-n -Hand avoid context (-C/-A/-B). - RLM results are verified against real file lines; invalid or duplicate matches are dropped and reported.
Development
- Install locally:
pip install -e .oruv tool install . - Run:
rlmgrep "query" . - No test suite is configured yet.
Security
Do not commit API keys. Use environment variables or ~/.rlmgrep/config.toml.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rlmgrep-0.1.0.tar.gz.
File metadata
- Download URL: rlmgrep-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6219b6a6763b69de35fbe713f7f4900dff5159fdd78150a234c1ef91ef366f12
|
|
| MD5 |
ea87028b926dcecdb4b8baff66a9082e
|
|
| BLAKE2b-256 |
04a165436a87b850387701a27ecc9374d5437aba31b09c58ce0dc9c01dcd4916
|
File details
Details for the file rlmgrep-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rlmgrep-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a699d413771568c4966a7d73f40e17fef466d0255538c562ca2036f28b0866d8
|
|
| MD5 |
4586fe45cbe0aaa675f8e8f25f2bdaf2
|
|
| BLAKE2b-256 |
5da9982530fb73b77788e08445d1bf3c7a5b6020e1f523d175db8b67284ba237
|