Files
michaelschiemer/tests/debug/debug-discovery-deep.php
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

109 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Cache\GeneralCache;
use App\Framework\Core\PathProvider;
use App\Framework\DateTime\SystemClock;
use App\Framework\DI\DefaultContainer;
use App\Framework\Discovery\Factory\DiscoveryServiceFactory;
echo "=== Deep Discovery Debugging ===" . PHP_EOL;
// Create dependencies
$basePath = __DIR__ . '/../..';
$pathProvider = new PathProvider($basePath);
$cache = new GeneralCache();
$clock = new SystemClock();
$container = new DefaultContainer();
// Create discovery service
$factory = new DiscoveryServiceFactory(
$container,
$pathProvider,
$cache,
$clock
);
// Create discovery service for development
$discoveryService = $factory->createForDevelopment();
echo "Source path: " . $pathProvider->getSourcePath() . PHP_EOL;
// Check if the MCP server command file exists
$mcpServerPath = $basePath . '/src/Framework/Mcp/Console/McpServerCommand.php';
echo "MCP Server Command file exists: " . (file_exists($mcpServerPath) ? 'YES' : 'NO') . PHP_EOL;
if (file_exists($mcpServerPath)) {
echo "MCP Server Command file path: " . $mcpServerPath . PHP_EOL;
// Check the file content for the attribute
$content = file_get_contents($mcpServerPath);
if (strpos($content, '#[ConsoleCommand') !== false) {
echo "✅ ConsoleCommand attribute found in file content" . PHP_EOL;
} else {
echo "❌ ConsoleCommand attribute NOT found in file content" . PHP_EOL;
}
// Check if it uses the correct namespace
if (strpos($content, 'use App\\Framework\\Console\\ConsoleCommand;') !== false) {
echo "✅ ConsoleCommand use statement found" . PHP_EOL;
} else {
echo "❌ ConsoleCommand use statement NOT found" . PHP_EOL;
}
}
echo PHP_EOL . "Running discovery..." . PHP_EOL;
// Run discovery and get results
$results = $discoveryService->discover();
echo "Total attributes discovered: " . $results->attributes->count() . PHP_EOL;
echo "Available attribute types: " . count($results->attributes->getAllTypes()) . PHP_EOL;
// Check specifically for ConsoleCommand attributes
$consoleCommands = $results->attributes->get('App\\Framework\\Console\\ConsoleCommand');
echo "ConsoleCommand attributes found: " . count($consoleCommands) . PHP_EOL;
if (! empty($consoleCommands)) {
foreach ($consoleCommands as $i => $command) {
echo " Command $i: " . $command->className->getFullyQualified() .
"::" . ($command->methodName?->toString() ?? 'unknown') . PHP_EOL;
$instance = $command->createAttributeInstance();
if ($instance) {
echo " Name: " . $instance->name . PHP_EOL;
echo " Description: " . $instance->description . PHP_EOL;
}
}
} else {
echo "No ConsoleCommand attributes discovered!" . PHP_EOL;
// Check if the specific class was discovered at all
$allClasses = [];
foreach ($results->attributes->getAllTypes() as $attrType) {
$attrs = $results->attributes->get($attrType);
foreach ($attrs as $attr) {
$className = $attr->className->getFullyQualified();
if (! in_array($className, $allClasses)) {
$allClasses[] = $className;
}
}
}
if (in_array('App\\Framework\\Mcp\\Console\\McpServerCommand', $allClasses)) {
echo "✅ McpServerCommand class was discovered with other attributes" . PHP_EOL;
} else {
echo "❌ McpServerCommand class was NOT discovered at all" . PHP_EOL;
}
echo "Classes discovered: " . count($allClasses) . PHP_EOL;
if (count($allClasses) < 20) {
foreach ($allClasses as $className) {
echo " - $className" . PHP_EOL;
}
}
}