#!/bin/bash

# Daily Check Auto-Spawn Hook
# Add this to your ~/.bashrc to enable auto-spawn on terminal open

# Configuration
FLAG_FILE="$HOME/.daily_check_pending"
DAILY_CHECK_DIR="/mnt/e/Users/Alexis Trouvé/Documents/Projets/couple_matters/daily_check"

# Check if flag file exists
if [ -f "$FLAG_FILE" ]; then
    # Read period from flag file
    PERIOD=$(cat "$FLAG_FILE" 2>/dev/null || echo "unknown")

    # Display notification
    echo ""
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo "🔔 DAILY CHECK EN ATTENTE ($PERIOD)"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo ""
    echo "Le daily check va se lancer automatiquement dans 3 secondes..."
    echo "(Appuie sur Ctrl+C pour annuler)"
    echo ""

    # Countdown (interruptible)
    sleep 3

    # Launch Claude Code with daily check
    cd "$DAILY_CHECK_DIR"
    claude "daily check"

    # Remove flag file after execution
    rm -f "$FLAG_FILE"

    echo ""
    echo "✅ Daily check terminé. Flag file supprimé."
    echo ""
fi
