opencode
opencode copied to clipboard
feat: plugin command execution hooks
Summary
Added plugin command system that enables plugins to register custom slash commands accessible via /command in TUI/web.
Key changes:
- Commands now have a
typefield ("template"or"plugin") to distinguish between template-based and plugin-provided commands - Plugin commands support
aliasesfor alternate names, andsessionOnlyflag to restrict commands to existing sessions - The
Command.get()function now resolves aliases by searching through all commands - Plugin command execution happens directly via the plugin's
executefunction, with error handling and event publishing -
Command.Event.Executedis only emitted when a plugin command creates a new message (checked by comparing message IDs before/after execution) - Added comprehensive test coverage for plugin commands including alias resolution, execution, error handling, and session-only guards