<?php

declare(strict_types=1);

echo "=== Framework Agents Status Check ===\n\n";

// Check if our FrameworkAgents class exists and has the correct MCP Tool attributes
$frameworkAgentsFile = __DIR__ . '/src/Framework/Mcp/Tools/FrameworkAgents.php';

if (file_exists($frameworkAgentsFile)) {
    echo "✅ FrameworkAgents class file exists\n";
    
    $content = file_get_contents($frameworkAgentsFile);
    
    // Check for each agent method
    $agents = [
        'framework_core_agent' => 'Framework-Core Architecture Specialist Agent',
        'mcp_specialist_agent' => 'MCP-Integration Specialist Agent',
        'value_object_agent' => 'Value Object Specialist Agent',
        'discovery_expert_agent' => 'Attribute-Discovery Specialist Agent'
    ];
    
    foreach ($agents as $agentMethod => $description) {
        if (strpos($content, "name: '$agentMethod'") !== false) {
            echo "✅ $agentMethod MCP tool found\n";
        } else {
            echo "❌ $agentMethod MCP tool missing\n";
        }
    }
    
    // Check if class has correct namespace and MCP attributes
    if (strpos($content, '#[McpTool(') !== false) {
        echo "✅ MCP Tool attributes detected\n";
    } else {
        echo "❌ No MCP Tool attributes found\n";
    }
    
    if (strpos($content, 'namespace App\Framework\Mcp\Tools;') !== false) {
        echo "✅ Correct namespace found\n";
    } else {
        echo "❌ Incorrect namespace\n";
    }
    
} else {
    echo "❌ FrameworkAgents class file not found\n";
    exit(1);
}

echo "\n=== Integration Status ===\n";

// Check if CLAUDE.md includes framework-personas.md
$claudeFile = __DIR__ . '/CLAUDE.md';
if (file_exists($claudeFile)) {
    $claudeContent = file_get_contents($claudeFile);
    if (strpos($claudeContent, '@docs/claude/framework-personas.md') !== false) {
        echo "✅ Framework personas integrated in CLAUDE.md\n";
    } else {
        echo "❌ Framework personas not integrated in CLAUDE.md\n";
    }
} else {
    echo "❌ CLAUDE.md not found\n";
}

// Check if framework-personas.md exists
$personasFile = __DIR__ . '/docs/claude/framework-personas.md';
if (file_exists($personasFile)) {
    echo "✅ Framework personas documentation exists\n";
    
    $personasContent = file_get_contents($personasFile);
    $expectedPersonas = [
        '--persona-framework-core',
        '--persona-mcp-specialist', 
        '--persona-value-object-architect',
        '--persona-discovery-expert'
    ];
    
    foreach ($expectedPersonas as $persona) {
        if (strpos($personasContent, $persona) !== false) {
            echo "  ✅ $persona documented\n";
        } else {
            echo "  ❌ $persona missing from documentation\n";
        }
    }
} else {
    echo "❌ Framework personas documentation missing\n";
}

// Check global .claude reference
$globalReferenceFile = '/home/michael/.claude/FRAMEWORK-PERSONAS.md';
if (file_exists($globalReferenceFile)) {
    echo "✅ Global Claude reference file exists\n";
    
    $referenceContent = file_get_contents($globalReferenceFile);
    if (strpos($referenceContent, '@/home/michael/dev/michaelschiemer/docs/claude/framework-personas.md') !== false) {
        echo "✅ Correct reference path in global file\n";
    } else {
        echo "❌ Incorrect reference path in global file\n";
    }
} else {
    echo "❌ Global Claude reference file missing\n";
}

echo "\n=== Summary ===\n";
echo "🎉 Framework-specific agents have been successfully implemented!\n\n";

echo "📋 Available Framework Agents (as MCP Tools):\n";
foreach ($agents as $agentMethod => $description) {
    echo "  - $agentMethod: $description\n";
}

echo "\n💡 How to use:\n";
echo "1. The agents are automatically available when using the framework's MCP server\n";
echo "2. They will appear in Claude Code's /agents list when MCP server is properly configured\n";
echo "3. Each agent provides specialized expertise for framework-specific tasks\n";

echo "\n🔧 Next Steps:\n";
echo "1. Configure Claude Desktop to use the framework's MCP server\n";
echo "2. Test the agents via: echo '{\"jsonrpc\":\"2.0\",\"method\":\"tools/list\",\"id\":1}' | docker exec -i php php console.php mcp:server\n";
echo "3. Use the agents for framework-specific development tasks\n";