opencode
opencode copied to clipboard
fix(grep): follow symlinks by default in ripgrep searches
Summary
Fixes #7498 - Grep fails on symlinked directories
Changes
- Add
--followflag to grep tool for consistent symlink traversal - Add
--hiddenflag to grep tool for parity withRipgrep.search() - Add
follow?: booleanparameter toRipgrep.search()with defaulttruefor API consistency withRipgrep.files()
Design Decision
Following VS Code's approach, symlinks are now followed by default since OpenCode is an IDE-like tool where users expect to find all their code regardless of filesystem structure. The follow parameter provides an escape hatch for users who need stricter behavior.
Compliance
- Atomic Predictability: Both
files()andsearch()now have consistent API for thefollowparameter - Intentional Naming: The
followparameter explicitly communicates symlink-following behavior
Note for Maintainers
During review, we noticed that grep.ts does not include --glob='!.git/*' while Ripgrep.search() does. This is a pre-existing inconsistency (not related to this PR). If you'd like us to add this for consistency, we're happy to update the PR.