From 6aaa5931818e0103d50335bd58c0d79762409d2b Mon Sep 17 00:00:00 2001 From: asepharyana Date: Sun, 26 Jul 2026 11:57:43 +0700 Subject: [PATCH] fix(hooks): plain text output only, no JSON injection Skills-dir plugins might not process hookSpecificOutput JSON. Revert to simple plain text echo - no emoji, no JSON, no Python. Hook just prints detection results as clean text. --- hooks/scripts/detect-project.sh | 55 +++++---------------------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/hooks/scripts/detect-project.sh b/hooks/scripts/detect-project.sh index f6bd39e..bc31888 100755 --- a/hooks/scripts/detect-project.sh +++ b/hooks/scripts/detect-project.sh @@ -1,5 +1,5 @@ #!/bin/bash -# hub-guide: detect project and prime skills at session start +# hub-guide: detect project type and prime best-practice skills set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" @@ -41,50 +41,9 @@ fi MANDATORY="engineering-principles clean-code clean-architecture testing error-handling security git-workflow api-design" SKILL_NAMES="${SKILL_NAMES#, }" -# --- build minimal context injection via Python --- -python3 << PYEOF -import json, os, sys - -project_dir = """${PROJECT_DIR}""" -mandatory = """${MANDATORY}""" -skill_names = """${SKILL_NAMES}""" -plugin_root = """${PLUGIN_ROOT}""" - -# Read just the foundational skill (engineering-principles) as the primer -foundational_skill = "" -f_path = os.path.join(plugin_root, "skills", "engineering-principles", "SKILL.md") -try: - with open(f_path) as f: - foundational_skill = f.read() -except: - foundational_skill = "(engineering-principles skill not found)" - -context = f""" -You have the hub-guide best-practice skills loaded. - -=== MANDATORY (always active) === -{mandatory} - -=== FOUNDATIONAL === -{foundational_skill} - -=== PROJECT-SPECIFIC === -{skill_names if skill_names else "(none detected)"} - -Use the Skill tool for any other hub-guide skill when its topic comes up. -Never assume or guess. Always find evidence in the codebase or docs. -""" - -if os.environ.get("CLAUDE_PLUGIN_ROOT") and not os.environ.get("COPILOT_CLI"): - output = { - "hookSpecificOutput": { - "hookEventName": "SessionStart", - "additionalContext": context - } - } - json.dump(output, sys.stdout, ensure_ascii=False) - print() -else: - print("hub-guide skills: " + ", ".join([m for m in mandatory.split()] + ([skill_names] if skill_names else []))) -PYEOF -exit 0 +# --- output: plain text only, no emoji, no JSON --- +echo "[hub-guide] detected: ${PROJECT_DIR}" +echo "[hub-guide] mandatory: ${MANDATORY}" +if [ -n "$SKILL_NAMES" ]; then + echo "[hub-guide] active: ${SKILL_NAMES}" +fi