feat(plugin): add dynamic skill discovery via plugin hooks #11060
+91
−7
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.
Add Dynamic Skill Discovery via Plugin Hooks
Fixes #8304 #10148
What does this PR do?
This PR adds support for plugins to dynamically provide skills through two new hooks:
skill.listandskill.load. Plugins can now register skills at runtime that will be discovered and made available to the LLM alongside static skills from.opencode/skill/directories.Problem Solved
Previously, skills were only loaded from static filesystem locations. Plugins had no way to dynamically provide skills based on runtime conditions. This limitation prevented use cases like:
Implementation
The implementation adds a skill provider registry system:
Provider Registration (
packages/opencode/src/plugin/index.ts):skill.listorskill.loadhooks are registered as skill providersDynamic Skill Discovery (
packages/opencode/src/skill/skill.ts):Skill.all()now queries all registered providers in addition to static skillsSkill.get()checks providers when looking up skills by nameSkill.loadContent()uses provider'sskill.loadhook to retrieve skill contentHook Definitions (
packages/plugin/src/index.ts):skill.list: Returns array of skill metadata (name, description, location)skill.load: Returns skill content for a given location stringHow did you verify your code works?
Type Safety:
bun typecheckpasses without errorsTest Suite:
bun turbo testexecutes successfullyManual Testing:
skill.listandskill.loadhooksCode Review:
anytypes, usesconst, error handling with.catch())Edge Cases Handled