feat(hooks): implement thin shim pattern (GH#615)

Replace full shell script hooks with thin shims that delegate to
'bd hooks run <hook-name>'. This eliminates hook version drift -
upgrading bd automatically updates hook behavior.

Changes:
- Add 'bd hooks run' subcommand with hook logic in Go
- Convert templates to minimal shims (~17 lines each)
- Shims use '# bd-shim v1' marker (format version, not bd version)
- Update version checking to recognize shim format
- Shims are never marked as "outdated"

Benefits:
- No more manual 'bd hooks install --force' after upgrades
- Hook logic always matches installed bd version
- Follows pattern used by husky, pre-commit, lefthook

Migration: Run 'bd hooks install --force' one final time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-20 02:38:12 -08:00
parent b4bc682d93
commit 3050fd2ef8
6 changed files with 358 additions and 314 deletions

View File

@@ -267,8 +267,12 @@ func TestHooksCheckGitHooks(t *testing.T) {
if !status.Installed {
t.Errorf("Hook %s should be installed", status.Name)
}
if status.Version != Version {
t.Errorf("Hook %s version mismatch: got %s, want %s", status.Name, status.Version, Version)
// Thin shims use version format "v1" (shim format version, not bd version)
if !status.IsShim {
t.Errorf("Hook %s should be a thin shim", status.Name)
}
if status.Version != "v1" {
t.Errorf("Hook %s shim version mismatch: got %s, want v1", status.Name, status.Version)
}
if status.Outdated {
t.Errorf("Hook %s should not be outdated", status.Name)