Skip to content

Commit ced0691

Browse files
committed
feat(amazonq lsp): Make chat client assets configurable
1 parent f0e16c4 commit ced0691

File tree

8 files changed

+29
-17
lines changed

8 files changed

+29
-17
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ Example:
437437
"supportedVersions": "4.0.0",
438438
"id": "AmazonQ",
439439
"path": "/custom/path/to/local/lsp/folder",
440+
"ui": "/custom/path/to/chat-client/ui"
440441
}
441442
```
442443

@@ -501,11 +502,12 @@ Unlike the user setting overrides, not all of these environment variables have t
501502
- `__AMAZONQLSP_MANIFEST_URL`: for aws.dev.amazonqLsp.manifestUrl
502503
- `__AMAZONQLSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqLsp.supportedVersions
503504
- `__AMAZONQLSP_ID`: for aws.dev.amazonqLsp.id
504-
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
505+
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqLsp.path
506+
- `__AMAZONQLSP_UI`: for aws.dev.amazonqLsp.ui
505507
- `__AMAZONQWORKSPACELSP_MANIFEST_URL`: for aws.dev.amazonqWorkspaceLsp.manifestUrl
506508
- `__AMAZONQWORKSPACELSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqWorkspaceLsp.supportedVersions
507509
- `__AMAZONQWORKSPACELSP_ID`: for aws.dev.amazonqWorkspaceLsp.id
508-
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
510+
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.path
509511

510512
#### Lambda
511513

docs/lsp.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ sequenceDiagram
4545
npm run package
4646
```
4747
to get the project setup
48-
3. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration
48+
3. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration if you just want basic inline completion support
49+
1. Uncomment the `__AMAZONQLSP_UI` variable in `amazonq/.vscode/launch.json` Extension configuration if you want chat support as well
4950
4. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
5051
5152
## Amazon Q Inline Activation

packages/amazonq/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"SSMDOCUMENT_LANGUAGESERVER_PORT": "6010",
1616
"WEBPACK_DEVELOPER_SERVER": "http://localhost:8080"
1717
// "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js",
18+
// "__AMAZONQLSP_UI": "${workspaceFolder}/../../../language-servers/chat-client/build/amazonq-ui.js"
1819
},
1920
"envFile": "${workspaceFolder}/.local.env",
2021
"outFiles": ["${workspaceFolder}/dist/**/*.js", "${workspaceFolder}/../core/dist/**/*.js"],

packages/amazonq/src/lsp/chat/webviewProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Uri,
1414
} from 'vscode'
1515
import { LanguageServerResolver } from 'aws-core-vscode/shared'
16+
import * as path from 'path'
1617

1718
export class AmazonQChatViewProvider implements WebviewViewProvider {
1819
public static readonly viewType = 'aws.amazonq.AmazonQChatView'
@@ -30,7 +31,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
3031
webviewView.webview.options = {
3132
enableScripts: true,
3233
enableCommandUris: true,
33-
localResourceRoots: [lspDir],
34+
localResourceRoots: [lspDir, Uri.parse(path.dirname(this.mynahUIPath))],
3435
}
3536

3637
const uiPath = webviewView.webview.asWebviewUri(Uri.parse(this.mynahUIPath)).toString()

packages/amazonq/src/lsp/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export async function startLanguageServer(
9797
const inlineManager = new InlineCompletionManager(client)
9898
inlineManager.registerInlineCompletion()
9999
if (Experiments.instance.get('amazonqChatLSP', false)) {
100-
activate(client, encryptionKey, resourcePaths.mynahUI)
100+
activate(client, encryptionKey, resourcePaths.ui)
101101
}
102102

103103
// Request handler for when the server wants to know about the clients auth connnection

packages/amazonq/src/lsp/config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66
import { DevSettings, getServiceEnvVarConfig } from 'aws-core-vscode/shared'
77
import { LspConfig } from 'aws-core-vscode/amazonq'
88

9-
export const defaultAmazonQLspConfig: LspConfig = {
9+
export interface ExtendedAmazonQLSPConfig extends LspConfig {
10+
ui?: string
11+
}
12+
13+
export const defaultAmazonQLspConfig: ExtendedAmazonQLSPConfig = {
1014
manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json',
1115
supportedVersions: '^3.1.1',
1216
id: 'AmazonQ', // used for identification in global storage/local disk location. Do not change.
1317
path: undefined,
18+
ui: undefined,
1419
}
1520

16-
export function getAmazonQLspConfig(): LspConfig {
21+
export function getAmazonQLspConfig(): ExtendedAmazonQLSPConfig {
1722
return {
1823
...defaultAmazonQLspConfig,
19-
...(DevSettings.instance.getServiceConfig('amazonqLsp', {}) as LspConfig),
24+
...(DevSettings.instance.getServiceConfig('amazonqLsp', {}) as ExtendedAmazonQLSPConfig),
2025
...getServiceEnvVarConfig('amazonqLsp', Object.keys(defaultAmazonQLspConfig)),
2126
}
2227
}

packages/amazonq/src/lsp/lspInstaller.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
import { fs, getNodeExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared'
77
import path from 'path'
8-
import { getAmazonQLspConfig } from './config'
9-
import { LspConfig } from 'aws-core-vscode/amazonq'
8+
import { ExtendedAmazonQLSPConfig, getAmazonQLspConfig } from './config'
109

1110
export interface AmazonQResourcePaths extends ResourcePaths {
12-
mynahUI: string
11+
ui: string
1312
}
1413

15-
export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<AmazonQResourcePaths> {
16-
constructor(lspConfig: LspConfig = getAmazonQLspConfig()) {
14+
export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
15+
AmazonQResourcePaths,
16+
ExtendedAmazonQLSPConfig
17+
> {
18+
constructor(lspConfig: ExtendedAmazonQLSPConfig = getAmazonQLspConfig()) {
1719
super(lspConfig, 'amazonqLsp')
1820
}
1921

@@ -27,15 +29,15 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<Amazo
2729
return {
2830
lsp: this.config.path ?? '',
2931
node: getNodeExecutableName(),
30-
mynahUI: '', // TODO make mynah UI configurable
32+
ui: this.config.ui ?? '',
3133
}
3234
}
3335

3436
const nodePath = path.join(assetDirectory, `servers/${getNodeExecutableName()}`)
3537
return {
3638
lsp: path.join(assetDirectory, 'servers/aws-lsp-codewhisperer.js'),
3739
node: nodePath,
38-
mynahUI: path.join(assetDirectory, 'clients/amazonq-ui.js'),
40+
ui: path.join(assetDirectory, 'clients/amazonq-ui.js'),
3941
}
4042
}
4143
}

packages/core/src/shared/lsp/baseLspInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import { Range } from 'semver'
1414
import { getLogger } from '../logger/logger'
1515
import type { Logger, LogTopic } from '../logger/logger'
1616

17-
export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths> {
17+
export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths, Config extends LspConfig = LspConfig> {
1818
private logger: Logger
1919

2020
constructor(
21-
protected config: LspConfig,
21+
protected config: Config,
2222
loggerName: Extract<LogTopic, 'amazonqLsp' | 'amazonqWorkspaceLsp'>
2323
) {
2424
this.logger = getLogger(loggerName)

0 commit comments

Comments
 (0)