Skip to content

fix(search): zero-match steering probe works on the grep fallback - #79605

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/79512-search-zero-match-grep-fallback
Open

fix(search): zero-match steering probe works on the grep fallback#79605
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/79512-search-zero-match-grep-fallback

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Summary

The search_files zero-match steering probe was a silent no-op on hosts without ripgrep installed. _zero_match_probe in tools/file_operations.py returned None immediately when rg was absent (if not self._has_command('rg'): return None), so all three zero-match hints ("case-insensitive matches — casing may be wrong" / "literal matches — metacharacters need escaping" / "match only in hidden or gitignored files") were lost even though the grep fallback search itself worked.

Root Cause

The probe feature added in 5797b5028 was implemented only for the rg engine path; the grep fallback path bailed out before running any probe variants.

Change

  • tools/file_operations.py: _zero_match_probe is now a dispatcher — rg_zero_match_probe_rg (original body, byte-identical, no regression), otherwise → new _zero_match_probe_grep that mirrors the three probe variants using the existing grep-fallback helpers (count-only output, head -50, 2>/dev/null, 30s timeout):
    • case-insensitive: grep -r -i -c -H --exclude-dir='.*' [--include glob] … → "case-insensitive match(es) … casing may be wrong"
    • hidden-only: re-run without --exclude-dir → "N match(es) in N hidden file(s) — hidden files are excluded by default"
    • literal: grep -r -F -c -H (only when the pattern has metacharacters) → "literal match(es) … need escaping"
  • tests/tools/test_search_zero_match_and_multipath.py: new coverage for the no-rg path (via _has_command patch) plus the existing rg path.

Verification

  • tests/tools/test_search_zero_match_and_multipath.py: 20 passed.

Closes #79512

@alt-glitch alt-glitch added type/bug Something isn't working tool/file File tools (read, write, patch, search) P3 Low — cosmetic, nice to have labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/file File tools (read, write, patch, search) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: search_files zero-match steering probe is a no-op without ripgrep (grep fallback loses all hints)

2 participants