opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: add --dir flag to opencode run --attach

Open athal7 opened this issue 6 days ago • 1 comments

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

athal7 avatar Jan 08 '26 21:01 athal7