#!/bin/bash
cd ~/firefrost-work/firefrost-operations-manual

# Create update script that runs after major milestones
cat > automation/update-sandbox-briefing.sh << 'UPDATE'
#!/bin/bash
# Auto-update SANDBOX-BRIEFING.md with current status
cd ~/firefrost-work/firefrost-operations-manual

# Extract current phase status from Infrastructure Manifest
PHASE_STATUS=$(grep -A 20 "## 1. Management Services" Firefrost_Infrastructure_Manifest.md | grep -E "✅|⏳" | head -7)

# Extract monitoring status
MONITORING=$(grep -A 10 "## 7. Monitoring Status" Firefrost_Infrastructure_Manifest.md)

# Update the Phase 0.5 section in sandbox briefing
sed -i '/### Phase 0.5/,/### Phase 1/{
    /### Phase 0.5/!{/### Phase 1/!d;}
}' docs/SANDBOX-BRIEFING.md

# Insert updated phase status
sed -i "/### Phase 0.5/a\\
**Management Services Migration to VPS Tier:**\\
$(echo "$PHASE_STATUS" | sed 's/^//')\\
\\
**Last Updated:** $(date '+%B %d, %Y')\\
" docs/SANDBOX-BRIEFING.md

echo "Sandbox briefing auto-updated with current phase status"
UPDATE

chmod +x automation/update-sandbox-briefing.sh

# Add to project-files for easy Gemini access
cp docs/SANDBOX-BRIEFING.md project-files/SANDBOX-BRIEFING.md

# Update workflow guide to include sandbox updates
cat >> docs/workflow-guide.md << 'WORKFLOW'

---

## Sandbox AI Integration (Added Feb 9, 2026)

**Purpose:** Keep exploratory AI (Gemini) in sync with production progress

**Auto-Update Trigger:**
After completing ANY of these milestones:
- Service deployment
- Phase completion
- Major infrastructure change
- Architecture decision

**Update Command:**
```bash
bash automation/update-sandbox-briefing.sh
git add docs/SANDBOX-BRIEFING.md project-files/SANDBOX-BRIEFING.md
git commit -m "Update sandbox briefing: [what changed]"
git push
```

**Gemini Access:**
https://raw.githubusercontent.com/frostystyle/firefrost-operations-manual/master/project-files/SANDBOX-BRIEFING.md

**Workflow:**
1. Production work happens with Claude
2. Auto-update sandbox briefing after milestones
3. Gemini always has current context for brainstorming
4. Ideas validated in sandbox → implemented in production
WORKFLOW

# Commit everything
git add -A
git commit -m "Create auto-update system for sandbox briefing

- automation/update-sandbox-briefing.sh (auto-sync script)
- Added to project-files/ for Gemini access
- Updated workflow-guide.md with sandbox integration
- Keeps exploratory AI in sync with production progress"

git push

echo "Sandbox auto-update system created!"
echo "Gemini URL: https://raw.githubusercontent.com/frostystyle/firefrost-operations-manual/master/project-files/SANDBOX-BRIEFING.md"
