#!/bin/bash
# CC VPS Auto-Sync - runs every 5 minutes (as root)
# Keeps VPS memory and sessions synced with remote

cd /home/ccuser/rateright-growth

# Pull latest (autostash handles local changes)
git pull --rebase --autostash --quiet 2>/dev/null || true

# Check for changes in VPS memory/sessions
if ! git diff --quiet .cc-vps/ .sessions/VPS.md 2>/dev/null; then
  git add .cc-vps/ .sessions/VPS.md
  git commit -m "VPS auto-sync: $(date +%Y-%m-%d_%H:%M)" --quiet 2>/dev/null || true
  git push --quiet 2>/dev/null || true
fi
