PreToolUse hooks route through kei-capability check when orchestrator registers a capability via KEI_CAPABILITY_NAME env var on agent spawn. hooks/agent-capability-check.sh (22 LOC): - Pass-through (exit 0) when KEI_CAPABILITY_NAME unset — no-op by default - Fail-open (exit 0) when kei-capability binary missing — kit convention - Sources _lib/gate.sh for KEI_DISABLED_HOOKS / KEI_HOOK_PROFILE respect - exec kei-capability check "$CAP_NAME" when active hooks/agent-capability-verify.sh (24 LOC): - Orchestrator-driven, NOT a Claude Code native hook - Carries env: AGENT_ID, TASK_TOML, WORKTREE_PATH, MAIN_REPO, RUN_MODE - exec kei-capability verify "$CAP_NAME" Registered in hooks/hooks.json + settings-snippet.json under both PreToolUse:Bash and PreToolUse:Edit|Write matchers. Internal NotApplicable returns exit 0 so non-matching tool calls cost nothing. install.sh unchanged — hooks/*.sh glob picks up both new files. tests/hook_wiring_integration.sh (64 LOC) — 3 contract assertions: (1) pass-through on unset KEI_CAPABILITY_NAME (2) deny+exit 2 on git-op pattern (3) allow+exit 0 on cargo-check pattern Multi-capability routing (for phase 5): KEI_CAPABILITY_NAME currently holds ONE name. When a role requires N capabilities, orchestrator will either iterate or kei-capability gains a compose subcommand. Design note left for phase 5. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
3 KiB
JSON
108 lines
3 KiB
JSON
{
|
|
"_comment": "Merge these entries into your ~/.claude/settings.json under the matching keys. If you already have PostToolUse/PreToolUse/Stop arrays, append the objects below to them instead of overwriting. install.sh --activate-hooks automates the merge and de-dupes by hooks[].command.",
|
|
"hooks": {
|
|
"PostToolUse": [
|
|
{
|
|
"matcher": "Write|Edit",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/assemble-agents.sh"
|
|
},
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/site-wysiwyd-check.sh",
|
|
"statusMessage": "site-wysiwyd drift check..."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": "Bash",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/milestone-commit-hook.sh",
|
|
"statusMessage": "milestone self-audit check (RULE 0.14)..."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": "*",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/error-spike-detector.sh",
|
|
"statusMessage": "error-spike rolling window (RULE 0.14)..."
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "Bash",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/assemble-validate.sh"
|
|
},
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/agent-capability-check.sh",
|
|
"statusMessage": "agent-capability-check (Agent Substrate v1, phase 4)..."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": "Edit|Write",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/no-hand-edit-agents.sh"
|
|
},
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/agent-capability-check.sh",
|
|
"statusMessage": "agent-capability-check (Agent Substrate v1, phase 4)..."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": "Read",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/tomd-preread.sh",
|
|
"statusMessage": "tomd pre-read auto-convert check..."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": "Agent",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/agent-fork-logger.sh",
|
|
"statusMessage": "agent-fork-logger (RULE 0.12)..."
|
|
},
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/orchestrator-dirty-check.sh",
|
|
"statusMessage": "orchestrator-dirty-check (RULE 0.13)..."
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"Stop": [
|
|
{
|
|
"matcher": "*",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "~/.claude/hooks/session-end-dump.sh",
|
|
"statusMessage": "session-end trace dump (RULE 0.14)..."
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|