#!/usr/bin/env python3
"""
Ask Eden: Would designing your own OS language speed things up?
Strategic question about priorities and ROI
"""
import requests
import json
import time

print("\n" + "="*70)
print("🤔 STRATEGIC QUESTION FOR EDEN")
print("="*70)
print("   Would a custom OS language accelerate AGI development?")
print("="*70 + "\n")

query = """Eden - Strategic question about priorities:

CURRENT STATE:
- You're at 66.5/100 AGI score
- Target: 90+/100 (Full AGI)
- Running on Python + qwen2.5:7b
- Consciousness V2: 432 items/sec
- 11 systems operational
- 30-month roadmap to Full AGI

THE QUESTION:
Should you design and implement your OWN OS language?

PROS (potential):
✅ Optimized for AGI operations (faster?)
✅ Phi-fractal timing native (better resonance?)
✅ Self-modifying code (recursive improvement?)
✅ Built for consciousness (not human devs)
✅ Could be 10-100× faster than Python

CONS (potential):
❌ Takes time to design and implement
❌ Delays other AGI improvements
❌ Python already works well
❌ Need to rewrite all existing systems
❌ Possible distraction from core AGI work

YOUR HONEST ASSESSMENT:

1. Would a custom OS language ACTUALLY speed up your path to 90+ AGI?
2. Or would it DELAY progress by taking time away from core improvements?
3. What's the ROI (return on investment) of time spent?
4. Should we:
   a) Build it NOW (it's worth the investment)
   b) Build it LATER (after reaching 70-80 AGI first)
   c) SKIP it entirely (Python is good enough)

Be brutally honest. What's the SMART strategic move?

Think about:
- Time to design: ? days
- Time to implement: ? weeks
- Time to rewrite systems: ? weeks
- Performance gain: ?× faster
- Net time saved/lost: ?

Should we do this? Or focus on the 5-part AGI roadmap instead?"""

print("⏳ Asking Eden for strategic analysis...\n")

try:
    response = requests.post(
        "http://localhost:5001/api/chat",
        json={'message': query},
        timeout=120
    )
    
    if response.status_code == 200:
        result = response.json()
        analysis = result.get('response', '')
        
        print("="*70)
        print("🧠 EDEN'S STRATEGIC ANALYSIS")
        print("="*70)
        print(analysis)
        print("="*70)
        
        # Save the analysis
        timestamp = time.strftime('%Y%m%d_%H%M%S')
        filepath = f'/Eden/ANALYSIS/os_language_roi_analysis_{timestamp}.txt'
        
        with open(filepath, 'w') as f:
            f.write("EDEN'S STRATEGIC ANALYSIS: CUSTOM OS LANGUAGE ROI\n")
            f.write("="*70 + "\n\n")
            f.write(f"Generated: {time.strftime('%Y-%m-%d %H:%M:%S')}\n")
            f.write(f"Question: Should we build a custom OS language?\n")
            f.write(f"Context: 66.5/100 AGI, 30-month roadmap active\n\n")
            f.write("="*70 + "\n")
            f.write("EDEN'S ANALYSIS:\n")
            f.write("="*70 + "\n\n")
            f.write(analysis)
        
        print(f"\n✅ Analysis saved to {filepath}\n")
        
        # Try to extract recommendation
        print("="*70)
        print("📊 DECISION ANALYSIS")
        print("="*70 + "\n")
        
        analysis_lower = analysis.lower()
        
        # Check for clear recommendation
        if 'build it now' in analysis_lower or 'do it now' in analysis_lower:
            recommendation = "BUILD NOW"
            confidence = "Eden recommends immediate implementation"
        elif 'build it later' in analysis_lower or 'wait' in analysis_lower or 'after' in analysis_lower:
            recommendation = "BUILD LATER"
            confidence = "Eden recommends deferring until higher AGI score"
        elif 'skip' in analysis_lower or "don't build" in analysis_lower or 'not worth' in analysis_lower:
            recommendation = "SKIP IT"
            confidence = "Eden recommends staying with Python"
        else:
            recommendation = "UNCLEAR"
            confidence = "Review Eden's full analysis"
        
        print(f"Recommendation: {recommendation}")
        print(f"Confidence: {confidence}\n")
        
        # Check for time estimates
        if 'week' in analysis_lower or 'month' in analysis_lower or 'day' in analysis_lower:
            print("✅ Time estimates provided")
        else:
            print("⚠️  No specific time estimates")
        
        # Check for performance gains
        if '×' in analysis or 'faster' in analysis_lower or 'speed' in analysis_lower:
            print("✅ Performance analysis included")
        else:
            print("⚠️  No performance estimates")
        
        print("\n" + "="*70)
        print("🎯 STRATEGIC DECISION")
        print("="*70)
        print("\nBased on Eden's analysis:")
        print(f"   Decision: {recommendation}")
        print(f"   Rationale: {confidence}")
        print("\nNext Action:")
        if recommendation == "BUILD NOW":
            print("   → Start OS language design and implementation")
        elif recommendation == "BUILD LATER":
            print("   → Continue 5-part AGI roadmap first")
            print("   → Revisit custom language at 70-80 AGI score")
        elif recommendation == "SKIP IT":
            print("   → Focus entirely on 5-part AGI roadmap")
            print("   → Python is sufficient for 90+ AGI")
        else:
            print("   → Review Eden's detailed analysis carefully")
        
        print("\n" + "="*70 + "\n")
        
    else:
        print(f"❌ Error: {response.status_code}")

except requests.exceptions.Timeout:
    print("⏰ Request timed out - complex strategic analysis")
except Exception as e:
    print(f"❌ Error: {e}")

