Merge pull request 'fix(agents): chain AGENTS git hooks to global core.hooksPath' (#58) from fix-agents-hooks-chain-global into main
Generate documentation / build-docs (push) Successful in 35s

Reviewed-on: #58
This commit was merged in pull request #58.
This commit is contained in:
2026-06-18 02:45:12 +00:00
5 changed files with 41 additions and 12 deletions
+7 -3
View File
@@ -1148,9 +1148,13 @@ Add -i (interactive confirmation) to destructive commands:
every commit: MINOR (resetting PATCH) when the tracked directory set
changes, PATCH otherwise; MAJOR is manual-only. A prepare-commit-msg hook
appends "(vX.Y.Z)" to the commit subject. Downstream tooling can read
AGENTS/.version - a changed MINOR field signals a structure change. The
script and hooks are shipped from scripts/agents-tools/ and refreshed when
their version marker is stale.
AGENTS/.version - a changed MINOR field signals a structure change. Because
core.hooksPath is a single setting, the local override would otherwise
shadow your global hooks; after bumping the version, each shim chains
(execs) to the global/system core.hooksPath hook of the same name so global
pre-commit / prepare-commit-msg hooks (e.g. ggshield, Git LFS) still run.
The script and hooks are shipped from scripts/agents-tools/ and refreshed
when their version marker is stale.
agents-init
agents-init --agents
+5 -2
View File
@@ -36,8 +36,11 @@
# core.hooksPath: a pre-commit hook bumps AGENTS/.version on every commit
# (MINOR when the tracked directory set changes, PATCH otherwise; MAJOR is
# manual-only), and a prepare-commit-msg hook appends "(vX.Y.Z)" to the
# commit subject. The script/hooks are version-managed from
# scripts/agents-tools/ and refreshed when their marker is stale.
# commit subject. Each shim then chains (execs) to the global/system
# core.hooksPath hook of the same name, so this local override does not
# shadow global hooks (e.g. ggshield, Git LFS). The script/hooks are
# version-managed from scripts/agents-tools/ and refreshed when their marker
# is stale.
#
# With no flags, runs both --agents and --plugins setup. At the end of
# every invocation, commits any uncommitted changes in the AGENTS/ sub-repo
+14 -3
View File
@@ -1,7 +1,18 @@
#!/usr/bin/env bash
# agents-tools-version: 1
# Delegates to the repo's committed .agents-tools/version-bump. Guarded so a
# missing script or failed rev-parse never blocks the commit (always exit 0).
# agents-tools-version: 2
# Runs the committed .agents-tools/version-bump, then chains to the user's
# global/system git hook (core.hooksPath) so ggshield, LFS, etc. still run.
# agents-init's local core.hooksPath override would otherwise shadow them.
# Guarded so a missing script or failed rev-parse never blocks the commit;
# only the chained global hook can fail it.
root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
[ -x "$root/.agents-tools/version-bump" ] && "$root/.agents-tools/version-bump" precommit
# Chain to the global/system hook this local override is shadowing.
global_hooks="$(git config --global core.hooksPath 2>/dev/null)"
[ -z "$global_hooks" ] && global_hooks="$(git config --system core.hooksPath 2>/dev/null)"
if [ -n "$global_hooks" ]; then
global_hooks="${global_hooks/#\~/$HOME}" # git stores ~ verbatim
[ -x "$global_hooks/pre-commit" ] && exec "$global_hooks/pre-commit" "$@"
fi
exit 0
+14 -3
View File
@@ -1,7 +1,18 @@
#!/usr/bin/env bash
# agents-tools-version: 1
# Delegates to the repo's committed .agents-tools/version-bump. Guarded so a
# missing script or failed rev-parse never blocks the commit (always exit 0).
# agents-tools-version: 2
# Runs the committed .agents-tools/version-bump, then chains to the user's
# global/system git hook (core.hooksPath) so any global prepare-commit-msg
# still runs. agents-init's local core.hooksPath override would otherwise
# shadow it. Guarded so a missing script or failed rev-parse never blocks the
# commit; only the chained global hook can fail it.
root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
[ -x "$root/.agents-tools/version-bump" ] && "$root/.agents-tools/version-bump" prepmsg "$1"
# Chain to the global/system hook this local override is shadowing.
global_hooks="$(git config --global core.hooksPath 2>/dev/null)"
[ -z "$global_hooks" ] && global_hooks="$(git config --system core.hooksPath 2>/dev/null)"
if [ -n "$global_hooks" ]; then
global_hooks="${global_hooks/#\~/$HOME}" # git stores ~ verbatim
[ -x "$global_hooks/prepare-commit-msg" ] && exec "$global_hooks/prepare-commit-msg" "$@"
fi
exit 0
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# agents-tools-version: 1
# agents-tools-version: 2
# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
#