25 seconds became <100ms. Same results. Structured output. No ANSI garbage.
AI agents need to search inside files. Not just find files—read their contents, extract patterns, understand code. The existing options:
| Method | Speed | Output | Verdict |
|---|---|---|---|
| PowerShell Select-String | ~25 seconds | Lines + ugly ANSI codes | Unusable for iteration |
| Everything content search | 500-2000ms | Filenames only | No content extraction |
| Load files into context | Variable | Full files | Token-expensive |
WHERE are the files?
<100ms file discovery
Indexed search across entire filesystem
WHAT's inside?
<100ms content extraction
Surgical line/pattern retrieval
Everything finds the needle's location. TextGrep pulls exactly what's needed from it. Together: surgical precision instead of dumping the whole haystack into context.
# PowerShell (the old way)
Get-ChildItem "X:\dev\*.toml" -Recurse | Select-String "tokio"
→ 25,537ms (25+ seconds)
→ Output cluttered with ANSI escape codes
# TextGrep (the new way)
textgrep:grep_files paths="X:\dev\**\*.toml" pattern="tokio"
→ <100ms
→ Clean JSON: {"files": [...], "count": 5}
Speed is one thing. But the real win is token efficiency—how much context an AI agent burns to get answers.
| Scenario | Old Way | With TextGrep | Savings |
|---|---|---|---|
| "Find all tokio versions" | Load 15 Cargo.toml (~3000 tokens) | Extract 5 lines (~50 tokens) | 98% |
| "Where's that error handler?" | Read 10 .rs files (~8000 tokens) | grep + context (~100 tokens) | 99% |
| "Compare two configs" | Load both files fully | compare_files → just diffs | 80-95% |
| Feature | PowerShell | Everything | TextGrep |
|---|---|---|---|
| Line numbers | ✓ | ✗ | ✓ |
| Context lines (before/after) | Manual | ✗ | ✓ Built-in |
| Regex capture groups | Clunky | ✗ | ✓ Native |
| Unique extraction | Manual | ✗ | ✓ One param |
| File comparison/diff | External tool | ✗ | ✓ Built-in |
| Search & Replace preview | ✗ | ✗ | ✓ |
| Recursive globs | Get-ChildItem | ✓ | ✓ |
| Structured JSON output | ✗ | ✓ | ✓ |
grep — Pattern search with line numbersgrep_context — Include N lines before/after matchesgrep_files — Return only filenames containing patterngrep_count — Count occurrences per fileextract_matches — Pull regex capture groups, optional unique filterextract_lines — Get specific line rangesfilter_lines — Keep/remove lines matching patternfile_stats — Lines, words, chars, encoding detectioncompare_files — Unified diff between two filesfind_duplicates — Locate duplicate lines across filesreplace — Preview regex replacements before executingreplace_confirm — Execute previewed replacement
┌─────────────────────────────────────────────────────────────┐
│ AI AGENT (DC/KALIC) │
├─────────────────────────────────────────────────────────────┤
│ "Find tokio versions in project" │
│ │
│ Step 1: everything_search "*.toml" → File locations │
│ Step 2: textgrep:grep "tokio" → Exact lines │
│ Step 3: Extract version numbers → Structured data │
│ │
│ Total context used: ~50 tokens (vs ~3000 old way) │
└─────────────────────────────────────────────────────────────┘
The combination enables a new operational pattern: locate → extract → act. No more loading entire files hoping the answer is inside. No more waiting for slow searches. No more parsing messy output.
Built on the regex crate for pattern matching, glob for file discovery, and standard Rust I/O for speed. No external dependencies. Instant startup. Minimal memory footprint.