diff options
| author | Jesse Vincent <jesse@fsck.com> | 2025-10-15 22:42:20 -0700 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2025-10-15 22:42:20 -0700 |
| commit | 0fdea80a7d6b2e5d6b2d3e59ff2ca378ecd56cc0 (patch) | |
| tree | d4be85bf7338d16dd00d723d5a04be03e628d2e3 /plugins/superpowers-bootstrap/hooks | |
| parent | d6ac9a8b5d5884413b194330653b6aa336d3c87a (diff) | |
Reapply "Move superpowers plugin into plugins/superpowers-bootstrap subdirectory"
This reverts commit d6ac9a8b5d5884413b194330653b6aa336d3c87a.
turns out this worked. it's just that anthropic changed claude's startup hook output
Diffstat (limited to 'plugins/superpowers-bootstrap/hooks')
| -rw-r--r-- | plugins/superpowers-bootstrap/hooks/hooks.json | 15 | ||||
| -rwxr-xr-x | plugins/superpowers-bootstrap/hooks/session-start.sh | 53 |
2 files changed, 68 insertions, 0 deletions
diff --git a/plugins/superpowers-bootstrap/hooks/hooks.json b/plugins/superpowers-bootstrap/hooks/hooks.json new file mode 100644 index 0000000..17e0ac8 --- /dev/null +++ b/plugins/superpowers-bootstrap/hooks/hooks.json @@ -0,0 +1,15 @@ +{ + "hooks": { + "SessionStart": [ + { + "matcher": "startup|resume|clear|compact", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh" + } + ] + } + ] + } +} diff --git a/plugins/superpowers-bootstrap/hooks/session-start.sh b/plugins/superpowers-bootstrap/hooks/session-start.sh new file mode 100755 index 0000000..1b540ac --- /dev/null +++ b/plugins/superpowers-bootstrap/hooks/session-start.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# SessionStart hook for superpowers plugin + +set -euo pipefail + +# Set SUPERPOWERS_SKILLS_ROOT environment variable +export SUPERPOWERS_SKILLS_ROOT="${HOME}/.config/superpowers/skills" + +# Run skills initialization script (handles clone/fetch/auto-update) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" +PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +init_output=$("${PLUGIN_ROOT}/lib/initialize-skills.sh" 2>&1 || echo "") + +# Extract status flags +skills_updated=$(echo "$init_output" | grep "SKILLS_UPDATED=true" || echo "") +skills_behind=$(echo "$init_output" | grep "SKILLS_BEHIND=true" || echo "") +# Remove status flags from display output +init_output=$(echo "$init_output" | grep -v "SKILLS_UPDATED=true" | grep -v "SKILLS_BEHIND=true" || true) + +# Run find-skills to show all available skills +find_skills_output=$("${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/find-skills" 2>&1 || echo "Error running find-skills") + +# Read using-skills content (renamed from getting-started) +using_skills_content=$(cat "${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/SKILL.md" 2>&1 || echo "Error reading using-skills") + +# Escape outputs for JSON +init_escaped=$(echo "$init_output" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}') +find_skills_escaped=$(echo "$find_skills_output" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}') +using_skills_escaped=$(echo "$using_skills_content" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}') + +# Build initialization output message if present +init_message="" +if [ -n "$init_escaped" ]; then + init_message="${init_escaped}\n\n" +fi + +# Build status messages that go at the end +status_message="" +if [ -n "$skills_behind" ]; then + status_message="\n\n⚠️ New skills available from upstream. Ask me to use the pulling-updates-from-skills-repository skill." +fi + +# Output context injection as JSON +cat <<EOF +{ + "hookSpecificOutput": { + "hookEventName": "SessionStart", + "additionalContext": "<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n${init_message}**The content below is from skills/using-skills/SKILL.md - your introduction to using skills:**\n\n${using_skills_escaped}\n\n**Tool paths (use these when you need to search for or run skills):**\n- find-skills: ${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/find-skills\n- skill-run: ${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/skill-run\n\n**Skills live in:** ${SUPERPOWERS_SKILLS_ROOT}/skills/ (you work on your own branch and can edit any skill)\n\n**Available skills (output of find-skills):**\n\n${find_skills_escaped}${status_message}\n</EXTREMELY_IMPORTANT>" + } +} +EOF + +exit 0 |
