Skip to content

feat(hook): support OpenCode 2.0 plugin format - #3899

Closed
jchuder wants to merge 1 commit into
rtk-ai:developfrom
jchuder:feat/opencode-v2-support
Closed

jchuder wants to merge 1 commit into
rtk-ai:developfrom
jchuder:feat/opencode-v2-support

Conversation

@jchuder

@jchuder jchuder commented Sep 6, 2026

Copy link
Copy Markdown

Summary

  • Add OpenCode 2.0 plugin compatibility to hooks/opencode/rtk.ts via default export { id, setup }, hooking execute.before (tool) and create.before (shell).
  • Maintain backward compatibility for OpenCode 1.0 via RtkOpenCodePlugin named export and server property.
  • Switch command execution to node:child_process execFile to eliminate dependency on $ shell interpolation and prevent shell injection.
  • Closes rtk init generates incompatible plugin format for OpenCode v2 #3898

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Verified test_opencode_plugin_dual_compatibility_v1_and_v2 unit test in src/hooks/init.rs
  • Verified plugin module structure matches OpenCode 2.0 plugin contracts

Update hooks/opencode/rtk.ts to support both OpenCode 1.0 and OpenCode 2.0 plugin interfaces.

- Add default export with id and setup for OpenCode 2.0 plugin loader
- Register execute.before and create.before hooks for shell commands
- Retain RtkOpenCodePlugin named export and server property for OpenCode 1.0 backward compatibility
- Use node:child_process execFile to invoke rtk rewrite cleanly
- Add unit test verifying dual compatibility in src/hooks/init.rs
- Update hooks/README.md documentation
@CLAassistant

CLAassistant commented Sep 6, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Xefreh

Xefreh commented Sep 26, 2026

Copy link
Copy Markdown

Thank you for this clean fix, any eta to merge this?

@Jiajun0413

Copy link
Copy Markdown

Thank you for this clean fix, any eta to merge this?感谢您解决了这个问题。那么,合并这个更改的预计时间是多少呢?

Same question.

@jchuder

jchuder commented Sep 26, 2026

Copy link
Copy Markdown
Author

Hi @KuSh , do you have time to review this PR?

A few users have asked about its merge status. Please let me know if you need any changes from me.

Thanks!

@jchuder

jchuder commented Sep 27, 2026

Copy link
Copy Markdown
Author

I am closing this PR in favor of #4187.

#4187 now covers the OpenCode 2.0 compatibility issue more completely, including exit code 3 handling, Windows support, binary resolution, and runtime tests.

Thanks to everyone who tested and followed up on this issue. Further work on this issue will be tracked in #4187.

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.

rtk init generates incompatible plugin format for OpenCode v2

4 participants