opencode icon indicating copy to clipboard operation
opencode copied to clipboard

New Plugin Hook: `command.execute.before`

Open rektide opened this issue 6 days ago • 2 comments

What does this PR do?

This PR proposes a command.execute.before, which allows for plugins to perform dynamic behavior & modification of command runs, including stopping their regular execution flow.

I have opened a discussion on the discord for this as well: https://discord.com/channels/1391832426048651334/1458986650184060978

How did you verify your code works?

I've been slow to go deep testing this, and doing so has kept me from making a PR or draft. But I saw a call to action, with Dex talking about skills and commands and even though it sort of seems un-wise / a sore topic at the moment, I wanted to share & get this out here.

I'm doing more testing now.

Bikeshed rename for symmetry

I also have a commit in here to rename command.executed to command.execute.after, which makes squares this PR with what see see for tool hooks, which have tool.execute.before / tool.execute.after. I opted to retain command.executed as a hook too, for backwards compatibility stake, but "deprecated" it. This commit is in no way loadbearing, but I appreciate the symmetry it offers!

rektide avatar Jan 09 '26 00:01 rektide