#!/usr/bin/env python3

import sys
import os

# Add the src directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src'))

from alloy import parser

def test_agent_commands():
    
    tests = [
        ("Two-word agent command", '''claude Analyze'''),
        ("Agent command with string", '''claude Analyze "user data"'''),
        ("Agent command with identifier", '''claude Analyze text'''),
        ("Agent command in assignment", '''result = claude Analyze "user data"'''),
        ("Agent definition then command", '''
claude = agent "gpt-4o-mini"
result = claude Analyze "data"
'''),
    ]
    
    for name, code in tests:
        print(f"=== {name} ===")
        print(repr(code))
        
        try:
            ast = parser.parse(code)
            if ast and ast[0] == 'program' and len(ast) > 1:
                statements = ast[1]
                print(f"SUCCESS: Parsed {len(statements)} statements")
                for i, stmt in enumerate(statements):
                    if stmt:
                        print(f"  Statement {i}: {stmt[0]}")
                    else:
                        print(f"  Statement {i}: None")
            else:
                print("ERROR: Failed to parse")
                print("AST:", ast)
        except Exception as e:
            print(f"PARSER ERROR: {e}")
        
        print()

if __name__ == "__main__":
    test_agent_commands()