From e3edcf613e28a48fb7cb5c2c90ffed3c80cb0c62 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Thu, 4 Dec 2025 03:19:01 -0500 Subject: [PATCH] fix(doctor): use actual installed clipproxy version instead of hardcoded --- src/cliproxy/binary-manager.ts | 16 ++++++++++++++++ src/cliproxy/index.ts | 1 + src/management/doctor.ts | 7 ++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/cliproxy/binary-manager.ts b/src/cliproxy/binary-manager.ts index 9f685314..b2d26bb1 100644 --- a/src/cliproxy/binary-manager.ts +++ b/src/cliproxy/binary-manager.ts @@ -900,4 +900,20 @@ export function getCLIProxyPath(): string { return manager.getBinaryPath(); } +/** + * Get installed CLIProxyAPI version from .version file + * Returns the fallback version if not installed or version file missing + */ +export function getInstalledCliproxyVersion(): string { + const versionFile = path.join(getBinDir(), '.version'); + if (fs.existsSync(versionFile)) { + try { + return fs.readFileSync(versionFile, 'utf8').trim(); + } catch { + return CLIPROXY_FALLBACK_VERSION; + } + } + return CLIPROXY_FALLBACK_VERSION; +} + export default BinaryManager; diff --git a/src/cliproxy/index.ts b/src/cliproxy/index.ts index 8673067d..27837e32 100644 --- a/src/cliproxy/index.ts +++ b/src/cliproxy/index.ts @@ -40,6 +40,7 @@ export { ensureCLIProxyBinary, isCLIProxyInstalled, getCLIProxyPath, + getInstalledCliproxyVersion, } from './binary-manager'; // Config generation diff --git a/src/management/doctor.ts b/src/management/doctor.ts index 51e9f5c8..af25862a 100644 --- a/src/management/doctor.ts +++ b/src/management/doctor.ts @@ -16,7 +16,7 @@ import { isPortAvailable, getAllAuthStatus, getConfigPath, - CLIPROXY_VERSION, + getInstalledCliproxyVersion, CLIPROXY_DEFAULT_PORT, } from '../cliproxy'; @@ -775,11 +775,12 @@ class Doctor { if (isCLIProxyInstalled()) { const binaryPath = getCLIProxyPath(); + const installedVersion = getInstalledCliproxyVersion(); binarySpinner.succeed(); - console.log(` ${ok('CLIProxy Binary'.padEnd(22))} v${CLIPROXY_VERSION}`); + console.log(` ${ok('CLIProxy Binary'.padEnd(22))} v${installedVersion}`); this.results.addCheck('CLIProxy Binary', 'success', undefined, undefined, { status: 'OK', - info: `v${CLIPROXY_VERSION} (${binaryPath})`, + info: `v${installedVersion} (${binaryPath})`, }); } else { binarySpinner.info();