Task 12: Implement Session Start Hook
**Files:**
- Modify: `.opencode/plugin/superpowers.js`
**Step 1: Add session.started hook**
After the tools array, add:
```javascript
'session.started': async () => {
// Read using-superpowers skill content
const usingSuperpowersPath = skillsCore.resolveSkillPath(
'using-superpowers',
superpowersSkillsDir,
personalSkillsDir
);
let usingSuperpowersContent = '';
if (usingSuperpowersPath) {
const fullContent = fs.readFileSync(usingSuperpowersPath.skillFile, 'utf8');
// Strip 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);
}
}
usingSuperpowersContent = contentLines.join('\n').trim();
}
// Tool mapping instructions
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)
- \`Skill\` tool → \`use_skill\` custom tool (already available)
- \`Read\`, \`Write\`, \`Edit\`, \`Bash\` → Use your native tools
**Skill directories contain supporting files:**
- Scripts you can run with bash tool
- Additional documentation you can read
- Utilities and helpers specific to that skill
**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
`;
// Check for updates (non-blocking)
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 to inject into session
return {
context: `