# Lefthook Git Hooks Configuration
# TDD Enforcement for Forge Workflow
#
# To skip hooks in emergencies:
#   git commit --no-verify  (skip pre-commit)
#   LEFTHOOK=0 git push     (skip pre-push)

commit-msg:
  commands:
    commitlint:
      run: node scripts/commitlint.js {1}
      tags: commitlint

pre-commit:
  commands:
    tdd-check:
      run: node .forge/hooks/check-tdd.js
      stage_fixed: false
      tags: tdd
      glob: "*.{js,ts,jsx,tsx,py,go,java,rb}"

pre-push:
  commands:
    # 1. Block direct push to main/master (dual-layer protection)
    # Uses Node.js for cross-platform compatibility (Windows, macOS, Linux)
    branch-protection:
      run: node scripts/branch-protection.js
      tags: protection
      skip:
        - run: node scripts/check-forge-token.js

    # 2. ESLint check (strict mode: blocks on errors and warnings)
    # Uses Node.js script for cross-platform compatibility
    lint:
      run: node scripts/lint.js
      tags: lint
      skip:
        - run: node scripts/check-forge-token.js

    # 3. Test suite (cross-platform Node.js script detects package manager)
    tests:
      run: node scripts/test.js
      tags: tests
      skip:
        - run: node scripts/check-forge-token.js

    # 4. Team sync — push Beads status to GitHub (non-blocking)
    team-sync:
      run: bash scripts/forge-team/lib/hooks.sh sync --quiet || true
      tags: team
