An agentic skills framework & software development methodology that works.
fix: use agent prompts instead of event hooks for context injection
Jesse Vincent368674419a90
diff --git a/.opencode/INSTALL.md b/.opencode/INSTALL.mdindex e5924191f..6a4198496 100644--- a/.opencode/INSTALL.md+++ b/.opencode/INSTALL.md@@ -33,14 +33,40 @@ mkdir -p .opencode/pluginln -sf ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js .opencode/plugin/superpowers.js```-### 3. Restart OpenCode+### 3. Configure Agent Prompt-Restart OpenCode to load the plugin. On the next session, you should see:+The plugin generates a prompt file at `~/.config/opencode/prompts/superpowers.txt`. Add this to your agent configuration.+**Option A: Extend the Build agent** (recommended)++Edit `~/.config/opencode/opencode.json`:++```json+{+ "agent": {+ "build": {+ "prompt": "{file:./prompts/superpowers.txt}"+ }+ }+}```-You have superpowers.++**Option B: Create a custom agent**++Create `~/.config/opencode/agent/superbuild.md`:++```markdown+---+description: Build agent with superpowers support+---++{file:./prompts/superpowers.txt}```+### 4. Restart OpenCode++Restart OpenCode to load the plugin. The prompt file will be generated automatically.+## Usage### Finding Skillsdiff --git a/.opencode/plugin/superpowers.js b/.opencode/plugin/superpowers.jsindex 92b204885..37e83335d 100644--- a/.opencode/plugin/superpowers.js+++ b/.opencode/plugin/superpowers.js@@ -2,7 +2,7 @@* Superpowers plugin for OpenCode.ai** Provides custom tools for loading and discovering skills,- * with automatic bootstrap on session start.+ * with prompt generation for agent configuration.*/import path from 'path';@@ -19,6 +19,8 @@ export const SuperpowersPlugin = async ({ project, client, $, directory, worktreconst homeDir = os.homedir();const superpowersSkillsDir = path.join(homeDir, '.config/opencode/superpowers/skills');const personalSkillsDir = path.join(homeDir, '.config/opencode/skills');+ const promptsDir = path.join(homeDir, '.config/opencode/prompts');+ const promptFile = path.join(promptsDir, 'superpowers.txt');return {tools: [@@ -79,18 +81,21 @@ ${content}`;}],- event: async ({ event }) => {- if (event.type === 'session.created') {- const usingSuperpowersPath = skillsCore.resolveSkillPath('using-superpowers', superpowersSkillsDir, personalSkillsDir);+ config: async () => {+ // Create prompts directory if it doesn't exist+ if (!fs.existsSync(promptsDir)) {+ fs.mkdirSync(promptsDir, { recursive: true });+ }- let usingSuperpowersContent = '';- if (usingSuperpowersPath) {- const fullContent = fs.readFileSync(usingSuperpowersPath.skillFile, 'utf8');- usingSuperpowersContent = skillsCore.stripFrontmatter(fullContent);- }+ // Generate prompt content+ const usingSuperpowersPath = skillsCore.resolveSkillPath('using-superpowers', superpowersSkillsDir, personalSkillsDir);+ let promptContent = '';++ if (usingSuperpowersPath) {+ const fullContent = fs.readFileSync(usingSuperpowersPath.skillFile, 'utf8');+ const usingSuperpowersContent = skillsCore.stripFrontmatter(fullContent);- const toolMapping = `-**Tool Mapping for OpenCode:**+ const toolMapping = `**Tool Mapping for OpenCode:**When skills reference tools you don't have, substitute OpenCode equivalents:- \`TodoWrite\` → \`update_plan\` (your planning/task tracking tool)- \`Task\` tool with subagents → Use OpenCode's subagent system (@mention syntax or automatic dispatch)@@ -105,27 +110,21 @@ When skills reference tools you don't have, substitute OpenCode equivalents:**Skills naming:**- Superpowers skills: \`superpowers:skill-name\` (from ~/.config/opencode/superpowers/skills/)- Personal skills: \`skill-name\` (from ~/.config/opencode/skills/)-- Personal skills override superpowers skills when names match-`;+- Personal skills override superpowers skills when names match`;- const hasUpdates = skillsCore.checkForUpdates(path.join(homeDir, '.config/opencode/superpowers'));-- const updateNotice = hasUpdates ?- '\n\n**Updates available!** Run `cd ~/.config/opencode/superpowers && git pull` to update superpowers.' :- '';-- return {- context: `<EXTREMELY_IMPORTANT>+ promptContent = `<EXTREMELY_IMPORTANT>You have superpowers.**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'use_skill' tool:**${usingSuperpowersContent}-${toolMapping}${updateNotice}-</EXTREMELY_IMPORTANT>`- };+${toolMapping}+</EXTREMELY_IMPORTANT>`;}++ // Write prompt file+ fs.writeFileSync(promptFile, promptContent, 'utf8');}};};