grep: a root that is not on disk stops the search of the other roots (main, after #1506)
At v0.68.0 (fe2ac520e), the grep tool searches the roots in path that are on disk and ignores a root that is not on disk. It tells the agent which root it ignored and sets complete: false. At d1c5982fc (main), the tool sends all the roots to native grep. Native grep refuses the call before it searches a root, so the agent gets an error and no results. The release tags do not have this problem. The change comes from commit 104110d0e ("send complete grep root arrays from both plugins", PR #1506).
Steps
- In a new project, make
src/hit.tswith the single lineneedle. Do not makemissing-dir. - With the OpenCode plugin and the binary at the same revision, call the
greptool with{"pattern":"needle","path":"src missing-dir"}. - Do step 2 again with
{"pattern":"needle","path":"src"}as a control.
Result at v0.68.0: The first call gives src/hit.ts:1, then Skipped 1 path not found: missing-dir, with complete: false.
Result at d1c5982fc: The first call gives the error path_not_found for missing-dir and no results. The control call gives the result.
Native check
In standalone NDJSON mode, with /ABS/fixture changed to the absolute fixture directory:
{"id":"configure","command":"configure","harness":"runner","project_root":"/ABS/fixture"}
{"id":"old-wire","command":"tool_call","name":"grep","arguments":{"pattern":"needle","path":"/ABS/fixture/src"}}
{"id":"new-wire","command":"tool_call","name":"grep","arguments":{"pattern":"needle","path":["/ABS/fixture/src","/ABS/fixture/missing-dir"]}}
The v0.68.0 plugin sends old-wire. At d1c5982fc, the plugin sends new-wire. On a d1c5982fc binary, old-wire gives the result, and new-wire gives path_not_found (grep: search path does not exist: …/missing-dir). The bare grep command at the two revisions also refuses a root that is not on disk. Thus the change is in what the tool sends, not in native grep.
Code
packages/opencode-plugin/src/tools/search.ts:173-224sendssplit.allfor grep, notsplit.paths(the roots that are on disk). OpenCode 2grepand Code Modeaft.code.grepuse this code.crates/aft-tools/src/subc_translate.rs:2002-2035keeps the array, andcrates/aft-index/src/grep_executor.rs:725-735,1100-1119refuses a missing root before the search.- The Pi grep tool has the same change. Its path function gives all the fragments if one fragment is on disk, and its bridge sends an array.
- The mock in
packages/opencode-plugin/src/__tests__/search.test.ts:360-385accepts[src, missing]and gives a result, so the test does not show the native refusal.
Possible repair
Keep the array for paths that contain spaces. When some roots are on disk and some are not, send only the roots that are on disk. Keep the skipped-path notice and complete: false. Add a test that sends the plugin's arguments to native grep.