diff --git a/packages/amazonq/src/lsp/lspInstaller.ts b/packages/amazonq/src/lsp/lspInstaller.ts index 9ac19601fe7..5b4c855c84f 100644 --- a/packages/amazonq/src/lsp/lspInstaller.ts +++ b/packages/amazonq/src/lsp/lspInstaller.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import * as nodeFs from 'fs' import vscode from 'vscode' import { fs, getNodeExecutableName, getRgExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared' import path from 'path' @@ -45,11 +46,15 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller< const nodePath = path.join(assetDirectory, `servers/${getNodeExecutableName()}`) const rgPath = path.join(assetDirectory, `servers/ripgrep/${getRgExecutableName()}`) + // Check for amazonq-ui.js in both locations for backwards compatibility + const amazonqUiInClientsPath = path.join(assetDirectory, 'clients/amazonq-ui.js') + const amazonqUiInServersPath = path.join(assetDirectory, 'servers/amazonq-ui.js') + const uiPath = nodeFs.existsSync(amazonqUiInClientsPath) ? amazonqUiInClientsPath : amazonqUiInServersPath return { lsp: path.join(assetDirectory, 'servers/aws-lsp-codewhisperer.js'), node: nodePath, ripGrep: rgPath, - ui: path.join(assetDirectory, 'clients/amazonq-ui.js'), + ui: uiPath, } } @@ -58,10 +63,14 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller< export function getBundledResourcePaths(ctx: vscode.ExtensionContext): AmazonQResourcePaths { const assetDirectory = vscode.Uri.joinPath(ctx.extensionUri, 'resources', 'language-server').fsPath + // Check for amazonq-ui.js in both locations for backwards compatibility + const amazonqUiInClientsPath = path.join(assetDirectory, 'clients/amazonq-ui.js') + const amazonqUiInServersPath = path.join(assetDirectory, 'servers/amazonq-ui.js') + const uiPath = nodeFs.existsSync(amazonqUiInClientsPath) ? amazonqUiInClientsPath : amazonqUiInServersPath return { lsp: path.join(assetDirectory, 'servers', 'aws-lsp-codewhisperer.js'), node: process.execPath, ripGrep: '', - ui: path.join(assetDirectory, 'clients', 'amazonq-ui.js'), + ui: uiPath, } } diff --git a/packages/core/src/shared/lsp/baseLspInstaller.ts b/packages/core/src/shared/lsp/baseLspInstaller.ts index 7acf58ad788..2c05a64dd5c 100644 --- a/packages/core/src/shared/lsp/baseLspInstaller.ts +++ b/packages/core/src/shared/lsp/baseLspInstaller.ts @@ -76,7 +76,8 @@ export abstract class BaseLspInstaller/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/amazonq-ui.js' // } // ``` resourcePaths: this.resourcePaths(assetDirectory), diff --git a/packages/core/src/shared/lsp/types.ts b/packages/core/src/shared/lsp/types.ts index 1262d6e8fd1..1e8321aa117 100644 --- a/packages/core/src/shared/lsp/types.ts +++ b/packages/core/src/shared/lsp/types.ts @@ -23,7 +23,8 @@ export interface LspResult { * resourcePaths = { * lsp = '/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/aws-lsp-codewhisperer.js' * node = '/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/node' - * ui = '/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' + * ui = '/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' or + * '/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/amazonq-ui.js' * } * ``` */ @@ -47,7 +48,8 @@ export interface LspResolution extends LspResult { * resourcePaths = { * lsp = '/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/aws-lsp-codewhisperer.js' * node = '/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/node' - * ui = '/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' + * ui = '/aws/toolkits/language-servers/AmazonQ/3.3.0/clients/amazonq-ui.js' or + * '/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/amazonq-ui.js' * } * ``` */ diff --git a/scripts/lspArtifact.ts b/scripts/lspArtifact.ts index 42b5c59907d..f889e2486a3 100644 --- a/scripts/lspArtifact.ts +++ b/scripts/lspArtifact.ts @@ -158,7 +158,10 @@ export async function downloadLanguageServer(): Promise { if (!fs.existsSync(path.join(resourcesDir, 'servers', 'aws-lsp-codewhisperer.js'))) { throw new Error(`Extracting aws-lsp-codewhisperer.js failure`) } - if (!fs.existsSync(path.join(resourcesDir, 'clients', 'amazonq-ui.js'))) { + // Check for amazonq-ui.js in both locations for backwards compatibility (moved from clients.zip to servers.zip) + const amazonqUiInClients = fs.existsSync(path.join(resourcesDir, 'clients', 'amazonq-ui.js')) + const amazonqUiInServers = fs.existsSync(path.join(resourcesDir, 'servers', 'amazonq-ui.js')) + if (!amazonqUiInClients && !amazonqUiInServers) { throw new Error(`Extracting amazonq-ui.js failure`) } console.log('Download and extraction completed successfully')