[PR #7501] fix(grep): follow symlinks by default in ripgrep searches #12418

Closed
opened 2026-02-16 18:17:19 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7501

State: closed
Merged: Yes


Summary

Fixes #7498 - Grep fails on symlinked directories

Changes

  • Add --follow flag to grep tool for consistent symlink traversal
  • Add --hidden flag to grep tool for parity with Ripgrep.search()
  • Add follow?: boolean parameter to Ripgrep.search() with default true for API consistency with Ripgrep.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() and search() now have consistent API for the follow parameter
  • Intentional Naming: The follow parameter 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.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7501 **State:** closed **Merged:** Yes --- ## Summary Fixes #7498 - Grep fails on symlinked directories ## Changes - Add `--follow` flag to grep tool for consistent symlink traversal - Add `--hidden` flag to grep tool for parity with `Ripgrep.search()` - Add `follow?: boolean` parameter to `Ripgrep.search()` with default `true` for API consistency with `Ripgrep.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()` and `search()` now have consistent API for the `follow` parameter - Intentional Naming: The `follow` parameter 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.
yindo added the pull-request label 2026-02-16 18:17:19 -05:00
yindo closed this issue 2026-02-16 18:17:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12418