Skip to content

Conversation

@athal7
Copy link
Contributor

@athal7 athal7 commented Jan 8, 2026

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 athal7 force-pushed the opencode/silent-meadow branch from 16ae83b to a89a143 Compare January 8, 2026 21:08
@athal7 athal7 changed the title feat(cli): add --dir flag to opencode run --attach feat: add --dir flag to opencode run --attach Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add --dir flag to opencode run --attach

1 participant