#!/usr/bin/env bash
# ArgosAI pre-commit hook.
#
# Runs `argosai lint` before allowing a commit — catches the mechanical
# mistakes (approved specs with unresolved open questions, done specs with
# unchecked tasks, verified bugs with no verification.md) before they get
# committed, not after. Fast and local: no agent/API call.
#
# Installed by: argosai hooks install
# Skip once with: git commit --no-verify

set -e

if ! command -v argosai >/dev/null 2>&1; then
  echo "argosai not found in PATH — skipping lint hook (install with 'pip install argosai')."
  exit 0
fi

if ! argosai lint .; then
  echo ""
  echo "argosai lint failed — fix the issues above before committing,"
  echo "or skip this hook just this once with: git commit --no-verify"
  exit 1
fi
