From 316e8314769c492288147acee862bf5057258470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?AI=E4=B8=8D=E6=AD=A2=E8=AF=AD?= <12096460+jnMetaCode@users.noreply.github.com> Date: Sat, 20 Jun 2026 01:48:03 +0800 Subject: [PATCH] =?UTF-8?q?sync(v6):=20hooks/session-start=20=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E4=B8=8A=E6=B8=B8=20v6.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 legacy ~/.config/superpowers/skills 迁移警告块及其 warning_escaped 注入(上游 v6.0.0 已删;与 v6 清理 ~/.config/superpowers/ 一致) - 三处 printf 输出补 | cat,对齐上游输出行为 验证:与上游 v6.0.3 逐字一致;实际运行 hook,三个平台分支 (CURSOR_PLUGIN_ROOT / CLAUDE_PLUGIN_ROOT / COPILOT_CLI) 均输出合法 JSON(字段分别为 additional_context / hookSpecificOutput.additionalContext / additionalContext)。注入内容仍为本 fork 的中文 using-superpowers SKILL.md。 关联 #19(v6 同步追踪) --- hooks/session-start | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hooks/session-start b/hooks/session-start index 2460429..93a6bc2 100755 --- a/hooks/session-start +++ b/hooks/session-start @@ -7,13 +7,6 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -# Check if legacy skills directory exists and build warning -warning_message="" -legacy_skills_dir="${HOME}/.config/superpowers/skills" -if [ -d "$legacy_skills_dir" ]; then - warning_message="\n\nIN 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" -fi - # Read using-superpowers content using_superpowers_content=$(cat "${PLUGIN_ROOT}/skills/using-superpowers/SKILL.md" 2>&1 || echo "Error reading using-superpowers skill") @@ -31,8 +24,7 @@ escape_for_json() { } using_superpowers_escaped=$(escape_for_json "$using_superpowers_content") -warning_escaped=$(escape_for_json "$warning_message") -session_context="\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" +session_context="\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" # Output context injection as JSON. # Cursor hooks expect additional_context (snake_case). @@ -45,13 +37,13 @@ session_context="\nYou have superpowers.\n\n**Below is the # 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" + 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" + 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" + printf '{\n "additionalContext": "%s"\n}\n' "$session_context" | cat fi exit 0