Skip to content

fix(tools): treat rg as grep and scope search before pagination - #368

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/rg-grep-synonym
Aug 16, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/rg-grep-synonym

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

Models keep calling bash(rg …) instead of grep, and scoped greps were returning No matches found for common terms like forge under crates/.

This follows OpenCode’s shape: advertise only grep, implement ripgrep-like regex search, and accept rg as an inbound name. Forge still rewrites inspection bash(rg …) onto grep so those calls do not prompt under Accept Edits.

  • Accept a tool named rg as grep (not a second advertised tool)
  • Rewrite inspection rg, /usr/bin/rg, rg -ni, --glob, and rg … | head onto grep
  • Use regex mode for rg rewrites (-F stays plain)
  • Apply path and include as FFF constraints before the page limit, so a search for forge in crates/ is no longer emptied by the first 50 root/docs hits

Test plan

  • cargo test --package forge-search --package forge-tools --package forge-governance --package forge-core --lib
  • Regression: grep forge with path=crates after 60 root hits still returns crate files
  • rg tool name and bash(rg | head) execute as grep without HITL
  • CI green on this PR

Advertise only grep (OpenCode-style) but accept a tool named rg and
rewrite inspection bash(rg …) — including rg | head — onto grep so
search does not pay a HITL tax.

Apply path and include as FFF constraints before the page limit. The
previous post-filter dropped every hit when the first page lived
outside the requested directory (e.g. forge under crates/).
@github-actions
github-actions Bot enabled auto-merge (squash) August 16, 2026 19:19
@github-actions
github-actions Bot merged commit a037ec6 into main Aug 16, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
Advertise only grep (OpenCode-style) but accept a tool named rg and
rewrite inspection bash(rg …) — including rg | head — onto grep so
search does not pay a HITL tax.

Apply path and include as FFF constraints before the page limit. The
previous post-filter dropped every hit when the first page lived
outside the requested directory (e.g. forge under crates/).
mohitranka added a commit that referenced this pull request Sep 11, 2026
Advertise only grep (OpenCode-style) but accept a tool named rg and
rewrite inspection bash(rg …) — including rg | head — onto grep so
search does not pay a HITL tax.

Apply path and include as FFF constraints before the page limit. The
previous post-filter dropped every hit when the first page lived
outside the requested directory (e.g. forge under crates/).
mohitranka added a commit that referenced this pull request Sep 11, 2026
Advertise only grep (OpenCode-style) but accept a tool named rg and
rewrite inspection bash(rg …) — including rg | head — onto grep so
search does not pay a HITL tax.

Apply path and include as FFF constraints before the page limit. The
previous post-filter dropped every hit when the first page lived
outside the requested directory (e.g. forge under crates/).
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.

1 participant