# Create virtual environment and install deps (uv.lock) on first use
if [ ! -d .venv ]; then
  uv venv && uv sync --group dev
fi

source .venv/bin/activate

# Pre-commit is a dev dependency but does not register Git hooks by itself; install once per clone.
if git rev-parse --git-dir >/dev/null 2>&1; then
  _hook="$(git rev-parse --git-path hooks/pre-commit 2>/dev/null)" || true
  if [ -n "${_hook}" ] && [ ! -f "${_hook}" ]; then
    uv run pre-commit install
  fi
fi
