From d19703b0a19608df0261fdc5e24bc6891ec2dac9 Mon Sep 17 00:00:00 2001 From: jesse Date: Sun, 15 Mar 2026 18:28:55 +0000 Subject: fix: stop firing SessionStart hook on --resume Resumed sessions already have injected context in their conversation history. Re-firing the hook was redundant and could cause issues. The hook now fires only on startup, clear, and compact. Co-Authored-By: Claude Opus 4.6 --- hooks/hooks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hooks') diff --git a/hooks/hooks.json b/hooks/hooks.json index 7e3d30d..79d8cee 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -2,7 +2,7 @@ "hooks": { "SessionStart": [ { - "matcher": "startup|resume|clear|compact", + "matcher": "startup|clear|compact", "hooks": [ { "type": "command", -- cgit From fd318b1b79caeac758f35b2653a4805790bbc39e Mon Sep 17 00:00:00 2001 From: jesse Date: Sun, 15 Mar 2026 18:40:33 +0000 Subject: fix(hooks): replace BASH_SOURCE with POSIX-safe $0 Replace ${BASH_SOURCE[0]:-$0} with $0 in hooks/session-start and the polyglot-hooks docs example. BASH_SOURCE uses bash array syntax that causes 'Bad substitution' on systems where /bin/sh is dash (Ubuntu). Since session-start is always executed (never sourced), $0 and BASH_SOURCE give the same result. Tested on Linux (bash + dash) and Windows (Git Bash via CMD and direct). Based on #553, closes #553. Co-Authored-By: Claude Opus 4.6 --- hooks/session-start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hooks') diff --git a/hooks/session-start b/hooks/session-start index f9e94dd..b4f9918 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 -- cgit From 537ec640fd8fd47fc0ff596abeb445d1515bd2bd Mon Sep 17 00:00:00 2001 From: jesse Date: Sun, 15 Mar 2026 19:14:34 +0000 Subject: fix(hooks): replace heredoc with printf to fix bash 5.3+ hang Bash 5.3 has a regression where heredoc variable expansion blocks when content exceeds ~512 bytes. The session_context variable is ~4,500 bytes, causing the SessionStart hook to hang indefinitely on macOS with Homebrew bash 5.3+. Replace cat < --- hooks/session-start | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'hooks') diff --git a/hooks/session-start b/hooks/session-start index b4f9918..dca5389 100755 --- a/hooks/session-start +++ b/hooks/session-start @@ -39,23 +39,16 @@ session_context="\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. +# +# Uses printf instead of heredoc (cat < Date: Sun, 15 Mar 2026 19:35:18 +0000 Subject: feat: add Cursor-compatible hooks and fix platform detection Add hooks/hooks-cursor.json with Cursor's camelCase format (sessionStart, version: 1) and update .cursor-plugin/plugin.json to reference it. Uses ${CURSOR_PLUGIN_ROOT} and run-hook.cmd for cross-platform support. Fix session-start platform detection: check CURSOR_PLUGIN_ROOT first (Cursor may also set CLAUDE_PLUGIN_ROOT), ensuring correct output format for each platform. Based on PR #709 with fixes for: wrong filename (.sh extension), missing Windows support, fragile relative paths, and incorrect platform detection. Co-Authored-By: Claude Opus 4.6 --- hooks/hooks-cursor.json | 10 ++++++++++ hooks/session-start | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 hooks/hooks-cursor.json (limited to 'hooks') diff --git a/hooks/hooks-cursor.json b/hooks/hooks-cursor.json new file mode 100644 index 0000000..70f22ad --- /dev/null +++ b/hooks/hooks-cursor.json @@ -0,0 +1,10 @@ +{ + "version": 1, + "hooks": { + "sessionStart": [ + { + "command": "\"${CURSOR_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start" + } + ] + } +} diff --git a/hooks/session-start b/hooks/session-start index dca5389..2371935 100755 --- a/hooks/session-start +++ b/hooks/session-start @@ -43,11 +43,14 @@ session_context="\nYou have superpowers.\n\n**Below is the # Uses printf instead of heredoc (cat < Date: Sun, 15 Mar 2026 19:35:36 +0000 Subject: Update changelog with Cursor hooks support (#709) Co-Authored-By: Claude Opus 4.6 --- hooks/hooks-cursor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hooks') diff --git a/hooks/hooks-cursor.json b/hooks/hooks-cursor.json index 70f22ad..6df4461 100644 --- a/hooks/hooks-cursor.json +++ b/hooks/hooks-cursor.json @@ -3,7 +3,7 @@ "hooks": { "sessionStart": [ { - "command": "\"${CURSOR_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start" + "command": "./hooks/session-start" } ] } -- cgit