diff --git a/packages/cli/src/ui/commands/ideCommand.ts b/packages/cli/src/ui/commands/ideCommand.ts index eff0a5b6..d5d1cb75 100644 --- a/packages/cli/src/ui/commands/ideCommand.ts +++ b/packages/cli/src/ui/commands/ideCommand.ts @@ -7,6 +7,7 @@ import { Config, DetectedIde, + QWEN_CODE_COMPANION_EXTENSION_NAME, IDEConnectionStatus, getIdeDisplayName, getIdeInstaller, @@ -170,7 +171,7 @@ export const ideCommand = (config: Config | null): SlashCommand | null => { context.ui.addItem( { type: 'error', - text: `No installer is available for ${ideClient.getDetectedIdeDisplayName()}. Please install the IDE companion manually from its marketplace.`, + text: `No installer is available for ${ideClient.getDetectedIdeDisplayName()}. Please install the '${QWEN_CODE_COMPANION_EXTENSION_NAME}' extension manually from the marketplace.`, }, Date.now(), ); diff --git a/packages/core/src/ide/constants.ts b/packages/core/src/ide/constants.ts new file mode 100644 index 00000000..e1c81430 --- /dev/null +++ b/packages/core/src/ide/constants.ts @@ -0,0 +1,7 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +export const QWEN_CODE_COMPANION_EXTENSION_NAME = 'Qwen Code Companion'; \ No newline at end of file diff --git a/packages/core/src/ide/ide-installer.test.ts b/packages/core/src/ide/ide-installer.test.ts index b2a33715..88a677b2 100644 --- a/packages/core/src/ide/ide-installer.test.ts +++ b/packages/core/src/ide/ide-installer.test.ts @@ -24,17 +24,14 @@ describe('ide-installer', () => { expect(installer).toBeInstanceOf(Object); }); - it('should return an OpenVSXInstaller for "vscodium"', () => { + it('should return null for "vscodium" (not implemented)', () => { const installer = getIdeInstaller(DetectedIde.VSCodium); - expect(installer).not.toBeNull(); - expect(installer).toBeInstanceOf(Object); + expect(installer).toBeNull(); }); - it('should return a DefaultIDEInstaller for an unknown IDE', () => { + it('should return null for an unknown IDE', () => { const installer = getIdeInstaller('unknown' as DetectedIde); - // Assuming DefaultIDEInstaller is the fallback - expect(installer).not.toBeNull(); - expect(installer).toBeInstanceOf(Object); + expect(installer).toBeNull(); }); }); @@ -67,44 +64,4 @@ describe('ide-installer', () => { }); }); }); - - describe('OpenVSXInstaller', () => { - let installer: IdeInstaller; - - beforeEach(() => { - installer = getIdeInstaller(DetectedIde.VSCodium)!; - }); - - afterEach(() => { - vi.restoreAllMocks(); - }); - - describe('install', () => { - it('should call execSync with the correct command and return success', async () => { - const execSyncSpy = vi - .spyOn(child_process, 'execSync') - .mockImplementation(() => ''); - const result = await installer.install(); - expect(execSyncSpy).toHaveBeenCalledWith( - 'npx ovsx get qwenlm.qwen-code-vscode-ide-companion', - { stdio: 'pipe' }, - ); - expect(result.success).toBe(true); - expect(result.message).toContain( - 'VS Code companion extension was installed successfully from OpenVSX', - ); - }); - - it('should return a failure message on failed installation', async () => { - vi.spyOn(child_process, 'execSync').mockImplementation(() => { - throw new Error('Command failed'); - }); - const result = await installer.install(); - expect(result.success).toBe(false); - expect(result.message).toContain( - 'Failed to install VS Code companion extension from OpenVSX', - ); - }); - }); - }); }); diff --git a/packages/core/src/ide/ide-installer.ts b/packages/core/src/ide/ide-installer.ts index bbd91f5d..602197c6 100644 --- a/packages/core/src/ide/ide-installer.ts +++ b/packages/core/src/ide/ide-installer.ts @@ -6,15 +6,13 @@ import * as child_process from 'child_process'; import * as process from 'process'; -import { glob } from 'glob'; import * as path from 'path'; import * as fs from 'fs'; import * as os from 'os'; -import { fileURLToPath } from 'url'; import { DetectedIde } from './detect-ide.js'; +import { QWEN_CODE_COMPANION_EXTENSION_NAME } from './constants.js'; const VSCODE_COMMAND = process.platform === 'win32' ? 'code.cmd' : 'code'; -const VSCODE_COMPANION_EXTENSION_FOLDER = 'vscode-ide-companion'; export interface IdeInstaller { install(): Promise; @@ -103,34 +101,7 @@ class VsCodeInstaller implements IdeInstaller { }; } - const bundleDir = path.dirname(fileURLToPath(import.meta.url)); - // The VSIX file is copied to the bundle directory as part of the build. - let vsixFiles = glob.sync(path.join(bundleDir, '*.vsix')); - if (vsixFiles.length === 0) { - // If the VSIX file is not in the bundle, it might be a dev - // environment running with `npm start`. Look for it in the original - // package location, relative to the bundle dir. - const devPath = path.join( - bundleDir, // .../packages/core/dist/src/ide - '..', // .../packages/core/dist/src - '..', // .../packages/core/dist - '..', // .../packages/core - '..', // .../packages - VSCODE_COMPANION_EXTENSION_FOLDER, - '*.vsix', - ); - vsixFiles = glob.sync(devPath); - } - if (vsixFiles.length === 0) { - return { - success: false, - message: - 'Could not find the required VS Code companion extension. Please file a bug via /bug.', - }; - } - - const vsixPath = vsixFiles[0]; - const command = `"${commandPath}" --install-extension "${vsixPath}" --force`; + const command = `"${commandPath}" --install-extension qwenlm.qwen-code-vscode-ide-companion --force`; try { child_process.execSync(command, { stdio: 'pipe' }); return { @@ -141,27 +112,7 @@ class VsCodeInstaller implements IdeInstaller { } catch (_error) { return { success: false, - message: `Failed to install VS Code companion extension. Please try installing it manually from the VS Code marketplace.`, - }; - } - } -} - -class OpenVSXInstaller implements IdeInstaller { - async install(): Promise { - // TODO: Use the correct extension path. - const command = `npx ovsx get qwenlm.qwen-code-vscode-ide-companion`; - try { - child_process.execSync(command, { stdio: 'pipe' }); - return { - success: true, - message: - 'VS Code companion extension was installed successfully from OpenVSX. Please restart your terminal to complete the setup.', - }; - } catch (_error) { - return { - success: false, - message: `Failed to install VS Code companion extension from OpenVSX. Please try installing it manually.`, + message: `Failed to install VS Code companion extension. Please try installing '${QWEN_CODE_COMPANION_EXTENSION_NAME}' manually from the VS Code extension marketplace.`, }; } } @@ -172,6 +123,6 @@ export function getIdeInstaller(ide: DetectedIde): IdeInstaller | null { case DetectedIde.VSCode: return new VsCodeInstaller(); default: - return new OpenVSXInstaller(); + return null; } } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 4896847d..3a1b0c3a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -52,6 +52,7 @@ export * from './ide/ide-client.js'; export * from './ide/ideContext.js'; export * from './ide/ide-installer.js'; export { getIdeDisplayName, DetectedIde } from './ide/detect-ide.js'; +export * from './ide/constants.js'; // Export Shell Execution Service export * from './services/shellExecutionService.js';