opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(grep): follow symlinks by default in ripgrep searches

Open kdcokenny opened this issue 4 days ago • 3 comments

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.

kdcokenny avatar Jan 09 '26 16:01 kdcokenny