|
|
@@ -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}`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
};
|
|
|
};
|