#!/bin/bash
# scripts/workflow/verify.sh — 验证工作流配置
set -e
cd "$(dirname "$0")/../.."

PROFILE="${1:-default}"
echo "📋 验证工作流 (profile: $PROFILE)..."

# 检查 workflow.json
if [ ! -f ".scale/workflow.json" ]; then
  echo "❌ 缺少 .scale/workflow.json"
  exit 1
fi

# 检查 quality-contract.json
if [ ! -f ".scale/quality-contract.json" ]; then
  echo "❌ 缺少 .scale/quality-contract.json"
  exit 1
fi

# 检查模板文件
TEMPLATE_COUNT=$(ls docs/workflow/templates/*.md 2>/dev/null | wc -l)
echo "  📄 工作流模板: $TEMPLATE_COUNT 个"

# 验证 JSON 格式
python3 -c "import json; json.load(open('.scale/workflow.json')); print('  ✅ workflow.json 格式正确')"
python3 -c "import json; json.load(open('.scale/quality-contract.json')); print('  ✅ quality-contract.json 格式正确')"

echo "✅ 工作流验证通过"
