summaryrefslogtreecommitdiff
path: root/hooks/session-start
diff options
context:
space:
mode:
authorJesse Vincent <jesse@fsck.com>2026-03-16 17:56:02 -0700
committerJesse Vincent <jesse@fsck.com>2026-03-16 17:56:02 -0700
commit1128a721ca3b7fd76bf12e8392cdeb89cfcfcf2a (patch)
treeec548034f8d61a509450679eab9d757fbc3e489a /hooks/session-start
parent825a142aa32af84a8f276b7d7ee38c5bcaee64b1 (diff)
parentd1b5f578b00371fb5330810134562758c67f581a (diff)
Merge branch 'dev'v5.0.4
Diffstat (limited to 'hooks/session-start')
-rwxr-xr-xhooks/session-start28
1 files changed, 12 insertions, 16 deletions
diff --git a/hooks/session-start b/hooks/session-start
index f9e94dd..2371935 100755
--- a/hooks/session-start
+++ b/hooks/session-start
@@ -4,7 +4,7 @@
set -euo pipefail
# Determine plugin root directory
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
# Check if legacy skills directory exists and build warning
@@ -39,23 +39,19 @@ session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the
# Claude Code hooks expect hookSpecificOutput.additionalContext.
# Claude Code reads BOTH fields without deduplication, so we must only
# emit the field consumed by the current platform to avoid double injection.
-if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
+#
+# Uses printf instead of heredoc (cat <<EOF) to work around a bash 5.3+
+# bug where heredoc variable expansion hangs when content exceeds ~512 bytes.
+# See: https://github.com/obra/superpowers/issues/571
+if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
+ # Cursor sets CURSOR_PLUGIN_ROOT (may also set CLAUDE_PLUGIN_ROOT) — emit additional_context
+ printf '{\n "additional_context": "%s"\n}\n' "$session_context"
+elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
# Claude Code sets CLAUDE_PLUGIN_ROOT — emit only hookSpecificOutput
- cat <<EOF
-{
- "hookSpecificOutput": {
- "hookEventName": "SessionStart",
- "additionalContext": "${session_context}"
- }
-}
-EOF
+ printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context"
else
- # Other platforms (Cursor, etc.) — emit only additional_context
- cat <<EOF
-{
- "additional_context": "${session_context}"
-}
-EOF
+ # Other platforms — emit additional_context as fallback
+ printf '{\n "additional_context": "%s"\n}\n' "$session_context"
fi
exit 0