summaryrefslogtreecommitdiff
path: root/.opencode/plugin
diff options
context:
space:
mode:
authorJesse Vincent <jesse@fsck.com>2025-11-22 12:30:20 -0800
committerJesse Vincent <jesse@fsck.com>2025-11-22 12:30:20 -0800
commit1aa29ad52b46a10cd7076ee3276aafeeddfa4cf7 (patch)
tree85ac3f5ba59dee387597abb4c37abe353f820d6c /.opencode/plugin
parent6847cf4cfc9e454bb1099fa939f649b67f50e8ed (diff)
feat: implement use_skill tool for opencode
Diffstat (limited to '.opencode/plugin')
-rw-r--r--.opencode/plugin/superpowers.js53
1 files changed, 52 insertions, 1 deletions
diff --git a/.opencode/plugin/superpowers.js b/.opencode/plugin/superpowers.js
index 2dc613e..4a092e3 100644
--- a/.opencode/plugin/superpowers.js
+++ b/.opencode/plugin/superpowers.js
@@ -15,7 +15,58 @@ const superpowersSkillsDir = path.join(homeDir, '.config/opencode/superpowers/sk
const personalSkillsDir = path.join(homeDir, '.config/opencode/skills');
module.exports = async ({ project, client, $, directory, worktree }) => {
+ const { z } = await import('zod');
+
return {
- // Custom tools and hooks will go here
+ tools: [
+ {
+ name: 'use_skill',
+ description: 'Load and read a specific skill to guide your work. Skills contain proven workflows, mandatory processes, and expert techniques.',
+ schema: z.object({
+ skill_name: z.string().describe('Name of the skill to load (e.g., "superpowers:brainstorming" or "my-custom-skill")')
+ }),
+ execute: async ({ skill_name }) => {
+ const resolved = skillsCore.resolveSkillPath(skill_name, superpowersSkillsDir, personalSkillsDir);
+
+ if (!resolved) {
+ return `Error: Skill "${skill_name}" not found.\n\nRun find_skills to see available skills.`;
+ }
+
+ const fullContent = fs.readFileSync(resolved.skillFile, 'utf8');
+ const { name, description } = skillsCore.extractFrontmatter(resolved.skillFile);
+
+ // Extract content after frontmatter
+ const lines = fullContent.split('\n');
+ let inFrontmatter = false;
+ let frontmatterEnded = false;
+ const contentLines = [];
+
+ for (const line of lines) {
+ if (line.trim() === '---') {
+ if (inFrontmatter) {
+ frontmatterEnded = true;
+ continue;
+ }
+ inFrontmatter = true;
+ continue;
+ }
+
+ if (frontmatterEnded || !inFrontmatter) {
+ contentLines.push(line);
+ }
+ }
+
+ const content = contentLines.join('\n').trim();
+ const skillDirectory = path.dirname(resolved.skillFile);
+
+ return `# ${name || skill_name}
+# ${description || ''}
+# Supporting tools and docs are in ${skillDirectory}
+# ============================================
+
+${content}`;
+ }
+ }
+ ]
};
};