[PR #2980] make file references & grep tool work on windows #10501

Closed
opened 2026-02-16 18:15:10 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/2980

State: closed
Merged: Yes


Related issues - #631

Issues

Currently, there are a couple of file related features broken in Windows.

  • Directly referencing a file path with @ displays a failed to send message. 400 Bad Request - Error: ENOENT: no such file or directory, scandir <directory-of-file> error.
  • Searching for a pattern with the grep tool always yields a "No Files Found" message even when there should be matching files.

Fixes

  • Direct file references are converted to file paths using decodeURIComponent in packages/opencode/src/session/prompt.ts. This results in a Windows file path that looks like this - /C:/Users/Username/samplefile.ts. The extra / at the start and the / separators prevent this from being a valid windows file path. Instead, we use the fileURLToPath function in Bun to create a valid, cross-platform filepath from the message part URL.
  • The grep tool sets the working directory for ripgrep to be the current directory (in absolute path terms) which causes ripgrep to output matches also in absolute path terms (which includes the Drive letter on Windows. This causes the line splitting logic to fail since the Windows Drive Letter includes a :). We use the --field-match-separator flag to change the separator to | and avoid issues on Windows and having to change the parsing logic
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/2980 **State:** closed **Merged:** Yes --- Related issues - #631 ### Issues Currently, there are a couple of file related features broken in Windows. - Directly referencing a file path with `@` displays a `failed to send message. 400 Bad Request - Error: ENOENT: no such file or directory, scandir <directory-of-file>` error. - Searching for a pattern with the grep tool always yields a "No Files Found" message even when there should be matching files. ### Fixes - Direct file references are converted to file paths using `decodeURIComponent` in `packages/opencode/src/session/prompt.ts`. This results in a Windows file path that looks like this - `/C:/Users/Username/samplefile.ts`. The extra `/` at the start and the `/` separators prevent this from being a valid windows file path. Instead, we use the `fileURLToPath` function in Bun to create a valid, cross-platform filepath from the message part URL. - The grep tool sets the working directory for ripgrep to be the current directory (in absolute path terms) which causes ripgrep to output matches also in absolute path terms (which includes the Drive letter on Windows. This causes the line splitting logic to fail since the Windows Drive Letter includes a `:`). We use the `--field-match-separator` flag to change the separator to `|` and avoid issues on Windows and having to change the parsing logic
yindo added the pull-request label 2026-02-16 18:15:10 -05:00
yindo closed this issue 2026-02-16 18:15:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10501