#!/bin/bash
# Scope: universal | Validates agents.json Schema
# MORPH-SPEC Pre-Commit Hook: Agent Configuration Validation
# Uses validate-agents.js to check agents.json

echo "🤖 Validating agent configuration..."

# Check if agents.json is being modified
if git diff --cached --name-only | grep -q 'agents\.json$'; then
  echo "Detected changes to agents.json"

  # Run validator
  if ! morph-spec validate-agents-skills; then
    echo ""
    echo "❌ COMMIT BLOCKED: agents.json validation failed"
    echo "   Fix errors above before committing"
    exit 1
  fi

  echo "✓ agents.json is valid"
else
  echo "✓ No changes to agents.json"
fi

exit 0
