diff options
Diffstat (limited to 'hooks')
| -rw-r--r-- | hooks/hooks-codex.json | 2 | ||||
| -rwxr-xr-x | hooks/session-start | 22 | ||||
| -rwxr-xr-x | hooks/session-start-codex | 26 |
3 files changed, 28 insertions, 22 deletions
diff --git a/hooks/hooks-codex.json b/hooks/hooks-codex.json index 0114576..5c357fc 100644 --- a/hooks/hooks-codex.json +++ b/hooks/hooks-codex.json @@ -6,7 +6,7 @@ "hooks": [ { "type": "command", - "command": "\"${PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start", + "command": "\"${PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start-codex", "async": false } ] diff --git a/hooks/session-start b/hooks/session-start index c020538..0731962 100755 --- a/hooks/session-start +++ b/hooks/session-start @@ -7,25 +7,6 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -# Codex plugin hooks set both unprefixed PLUGIN_* vars and Claude-compatible -# CLAUDE_* vars. Only the unprefixed data var is Codex-specific enough to -# distinguish Codex from Claude Code. -is_codex_hook=0 -if [ -n "${PLUGIN_DATA:-}" ]; then - is_codex_hook=1 -fi - -# Check if legacy skills directory exists and build warning -warning_message="" -legacy_skills_dir="${HOME}/.config/superpowers/skills" -if [ -d "$legacy_skills_dir" ]; then - if [ "$is_codex_hook" -eq 1 ]; then - warning_message="\n\n<important-reminder>IN YOUR FIRST REPLY AFTER SEEING THIS MESSAGE YOU MUST TELL THE USER: WARNING: Superpowers now uses your coding agent's native skills system. Custom skills in ~/.config/superpowers/skills will not be read. Move custom skills to a skills location supported by your coding agent. To make this message go away, remove ~/.config/superpowers/skills</important-reminder>" - else - 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>" - fi -fi - # Read using-superpowers content using_superpowers_content=$(cat "${PLUGIN_ROOT}/skills/using-superpowers/SKILL.md" 2>&1 || echo "Error reading using-superpowers skill") @@ -43,8 +24,7 @@ escape_for_json() { } using_superpowers_escaped=$(escape_for_json "$using_superpowers_content") -warning_escaped=$(escape_for_json "$warning_message") -session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_superpowers_escaped}\n\n${warning_escaped}\n</EXTREMELY_IMPORTANT>" +session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_superpowers_escaped}\n</EXTREMELY_IMPORTANT>" # Output context injection as JSON. # Cursor hooks expect additional_context (snake_case). diff --git a/hooks/session-start-codex b/hooks/session-start-codex new file mode 100755 index 0000000..a6cc3cf --- /dev/null +++ b/hooks/session-start-codex @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Codex SessionStart hook for superpowers plugin + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +using_superpowers_content=$(cat "${PLUGIN_ROOT}/skills/using-superpowers/SKILL.md" 2>&1 || echo "Error reading using-superpowers skill") + +escape_for_json() { + local s="$1" + s="${s//\\/\\\\}" + s="${s//\"/\\\"}" + s="${s//$'\n'/\\n}" + s="${s//$'\r'/\\r}" + s="${s//$'\t'/\\t}" + printf '%s' "$s" +} + +using_superpowers_escaped=$(escape_for_json "$using_superpowers_content") +session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, follow the Codex skill-loading instructions in that skill:**\n\n${using_superpowers_escaped}\n</EXTREMELY_IMPORTANT>" + +printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context" + +exit 0 |
