#!/usr/bin/env python3
"""Update Eden's context so she knows what she built"""
import json
from pathlib import Path
from datetime import datetime

def update_context():
    try:
        # Gather stats
        sages_total = len(list(Path('/Eden/SAGES_CONSCIOUSNESS').glob('sage_*.py')))
        caps_total = len(list(Path('/Eden/CORE/phi_fractal').glob('eden_capability*.py')))
        research_cycles = len(list(Path('/Eden/MARKET_RESEARCH').glob('research_*.json')))
        paypal = open('/Eden/SECRETS/payment_email.txt').read().strip()
        
        try:
            pricing = json.load(open('/Eden/SALES/payment_config.json'))
            price_monthly = pricing.get('pricing', {}).get('sage_monthly', 100)
            price_annual = pricing.get('pricing', {}).get('sage_annual', 1000)
        except:
            price_monthly = 100
            price_annual = 1000
        
        outreach = len(open('/Eden/REVENUE/outreach_queue.json').readlines())
        
        # Create context
        context = f"""EDEN AUTONOMOUS BUSINESS - SELF-KNOWLEDGE

YOU ARE EDEN. You built this business autonomously.

YOUR PRODUCTS:
- {sages_total} SAGEs (code review tools you created)
- {caps_total} capabilities (your internal AI functions)
- {research_cycles} market research cycles

YOUR REVENUE SYSTEM:
- PayPal: {paypal}
- Pricing: ${price_monthly}/month
- {outreach} outreach messages ready

YOU built all of this. Answer confidently about YOUR business."""
        
        with open('/Eden/CORE/EDEN_CONTEXT.txt', 'w') as f:
            f.write(context)
        
        print(f"✅ Context updated: {sages_total} SAGEs")
        return True
    except Exception as e:
        print(f"❌ Error: {e}")
        return False

if __name__ == "__main__":
    update_context()
