Skip to content

fix(opencode-handler): port to the opencode 2.x CLI - #119

Merged
gianlucamazza merged 2 commits into
mainfrom
fix/opencode-handler-2x
Sep 22, 2026
Merged

gianlucamazza merged 2 commits into
mainfrom
fix/opencode-handler-2x

Conversation

@gianlucamazza

@gianlucamazza gianlucamazza commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

opencode 2.0 removed opencode run --attach / --dir. With the old flags the handler exited 0 and forwarded the CLI help text as the agent's chat reply.

  • --attach → --server (default http://127.0.0.1:4096; OPENCODE_SERVER overrides, OPENCODE_ATTACH still honoured)
  • --dir → cd "$OPENCODE_DIR" (2.x uses the client cwd as the session working dir)

Test plan

  • shellcheck scripts/opencode-handler.sh
  • echo "Ciao, come va il test?" | scripts/opencode-handler.sh against opencode 2.0.8 → one-line Italian reply, exit 0

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Updated the OpenCode integration for compatibility with OpenCode 2.x.
    • Improved server connection configuration with environment-variable support and a default local server address.
    • Working-directory handling now uses the configured directory when available.

opencode 2.0 removed `run --attach` and `--dir`. The handler kept exiting 0
and forwarded the CLI help text as the chat reply. Use `--server` (default
http://127.0.0.1:4096, OPENCODE_SERVER overrides, OPENCODE_ATTACH still
honoured) and cd into OPENCODE_DIR, since 2.x takes the working dir from the
client cwd.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 2e730e2c-09c4-4dd0-b72b-aa318befa465

📥 Commits

Reviewing files that changed from the base of the PR and between 5d68977 and 02b10ce.

📒 Files selected for processing (1)
  • scripts/opencode-handler.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The handler now targets OpenCode 2.x. It selects the server URL from updated environment variables, uses --server, and changes to OPENCODE_DIR before execution. Retry behavior remains unchanged.

Changes

OpenCode handler compatibility

Layer / File(s) Summary
Update OpenCode 2.x invocation
scripts/opencode-handler.sh
The wrapper prefers OPENCODE_SERVER, falls back to OPENCODE_ATTACH, and defaults to http://127.0.0.1:4096. It uses opencode run --server. When OPENCODE_DIR is set, it changes to that directory before execution. The existing retry behavior remains unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to db0e6

The handler updates OpenCode 2.x server and working-directory handling while preserving retries; no actionable merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the OpenCode 2.x migration and includes testing details, but it does not use the required ## What and ## Checklist sections or address the checklist items. Add a ## What section with the change and reason. Add the required ## Checklist section and mark each item as applicable, completed, or not applicable with a brief explanation where needed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix and the migration of the handler to the OpenCode 2.x CLI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gianlucamazza
gianlucamazza merged commit da2dd78 into main Sep 22, 2026
8 checks passed
@gianlucamazza
gianlucamazza deleted the fix/opencode-handler-2x branch September 22, 2026 11:24
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.

1 participant