()
| 28 | import { getInitialSettings } from 'src/utils/settings/settings.js' |
| 29 | |
| 30 | export async function update() { |
| 31 | logEvent('tengu_update_check', {}) |
| 32 | writeToStdout(`Current version: ${MACRO.VERSION}\n`) |
| 33 | |
| 34 | const channel = getInitialSettings()?.autoUpdatesChannel ?? 'latest' |
| 35 | writeToStdout(`Checking for updates to ${channel} version...\n`) |
| 36 | |
| 37 | logForDebugging('update: Starting update check') |
| 38 | |
| 39 | // Run diagnostic to detect potential issues |
| 40 | logForDebugging('update: Running diagnostic') |
| 41 | const diagnostic = await getDoctorDiagnostic() |
| 42 | logForDebugging(`update: Installation type: ${diagnostic.installationType}`) |
| 43 | logForDebugging( |
| 44 | `update: Config install method: ${diagnostic.configInstallMethod}`, |
| 45 | ) |
| 46 | |
| 47 | // Check for multiple installations |
| 48 | if (diagnostic.multipleInstallations.length > 1) { |
| 49 | writeToStdout('\n') |
| 50 | writeToStdout(chalk.yellow('Warning: Multiple installations found') + '\n') |
| 51 | for (const install of diagnostic.multipleInstallations) { |
| 52 | const current = |
| 53 | diagnostic.installationType === install.type |
| 54 | ? ' (currently running)' |
| 55 | : '' |
| 56 | writeToStdout(`- ${install.type} at ${install.path}${current}\n`) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // Display warnings if any exist |
| 61 | if (diagnostic.warnings.length > 0) { |
| 62 | writeToStdout('\n') |
| 63 | for (const warning of diagnostic.warnings) { |
| 64 | logForDebugging(`update: Warning detected: ${warning.issue}`) |
| 65 | |
| 66 | // Don't skip PATH warnings - they're always relevant |
| 67 | // The user needs to know that 'which claude' points elsewhere |
| 68 | logForDebugging(`update: Showing warning: ${warning.issue}`) |
| 69 | |
| 70 | writeToStdout(chalk.yellow(`Warning: ${warning.issue}\n`)) |
| 71 | |
| 72 | writeToStdout(chalk.bold(`Fix: ${warning.fix}\n`)) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // Update config if installMethod is not set (but skip for package managers) |
| 77 | const config = getGlobalConfig() |
| 78 | if ( |
| 79 | !config.installMethod && |
| 80 | diagnostic.installationType !== 'package-manager' |
| 81 | ) { |
| 82 | writeToStdout('\n') |
| 83 | writeToStdout('Updating configuration to track installation method...\n') |
| 84 | let detectedMethod: 'local' | 'native' | 'global' | 'unknown' = 'unknown' |
| 85 | |
| 86 | // Map diagnostic installation type to config install method |
| 87 | switch (diagnostic.installationType) { |
no test coverage detected