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:
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
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"
|
MANDATORY="engineering-principles clean-code clean-architecture testing error-handling security git-workflow api-design"
|
||||||
SKILL_NAMES="${SKILL_NAMES#, }"
|
SKILL_NAMES="${SKILL_NAMES#, }"
|
||||||
|
|
||||||
# --- build minimal context injection via Python ---
|
# --- output: plain text only, no emoji, no JSON ---
|
||||||
python3 << PYEOF
|
echo "[hub-guide] detected: ${PROJECT_DIR}"
|
||||||
import json, os, sys
|
echo "[hub-guide] mandatory: ${MANDATORY}"
|
||||||
|
if [ -n "$SKILL_NAMES" ]; then
|
||||||
project_dir = """${PROJECT_DIR}"""
|
echo "[hub-guide] active: ${SKILL_NAMES}"
|
||||||
mandatory = """${MANDATORY}"""
|
fi
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user