#!/usr/bin/env sh
# Pre-push — fast, diff-scoped gates against origin/main (see
# delivery.quality.gateScoping in .agentrc.json). Does NOT run full-repo
# lint, docs:check, or the full test suite.
#
# Before opening a PR or when you want CI-parity confidence locally, run:
#   npm run verify
# That runs lint (biome + docs:check) → npm test → unified check-baselines.
# CI (.github/workflows/ci.yml) remains the authoritative full gate on every PR.
#
# Optional: PREPUSH_AUDIT=1 re-enables npm audit (CI still audits on PR/push).

node .agents/scripts/quality-preview.js --changed-since origin/main
if [ "${PREPUSH_AUDIT:-0}" = "1" ]; then
  npm audit --audit-level=high
fi
node .agents/scripts/coverage-capture.js --skip-when-no-crap-files --ref origin/main
npm run crap:check
