From dcef146935cc7b551df3442430086a9fd8d106bd Mon Sep 17 00:00:00 2001 From: It Apilium Date: Mon, 9 Mar 2026 20:05:27 +0100 Subject: [PATCH] feat: auto-update outdated Cortex binary on sidecar start When the installed binary version is older than REQUIRED_CORTEX_VERSION, the sidecar now automatically downloads the latest release instead of just printing a warning. Only applies to auto-detected binaries (not explicitly configured via binaryPath). Falls back gracefully to the existing version if the update fails. --- extensions/memory-semantic/cortex-sidecar.ts | 21 ++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/extensions/memory-semantic/cortex-sidecar.ts b/extensions/memory-semantic/cortex-sidecar.ts index d165e87..8b81286 100644 --- a/extensions/memory-semantic/cortex-sidecar.ts +++ b/extensions/memory-semantic/cortex-sidecar.ts @@ -91,16 +91,29 @@ export class CortexSidecar { } } - // Warn (but don't block) if the installed binary is older than required + // Auto-update if the installed binary is older than required const installedVersion = getCortexBinaryVersion(binaryPath); if (installedVersion && REQUIRED_CORTEX_VERSION) { const [iMaj, iMin, iPat] = installedVersion.split(".").map(Number); const [rMaj, rMin, rPat] = REQUIRED_CORTEX_VERSION.split(".").map(Number); - if ( + const isOutdated = iMaj < rMaj || (iMaj === rMaj && iMin < rMin) || - (iMaj === rMaj && iMin === rMin && iPat < rPat) - ) { + (iMaj === rMaj && iMin === rMin && iPat < rPat); + if (isOutdated && !this.config.binaryPath) { + console.info( + `[cortex] binary outdated (${installedVersion} < ${REQUIRED_CORTEX_VERSION}) — auto-updating...`, + ); + try { + const { installOrUpdateCortex } = await import("../shared/cortex-update-check.js"); + await installOrUpdateCortex((msg) => console.info(`[cortex] ${msg}`)); + binaryPath = (await locateCortexBinary()) ?? binaryPath; + } catch (err) { + console.warn( + `[cortex] auto-update failed: ${err instanceof Error ? err.message : err}. Continuing with ${installedVersion}`, + ); + } + } else if (isOutdated) { console.warn( `[cortex] binary outdated (${installedVersion} < ${REQUIRED_CORTEX_VERSION}). Run: mayros update`, );