(filter?: 'all' | 'runner')
| 74 | } |
| 75 | |
| 76 | export async function runDoctorCommand(filter?: 'all' | 'runner'): Promise<void> { |
| 77 | // Default to 'all' if no filter specified |
| 78 | if (!filter) { |
| 79 | filter = 'all'; |
| 80 | } |
| 81 | |
| 82 | console.log(chalk.bold.cyan('\n🩺 hapi CLI Doctor\n')); |
| 83 | |
| 84 | // For 'all' filter, show everything. For 'runner', only show runner-related info |
| 85 | if (filter === 'all') { |
| 86 | // Version and basic info |
| 87 | console.log(chalk.bold('📋 Basic Information')); |
| 88 | console.log(`hapi CLI Version: ${chalk.green(packageJson.version)}`); |
| 89 | console.log(`Platform: ${chalk.green(process.platform)} ${process.arch}`); |
| 90 | console.log(`Node.js Version: ${chalk.green(process.version)}`); |
| 91 | console.log(''); |
| 92 | |
| 93 | // Runner spawn diagnostics |
| 94 | console.log(chalk.bold('🔧 Runner Spawn Diagnostics')); |
| 95 | const projectRoot = projectPath(); |
| 96 | const cliEntrypoint = join(projectRoot, 'src', 'index.ts'); |
| 97 | |
| 98 | if (isBunCompiled()) { |
| 99 | console.log(`Executable: ${chalk.blue(process.execPath)}`); |
| 100 | console.log(`Runtime Assets: ${chalk.blue(runtimePath())}`); |
| 101 | } else { |
| 102 | console.log(`Project Root: ${chalk.blue(projectRoot)}`); |
| 103 | console.log(`CLI Entrypoint: ${chalk.blue(cliEntrypoint)}`); |
| 104 | console.log(`CLI Exists: ${existsSync(cliEntrypoint) ? chalk.green('✓ Yes') : chalk.red('❌ No')}`); |
| 105 | } |
| 106 | console.log(''); |
| 107 | |
| 108 | // Configuration |
| 109 | console.log(chalk.bold('⚙️ Configuration')); |
| 110 | console.log(`hapi Home: ${chalk.blue(configuration.happyHomeDir)}`); |
| 111 | console.log(`Bot URL: ${chalk.blue(configuration.apiUrl)}`); |
| 112 | console.log(`Logs Dir: ${chalk.blue(configuration.logsDir)}`); |
| 113 | |
| 114 | // Environment |
| 115 | console.log(chalk.bold('\n🌍 Environment Variables')); |
| 116 | const env = getEnvironmentInfo(); |
| 117 | console.log(`HAPI_HOME: ${env.HAPI_HOME ? chalk.green(env.HAPI_HOME) : chalk.gray('not set')}`); |
| 118 | console.log(`HAPI_API_URL: ${env.HAPI_API_URL ? chalk.green(env.HAPI_API_URL) : chalk.gray('not set')}`); |
| 119 | console.log(`CLI_API_TOKEN: ${env.CLI_API_TOKEN_SET ? chalk.green('set') : chalk.gray('not set')}`); |
| 120 | console.log(`DANGEROUSLY_LOG_TO_SERVER: ${env.DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING ? chalk.yellow('ENABLED') : chalk.gray('not set')}`); |
| 121 | console.log(`DEBUG: ${env.DEBUG ? chalk.green(env.DEBUG) : chalk.gray('not set')}`); |
| 122 | console.log(`NODE_ENV: ${env.NODE_ENV ? chalk.green(env.NODE_ENV) : chalk.gray('not set')}`); |
| 123 | |
| 124 | // Settings |
| 125 | let settings; |
| 126 | try { |
| 127 | settings = await readSettings(); |
| 128 | console.log(chalk.bold('\n📄 Settings (settings.json):')); |
| 129 | // Hide cliApiToken in output for security |
| 130 | const displaySettings = { ...settings, cliApiToken: settings.cliApiToken ? '***' : undefined }; |
| 131 | console.log(chalk.gray(JSON.stringify(displaySettings, null, 2))); |
| 132 | } catch (error) { |
| 133 | console.log(chalk.bold('\n📄 Settings:')); |
no test coverage detected