fix(hooks): match superpowers pattern exactly
- Add matcher: startup|clear|compact to SessionStart hook - Inject only engineering-principles as foundational skill (19KB) - Strip emoji, use plain text everywhere - Remove 55KB of verbosity, keep focused primer
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"SessionStart": [{
|
"SessionStart": [{
|
||||||
|
"matcher": "startup|clear|compact",
|
||||||
"hooks": [{
|
"hooks": [{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/detect-project.sh\"",
|
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/detect-project.sh\"",
|
||||||
|
|||||||
@@ -10,24 +10,24 @@ EXT="${FILE_PATH##*.}"
|
|||||||
|
|
||||||
case "$EXT" in
|
case "$EXT" in
|
||||||
ts|tsx)
|
ts|tsx)
|
||||||
echo "📐 [hub-guide] TypeScript file — apply typescript skill rules (strict types, no-any, proper generics)"
|
echo "[hub-guide] TypeScript file — apply typescript skill rules (strict types, no-any, proper generics)"
|
||||||
;;
|
;;
|
||||||
py)
|
py)
|
||||||
echo "📐 [hub-guide] Python file — apply python skill rules (type hints, PEP 8, no wildcard imports)"
|
echo "[hub-guide] Python file — apply python skill rules (type hints, PEP 8, no wildcard imports)"
|
||||||
;;
|
;;
|
||||||
rs)
|
rs)
|
||||||
echo "📐 [hub-guide] Rust file — apply rust skill rules (ownership, error handling, clippy clean)"
|
echo "[hub-guide] Rust file — apply rust skill rules (ownership, error handling, clippy clean)"
|
||||||
;;
|
;;
|
||||||
go)
|
go)
|
||||||
echo "📐 [hub-guide] Go file — apply go skill rules (idiomatic Go, interfaces, error handling)"
|
echo "[hub-guide] Go file — apply go skill rules (idiomatic Go, interfaces, error handling)"
|
||||||
;;
|
;;
|
||||||
js|jsx)
|
js|jsx)
|
||||||
echo "📐 [hub-guide] JavaScript file — apply typescript skill rules (ESM, modern JS)"
|
echo "[hub-guide] JavaScript file — apply typescript skill rules (ESM, modern JS)"
|
||||||
;;
|
;;
|
||||||
dockerfile|Dockerfile)
|
dockerfile|Dockerfile)
|
||||||
echo "📐 [hub-guide] Dockerfile — apply docker skill rules (multi-stage, minimal layers, no root)"
|
echo "[hub-guide] Dockerfile — apply docker skill rules (multi-stage, minimal layers, no root)"
|
||||||
;;
|
;;
|
||||||
yml|yaml)
|
yml|yaml)
|
||||||
echo "📐 [hub-guide] YAML file — check ci-cd and docker skill rules"
|
echo "[hub-guide] YAML file — check ci-cd and docker skill rules"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# hub-guide: inject best-practice skill content at session start
|
# hub-guide: detect project and prime skills at session start
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
@@ -41,7 +41,7 @@ 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 context and output via Python for reliable JSON ---
|
# --- build minimal context injection via Python ---
|
||||||
python3 << PYEOF
|
python3 << PYEOF
|
||||||
import json, os, sys
|
import json, os, sys
|
||||||
|
|
||||||
@@ -50,56 +50,41 @@ mandatory = """${MANDATORY}"""
|
|||||||
skill_names = """${SKILL_NAMES}"""
|
skill_names = """${SKILL_NAMES}"""
|
||||||
plugin_root = """${PLUGIN_ROOT}"""
|
plugin_root = """${PLUGIN_ROOT}"""
|
||||||
|
|
||||||
def read_skill(name):
|
# Read just the foundational skill (engineering-principles) as the primer
|
||||||
path = os.path.join(plugin_root, "skills", name, "SKILL.md")
|
foundational_skill = ""
|
||||||
try:
|
f_path = os.path.join(plugin_root, "skills", "engineering-principles", "SKILL.md")
|
||||||
with open(path) as f:
|
try:
|
||||||
return f.read()
|
with open(f_path) as f:
|
||||||
except:
|
foundational_skill = f.read()
|
||||||
return ""
|
except:
|
||||||
|
foundational_skill = "(engineering-principles skill not found)"
|
||||||
|
|
||||||
# Build summary
|
context = f"""<EXTREMELY_IMPORTANT>
|
||||||
summary = f"[hub-guide] detected: {project_dir}\n[hub-guide] mandatory: {mandatory}"
|
You have the hub-guide best-practice skills loaded.
|
||||||
if skill_names:
|
|
||||||
summary += f"\n[hub-guide] active: {skill_names}"
|
|
||||||
summary += "\n[hub-guide] When in doubt — ask instead of assuming."
|
|
||||||
summary += "\n[hub-guide] Never assume — show evidence for everything."
|
|
||||||
summary += "\n[hub-guide] All skills work regardless of your spoken language."
|
|
||||||
|
|
||||||
# Build skill content
|
=== MANDATORY (always active) ===
|
||||||
content_parts = []
|
{mandatory}
|
||||||
content_parts.append("<EXTREMELY_IMPORTANT>")
|
|
||||||
content_parts.append("You have the following hub-guide skills loaded and active. They apply to every code decision, review, and architecture discussion in this session — regardless of what language the user speaks.")
|
|
||||||
|
|
||||||
for skill in mandatory.split():
|
=== FOUNDATIONAL ===
|
||||||
c = read_skill(skill.strip())
|
{foundational_skill}
|
||||||
content_parts.append(f"\n=== hub-guide:{skill} ===\n{c}")
|
|
||||||
|
|
||||||
if skill_names:
|
=== PROJECT-SPECIFIC ===
|
||||||
content_parts.append(f"\n=== hub-guide:detected ===\nThe following skills are relevant to this project. If their topics come up, use the Skill tool to load them: {skill_names}")
|
{skill_names if skill_names else "(none detected)"}
|
||||||
|
|
||||||
content_parts.append("\nIMPORTANT: Never assume or guess. Always find evidence in the codebase, documentation, or by asking the user. Show your sources.\n</EXTREMELY_IMPORTANT>")
|
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>"""
|
||||||
|
|
||||||
skill_content = "\n".join(content_parts)
|
|
||||||
full_context = f"{summary}\n\n{skill_content}"
|
|
||||||
|
|
||||||
# Output
|
|
||||||
if os.environ.get("CLAUDE_PLUGIN_ROOT") and not os.environ.get("COPILOT_CLI"):
|
if os.environ.get("CLAUDE_PLUGIN_ROOT") and not os.environ.get("COPILOT_CLI"):
|
||||||
output = {
|
output = {
|
||||||
"hookSpecificOutput": {
|
"hookSpecificOutput": {
|
||||||
"hookEventName": "SessionStart",
|
"hookEventName": "SessionStart",
|
||||||
"additionalContext": full_context
|
"additionalContext": context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
json.dump(output, sys.stdout, ensure_ascii=False)
|
json.dump(output, sys.stdout, ensure_ascii=False)
|
||||||
print()
|
print()
|
||||||
else:
|
else:
|
||||||
print(f"[hub-guide] detected: {project_dir}")
|
print("hub-guide skills: " + ", ".join([m for m in mandatory.split()] + ([skill_names] if skill_names else [])))
|
||||||
print(f"[hub-guide] mandatory: {mandatory}")
|
|
||||||
if skill_names:
|
|
||||||
print(f"[hub-guide] active: {skill_names}")
|
|
||||||
print("[hub-guide] When in doubt — ask instead of assuming.")
|
|
||||||
print()
|
|
||||||
print(skill_content)
|
|
||||||
PYEOF
|
PYEOF
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user