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.
This commit is contained in:
asepharyana
2026-07-26 11:57:43 +07:00
parent a237759788
commit 6aaa593181
+7 -48
View File
@@ -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"""<EXTREMELY_IMPORTANT>
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.
</EXTREMELY_IMPORTANT>"""
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