- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
137 lines
5.4 KiB
PHP
137 lines
5.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Console\ConsoleApplication;
|
|
use App\Framework\Core\AppBootstrapper;
|
|
use App\Framework\DateTime\SystemClock;
|
|
use App\Framework\DateTime\SystemHighResolutionClock;
|
|
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
|
use App\Framework\Performance\EnhancedPerformanceCollector;
|
|
use App\Framework\Performance\MemoryMonitor;
|
|
|
|
// Create bootstrapper
|
|
$clock = new SystemClock();
|
|
$highResClock = new SystemHighResolutionClock();
|
|
$memoryMonitor = new MemoryMonitor();
|
|
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
|
|
$bootstrapper = new AppBootstrapper(__DIR__ . '/../..', $collector, $memoryMonitor);
|
|
|
|
try {
|
|
echo "=== Debugging Console Command Discovery ===" . PHP_EOL;
|
|
|
|
// Bootstrap console
|
|
$consoleApp = $bootstrapper->bootstrapConsole();
|
|
|
|
// Get container via reflection
|
|
$reflection = new ReflectionClass($consoleApp);
|
|
$containerProperty = $reflection->getProperty('container');
|
|
$containerProperty->setAccessible(true);
|
|
$container = $containerProperty->getValue($consoleApp);
|
|
|
|
if (! $container->has(DiscoveryRegistry::class)) {
|
|
echo '❌ DiscoveryRegistry nicht im Container gefunden!' . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
$registry = $container->get(DiscoveryRegistry::class);
|
|
|
|
// Check for ConsoleCommand attributes with different variations
|
|
$possibleKeys = [
|
|
'App\Framework\Console\ConsoleCommand',
|
|
'ConsoleCommand',
|
|
'App\\Framework\\Console\\ConsoleCommand',
|
|
];
|
|
|
|
echo "Available attribute classes:" . PHP_EOL;
|
|
foreach ($registry->attributes->getAllTypes() as $attrClass) {
|
|
echo " - $attrClass" . PHP_EOL;
|
|
}
|
|
echo PHP_EOL;
|
|
|
|
$foundCommands = [];
|
|
foreach ($possibleKeys as $key) {
|
|
$commands = $registry->attributes->get($key) ?? [];
|
|
if (! empty($commands)) {
|
|
$foundCommands[$key] = $commands;
|
|
echo "Found " . count($commands) . " commands with key '$key'" . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
// Check if MCP server command is found specifically
|
|
$mcpServerFound = false;
|
|
foreach ($foundCommands as $key => $commands) {
|
|
foreach ($commands as $attr) {
|
|
if ($attr instanceof App\Framework\Discovery\ValueObjects\DiscoveredAttribute) {
|
|
if ($attr->className->getFullyQualified() === 'App\\Framework\\Mcp\\Console\\McpServerCommand') {
|
|
$mcpServerFound = true;
|
|
echo "✅ MCP Server command found!" . PHP_EOL;
|
|
|
|
break 2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (! $mcpServerFound) {
|
|
echo "❌ MCP Server command NOT found!" . PHP_EOL;
|
|
}
|
|
|
|
if (empty($foundCommands)) {
|
|
echo "❌ No console commands found with any key!" . PHP_EOL;
|
|
|
|
// Try to find any attributes that might be console commands
|
|
echo "Searching for any method-level attributes..." . PHP_EOL;
|
|
foreach ($registry->attributes->getAllTypes() as $attrClass) {
|
|
$attrs = $registry->attributes->get($attrClass);
|
|
foreach ($attrs as $attr) {
|
|
if ($attr instanceof App\Framework\Discovery\ValueObjects\DiscoveredAttribute
|
|
&& $attr->target === App\Framework\Discovery\ValueObjects\AttributeTarget::METHOD) {
|
|
echo " Found method attribute: $attrClass on " .
|
|
$attr->className->getFullyQualified() . "::" .
|
|
($attr->methodName?->toString() ?? 'unknown') . PHP_EOL;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
foreach ($foundCommands as $key => $commands) {
|
|
echo PHP_EOL . "=== Commands found with key '$key' ===" . PHP_EOL;
|
|
foreach ($commands as $i => $attr) {
|
|
echo "Command #$i:" . PHP_EOL;
|
|
if ($attr instanceof App\Framework\Discovery\ValueObjects\DiscoveredAttribute) {
|
|
echo " Class: " . $attr->className->getFullyQualified() . PHP_EOL;
|
|
echo " Method: " . ($attr->methodName?->toString() ?? 'null') . PHP_EOL;
|
|
echo " Arguments: " . json_encode($attr->arguments) . PHP_EOL;
|
|
echo " Additional Data: " . json_encode($attr->additionalData) . PHP_EOL;
|
|
|
|
// Try to create the attribute instance
|
|
$instance = $attr->createAttributeInstance();
|
|
if ($instance) {
|
|
echo " Command Name: " . ($instance->name ?? 'N/A') . PHP_EOL;
|
|
echo " Description: " . ($instance->description ?? 'N/A') . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo " Raw data: " . print_r($attr, true) . PHP_EOL;
|
|
}
|
|
echo PHP_EOL;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Check if any commands are registered in the ConsoleApplication
|
|
$commandsProperty = $reflection->getProperty('commands');
|
|
$commandsProperty->setAccessible(true);
|
|
$registeredCommands = $commandsProperty->getValue($consoleApp);
|
|
|
|
echo "Commands registered in ConsoleApplication: " . count($registeredCommands) . PHP_EOL;
|
|
foreach ($registeredCommands as $name => $command) {
|
|
echo " - $name: " . ($command['description'] ?? 'No description') . PHP_EOL;
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo '❌ Error: ' . $e->getMessage() . PHP_EOL;
|
|
echo 'Trace: ' . $e->getTraceAsString() . PHP_EOL;
|
|
}
|