10 hooks get 21-line guard block: env-var short-circuit, 4 profiles (full/advisory-off/minimal/off), per-hook disable. Safety-critical preserved in 'minimal': no-hand-edit-agents, assemble-validate, git-pre-commit-genesis. Advisory off list: recurrence-suggest, citation-verify, error-spike-detector, milestone-commit-hook. skills/hooks-control/SKILL.md — click-only toggle emitting shell export commands. README +27 LOC 'Runtime hook controls' section with examples.
67 lines
2.1 KiB
Bash
Executable file
67 lines
2.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# PostToolUse(Edit|Write) — auto-regenerate agent .md files.
|
|
#
|
|
# Trigger logic:
|
|
# - manifest edited (_manifests/<name>.toml) → rebuild that one agent
|
|
# - block edited (_blocks/<name>.md) → rebuild ALL agents
|
|
# - otherwise → no-op
|
|
#
|
|
# Stdin: JSON with tool_input.file_path
|
|
# Exit 0 always (non-blocking advisory)
|
|
|
|
# Silent fall-through if jq is absent; otherwise `set -eu` would abort and
|
|
# Claude Code would refuse the tool call system-wide.
|
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
|
|
# --- RUNTIME CONTROLS (v0.14.2) ---
|
|
_hook_name="$(basename "$0" .sh)"
|
|
case "${KEI_DISABLED_HOOKS:-}" in
|
|
*"$_hook_name"*|*all*) exit 0 ;;
|
|
esac
|
|
case "${KEI_HOOK_PROFILE:-full}" in
|
|
off) exit 0 ;;
|
|
minimal)
|
|
case "$_hook_name" in
|
|
no-github-push|genesis-leak-guard|no-hand-edit-agents|secrets-guard|assemble-validate|git-pre-commit-genesis) ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
;;
|
|
advisory-off)
|
|
case "$_hook_name" in
|
|
recurrence-suggest|citation-verify|error-spike-detector|milestone-commit-hook) exit 0 ;;
|
|
esac
|
|
;;
|
|
full|*) ;;
|
|
esac
|
|
# --- end runtime controls ---
|
|
|
|
set -eu
|
|
|
|
ASSEMBLER="$HOME/.claude/agents/_assembler/target/release/assemble"
|
|
[ -x "$ASSEMBLER" ] || exit 0
|
|
|
|
FILE=$(jq -r '.tool_input.file_path // empty')
|
|
[ -n "$FILE" ] || exit 0
|
|
|
|
case "$FILE" in
|
|
*/agents/_manifests/*.toml)
|
|
# Single-manifest rebuild
|
|
"$ASSEMBLER" --in-place "$FILE" 2>&1 | sed 's/^/[assemble-agents] /'
|
|
;;
|
|
*/agents/_blocks/*.md)
|
|
# Block changed → rebuild everything (block is shared).
|
|
# Always surface FAIL/ERROR lines; truncate only the OK tail.
|
|
echo "[assemble-agents] block changed, rebuilding all agents..."
|
|
OUTPUT=$("$ASSEMBLER" --in-place 2>&1 || true)
|
|
FAILS=$(printf '%s\n' "$OUTPUT" | grep -E '^(FAIL|ERROR)' || true)
|
|
if [ -n "$FAILS" ]; then
|
|
printf '%s\n' "$FAILS" | sed 's/^/[assemble-agents] /'
|
|
fi
|
|
printf '%s\n' "$OUTPUT" | sed 's/^/[assemble-agents] /' | head -40
|
|
;;
|
|
*)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
exit 0
|