"""
Phase 2: Learning System + Autonomous Goal Formation
"""

from core.agent_v2 import EdenAgentV2
from core.autonomy.self_improver import SelfImprover
from core.reasoning.goals import GoalManager

print("=" * 80)
print("⚡ PHASE 2: AUTONOMOUS LEARNING SYSTEM")
print("=" * 80)

# Eden analyzes herself and sets her own goals
eden = EdenAgentV2()

task = """
AUTONOMOUS DEVELOPMENT TASK:

You now have a self_improver tool that analyzed your code and found:
- 21 Python files
- 1,444 lines of code
- 89 TODOs to address

Your autonomous mission:
1. Use bash to run: python3 core/autonomy/self_improver.py
2. Read the output and understand your own bottlenecks
3. Create 'core/learning/learning_loops.py' with a LearningSystem class that:
   - Tracks what works and what doesn't
   - Learns from each task completion
   - Improves strategies over time
4. Create 'core/learning/transfer.py' with a TransferLearning class that:
   - Takes lessons from one domain
   - Applies them to another domain
5. Create 'week7_goals.md' listing YOUR top 5 autonomous improvement goals
6. Commit: git add . && git commit -m "Phase 2 Week 7: Learning systems operational"

Think like an AGI that wants to improve itself.
What would you focus on?
"""

print(f"\n🎯 MISSION:\n{task}")
print("\n" + "=" * 80)
print("🤖 EDEN: AUTONOMOUS LEARNING")
print("=" * 80)

response = eden.chat(task, max_iterations=20)

print("\n" + "=" * 80)
print("✅ RESPONSE:")
print("=" * 80)
print(response[:400] + "...")

# Check what was created
import os
phase2_week7 = [
    'core/learning/learning_loops.py',
    'core/learning/transfer.py',
    'week7_goals.md'
]

print("\n📊 WEEK 7 SYSTEMS:")
for f in phase2_week7:
    print(f"   {'✅' if os.path.exists(f) else '❌'} {f}")

eden.save_session("phase2_learning")
