feat(init): add --opencode flag for OpenCode plugin install#455
Open
wouter-intveld wants to merge 1 commit intortk-ai:masterfrom
Open
feat(init): add --opencode flag for OpenCode plugin install#455wouter-intveld wants to merge 1 commit intortk-ai:masterfrom
wouter-intveld wants to merge 1 commit intortk-ai:masterfrom
Conversation
|
can we get this faster? It's really good, cant wait to use it in my opencode sessions! |
Add rtk init --opencode to install an OpenCode plugin that transparently rewrites bash commands via the tool.execute.before hook, equivalent to the existing Claude Code PreToolUse hook. The plugin is embedded in the binary and written to ~/.config/opencode/plugins/opencode-rtk.js on install. Complements rtk-ai#417 (OpenCode discover provider).
64e6929 to
1d0de01
Compare
Collaborator
|
Hi! Thanks for the contribution! Since March 6, all PRs should target the Could you update the base branch? Click Edit at the top right of this PR and change it from Thanks! |
Collaborator
|
Thanks for the contribution! OpenCode support has been merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk init --opencodeto install an OpenCode plugin that transparently rewrites bash commands to use rtktool.execute.beforehook — the equivalent of Claude Code'sPreToolUsehookHow it works
Installs
opencode-rtk.jsto~/.config/opencode/plugins/— OpenCode auto-discovers it on restart. The plugin intercepts bash tool calls, runsrtk rewriteon the command, and mutates the args before execution. The LLM never sees the rewrite, just compressed output.Changes
hooks/opencode-rtk.jsinclude_str!)src/main.rs--opencodeflag to init subcommand (mutually exclusive with--claude-md,--hook-only)src/init.rsrun_opencode_mode()+resolve_opencode_dir()README.mdDesign decisions
plugins/directory (unlike Claude Code'ssettings.jsonpatching)include_str!(),write_if_changed(),resolve_*_dir()Validation
cargo buildpassesrtk init --opencodeinstalls the plugin correctlygit status,ls,cargo testare transparently rewrittenRelated
Complements #417 (OpenCode discover provider) — that PR adds analytics for missed savings, this PR adds the actual command rewriting.