feat: add OpenCode plugin support#300
Conversation
7fc90d2 to
c2d5478
Compare
519deff to
8a99cbe
Compare
|
Rebased after #241 was merged. @pszymkowiak could I have your input on this? I'm not entirely sure about the |
|
Hi @zeval, @tom-thompson, @AlecMcQuarrie, @itai-delphos! We have four OpenCode integration PRs open (#225, #262, #300, #303) — they overlap significantly. We're leaning toward the lighter plugin approach (#303 or #300) for a first merge, then building on top. @AlecMcQuarrie (#225), @itai-delphos (#262) — could you rebase first (CI is failing on both), and let's discuss in a comment which features go beyond what #300/#303 offer? We'd like to avoid landing four competing implementations. |
8a99cbe to
0d88f52
Compare
|
Hey @FlorianBruniaux, thanks for the attention. My objective with this was to get the functionality working with OpenCode while respecting the decisions behind |
Add `--opencode` flag to `rtk init` for installing a global OpenCode plugin that rewrites Bash/shell commands through `rtk rewrite`. - New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite) - New init modes: --opencode (OpenCode only), combinable with Claude modes - Plugin install/update/remove lifecycle with idempotent writes - Uninstall cleans up OpenCode plugin alongside Claude Code artifacts - `rtk init --show` reports OpenCode plugin status - Replace unreachable!() with bail!() in match exhaustiveness guard
- README: OpenCode plugin section, install flags, troubleshooting - TROUBLESHOOTING: OpenCode-specific checklist - Update init mode table to reflect Claude Code default
0d88f52 to
2976701
Compare
Warning
Depends on #241 which streamlines the rewrite logic so that hooks don't have to repeat code
Summary
Add OpenCode plugin support to RTK. The plugin uses OpenCode's
tool.execute.beforehook to rewrite Bash/Shell tool commands tortk ...before execution.Built on top of PR #241 (
rtk rewrite): the OpenCode plugin is a thin 38-line wrapper that delegates all rewrite logic tortk rewrite.What's added
hooks/opencode-rtk.ts(38 lines) — OpenCode plugin that callsrtk rewritevia shellrtk init -g --opencode— install the plugin to~/.config/opencode/plugins/rtk.tsrtk init -g— now installs both Claude Code hook AND OpenCode plugin by defaultrtk init -g --claude/--opencode— install only one integrationrtk init --show— reports OpenCode plugin statusrtk init -g --uninstall— removes OpenCode plugin alongside Claude Code artifactsArchitecture
Both hooks are thin protocol adapters. All rewrite logic lives in Rust.
Design decisions
--opencodeas opt-in flag: `rtk init -g` installs both by default; `--claude` or `--opencode` installs only oneFiles changed
hooks/opencode-rtk.tsrtk rewritesrc/init.rssrc/main.rs--claude/--opencodeflags to Init commandREADME.mddocs/TROUBLESHOOTING.mdTesting
Closes