Skip to content

Fix: Add --attach flag to opencode run (Fixes #3188) - #3889

Merged
rekram1-node merged 9 commits into
anomalyco:devfrom
monke-yo:fix-issue-3188
Nov 5, 2025
Merged

rekram1-node merged 9 commits into
anomalyco:devfrom
monke-yo:fix-issue-3188

Conversation

@monke-yo

@monke-yo monke-yo commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Add --attach flag to opencode run

Fixes #3188

Changes

Added --attach <url> option to opencode run that connects to a running opencode serve instance via the SDK client, avoiding MCP server cold boot times on every invocation.

Modified files:

  • run.ts - Added attach mode that uses createOpencodeClient() to connect to remote server instead of bootstrap(). Subscribes to SSE event stream and processes events identically to local mode.
  • cli.mdx - Added --attach flag documentation with usage example.

Usage:

# Terminal 1
opencode serve

# Terminal 2
opencode run --attach http://localhost:4096 "Explain closures"

All existing flags (--model, --agent, --file, --command, --continue, --session, --share, --format, --title) work with --attach. Output format is identical to local execution.

@rekram1-node

Copy link
Copy Markdown
Collaborator

I think ideally we wouldn't need to duplicate so much logic

@monke-yo

monke-yo commented Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

@rekram1-node reused some logic, check again

Comment thread packages/opencode/src/cli/cmd/run.ts Resolved
Comment thread packages/opencode/src/cli/cmd/run.ts Resolved
@rekram1-node
rekram1-node merged commit ee8b812 into anomalyco:dev Nov 5, 2025
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
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.

opencode run --attach <server>

2 participants