fix(hooks): restore hooks.json in plugin dir, remove from settings.local
hooks.json in ~/.claude/skills/hub-guide/hooks/hooks.json IS auto-detected by Claude Code for skills-dir plugins. Remove from settings.local.json to avoid duplication. - hooks.json restored with hooks wrapper + proper matchers - install.sh simplified, no settings.json manipulation
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"SessionStart": [{
|
||||||
|
"matcher": "startup|resume|compact",
|
||||||
|
"hooks": [{
|
||||||
|
"type": "command",
|
||||||
|
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/detect-project.sh\"",
|
||||||
|
"shell": "bash",
|
||||||
|
"timeout": 10,
|
||||||
|
"async": false
|
||||||
|
}]
|
||||||
|
}],
|
||||||
|
"PreToolUse": [{
|
||||||
|
"matcher": "Write|Edit",
|
||||||
|
"hooks": [{
|
||||||
|
"type": "command",
|
||||||
|
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/detect-file-type.sh\"",
|
||||||
|
"shell": "bash",
|
||||||
|
"timeout": 10
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-65
@@ -1,23 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# install.sh — hub-guide installer for Claude Code
|
# install.sh — hub-guide installer for Claude Code
|
||||||
# Installs skills to ~/.claude/skills/ + configures hooks in settings.local.json
|
# Installs the entire hub-guide directory as one unit into ~/.claude/skills/.
|
||||||
|
# Skills auto-discover, hooks auto-load from hooks/hooks.json.
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./install.sh # Copy + hooks
|
# ./install.sh # Copy hub-guide to ~/.claude/skills/
|
||||||
# ./install.sh --link # Symlink (edits live) + hooks
|
# ./install.sh --link # Symlink (edits live)
|
||||||
# ./install.sh --no-hooks # Skills only, no hook setup
|
# Requires: Claude Code
|
||||||
# Requires: Claude Code, python3
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
SKILLS_DIR="${HOME}/.claude/skills"
|
SKILLS_DIR="${HOME}/.claude/skills"
|
||||||
LINK_MODE=false
|
LINK_MODE=false
|
||||||
NO_HOOKS=false
|
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--link) LINK_MODE=true ;;
|
--link) LINK_MODE=true ;;
|
||||||
--no-hooks) NO_HOOKS=true ;;
|
|
||||||
--*) echo "Unknown: $arg"; exit 1 ;;
|
--*) echo "Unknown: $arg"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -26,7 +24,6 @@ echo "hub-guide installer"
|
|||||||
echo " target: ${SKILLS_DIR}/hub-guide/"
|
echo " target: ${SKILLS_DIR}/hub-guide/"
|
||||||
echo " mode: $([ "$LINK_MODE" = true ] && echo 'symlink' || echo 'copy')"
|
echo " mode: $([ "$LINK_MODE" = true ] && echo 'symlink' || echo 'copy')"
|
||||||
|
|
||||||
# --- install skills ---
|
|
||||||
mkdir -p "$SKILLS_DIR"
|
mkdir -p "$SKILLS_DIR"
|
||||||
DST="${SKILLS_DIR}/hub-guide"
|
DST="${SKILLS_DIR}/hub-guide"
|
||||||
|
|
||||||
@@ -38,64 +35,10 @@ else
|
|||||||
cp -r "$SCRIPT_DIR" "$DST"
|
cp -r "$SCRIPT_DIR" "$DST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " skills installed to ${DST}/"
|
echo " installed to ${DST}/"
|
||||||
if [ "$LINK_MODE" = true ]; then
|
if [ "$LINK_MODE" = true ]; then
|
||||||
echo " (symlink)"
|
echo " (symlink — edits in this repo are live)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- configure hooks in settings.local.json ---
|
|
||||||
if [ "$NO_HOOKS" = false ]; then
|
|
||||||
HOOKS_DIR="${DST}/hooks"
|
|
||||||
SETTINGS_FILE="${HOME}/.claude/settings.local.json"
|
|
||||||
|
|
||||||
python3 << PYEOF
|
|
||||||
import json, os
|
|
||||||
|
|
||||||
dst = "${DST}"
|
|
||||||
settings_file = os.path.expanduser("${SETTINGS_FILE}")
|
|
||||||
|
|
||||||
# Read existing settings or create empty
|
|
||||||
settings = {}
|
|
||||||
if os.path.exists(settings_file):
|
|
||||||
with open(settings_file) as f:
|
|
||||||
settings = json.load(f)
|
|
||||||
|
|
||||||
# Ensure hooks key exists
|
|
||||||
if "hooks" not in settings:
|
|
||||||
settings["hooks"] = {}
|
|
||||||
|
|
||||||
hooks_config = {
|
|
||||||
"SessionStart": [{
|
|
||||||
"matcher": "startup|resume|compact",
|
|
||||||
"hooks": [{
|
|
||||||
"type": "command",
|
|
||||||
"command": "bash \"" + dst + "/hooks/scripts/detect-project.sh\"",
|
|
||||||
"timeout": 10,
|
|
||||||
"async": False
|
|
||||||
}]
|
|
||||||
}],
|
|
||||||
"PreToolUse": [{
|
|
||||||
"matcher": "Write|Edit",
|
|
||||||
"hooks": [{
|
|
||||||
"type": "command",
|
|
||||||
"command": "bash \"" + dst + "/hooks/scripts/detect-file-type.sh\"",
|
|
||||||
"timeout": 10
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Merge hooks into settings (update existing, don't overwrite unrelated hooks)
|
|
||||||
for event, handlers in hooks_config.items():
|
|
||||||
settings["hooks"][event] = handlers
|
|
||||||
|
|
||||||
os.makedirs(os.path.dirname(settings_file), exist_ok=True)
|
|
||||||
with open(settings_file, 'w') as f:
|
|
||||||
json.dump(settings, f, indent=2)
|
|
||||||
|
|
||||||
print(" hooks configured in " + settings_file)
|
|
||||||
PYEOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done. Restart Claude Code or run /reload."
|
echo "Done. Restart Claude Code or run /reload."
|
||||||
echo "Skills auto-trigger when you work."
|
echo "Skills auto-trigger. Hooks auto-load from hooks/hooks.json."
|
||||||
|
|||||||
Reference in New Issue
Block a user