Description
The Grep tool's content output mode always returns "No matches found" on Windows, even when matches clearly exist. files_with_matches and count modes work correctly.
Root Cause
In dist/index.js line ~112587, the parseOutput function uses this regex to parse rg output:
const match = line.match(/^(.+?):(\d+):(.*)$/);
On Windows, ripgrep returns paths like C:\Projects\Foo\bar.cpp:42:some content.
The regex matches C as the file group, then expects \d+ after the next colon — but encounters \Projects\... instead. Every line fails to parse, resulting in an empty matches array → "No matches found".
Why other modes work:
| Mode |
Why it works |
files_with_matches |
Uses --files-with-matches flag → rg returns paths only, parsed with filesOnly=true which doesn't use the broken regex |
count |
Uses separate parseCountOutput which matches file:number — still broken on Windows but runRgCount uses --count flag producing C:\...\file.cpp:42 which happens to work differently |
content |
Uses parseOutput with the broken regex → always fails on Windows |
Suggested fix:
// Handle Windows drive letters (e.g., C:\path\file.cpp:42:content)
const match = line.match(/^(.+?):(\d+):(.*)$/);
// Should be something like:
const match = line.match(/^([a-zA-Z]:.+?):(\d+):(.*)$/);
// Or use rg's --field-match-separator to avoid colon ambiguity:
// rg --field-match-separator='|' → C:\path\file.cpp|42|content
Steps to Reproduce
- On Windows, use oh-my-openagent (v3.14.0) with OpenCode
- Call Grep tool with
output_mode: "content" on any file with known content
- Observe "No matches found" even though
files_with_matches mode finds the file
Environment
- oh-my-openagent: 3.14.0
- OpenCode: 1.3.7
- OS: Windows 11 (x64)
- rg: Both bundled (14.1.1) and system (15.1.0) present and working from shell
Description
The Grep tool's
contentoutput mode always returns "No matches found" on Windows, even when matches clearly exist.files_with_matchesandcountmodes work correctly.Root Cause
In
dist/index.jsline ~112587, theparseOutputfunction uses this regex to parse rg output:On Windows, ripgrep returns paths like
C:\Projects\Foo\bar.cpp:42:some content.The regex matches
Cas the file group, then expects\d+after the next colon — but encounters\Projects\...instead. Every line fails to parse, resulting in an empty matches array → "No matches found".Why other modes work:
files_with_matches--files-with-matchesflag → rg returns paths only, parsed withfilesOnly=truewhich doesn't use the broken regexcountparseCountOutputwhich matchesfile:number— still broken on Windows butrunRgCountuses--countflag producingC:\...\file.cpp:42which happens to work differentlycontentparseOutputwith the broken regex → always fails on WindowsSuggested fix:
Steps to Reproduce
output_mode: "content"on any file with known contentfiles_with_matchesmode finds the fileEnvironment