clawdie-ai/hooks/pre-commit
Operator & Claude 8bafe79e6b docs(multitenant): guard commit attribution via pre-commit hook
Confirms the Agent Identity fix zAI landed in 8138173: per-clone
`user.name` is sufficient for distinguishing zAI and Claude commits on
shared-Linux setups, provided each agent resets `user.name` at session
start. The one gotcha is that `.git/config` persists whichever name was
set last, so a forgotten reset silently misattributes.

Adds a dormant hooks/pre-commit guard that rejects any commit whose
`user.name` does not start with `Operator & ` (or the legacy
`Clawdie AI`). The hook only activates after `npm run install-hooks`
sets `core.hooksPath=hooks`, matching the existing opt-in pattern.

This commit itself is authored as `Operator & Claude`, proving the
mechanism end-to-end.
2026-04-24 19:59:21 +02:00

22 lines
875 B
Bash
Executable file

#!/bin/sh
# Attribution guard: fail fast if user.name was not set for this session.
# Each agent must run `git config user.name "Operator & <agent>"` before
# committing — see docs/internal/MULTITENANT-HANDOFF.md § Agent Identity.
AUTHOR_NAME=$(git config user.name || true)
case "$AUTHOR_NAME" in
"Operator & "*|"Clawdie AI") ;;
*)
echo "pre-commit: git user.name is '$AUTHOR_NAME' — expected 'Operator & <agent>'." >&2
echo " Run: git config user.name \"Operator & <agent>\"" >&2
exit 1
;;
esac
# Auto-update README Current Release version from package.json
VERSION=$(node -e "process.stdout.write(require('./package.json').version)")
if [ -z "$VERSION" ]; then exit 0; fi
# Replace the backtick version line under ## Current Release
sed -i '' "s/^\`v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^\`]*\`$/\`v${VERSION}\`/" README.md
git add README.md