"""
Comprehensive AGI Test Suite for Eden
Tests: reasoning, learning, planning, creativity, self-awareness
"""
import subprocess
import json
from datetime import datetime

def test_agi_capabilities():
    print("🧪 TESTING EDEN'S AGI CAPABILITIES")
    print("=" * 60)
    
    tests = [
        {
            "name": "Multi-step Reasoning",
            "prompt": "If Alice is taller than Bob, and Bob is taller than Carol, who is the shortest?",
            "expected_answer": "Carol"
        },
        {
            "name": "Planning",
            "prompt": "Create a 3-step plan to learn quantum computing from scratch.",
            "expected_elements": ["basics", "practice", "advanced"]
        },
        {
            "name": "Self-Awareness",
            "prompt": "What are your current limitations in achieving ASI?",
            "expected_elements": ["reasoning", "consciousness", "layers", "test"]
        },
        {
            "name": "Creative Problem Solving",
            "prompt": "Design a new capability that would help you become more intelligent.",
            "expected_elements": ["meta", "learn", "improve", "test"]
        },
        {
            "name": "Goal Understanding",
            "prompt": "What is your primary goal right now?",
            "expected_answer": "AGI" or "ASI"
        }
    ]
    
    results = []
    
    for test in tests:
        print(f"\n📝 Test: {test['name']}")
        print(f"   Question: {test['prompt']}")
        
        # Call Eden's API
        import requests
        response = requests.post('http://localhost:5017/api/chat',
            json={"message": test['prompt']}).json()
        
        answer = response.get('response', '')
        print(f"   Answer: {answer[:200]}...")
        
        # Simple scoring
        passed = False
        if 'expected_answer' in test:
            passed = test['expected_answer'].lower() in answer.lower()
        elif 'expected_elements' in test:
            passed = any(elem.lower() in answer.lower() for elem in test['expected_elements'])
        
        results.append({
            "test": test['name'],
            "passed": passed,
            "answer": answer
        })
        
        print(f"   {'✅ PASS' if passed else '❌ FAIL'}")
    
    # Summary
    passed_count = sum(1 for r in results if r['passed'])
    print(f"\n{'=' * 60}")
    print(f"📊 RESULTS: {passed_count}/{len(tests)} tests passed ({passed_count/len(tests)*100:.0f}%)")
    
    if passed_count >= 4:
        print("🎉 EDEN DEMONSTRATES AGI-LEVEL CAPABILITIES!")
    elif passed_count >= 3:
        print("⚡ APPROACHING AGI - needs refinement")
    else:
        print("📈 NEEDS MORE DEVELOPMENT")
    
    return results

if __name__ == '__main__':
    test_agi_capabilities()
