Skip to content

feat: add OpenCode integration (plugin + setup)#339

Open
ComputelessComputer wants to merge 1 commit intortk-ai:masterfrom
ComputelessComputer:feat/opencode-integration
Open

feat: add OpenCode integration (plugin + setup)#339
ComputelessComputer wants to merge 1 commit intortk-ai:masterfrom
ComputelessComputer:feat/opencode-integration

Conversation

@ComputelessComputer
Copy link
Copy Markdown

Summary

Add support for OpenCode alongside the existing Claude Code integration. RTK's rewrite engine (rtk rewrite) is already agent-agnostic — this PR wires it into OpenCode's plugin system.

What's included

File Purpose
opencode/plugins/rtk-rewrite.ts tool.execute.before hook that calls rtk rewrite to transparently rewrite bash commands
opencode/rtk-awareness.md Slim RTK instructions for AGENTS.md (meta commands, verification)
opencode/setup.sh One-command installer — copies plugin + patches AGENTS.md (global or per-project)
opencode/README.md Setup guide, command table, comparison with Claude Code flow

How it works

OpenCode plugins hook into tool.execute.before. When the tool is bash, the plugin:

  1. Extracts the command string from output.args.command
  2. Calls rtk rewrite <cmd> (same Rust binary / registry used by the Claude Code hook)
  3. If a rewrite is returned, replaces the command — otherwise passes through unchanged

Commands already prefixed with rtk and heredocs are skipped. The plugin gracefully disables itself if rtk is missing or < 0.23.0.

Setup

# Global (all OpenCode projects):
./opencode/setup.sh

# Per-project:
./opencode/setup.sh --local

Or manually copy opencode/plugins/rtk-rewrite.ts to ~/.config/opencode/plugins/.

Co-Authored-By: Oz oz-agent@warp.dev

Add support for OpenCode (sst/opencode) alongside the existing Claude Code
integration. RTK's rewrite engine (rtk rewrite) is agent-agnostic; this PR
wires it into OpenCode's plugin system.

New files:
- opencode/plugins/rtk-rewrite.ts — tool.execute.before hook that calls
  rtk rewrite to transparently rewrite bash commands
- opencode/rtk-awareness.md — slim RTK instructions for AGENTS.md
- opencode/setup.sh — one-command installer (global or per-project)
- opencode/README.md — setup guide and comparison with Claude Code flow

Co-Authored-By: Oz <oz-agent@warp.dev>
@pszymkowiak
Copy link
Copy Markdown
Collaborator

Thanks for the contribution! OpenCode support has been merged into develop via #300 (plugin + init lifecycle). It will be available in the next release once develop is merged to master. This PR is now superseded — if you'd like to contribute further, check the open issues!

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


ComputelessComputer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pszymkowiak
Copy link
Copy Markdown
Collaborator

Hi! Two things needed before we can review:

  1. Retarget to develop — this PR targets master, but all PRs should target develop. You can change the base branch in the PR settings (right sidebar).
  2. Sign the CLA — if not already done, please sign at https://cla-assistant.io/rtk-ai/rtk

Thanks!

@aeppling
Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

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.

5 participants