feat(plugin commands): allows for code execution on plugin registered slash commands
This PR adds a powerful new plugin hook to opencode making it possible to run plugins through custom /commands registered by the plugin itself allowing for code execution
needs sdk rebuild to test
cd packages/sdk/js
bun run script/build.ts
As a proof of concept, this PR allowed me to create a plugin with a "/prune" command that prunes all tool outputs from the session
This could also allow to turn a plugin on/off, create composable workflows and many more things i'm sure
YES! I was just about to do this feature request. I reaaaaally hope this get merged!
Added support for command drop-in in command/ folder as suggested by https://github.com/sst/opencode/issues/5305
Hi @spoons-and-mirrors Thanks for making that happen, seems that a few cleanups still needed to pass tests and solve merge conflicts. While it is really powerful to run commands directly from the TUI (I know that I suggested that myself) but the more I think about it a better approach could be to run these server side. This way these slash commands can be triggered from any client (including the new desktop client) what are you thoughts here? Could need more work to make that happen
hey @malhashemi, this implementation does run server side. The TUI just wraps around it calling sdk.client.session.command().
as for the merge conflicts, they happen quite alot in this repo heh, I will get to it at some point.
@spoons-and-mirrors a question that just came to mind, would this work with desktop or any custom WebUI like CodeNomad, not that I use any of these, but was just thinking about how would this register. Could be already working there but would be nice to verify if you are doing any manual testing. additionally does it support sending arguments? something like /command "arg1" "arg2" etc. Finally how far away are we from a merge-able state haha
Yes to both. Can work with other clients, passes args
Yes to both. Can work with other clients, passes args