#!/usr/bin/env python3

# Manual test to check our current implementation status
import sys
import os
sys.path.insert(0, os.getcwd())

def test_basic_functionality():
    try:
        from alloy_interpreter import parser, Interpreter
        print("✅ Successfully imported alloy_interpreter")
        
        # Test 1: Basic variable assignment
        print("\n🧪 Test 1: Basic variable assignment")
        code1 = "x = 42"
        ast1 = parser.parse(code1)
        interpreter1 = Interpreter()
        interpreter1.interpret(ast1)
        result1 = interpreter1.global_env.get('x')
        print(f"   Code: {code1}")
        print(f"   Result: x = {result1}")
        print("   ✅ PASS" if result1 == 42 else "   ❌ FAIL")
        
        # Test 2: Tool definition
        print("\n🧪 Test 2: Tool definition")
        code2 = '''
tool add_numbers takes a, b returns sum {
    sum = a + b
    return sum
}
result = add_numbers(10, 20)
'''
        ast2 = parser.parse(code2)
        interpreter2 = Interpreter()
        interpreter2.interpret(ast2)
        result2 = interpreter2.global_env.get('result')
        print(f"   Code: tool definition and call")
        print(f"   Result: result = {result2}")
        print("   ✅ PASS" if result2 and result2[0] == 30 else "   ❌ FAIL")
        
        # Test 3: Clean agent syntax (NEW)
        print("\n🧪 Test 3: Clean agent syntax")
        code3 = 'claude = agent "claude-3.5-sonnet"'
        try:
            ast3 = parser.parse(code3)
            interpreter3 = Interpreter()
            interpreter3.interpret(ast3)
            claude_info = interpreter3.global_env.get_agent('claude')
            print(f"   Code: {code3}")
            print(f"   Result: claude agent = {claude_info}")
            print("   ✅ PASS" if claude_info else "   ❌ FAIL")
        except Exception as e:
            print(f"   Code: {code3}")
            print(f"   Error: {e}")
            print("   ❌ FAIL")
        
        # Test 4: Agent with tools (NEW)
        print("\n🧪 Test 4: Agent with tools")
        code4 = 'researcher = agent "claude-3.5-sonnet" with tools web_search, read_files'
        try:
            ast4 = parser.parse(code4)
            interpreter4 = Interpreter()
            interpreter4.interpret(ast4)
            researcher_info = interpreter4.global_env.get_agent('researcher')
            print(f"   Code: {code4}")
            print(f"   Result: researcher agent = {researcher_info}")
            print("   ✅ PASS" if researcher_info and 'tools' in researcher_info else "   ❌ FAIL")
        except Exception as e:
            print(f"   Code: {code4}")
            print(f"   Error: {e}")
            print("   ❌ FAIL")
            
        print("\n" + "="*50)
        print("🎉 Manual testing complete!")
        
    except Exception as e:
        print(f"❌ Import or setup error: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    test_basic_functionality()