Repository navigation
refactor(bettergrep): smaller, faster and deterministic search - #13
Conversation
|
|
@greptile-apps updated review requested: both findings were real regressions from this PR, both fixed. F1 (probe timeout can hang): confirmed. The exit wait relied on F2 (cached fallback hides ripgrep): confirmed. The memo only invalidated on PATH text, cacheDir or binary stamp, so an |
|
Both reported regressions are confirmed fixed.
The fixes in |
|
@greptile-apps updated review requested: the follow-up finding was real, fixed. F3 (unsupported rg defeats fallback caching): confirmed against our own F2 fix. The validity check treated any |
|
Confirmed. F3 is fixed in |
|
@greptile-apps updated review requested: the follow-up finding was real, fixed. F4 (transient failure locks in fallback): confirmed. A transient |
This branch rewrites the search plugin (opencode-bettergrep) from the inside: same features, less code, faster, with several fixed bugs. Nothing about what the plugin does or how it is used changes.
Numbers
Less code means less surface for bugs to hide in and less work for maintainers.
What got simplified
The plugin had several pieces doing almost the same thing through different paths. There is now one path per job: a single JSON stream reader, one pipe for running ripgrep or the GNU grep fallback, one factory for matches, one place for summaries. The custom logger, the process-compatibility shim and duplicated runners are gone. The worker pool is dynamic (16) and mtime replay works in batches of 64 instead of file by file.
Day to day use feels the same. Behavior is now uniform across paths because only one remains.
Fixed bugs
Each of these reproduced on the old code and now has its test:
grepfor GNU grep.Deterministic ordering
Date sorting now tie-breaks on path bytes, and child processes run with
LC_ALL=C.UTF-8and an emptyLANGUAGEso messages always parse in English on any machine. In practice: the same search returns the same results in the same order on Linux, under Bun or Node, with the system in any language.Measured performance
Dependencies
plugin 1.18.32, exact effect beta.83 (no nested copies), TypeScript 7.0.2, Biome 2.5.14, @types/node from v24, bun-types 1.4.2, which 7 and packageManager [email protected].
Verification
Severity review (P0–P3) with an independent APTO verdict, full mutant matrix killed by assertion, 300/0 suite with unchanged 79 snapshots, clean check and typecheck, and a 6000-file smoke test on Node and Bun. No behavior changes: everything it did before still works.