#!/bin/bash
set -euo pipefail

output=$(npx biome check src/ --reporter=json 2>/dev/null || true)

diagnostics=$(echo "$output" | python3 -c "
import json, sys
data = json.load(sys.stdin)
s = data.get('summary', {})
print(s.get('errors', 0) + s.get('warnings', 0) + s.get('infos', 0))
")
errors=$(echo "$output" | python3 -c "
import json, sys
data = json.load(sys.stdin)
print(data.get('summary', {}).get('errors', 0))
")
warnings=$(echo "$output" | python3 -c "
import json, sys
data = json.load(sys.stdin)
print(data.get('summary', {}).get('warnings', 0))
")

echo "METRIC diagnostics=$diagnostics"
echo "METRIC errors=$errors"
echo "METRIC warnings=$warnings"
