-
Notifications
You must be signed in to change notification settings - Fork 381
sync superpowers v6.0.1 from upstream main @ a21956e4 #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arittr
wants to merge
1
commit into
openai:main
Choose a base branch
from
prime-radiant-inc:sync/superpowers-a21956e4-20260617-000426
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "hooks": { | ||
| "SessionStart": [ | ||
| { | ||
| "matcher": "startup|resume|clear", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "\"${PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start-codex", | ||
| "async": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "version": 1, | ||
| "hooks": { | ||
| "sessionStart": [ | ||
| { | ||
| "command": "./hooks/run-hook.cmd session-start" | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "hooks": { | ||
| "SessionStart": [ | ||
| { | ||
| "matcher": "startup|clear|compact", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start", | ||
| "async": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| : << 'CMDBLOCK' | ||
| @echo off | ||
| REM Cross-platform polyglot wrapper for hook scripts. | ||
| REM On Windows: cmd.exe runs the batch portion, which finds and calls bash. | ||
| REM On Unix: the shell interprets this as a script (: is a no-op in bash). | ||
| REM | ||
| REM Hook scripts use extensionless filenames (e.g. "session-start" not | ||
| REM "session-start.sh") so Claude Code's Windows auto-detection -- which | ||
| REM prepends "bash" to any command containing .sh -- doesn't interfere. | ||
| REM | ||
| REM Usage: run-hook.cmd <script-name> [args...] | ||
|
|
||
| if "%~1"=="" ( | ||
| echo run-hook.cmd: missing script name >&2 | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| set "HOOK_DIR=%~dp0" | ||
|
|
||
| REM Try Git for Windows bash in standard locations | ||
| if exist "C:\Program Files\Git\bin\bash.exe" ( | ||
| "C:\Program Files\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9 | ||
| exit /b %ERRORLEVEL% | ||
| ) | ||
| if exist "C:\Program Files (x86)\Git\bin\bash.exe" ( | ||
| "C:\Program Files (x86)\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9 | ||
| exit /b %ERRORLEVEL% | ||
| ) | ||
|
|
||
| REM Try bash on PATH (e.g. user-installed Git Bash, MSYS2, Cygwin) | ||
| where bash >nul 2>nul | ||
| if %ERRORLEVEL% equ 0 ( | ||
| bash "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9 | ||
| exit /b %ERRORLEVEL% | ||
| ) | ||
|
|
||
| REM No bash found - exit silently rather than error | ||
| REM (plugin still works, just without SessionStart context injection) | ||
| exit /b 0 | ||
| CMDBLOCK | ||
|
|
||
| # Unix: run the named script directly | ||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| SCRIPT_NAME="$1" | ||
| shift | ||
| exec bash "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/env bash | ||
| # SessionStart hook for superpowers plugin | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Determine plugin root directory | ||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" | ||
|
|
||
| # Read using-superpowers content | ||
| using_superpowers_content=$(cat "${PLUGIN_ROOT}/skills/using-superpowers/SKILL.md" 2>&1 || echo "Error reading using-superpowers skill") | ||
|
|
||
| # Escape string for JSON embedding using bash parameter substitution. | ||
| # Each ${s//old/new} is a single C-level pass - orders of magnitude | ||
| # faster than the character-by-character loop this replaces. | ||
| 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, use the 'Skill' tool:**\n\n${using_superpowers_escaped}\n</EXTREMELY_IMPORTANT>" | ||
|
|
||
| # Output context injection as JSON. | ||
| # Cursor hooks expect additional_context (snake_case). | ||
| # Claude Code hooks expect hookSpecificOutput.additionalContext (nested). | ||
| # Copilot CLI (v1.0.11+) and others expect additionalContext (top-level, SDK standard). | ||
| # Claude Code reads BOTH additional_context and hookSpecificOutput without | ||
| # deduplication, so we must emit only the field the current platform consumes. | ||
| # | ||
| # Uses printf instead of heredoc to work around bash 5.3+ heredoc hang. | ||
| # 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) | ||
| printf '{\n "additional_context": "%s"\n}\n' "$session_context" | cat | ||
| elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then | ||
| # Claude Code sets CLAUDE_PLUGIN_ROOT without COPILOT_CLI | ||
| printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context" | cat | ||
| else | ||
| # Copilot CLI (sets COPILOT_CLI=1) or unknown platform — SDK standard format | ||
| printf '{\n "additionalContext": "%s"\n}\n' "$session_context" | cat | ||
| fi | ||
|
|
||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | cat | ||
|
|
||
| exit 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex hook docs say
SessionStartmatchers are applied tosource, whose values includestartup,resume,clear, andcompact; this Codex-specific hook omitscompacteven though the Claude hook in this commit includes it. In sessions that hit manual or automatic compaction, the Superpowers bootstrap will not be re-injected after the context is rewritten, so long-running sessions can lose the skill-loading instructions. Includecompactin this matcher.Useful? React with 👍 / 👎.