Skip to content

Conversation

@ryanrhughes
Copy link

While trying to create an inclusive plugin that could contain a related set of items, I kept having to take hackish routes to get skills and commands populated.

This PR seeks to remedy that by adding hooks such that a plugin could be capable of shipping Agent, Command, Skill, and MCP definitions.

I've created and tested against an example plugin https://github.com/ryanrhughes/opencode-plugin-example (keep in mind the devDependency is using a local ref for @opencode-ai/plugin.

Fixes: #6347 & #6013

Add new extension types to the plugin package:
- CommandDefinition: defines slash commands with templates
- SkillDefinition: defines skills with name, description, content
- AgentDefinition: defines agents with model, mode, prompt, etc.

Add helper functions for type-safe extension creation:
- command(): creates CommandDefinition
- skill(): creates SkillDefinition
- agent(): creates AgentDefinition

Export new types and helpers from package index.
Modify plugin loading to collect command, skill, and agent definitions
from plugins during initialization. Add accessor functions:
- Plugin.commands(): returns plugin-provided commands
- Plugin.skills(): returns plugin-provided skills
- Plugin.agents(): returns plugin-provided agents

Include duplicate name warnings for consistency with skill loader.
Update trigger function type to exclude new non-function hook properties.
Load plugin-provided commands after built-ins but before config-based
commands, establishing precedence: built-in < plugin < config < file.
Users can override plugin commands via config or file-based commands.
Load plugin-provided skills first with special 'plugin:' location prefix.
File-based skills override plugin skills with the same name.
Load plugin-provided agents after built-ins but before config-based
agents. Plugin agents can override built-in agents and be overridden
by config-based agents.
Check for 'plugin:' prefix in skill location and fetch content from
plugin instead of filesystem. Add error logging when plugin skill
content is unavailable.
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.

[FEATURE]: Plugin Hook for Registering Additional Config Directories

1 participant