#!/usr/bin/env sh
set -eu

if ! command -v npx >/dev/null 2>&1; then
  echo "npx not found in PATH — install the project's Node/npm toolchain before committing." >&2
  exit 1
fi

# Cheap, deterministic local gates (re-enabled). Slower checks (i18n drift,
# openapi coverage/security-tiers, env-doc sync) run in CI to keep commits fast.
sh scripts/check/check-git-identity.sh
# The stash is shared by every worktree. Never let a local hook stash another
# session's changes, and never download a missing tool during a commit.
npx --no-install lint-staged --no-stash
node scripts/quality/gate-manifest.mjs
node scripts/check/check-docs-sync.mjs
npm run check:any-budget:t11
node scripts/check/check-tracked-artifacts.mjs
# vendored kit must stay byte-identical to the pinned upstream commit; skips with a warning where the private clone is absent
npm run --silent check:ui-kit-snapshot
