From cf1b1d4036b96d6d2ac743cd93fe2532fcbd51ac Mon Sep 17 00:00:00 2001 From: Dmitry Stoyanov Date: Thu, 19 Mar 2026 09:10:16 +0300 Subject: [PATCH] fix(agents): add installVersion to BaseAgentAdapter for npm-based agents When running `codemie install gemini --supported`, the install command was falling back to `install()` which always installs the latest version, because `installVersion()` method was missing from BaseAgentAdapter. Added `installVersion(version?: string)` method that: - Resolves 'supported' to the actual version from metadata.supportedVersion - Calls npm.installGlobal() with the version option This fix applies to all npm-based agents (Gemini, OpenCode, etc.), while Claude continues to use its custom override for native installation. Generated with AI --- src/agents/core/BaseAgentAdapter.ts | 38 ++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/agents/core/BaseAgentAdapter.ts b/src/agents/core/BaseAgentAdapter.ts index 564a982a..e0cd50ca 100644 --- a/src/agents/core/BaseAgentAdapter.ts +++ b/src/agents/core/BaseAgentAdapter.ts @@ -98,7 +98,7 @@ export abstract class BaseAgentAdapter implements AgentAdapter { } /** - * Install agent via npm + * Install agent via npm (latest version) */ async install(): Promise { if (!this.metadata.npmPackage) { @@ -115,6 +115,42 @@ export abstract class BaseAgentAdapter implements AgentAdapter { } } + /** + * Install agent via npm with specific version + * Resolves 'supported' to the version from metadata.supportedVersion + * + * Override in agent plugins for non-npm installation (e.g., native installers) + * + * @param version - Specific version, 'supported', or undefined for latest + */ + async installVersion(version?: string): Promise { + if (!this.metadata.npmPackage) { + throw new Error(`${this.displayName} is built-in and cannot be installed`); + } + + // Resolve 'supported' to actual version from metadata + let resolvedVersion: string | undefined = version; + if (version === 'supported') { + if (!this.metadata.supportedVersion) { + throw new Error(`${this.displayName}: No supported version defined in metadata`); + } + resolvedVersion = this.metadata.supportedVersion; + logger.debug('Resolved version', { + from: 'supported', + to: resolvedVersion, + }); + } + + try { + await npm.installGlobal(this.metadata.npmPackage, { version: resolvedVersion }); + } catch (error: unknown) { + if (error instanceof NpmError) { + throw new Error(`Failed to install ${this.displayName}: ${error.message}`); + } + throw error; + } + } + /** * Uninstall agent via npm */