grep: optional tgrep backend for large workspaces
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- git, node.js, typescript
- Bereich
- cli, performance, tooling
Rechercherichtung
Start by locating the grep tool implementation, its settings, and the beforeToolCall interception path. Review how the built-in grep handles output_mode, head_limit, and offset, then check whether a live tgrep server is available before considering query behavior. Done means an opt-in backend uses tgrep only when safe, preserves the built-in output behavior, and falls back to ripgrep for unavailable servers or unsuitable patterns.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Feature Description
Let the grep tool run against a tgrep trigram index when one exists for the session root, and fall back to the bundled ripgrep otherwise. Opt-in, not a default change — tgrep only pays off with an index plus a live server, and it is slower than ripgrep on patterns the index cannot narrow.
Today there is no setting to change the grep backend, and a mod cannot register a tool named grep (colliding names are skipped with mod_error), so the only seam is beforeToolCall interception.
Use Case
On a 124,465-file / 29 GB workspace, a selective search such as TODO takes ~3.1s through the grep tool. Agents issue dozens per session, serially. With a live tgrep server the same search returns in 31ms end to end — 100x. Measured on macOS arm64, tgrep 1.2.5, ripgrep 15.2.0, warm cache, best of 5:
| query | ripgrep (full search) | tgrep |
|---|---|---|
TODO (selective, 1,280 files) |
3.07s | 31ms |
function (broad, 65,004 matching lines) |
3.37s | 163ms |
| absent token | 3.01s | 16ms |
For comparison, engine-to-engine with full output the broad case is only 1.2x (3.31s vs 2.83s); the 21x through a tool result comes from stopping at the page limit instead of materialising everything.
Additional Context
I built this as a mod and hit six things a native implementation would need to handle:
output_modedefaults differ — the built-in isfiles_with_matches, tgrep is content, so-lmust be passed when the field is absent.- tgrep omits line numbers unless
-nis given explicitly. head_limit/offsetneed a stream that aborts atoffset + limit + 1lines; buffering a broad match set hit 23 MB and a 285k-line result.- An index without a running server is not safe. It silently misses files written since the build. Reproduced: a newly created file returned exit 1 (no matches) from tgrep while ripgrep found it. A native backend should require a live server, not just an index on disk.
- A cheap
tgrep status .probe gates it (0.00s live, 0.08s dead), plus a stderr check forfalling back to local indexto cover a server dying mid-query. - Patterns with no literal trigrams scan every indexed file —
\d{9,}took 40.5s against ripgrep's 3.0s — so a timeout fallback or trigram heuristic is required. My mod caps at 30s and then defers to the built-in.
Prototype with methodology, raw output and limitations: https://github.com/Hashimlokasher/cmd-mod-tgrep-grep (BENCHMARKS.md). tgrep also powers GitHub Copilot CLI's grep, so it is actively maintained.
Proposal: a grep.backend: "tgrep" setting, or auto-detect when tgrep is installed and a live index is present, keeping ripgrep as the default and the fallback. Happy to test or contribute.
Priority: Important for my workflow
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 4.2k
- Forks
- 377
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus CommandCodeAI/command-code
-
Provider /v1/messages rejects role:"system" inside messages[] — Claude Code ≥ 2.1.154 incompatibleOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
CommandCodeAI/command-code#1085 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Feature request: auto-reconnect remote control (/rc) after restartEvtl. vergeben @aliarain hat das vor 20 Tagen übernommen. Offenp2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
CommandCodeAI/command-code#992 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
CommandCodeAI/command-code#933 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
CommandCodeAI/command-code#855 ·
Maintainer antworten meist innerhalb von 1 Tag
-
grep tool passes empty file type to ripgrepEvtl. vergeben @ahmadbilaldev hat das vor 19 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
CommandCodeAI/command-code#655 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in CommandCodeAI/command-code
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
FinanceFlash/unvibecode#675 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:tui bug platform:macos
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
anthropics/claude-code#109005 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
criticalmanufacturing/cli#909 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
vercel-labs/just-bash#756 ·
Maintainer antworten meist innerhalb von 1 Tag