#!/bin/bash
# Watch for Qwen3.5 GGUF quantizations from Bartowski
# Notifies via James dashboard + Signal when available

MODELS=(
  "bartowski/Qwen3.5-27B-GGUF"
  "bartowski/Qwen3.5-35B-A3B-GGUF"
  "Qwen/Qwen3.5-27B-GGUF"
  "Qwen/Qwen3.5-35B-A3B-GGUF"
)

FOUND=0
for model in "${MODELS[@]}"; do
  result=$(curl -s "https://huggingface.co/api/models/$model" 2>/dev/null)
  if echo "$result" | python3 -c "import json,sys; d=json.load(sys.stdin); files=[s.get('rfilename','') for s in d.get('siblings',[])]; has_gguf=any('.gguf' in f.lower() for f in files); print(has_gguf)" 2>/dev/null | grep -q "True"; then
    model_short=$(basename "$model")
    echo "FOUND: $model"
    
    # Post to dashboard + notify
    /home/johan/clawd/scripts/notify.sh -c dashboard -t "GGUF Available: $model_short" -T "package" "$model is now available for download on HuggingFace."
    /home/johan/clawd/scripts/notify.sh -t "GGUF ready: $model_short" -T "package" -p 3 "https://huggingface.co/$model"

    FOUND=$((FOUND + 1))
  fi
done

if [ $FOUND -eq 0 ]; then
  echo "No Qwen3.5 GGUFs yet."
fi
cation/json" \
      -d "{\"jsonrpc\":\"2.0\",\"method\":\"send\",\"params\":{\"recipient\":[\"+17272252475\"],\"message\":\"⚡ GGUF ready: $model_short — https://huggingface.co/$model\"},\"id\":1}" \
      > /dev/null

    FOUND=$((FOUND + 1))
  fi
done

if [ $FOUND -eq 0 ]; then
  echo "No Qwen3.5 GGUFs yet."
fi
