Bladeren bron

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 <noreply@anthropic.com>
jesse 5 maanden geleden
bovenliggende
commit
4e7c0842f8
3 gewijzigde bestanden met toevoegingen van 16 en 3 verwijderingen
  1. 1 1
      .cursor-plugin/plugin.json
  2. 10 0
      hooks/hooks-cursor.json
  3. 5 2
      hooks/session-start

+ 1 - 1
.cursor-plugin/plugin.json

@@ -14,5 +14,5 @@
   "skills": "./skills/",
   "agents": "./agents/",
   "commands": "./commands/",
-  "hooks": "./hooks/hooks.json"
+  "hooks": "./hooks/hooks-cursor.json"
 }

+ 10 - 0
hooks/hooks-cursor.json

@@ -0,0 +1,10 @@
+{
+  "version": 1,
+  "hooks": {
+    "sessionStart": [
+      {
+        "command": "\"${CURSOR_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start"
+      }
+    ]
+  }
+}

+ 5 - 2
hooks/session-start

@@ -43,11 +43,14 @@ session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the
 # 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 "${CLAUDE_PLUGIN_ROOT:-}" ]; then
+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
   printf '{\n  "hookSpecificOutput": {\n    "hookEventName": "SessionStart",\n    "additionalContext": "%s"\n  }\n}\n' "$session_context"
 else
-  # Other platforms (Cursor, etc.) — emit only additional_context
+  # Other platforms — emit additional_context as fallback
   printf '{\n  "additional_context": "%s"\n}\n' "$session_context"
 fi