#!/usr/bin/env bash
# Generate the full 5-draft agent ecosystem family
# Usage: ./scripts/generate-draft-family.sh [--cheap]
#
# Generates: AEM, ATD, HITL, AEPB, APAE drafts
# Output: data/reports/generated-drafts/
# Estimated cost: ~$0.28/draft ($1.50 total with --quality, ~$0.15 with --cheap)

set -euo pipefail

QUALITY_FLAG="${1:---quality}"

echo "=== Generating Agent Ecosystem Draft Family ==="
echo "Mode: ${QUALITY_FLAG}"
echo ""

# Generate the full family
ietf pipeline family --name agent-ecosystem "${QUALITY_FLAG}"

echo ""
echo "=== Running quality gates ==="

# Get IDs of generated drafts and run quality gates
for id in $(sqlite3 data/drafts.db "SELECT id FROM generated_drafts WHERE family_name='agent-ecosystem' ORDER BY id"); do
    echo "Quality check: draft #${id}"
    ietf pipeline quality "${id}" || true
done

echo ""
echo "=== Done ==="
echo "Drafts saved to: data/reports/generated-drafts/"
echo "Run 'ietf pipeline status' to see all generated drafts"
