Skip to content

Commit 8c875fb

Browse files
Merge master into feature/agentic-chat
2 parents 3659236 + 3cf9e4b commit 8c875fb

File tree

9 files changed

+39
-36
lines changed

9 files changed

+39
-36
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Example:
439439
"supportedVersions": "4.0.0",
440440
"id": "AmazonQ",
441441
"path": "/custom/path/to/local/lsp/folder",
442+
"ui": "/custom/path/to/chat-client/ui"
442443
}
443444
```
444445

@@ -503,11 +504,12 @@ Unlike the user setting overrides, not all of these environment variables have t
503504
- `__AMAZONQLSP_MANIFEST_URL`: for aws.dev.amazonqLsp.manifestUrl
504505
- `__AMAZONQLSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqLsp.supportedVersions
505506
- `__AMAZONQLSP_ID`: for aws.dev.amazonqLsp.id
506-
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
507+
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqLsp.path
508+
- `__AMAZONQLSP_UI`: for aws.dev.amazonqLsp.ui
507509
- `__AMAZONQWORKSPACELSP_MANIFEST_URL`: for aws.dev.amazonqWorkspaceLsp.manifestUrl
508510
- `__AMAZONQWORKSPACELSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqWorkspaceLsp.supportedVersions
509511
- `__AMAZONQWORKSPACELSP_ID`: for aws.dev.amazonqWorkspaceLsp.id
510-
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
512+
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.path
511513

512514
#### Lambda
513515

docs/lsp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ sequenceDiagram
5454
}
5555
```
5656
4. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration
57+
1. Uncomment the `__AMAZONQLSP_UI` variable in `amazonq/.vscode/launch.json` Extension configuration if you want to debug the flare chat-client as well
5758
5. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
5859
5960
## 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
@@ -14,6 +14,7 @@ import {
1414
} from 'vscode'
1515
import { LanguageServerResolver } from 'aws-core-vscode/shared'
1616
import { QuickActionCommandGroup } from '@aws/mynah-ui'
17+
import * as path from 'path'
1718

1819
export class AmazonQChatViewProvider implements WebviewViewProvider {
1920
public static readonly viewType = 'aws.amazonq.AmazonQChatView'
@@ -49,7 +50,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
4950
webviewView.webview.options = {
5051
enableScripts: true,
5152
enableCommandUris: true,
52-
localResourceRoots: [lspDir],
53+
localResourceRoots: [lspDir, Uri.parse(path.dirname(this.mynahUIPath))],
5354
}
5455

5556
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
@@ -126,7 +126,7 @@ export async function startLanguageServer(
126126
}
127127

128128
if (Experiments.instance.get('amazonqChatLSP', false)) {
129-
activate(client, encryptionKey, resourcePaths.mynahUI)
129+
activate(client, encryptionKey, resourcePaths.ui)
130130
}
131131

132132
// Temporary code for pen test. Will be removed when we switch to the real flare auth

packages/amazonq/src/lsp/config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@
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 across IDEs for identifying global storage/local disk locations. Do not change.
1317
suppressPromptPrefix: 'amazonQ',
1418
path: undefined,
19+
ui: undefined,
1520
}
1621

17-
export function getAmazonQLspConfig(): LspConfig {
22+
export function getAmazonQLspConfig(): ExtendedAmazonQLSPConfig {
1823
return {
1924
...defaultAmazonQLspConfig,
20-
...(DevSettings.instance.getServiceConfig('amazonqLsp', {}) as LspConfig),
25+
...(DevSettings.instance.getServiceConfig('amazonqLsp', {}) as ExtendedAmazonQLSPConfig),
2126
...getServiceEnvVarConfig('amazonqLsp', Object.keys(defaultAmazonQLspConfig)),
2227
}
2328
}

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/amazonq/test/unit/amazonq/lsp/config.test.ts

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@
66
import assert from 'assert'
77
import { DevSettings } from 'aws-core-vscode/shared'
88
import sinon from 'sinon'
9-
import { defaultAmazonQLspConfig, getAmazonQLspConfig } from '../../../../src/lsp/config'
10-
import { LspConfig, getAmazonQWorkspaceLspConfig, defaultAmazonQWorkspaceLspConfig } from 'aws-core-vscode/amazonq'
9+
import { defaultAmazonQLspConfig, ExtendedAmazonQLSPConfig, getAmazonQLspConfig } from '../../../../src/lsp/config'
10+
import { defaultAmazonQWorkspaceLspConfig, getAmazonQWorkspaceLspConfig, LspConfig } from 'aws-core-vscode/amazonq'
1111

1212
for (const [name, config, defaultConfig, setEnv, resetEnv] of [
1313
[
1414
'getAmazonQLspConfig',
1515
getAmazonQLspConfig,
1616
defaultAmazonQLspConfig,
17-
(envConfig: LspConfig) => {
17+
(envConfig: ExtendedAmazonQLSPConfig) => {
1818
process.env.__AMAZONQLSP_MANIFEST_URL = envConfig.manifestUrl
1919
process.env.__AMAZONQLSP_SUPPORTED_VERSIONS = envConfig.supportedVersions
2020
process.env.__AMAZONQLSP_ID = envConfig.id
2121
process.env.__AMAZONQLSP_PATH = envConfig.path
22+
process.env.__AMAZONQLSP_UI = envConfig.ui
2223
},
2324
() => {
2425
delete process.env.__AMAZONQLSP_MANIFEST_URL
2526
delete process.env.__AMAZONQLSP_SUPPORTED_VERSIONS
2627
delete process.env.__AMAZONQLSP_ID
2728
delete process.env.__AMAZONQLSP_PATH
29+
delete process.env.__AMAZONQLSP_UI
2830
},
2931
],
3032
[
@@ -52,8 +54,9 @@ for (const [name, config, defaultConfig, setEnv, resetEnv] of [
5254
manifestUrl: 'https://custom.url/manifest.json',
5355
supportedVersions: '4.0.0',
5456
id: 'AmazonQSetting',
55-
suppressPromptPrefix: 'amazonQSetting',
57+
suppressPromptPrefix: config().suppressPromptPrefix,
5658
path: '/custom/path',
59+
...(name === 'getAmazonQLspConfig' && { ui: '/chat/client/location' }),
5760
}
5861

5962
beforeEach(() => {
@@ -75,7 +78,7 @@ for (const [name, config, defaultConfig, setEnv, resetEnv] of [
7578
assert.deepStrictEqual(config(), defaultConfig)
7679
})
7780

78-
it('overrides location', () => {
81+
it('overrides path', () => {
7982
const path = '/custom/path/to/lsp'
8083
serviceConfigStub.returns({ path })
8184

@@ -92,21 +95,9 @@ for (const [name, config, defaultConfig, setEnv, resetEnv] of [
9295
})
9396

9497
it('environment variable takes precedence over settings', () => {
95-
const envConfig: LspConfig = {
96-
manifestUrl: 'https://another-custom.url/manifest.json',
97-
supportedVersions: '5.1.1',
98-
id: 'AmazonQSetting',
99-
suppressPromptPrefix: 'amazonQSetting',
100-
path: '/some/new/custom/path',
101-
}
102-
103-
setEnv(envConfig)
104-
serviceConfigStub.returns(settingConfig)
105-
106-
assert.deepStrictEqual(config(), {
107-
...defaultAmazonQLspConfig,
108-
...envConfig,
109-
})
98+
setEnv(settingConfig)
99+
serviceConfigStub.returns({})
100+
assert.deepStrictEqual(config(), settingConfig)
110101
})
111102
})
112103
}

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)