# Git hooks (lefthook). Keep these local checkpoints fast; CI owns the full
# repository-wide gate matrix.
# Install: `node scripts/install-lefthook.mjs` (runs automatically via postinstall).

pre-commit:
  jobs:
    - name: translation pairing (staged records)
      glob: '*.i18n.yaml'
      exclude:
        - '.agents/notes/archived/**'
      run: node_modules/.bin/tsx scripts/verify-translation-pairing.ts --cached {staged_files}

    - name: archived agent notes
      glob: '.agents/notes/archived/**'
      run: node_modules/.bin/tsx scripts/verify-archived-agent-notes.ts

    - name: lint (staged)
      glob: '*.{ts,tsx,mts,cts,mjs}'
      exclude:
        - 'vendor/*/src/**'
      run: node_modules/.bin/tsx scripts/run-oxlint.ts --config .oxlintrc.staged.json --fix --no-error-on-unmatched-pattern {staged_files}
      stage_fixed: true

    # Regenerate rather than reject: a dependency edit that forgot the notices
    # would otherwise fail the test lane long after the commit. The glob matches
    # every input the generator reads, including the generator itself and the
    # build-time pin source. Deleting a manifest cannot trigger this job —
    # lefthook only inspects files present on disk — so that one case still
    # falls through to the freshness assertion in the test lane.
    - name: third-party notices (staged)
      glob: '{package.json,*/package.json,*/*/package.json,*/*/*/package.json,*/*/*/*/package.json,pnpm-workspace.yaml,*/*/pnpm-workspace.yaml,pnpm-lock.yaml,vendor/README.md,python/*/pyproject.toml,scripts/gen-third-party-notices.ts,scripts/build-exe-for-python-sdk.ts}'
      run: node_modules/.bin/tsx scripts/gen-third-party-notices.ts && git add THIRD_PARTY_NOTICES.md

    - name: whitespace (staged)
      run: git diff --cached --check

    - name: vendor manifest guard
      run: scripts/check-vendor-manifest.sh

pre-merge-commit:
  jobs:
    - name: translation pairing (staged records)
      glob: '*.i18n.yaml'
      exclude:
        - '.agents/notes/archived/**'
      run: node_modules/.bin/tsx scripts/verify-translation-pairing.ts --cached {staged_files}

    - name: archived agent notes
      glob: '.agents/notes/archived/**'
      run: node_modules/.bin/tsx scripts/verify-archived-agent-notes.ts

pre-push:
  jobs:
    - name: typecheck
      run: pnpm run typecheck
