diff options
| author | Jesse Vincent <jesse@fsck.com> | 2025-11-23 10:51:26 -0800 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2025-11-23 10:51:26 -0800 |
| commit | 5f5b789e3ee91c79d41ce932c0865da258623f5e (patch) | |
| tree | ecb68c84e217b9750991f567cbda1fc15e07e2db /.opencode/plugin | |
| parent | 7db10cf5403d12d83b0ce997157f3f93617076b2 (diff) | |
feat: add chat.message hook to inject superpowers context automatically
Diffstat (limited to '.opencode/plugin')
| -rw-r--r-- | .opencode/plugin/superpowers.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/.opencode/plugin/superpowers.js b/.opencode/plugin/superpowers.js index a3ca5c7..24af57b 100644 --- a/.opencode/plugin/superpowers.js +++ b/.opencode/plugin/superpowers.js @@ -77,6 +77,37 @@ ${content}`; return output; } }) + }, + "chat.message": async (input, output) => { + // Only inject on first message of session (or every message if needed) + if (!output.message.system || output.message.system.length === 0) { + const usingSuperpowersPath = skillsCore.resolveSkillPath('using-superpowers', superpowersSkillsDir, personalSkillsDir); + + if (usingSuperpowersPath) { + const fullContent = fs.readFileSync(usingSuperpowersPath.skillFile, 'utf8'); + const usingSuperpowersContent = skillsCore.stripFrontmatter(fullContent); + + const toolMapping = `**Tool Mapping for OpenCode:** +When skills reference tools you don't have, substitute OpenCode equivalents: +- \`TodoWrite\` → \`update_plan\` +- \`Task\` tool with subagents → Use OpenCode's subagent system (@mention) +- \`Skill\` tool → \`use_skill\` custom tool +- \`Read\`, \`Write\`, \`Edit\`, \`Bash\` → Your native tools + +**Skills naming:** +- Superpowers skills: \`superpowers:skill-name\` +- Personal skills: \`skill-name\` +- Personal skills override superpowers when names match`; + + output.message.system = `<EXTREMELY_IMPORTANT> +You have superpowers. + +${usingSuperpowersContent} + +${toolMapping} +</EXTREMELY_IMPORTANT>`; + } + } } }; }; |
