Repository navigation
Conversation
The OpenCode plugin used the Bun-only \$ shell helper and a Unix-only 'which' probe, which made it silently fail in two environments: - OpenCode Desktop and any Node runtime: \$ is undefined in the plugin context, so \\$\\\which rtk\\\\ throws TypeError, the factory crashes, and no hooks are registered (no error surfaced to the user) - Windows CLI: 'which' does not exist Replace both with node:child_process execFile: - probe with 'rtk --version' (also verifies rewrite support) - pass arguments as a literal array, no shell involved - windowsHide: true to avoid console window flashes on Windows - resolve stdout regardless of exit code, because 'rtk rewrite' uses non-zero exit codes as status signals (exit 3 = permission-gated rewrite) while still emitting the rewrite on stdout Also update the three doc references to the zx library and add a regression test asserting the embedded plugin template no longer references \$ or 'which rtk'. Verified on Windows 11 + OpenCode CLI: hooks fire, git commands are rewritten to rtk git, PowerShell commands pass through unchanged, double-prefixing of already-rewritten commands is avoided. Closes #3326 Related: #1993, #3330 Signed-off-by: amnesiaof <dolombovskyyalexs@gmail.com>
4 tasks done
Collaborator
|
Closing in favour of #3330, which makes the same execFile change to the OpenCode plugin and has a green CI run across the Linux, macOS and Windows test matrix. #3330 still needs a rebase onto current develop, which is the work done on this branch, so a note there pointing at it would be useful. Review and comments are welcome on #3330. |
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
$shell helper and Unix-onlywhichprobe with NodeexecFilein the OpenCode pluginrtk rewriteexits non-zero (exit 3 = permission-gated rewrite)Why
The current plugin fails silently in two environments:
$isundefinedin the plugin context, so$`which rtk`throwsTypeError: $ is not a function, the plugin factory crashes, and no hooks are registered — nothing is surfaced to the user.whichdoes not exist.A third subtlety:
rtk rewriteuses non-zero exit codes as status signals (exit 3 with valid stdout such asrtk git status), so stdout must be resolved regardless of the exit code.Test plan
cargo fmt --all --checkcargo clippy --all-targetscargo test—test_opencode_plugin*pass (3/3). Note: 18 pre-existing failures incore::stream::testson Windows ("program not found" — tests spawn Unix utils likecat/echo), present on a cleandeveloptree as well, unrelated to this change.@opencode-ai/plugincontract):"git status"→"rtk git status", PowerShell commands pass through unchanged, already-prefixedrtk ...commands are not double-prefixedrtk gaintracks savingsCloses #3326
Related: #1993, #3330 (independent fix, same root causes; this PR targets current
develop)