fix(agents): chain AGENTS git hooks to global core.hooksPath #58
Reference in New Issue
Block a user
Delete Branch "fix-agents-hooks-chain-global"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
agents-initsets a localcore.hooksPath = .agents-tools/hooksin every AGENTS sub-repo to wire up the version-increment hooks. Since git honors only onecore.hooksPath, this silently shadowed the user's global hooks (~/.git/hooks— ggshield secret scanning + Git LFS auto-tracking), which never ran on commits in AGENTS repos.This makes each committed hook shim, after running
version-bump, chain (exec) to the global/systemcore.hooksPathhook of the same name. So in AGENTS repos the order is now: version increment → global hooks (ggshield, LFS, etc.).Changes
scripts/agents-tools/hooks/pre-commit— runsversion-bump precommit, then execs the global/systempre-commitif present.scripts/agents-tools/hooks/prepare-commit-msg— runsversion-bump prepmsg, then execs the global/systemprepare-commit-msgif present.scripts/agents-tools/version-bump— bumpedagents-tools-versionmarker1 → 2so existing AGENTS repos auto-refresh their shims on nextagents-init.functions/agents-init.fish+docs/fish-config.md— documented the chaining behavior.Design notes
git config --global core.hooksPath(falls back to--system); no hardcoded paths, so the committed shims stay portable. Repos/machines with no global hook simplyexit 0.execmeans the chained global hook's exit status becomes the commit gate — so ggshield can still block a commit.version-bumpremains non-blocking (guardedexit 0).AGENTS/.agents-tools/is generated/gitignored; the live copy was refreshed to v2 and verified.Manual Verification
agents-initand confirm it reportsUpdated AGENTS/.agents-tools/ (v1 → v2).AGENTS/.agents-tools/hooks/pre-commitandprepare-commit-msgnow carryagents-tools-version: 2.AGENTS/.versionstill bumps, (b) the commit subject still gets(vX.Y.Z)appended, and (c) the global ggshield scan output appears (Checking staged changes for secrets/PII...).core.hooksPath, confirm commits still succeed (shim exits 0, no error).