fix(run): port upstream reject FIFO attachments without blocking (anomalyco/opencode#64696)

DE
2h ago
+58-2

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 real mkfifo pipe returns special immediately 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 typecheck in packages/opencode passes.
  • bun run script/upstream/analyze.ts --markers --base origin/main --strict passes.

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"

Devin Review


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 stat via the new attachmentKind helper, 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 with Not a regular file or directory: <path>.