Files
boshu2__agentops/hooks/hooks.json
T
Boden Fuller 7f9a6bfb38 feat(hooks): enforce lead-only worker git guard as PreToolUse hook
Adds hooks/lead-only-worker-git-guard.sh: mechanical PreToolUse guard
that blocks destructive git commands (commit, push, reset, rebase,
merge, cherry-pick, branch -D, checkout -B, worktree remove) when
running inside a swarm worker context.

Worker detection (in order): AGENTOPS_SWARM_ROLE=worker,
AGENTOPS_ROLE=worker (legacy), CLAUDE_AGENT_NAME=worker-*,
.agents/swarm-role file, CWD under /.claude/worktrees/. Allows all
non-destructive git (status, diff, log, show, blame, fetch) and safe
variants (branch -d, checkout -b). Allows everything in lead context.

Respects AGENTOPS_HOOKS_DISABLED=1 (global kill) and
AGENTOPS_LEAD_ONLY_GUARD_DISABLED=1 (local disable). Catches chained
commands (foo && git commit) via leading-token regex.

Registered under PreToolUse / Bash matcher in hooks/hooks.json.
Synced to cli/embedded/hooks/ via make sync-hooks. Adds 30-assertion
test file covering block paths, allow paths, kill switches, legacy
signals, and native-team worker naming.

Consumes ag-yhr 'Enforce lead-only worker git guard before spawn'.
Mechanical enforcement of the swarm skill's lead-only commit policy
which was previously informational only.
2026-04-15 16:48:09 -04:00

247 lines
5.7 KiB
JSON

{
"$schema": "../schemas/hooks-manifest.v1.schema.json",
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh"
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/ao-inject.sh",
"timeout": 10
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-end-maintenance.sh",
"timeout": 35
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/compile-session-defrag.sh",
"timeout": 20
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/ao-flywheel-close.sh",
"timeout": 15
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/factory-router.sh",
"timeout": 8
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/new-user-welcome.sh",
"timeout": 3
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/prompt-nudge.sh",
"timeout": 5
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/intent-echo.sh",
"timeout": 3
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/quality-signals.sh",
"timeout": 3
}
]
}
],
"PreToolUse": [
{
"matcher": "Skill",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-mortem-gate.sh",
"timeout": 30
}
]
},
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/go-test-precommit.sh",
"timeout": 60
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/commit-review-gate.sh",
"timeout": 10
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/git-worker-guard.sh",
"timeout": 5
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/lead-only-worker-git-guard.sh",
"timeout": 5
}
]
},
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/edit-knowledge-surface.sh",
"timeout": 3
}
]
},
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/codex-parity-warn.sh",
"timeout": 3
}
]
},
{
"matcher": "Read",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/holdout-isolation-gate.sh",
"timeout": 5
}
]
},
{
"matcher": "Glob",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/holdout-isolation-gate.sh",
"timeout": 5
}
]
},
{
"matcher": "Grep",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/holdout-isolation-gate.sh",
"timeout": 5
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/holdout-isolation-gate.sh",
"timeout": 5
}
]
}
],
"PostToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/write-time-quality.sh",
"timeout": 5
}
]
},
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/write-time-quality.sh",
"timeout": 5
}
]
},
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/go-complexity-precommit.sh",
"timeout": 10
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/go-vet-post-edit.sh",
"timeout": 15
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/research-loop-detector.sh",
"timeout": 5
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/context-monitor.sh",
"timeout": 2
}
]
}
],
"TaskCompleted": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/task-validation-gate.sh",
"timeout": 60
}
]
}
]
}
}