[PR #7378] feat: add --dir flag to opencode run --attach #12374

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

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

State: closed
Merged: No


Summary

  • Add --dir flag to opencode run command
  • When used with --attach, passes directory to SDK client via x-opencode-directory header
  • Enables sessions attached to a global server to run in the correct project directory

Use Case

When using opencode-pilot to spawn sessions that attach to a running OpenCode Desktop with worktree="/", sessions now run in the correct project directory instead of the server's home directory.

# Before: sessions run in wrong directory
opencode run --attach http://localhost:4096 "fix bug"
# Working directory: /Users/me (wrong!)

# After: sessions run in correct directory
opencode run --attach http://localhost:4096 --dir /path/to/project "fix bug"
# Working directory: /path/to/project (correct!)

Closes #7376

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7378 **State:** closed **Merged:** No --- ## Summary - Add `--dir` flag to `opencode run` command - When used with `--attach`, passes directory to SDK client via `x-opencode-directory` header - Enables sessions attached to a global server to run in the correct project directory ## Use Case When using [opencode-pilot](https://github.com/athal7/opencode-pilot) to spawn sessions that attach to a running OpenCode Desktop with worktree="/", sessions now run in the correct project directory instead of the server's home directory. ```bash # Before: sessions run in wrong directory opencode run --attach http://localhost:4096 "fix bug" # Working directory: /Users/me (wrong!) # After: sessions run in correct directory opencode run --attach http://localhost:4096 --dir /path/to/project "fix bug" # Working directory: /path/to/project (correct!) ``` Closes #7376
yindo added the pull-request label 2026-02-16 18:17:17 -05:00
yindo closed this issue 2026-02-16 18:17:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12374