fix(agent hooks): wire hooks into real harness entry points and fix payload parsing

Claude Code never reads a standalone .claude/hooks.json, so the PostToolUse and
Stop pipeline is moved into .claude/settings.json and hooks.json is removed;
.cursor/hooks.json is rewritten in Cursor's version+afterFileEdit/stop schema;
.codex/hooks.json is already Codex-valid and stays. The shared scripts now
parse both the Cursor file_path and Claude/Codex tool_input.file_path stdin
shapes and normalize absolute paths, so the format, yarn-install, and
react-pattern-review hooks stop being silent no-ops. verify.sh blocks with
exit 2 plus a stderr reason, guards stop_hook_active, and skips clean trees;
react-pattern-review surfaces its reminder via hookSpecificOutput on
PostToolUse; sync-git-branches no longer misreports open PRs as merged. The
validator now checks that the three harness-specific entry points wire the
same hook scripts instead of requiring byte-identical hooks.json copies.
This commit is contained in:
Tommaso Casaburi
2026-07-03 13:58:36 +07:00
parent 0166f2f4e8
commit 1ac3e5883b
9 changed files with 190 additions and 123 deletions
+10 -46
View File
@@ -1,52 +1,16 @@
{
"version": 1,
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|apply_patch",
"hooks": [
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/format.sh\"",
"timeout": 10
},
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/yarn-install.sh\"",
"timeout": 120
},
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/react-pattern-review.sh\"",
"timeout": 10
}
]
}
"afterFileEdit": [
{ "command": "./.cursor/hooks/format.sh" },
{ "command": "./.cursor/hooks/yarn-install.sh" },
{ "command": "./.cursor/hooks/react-pattern-review.sh" }
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/sync-git-branches.sh\"",
"timeout": 60
},
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/react-pattern-review.sh\"",
"timeout": 10
},
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/code-quality-review-reminder.sh\"",
"timeout": 10
},
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.cursor/hooks/verify.sh\"",
"timeout": 60
}
]
}
"stop": [
{ "command": "./.cursor/hooks/sync-git-branches.sh" },
{ "command": "./.cursor/hooks/react-pattern-review.sh" },
{ "command": "./.cursor/hooks/code-quality-review-reminder.sh" },
{ "command": "./.cursor/hooks/verify.sh" }
]
}
}