Skip to content

Conversation

@kdcokenny
Copy link
Contributor

@kdcokenny kdcokenny commented Jan 9, 2026

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.

Fixes anomalyco#7498

- 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() (default: true)
  for API flexibility while maintaining backward compatibility
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@rekram1-node
Copy link
Collaborator

/review

@github-actions
Copy link
Contributor

lgtm

@rekram1-node rekram1-node merged commit d5738f5 into anomalyco:dev Jan 10, 2026
3 checks passed
@kdcokenny kdcokenny deleted the fix/grep-follow-symlinks branch January 10, 2026 17:02
@kdcokenny
Copy link
Contributor Author

TYSM!

fwang pushed a commit to lifefloating/opencode that referenced this pull request Jan 10, 2026
zerone0x pushed a commit to zerone0x/opencode that referenced this pull request Jan 12, 2026
zerone0x pushed a commit to zerone0x/opencode that referenced this pull request Jan 12, 2026
vtemian added a commit to vtemian/opencode that referenced this pull request Jan 12, 2026
Resolve conflicts:
- grep.ts: use renamed rg() + add --hidden/--follow flags from anomalyco#7501
- ripgrep.ts: accept deletion, port follow param to ripgrep/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grep Tool Fails on Symlinks

2 participants