|
| 1 | +:<<"::CMDLITERAL" |
| 2 | +@ECHO OFF |
| 3 | +GOTO :CMDSCRIPT |
| 4 | +::CMDLITERAL |
| 5 | + |
| 6 | +# ============================================================================== |
| 7 | +# Bash/sh section - runs on Unix/Linux/macOS |
| 8 | +# ============================================================================== |
| 9 | + |
| 10 | +set -euo pipefail |
| 11 | + |
| 12 | +# Determine plugin root directory |
| 13 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" |
| 14 | +PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" |
| 15 | + |
| 16 | +# Check if legacy skills directory exists and build warning |
| 17 | +warning_message="" |
| 18 | +legacy_skills_dir="${HOME}/.config/superpowers/skills" |
| 19 | +if [ -d "$legacy_skills_dir" ]; then |
| 20 | + warning_message="\n\n<important-reminder>IN YOUR FIRST REPLY AFTER SEEING THIS MESSAGE YOU MUST TELL THE USER:⚠️ **WARNING:** Superpowers now uses Claude Code's skills system. Custom skills in ~/.config/superpowers/skills will not be read. Move custom skills to ~/.claude/skills instead. To make this message go away, remove ~/.config/superpowers/skills</important-reminder>" |
| 21 | +fi |
| 22 | + |
| 23 | +# Read using-superpowers content |
| 24 | +using_superpowers_content=$(cat "${PLUGIN_ROOT}/skills/using-superpowers/SKILL.md" 2>&1 || echo "Error reading using-superpowers skill") |
| 25 | + |
| 26 | +# Escape outputs for JSON |
| 27 | +using_superpowers_escaped=$(echo "$using_superpowers_content" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}') |
| 28 | +warning_escaped=$(echo "$warning_message" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}') |
| 29 | + |
| 30 | +# Output context injection as JSON |
| 31 | +cat <<EOF |
| 32 | +{ |
| 33 | + "hookSpecificOutput": { |
| 34 | + "hookEventName": "SessionStart", |
| 35 | + "additionalContext": "<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**The content below is from skills/using-superpowers/SKILL.md - your introduction to using skills:**\n\n${using_superpowers_escaped}\n\n${warning_escaped}\n</EXTREMELY_IMPORTANT>" |
| 36 | + } |
| 37 | +} |
| 38 | +EOF |
| 39 | + |
| 40 | +exit 0 |
| 41 | + |
| 42 | +:CMDSCRIPT |
| 43 | +REM ============================================================================== |
| 44 | +REM Windows cmd.exe section - runs on Windows |
| 45 | +REM ============================================================================== |
| 46 | + |
| 47 | +SETLOCAL EnableDelayedExpansion |
| 48 | + |
| 49 | +REM Determine plugin root directory |
| 50 | +SET "SCRIPT_DIR=%~dp0" |
| 51 | +SET "PLUGIN_ROOT=%SCRIPT_DIR%.." |
| 52 | + |
| 53 | +REM Check if legacy skills directory exists and build warning |
| 54 | +SET "warning_message=" |
| 55 | +SET "legacy_skills_dir=%USERPROFILE%\.config\superpowers\skills" |
| 56 | +IF EXIST "%legacy_skills_dir%" ( |
| 57 | + SET "warning_message=\n\n<important-reminder>IN YOUR FIRST REPLY AFTER SEEING THIS MESSAGE YOU MUST TELL THE USER:⚠️ **WARNING:** Superpowers now uses Claude Code's skills system. Custom skills in ~/.config/superpowers/skills will not be read. Move custom skills to ~/.claude/skills instead. To make this message go away, remove ~/.config/superpowers/skills</important-reminder>" |
| 58 | +) |
| 59 | + |
| 60 | +REM Call PowerShell to handle the JSON generation (it's much better at this) |
| 61 | +powershell -NoProfile -ExecutionPolicy Bypass -Command "$scriptDir = '%SCRIPT_DIR%'; $pluginRoot = '%PLUGIN_ROOT%'; $warningMessage = '%warning_message%'; $skillFile = Join-Path $pluginRoot 'skills\using-superpowers\SKILL.md'; if (Test-Path $skillFile) { $skillContent = Get-Content -Path $skillFile -Raw -Encoding UTF8 } else { $skillContent = 'Error: using-superpowers skill file not found' }; $contextContent = '<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**The content below is from skills/using-superpowers/SKILL.md - your introduction to using skills:**\n\n' + $skillContent + '\n\n' + $warningMessage + '\n</EXTREMELY_IMPORTANT>'; $output = @{ hookSpecificOutput = @{ hookEventName = 'SessionStart'; additionalContext = $contextContent } }; $output | ConvertTo-Json -Depth 10 -Compress:$false" |
| 62 | + |
| 63 | +EXIT /B 0 |
0 commit comments