fix(run): port upstream reject FIFO attachments without blocking (anomalyco/opencode#64696)
Issue for this PR
Closes #1876
Tracking: #1478. Upstream: https://github.com/anomalyco/opencode/pull/64696
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
User-visible failure: altimate-code run --file <path> hangs when <path> is a named pipe (FIFO), socket or device. run only checked that the path existed and whether it was a directory, then attached it as text/plain. Reading it later (or right away with --query) blocks until a writer opens the pipe, so a headless run never finishes.
Fix: run now classifies each --file path with stat through a new helper, attachmentKind in src/altimate/cli/run-attach.ts. stat never opens the file, so it cannot block. Missing paths keep the same File not found error. Anything that is not a regular file or a directory now exits with Not a regular file or directory: <path>.
Upstream's v2 CLI opens the file with O_NONBLOCK before checking it, because its attach path reads the file right away. The fork's run only attaches a file:// URL, so checking with stat is enough here. The call site in src/cli/cmd/run.ts is wrapped in altimate_change … upstream_fix markers.
How did you verify your code works?
- New
test/cli/run/run-attach.test.ts: regular file, directory and missing path are classified correctly, and a realmkfifopipe returnsspecialimmediately instead of blocking. The FIFO test is skipped on Windows. bun test test/cli/run/run-attach.test.ts test/cli/run/run-stdin.test.ts: 13 pass.bun run typecheckinpackages/opencodepasses.bun run script/upstream/analyze.ts --markers --base origin/main --strictpasses.
Cost side effects
None. This only adds a local stat call per attached file.
Screenshots / recordings
N/A. This is a CLI change with no UI.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
- I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"
Summary by cubic
Fixes altimate-code run --file hanging when the path is a named pipe (FIFO), socket, or device. run only checked that the path existed and wasn't a directory, then attached it as text/plain; reading it blocked until a writer opened the pipe.
- Paths are now classified with
statvia the newattachmentKindhelper, which never opens the file so it can't block. - Missing paths still report
File not found; any path that is not a regular file or directory now exits withNot a regular file or directory: <path>.