Skip to content

Consolidate hooks: language-universal support, 14 → 9 hooks - #16

Merged
5uck1ess merged 3 commits into
mainfrom
feat/universal-hooks-consolidation
Apr 5, 2026
Merged

Consolidate hooks: language-universal support, 14 → 9 hooks#16
5uck1ess merged 3 commits into
mainfrom
feat/universal-hooks-consolidation

Conversation

@5uck1ess

@5uck1ess 5uck1ess commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • lang-review.sh — replaces go-review.sh, go-nil-return.sh, and shell-compat.sh with a single language-aware hook. Detects language from file extension and runs the appropriate quality checks for Go, TypeScript, Rust, Python, and Shell.
  • stop-gate.sh — replaces dirty-bit.sh, go-vet-stop.sh, and the old stop-gate.sh with a consolidated quality gate. Handles merge conflict detection, cross-domain test evidence, and language-specific vet/lint (go vet, clippy, tsc, ruff).
  • hooks.json — 14 hook entries → 9. Per-edit shell processes reduced from 7 to 4.
  • Old hooks (go-review.sh, go-nil-return.sh, go-vet-stop.sh, dirty-bit.sh, shell-compat.sh) remain in the repo for reference but are no longer registered.

Test plan

  • All hook scripts pass bash -n syntax validation
  • hooks.json is valid JSON
  • Full Go test suite passes (5 packages)
  • Manual: edit a .go file → lang-review fires with Go checks
  • Manual: edit a .ts file → lang-review fires with TS checks
  • Manual: edit a .sh file → lang-review catches grep -P
  • Manual: stop with Go changes → stop-gate runs go vet

5uck1ess added 3 commits April 4, 2026 19:56
lang-review.sh (replaces go-review.sh + go-nil-return.sh + shell-compat.sh):
- Detects language from file extension, runs appropriate checks
- Go: error-path access, map races, nil-error returns, filepath traversal
- TypeScript: empty catch blocks, any-type, unhandled promises
- Rust: unwrap in non-test, let _ = discard, unsafe blocks
- Python: bare except, pass-in-except, mutable default args
- Shell: macOS portability (grep -P, sed -i, readlink -f, timeout, etc.)

stop-gate.sh (replaces dirty-bit.sh + go-vet-stop.sh + old stop-gate.sh):
- Phase 1: merge conflict detection
- Phase 2: cross-domain test evidence (dirty-bit logic)
- Phase 3: language-specific vet/lint (go vet, clippy, tsc, ruff)

hooks.json: 14 entries → 9, per-edit processes 7 → 4
README: updated hook tables, repo structure, roadmap items checked off
lang-review.sh:
- Rewrite awk error-path scanner: proper brace depth tracking,
  matched variable instead of broken END{exit 1} (Claude + Codex)
- Replace \s with [[:space:]] in awk regexes for POSIX compat (Codex)

stop-gate.sh:
- Fix GO_PKGS: strip module-relative prefix, add ./ prefix for
  go test resolution (Claude critical)
- Skip cross-domain check when transcript is empty — prevents
  false blocks when hook input lacks transcript field (Claude)
- Gate Go vet/test behind `command -v go` check (Codex)
- Add || true to TSC grep to prevent set -e abort (Codex)
- Non-race test failures no longer silently approved (Codex)
Both hooks now guarantee JSON output even on unexpected failures:

lang-review.sh:
- Remove set -e, add trap 'exit 0' ERR — hook exits cleanly on crash
- Guard jq calls with 2>/dev/null || true for malformed input
- Fix awk exit code masking: use && true || false pattern instead
  of $? check that set -e would intercept

stop-gate.sh:
- Remove set -e, add trap that emits {"decision":"approve"} on ERR
- Guard jq/cat calls for empty/malformed input
- Stop hooks MUST return JSON — a crash with no output violates
  the hook contract and hangs the harness

Found by silent-failure-hunter agent.
@5uck1ess
5uck1ess merged commit c001bf3 into main Apr 5, 2026
1 check passed
@5uck1ess
5uck1ess deleted the feat/universal-hooks-consolidation branch April 5, 2026 02:12
5uck1ess added a commit that referenced this pull request Apr 5, 2026
…te.sh

Removed: dirty-bit.sh, go-nil-return.sh, go-review.sh, go-vet-stop.sh,
shell-compat.sh. All were consolidated in PR #16 but the files were kept.
None are registered in hooks.json. Updated README architecture diagram
to reference current hook names.
@5uck1ess 5uck1ess mentioned this pull request Apr 5, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant