From ca209439db3774c791cb917c6a56d79ce2c93dcc Mon Sep 17 00:00:00 2001 From: clh02467605 Date: Tue, 13 Oct 2026 16:32:21 +0800 Subject: [PATCH 1/2] fix(update): exit non-zero when CLI upgrade fails --- packages/commands/src/commands/update.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/commands/src/commands/update.ts b/packages/commands/src/commands/update.ts index f7753e0c0..72cadc87d 100644 --- a/packages/commands/src/commands/update.ts +++ b/packages/commands/src/commands/update.ts @@ -6,6 +6,7 @@ import { DEFAULT_INSTALL_PS1_URL, DEFAULT_INSTALL_SCRIPT_URL, defineCommand, + ExitCode, getConfigDir, getUpdateInstallMethod, type InstallMethod, @@ -155,9 +156,12 @@ export default defineCommand({ error instanceof BailianError && error.hint ? error.hint.replace(/^Re-run:\s*/i, "") : binaryReinstallHint().trim(); - process.stderr.write(`\nAutomatic binary update failed: ${message}\n`); - process.stderr.write("Re-run the install script:\n"); - process.stderr.write(` ${reinstall}\n\n`); + throw new BailianError( + `Automatic binary update failed: ${message}`, + ExitCode.GENERAL, + `Re-run the install script:\n ${reinstall}`, + { cause: error }, + ); } return; } @@ -179,9 +183,13 @@ export default defineCommand({ process.stderr.write(`\n${color.green("\u2713 Update complete.")}\n`); } updateAgentSkill(color); - } catch { - process.stderr.write("\nAutomatic update failed. Please run manually:\n"); - process.stderr.write(` ${cmd}\n\n`); + } catch (error) { + throw new BailianError( + "Automatic update failed.", + ExitCode.GENERAL, + `Please run manually:\n ${cmd}`, + { cause: error }, + ); } }, }); From 47121801aef1ecadd85e14091b07346d8b909dd4 Mon Sep 17 00:00:00 2001 From: clh02467605 Date: Tue, 13 Oct 2026 17:06:54 +0800 Subject: [PATCH 2/2] fix(update): non-zero exit when latest version unknown; dedupe binary failure message --- packages/commands/src/commands/update.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/commands/src/commands/update.ts b/packages/commands/src/commands/update.ts index 72cadc87d..1d1b40bee 100644 --- a/packages/commands/src/commands/update.ts +++ b/packages/commands/src/commands/update.ts @@ -122,8 +122,11 @@ export default defineCommand({ const targetVersion = pinnedVersion ?? (await resolveLatest(method, npmPackage)); if (!targetVersion) { - process.stderr.write(`${color.yellow("Could not determine the latest version.")}\n`); - return; + throw new BailianError( + "Could not determine the latest version.", + ExitCode.GENERAL, + "Check network access, or pass --to .", + ); } if (targetVersion === currentVersion) { @@ -157,10 +160,10 @@ export default defineCommand({ ? error.hint.replace(/^Re-run:\s*/i, "") : binaryReinstallHint().trim(); throw new BailianError( - `Automatic binary update failed: ${message}`, + "Automatic binary update failed.", ExitCode.GENERAL, `Re-run the install script:\n ${reinstall}`, - { cause: error }, + { cause: message }, ); } return;