Skip to content

Commit 07a70bc

Browse files
authored
Merge branch 'feature/hybridChat' into autoMerge/feature/hybridChat
2 parents 3549e33 + 4ceed6e commit 07a70bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1482
-1412
lines changed

docs/lsp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ sequenceDiagram
2626

2727
## Language Server Debugging
2828

29-
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project
29+
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-servers folder that you just cloned. Your VS code folder structure should look like below.
3030

31-
e.g.
31+
3232

3333
```
3434
/aws-toolkit-vscode
@@ -53,9 +53,9 @@ sequenceDiagram
5353
"amazonqLSPChat": true // optional: enables chat from flare
5454
}
5555
```
56-
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
56+
4. Uncomment the `__AMAZONQLSP_PATH` and `__AMAZONQLSP_UI` variables in the `amazonq/.vscode/launch.json` extension configuration
5857
5. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
58+
6. (Optional): Enable `"amazonq.trace.server": "on"` or `"amazonq.trace.server": "verbose"` in your VSCode settings to view detailed log messages sent to/from the language server. These log messages will show up in the "Amazon Q Language Server" output channel
5959
6060
## Amazon Q Inline Activation
6161

package-lock.json

Lines changed: 510 additions & 1010 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"skippedTestReport": "ts-node ./scripts/skippedTestReport.ts ./packages/amazonq/test/e2e/"
4242
},
4343
"devDependencies": {
44-
"@aws-toolkits/telemetry": "^1.0.312",
44+
"@aws-toolkits/telemetry": "^1.0.317",
4545
"@playwright/browser-chromium": "^1.43.1",
4646
"@stylistic/eslint-plugin": "^2.11.0",
4747
"@types/he": "^1.2.3",

packages/amazonq/.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"env": {
1515
"SSMDOCUMENT_LANGUAGESERVER_PORT": "6010",
1616
"WEBPACK_DEVELOPER_SERVER": "http://localhost:8080"
17-
// "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js",
17+
// Below allows for overrides used during development
18+
// "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/agent-standalone.js",
1819
// "__AMAZONQLSP_UI": "${workspaceFolder}/../../../language-servers/chat-client/build/amazonq-ui.js"
1920
},
2021
"envFile": "${workspaceFolder}/.local.env",

packages/amazonq/package.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@
132132
"type": "boolean",
133133
"default": false
134134
},
135+
"amazonQChatPairProgramming": {
136+
"type": "boolean",
137+
"default": false
138+
},
135139
"amazonQSelectDeveloperProfile": {
136140
"type": "boolean",
137141
"default": false
@@ -181,7 +185,25 @@
181185
"amazonQ.workspaceIndexMaxSize": {
182186
"type": "number",
183187
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxSize%",
184-
"default": 250,
188+
"default": 2048,
189+
"scope": "application"
190+
},
191+
"amazonQ.workspaceIndexMaxFileSize": {
192+
"type": "number",
193+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxFileSize%",
194+
"default": 10,
195+
"scope": "application"
196+
},
197+
"amazonQ.workspaceIndexCacheDirPath": {
198+
"type": "string",
199+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexCacheDirPath%",
200+
"default": null,
201+
"scope": "application"
202+
},
203+
"amazonQ.workspaceIndexIgnoreFilePatterns": {
204+
"type": "array",
205+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns%",
206+
"default": [],
185207
"scope": "application"
186208
},
187209
"amazonQ.ignoredSecurityIssues": {

packages/amazonq/src/app/chat/activation.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,14 @@
44
*/
55

66
import * as vscode from 'vscode'
7-
import { ExtensionContext, window } from 'vscode'
7+
import { ExtensionContext } from 'vscode'
88
import { telemetry } from 'aws-core-vscode/telemetry'
99
import { AuthUtil, CodeWhispererSettings } from 'aws-core-vscode/codewhisperer'
1010
import { Commands, placeholder, funcUtil } from 'aws-core-vscode/shared'
1111
import * as amazonq from 'aws-core-vscode/amazonq'
12-
import { scanChatAppInit } from '../amazonqScan'
1312

1413
export async function activate(context: ExtensionContext) {
1514
const appInitContext = amazonq.DefaultAmazonQAppInitContext.instance
16-
17-
registerApps(appInitContext, context)
18-
19-
const provider = new amazonq.AmazonQChatViewProvider(
20-
context,
21-
appInitContext.getWebViewToAppsMessagePublishers(),
22-
appInitContext.getAppsToWebViewMessageListener(),
23-
appInitContext.onDidChangeAmazonQVisibility
24-
)
25-
2615
await amazonq.TryChatCodeLensProvider.register(appInitContext.onDidChangeAmazonQVisibility.event)
2716

2817
const setupLsp = funcUtil.debounce(async () => {
@@ -34,11 +23,6 @@ export async function activate(context: ExtensionContext) {
3423
}, 5000)
3524

3625
context.subscriptions.push(
37-
window.registerWebviewViewProvider(amazonq.AmazonQChatViewProvider.viewType, provider, {
38-
webviewOptions: {
39-
retainContextWhenHidden: true,
40-
},
41-
}),
4226
amazonq.focusAmazonQChatWalkthrough.register(),
4327
amazonq.walkthroughInlineSuggestionsExample.register(),
4428
amazonq.walkthroughSecurityScanExample.register(),
@@ -64,15 +48,6 @@ export async function activate(context: ExtensionContext) {
6448
void setupAuthNotification()
6549
}
6650

67-
function registerApps(appInitContext: amazonq.AmazonQAppInitContext, context: ExtensionContext) {
68-
amazonq.cwChatAppInit(appInitContext)
69-
amazonq.featureDevChatAppInit(appInitContext)
70-
amazonq.gumbyChatAppInit(appInitContext)
71-
amazonq.testChatAppInit(appInitContext)
72-
scanChatAppInit(appInitContext)
73-
amazonq.docChatAppInit(appInitContext)
74-
}
75-
7651
/**
7752
* Display a notification to user for Log In.
7853
*
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as amazonqNode from 'aws-core-vscode/amazonq/node'
7+
import { scanChatAppInit } from '../../amazonqScan'
8+
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
9+
10+
export function activateAgents() {
11+
const appInitContext = DefaultAmazonQAppInitContext.instance
12+
13+
amazonqNode.cwChatAppInit(appInitContext)
14+
amazonqNode.featureDevChatAppInit(appInitContext)
15+
amazonqNode.gumbyChatAppInit(appInitContext)
16+
amazonqNode.testChatAppInit(appInitContext)
17+
amazonqNode.docChatAppInit(appInitContext)
18+
scanChatAppInit(appInitContext)
19+
}

packages/amazonq/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
121121
// This contains every lsp agnostic things (auth, security scan, code scan)
122122
await activateCodeWhisperer(extContext as ExtContext)
123123
if (
124-
(Experiments.instance.get('amazonqLSP', false) || Auth.instance.isInternalAmazonUser()) &&
124+
(Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) &&
125125
!isAmazonInternalOs()
126126
) {
127127
// start the Amazon Q LSP for internal users first

packages/amazonq/src/extensionNode.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import * as vscode from 'vscode'
77
import { activateAmazonQCommon, amazonQContextPrefix, deactivateCommon } from './extension'
8-
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
9-
import { activate as activateQGumby } from 'aws-core-vscode/amazonqGumby'
8+
import { DefaultAmazonQAppInitContext, AmazonQChatViewProvider } from 'aws-core-vscode/amazonq'
9+
import { activate as activateTransformationHub } from 'aws-core-vscode/amazonqGumby'
1010
import {
1111
ExtContext,
1212
globals,
@@ -30,6 +30,7 @@ import { beta } from 'aws-core-vscode/dev'
3030
import { activate as activateNotifications, NotificationsController } from 'aws-core-vscode/notifications'
3131
import { AuthState, AuthUtil } from 'aws-core-vscode/codewhisperer'
3232
import { telemetry, AuthUserState } from 'aws-core-vscode/telemetry'
33+
import { activateAgents } from './app/chat/node/activateAgents'
3334

3435
export async function activate(context: vscode.ExtensionContext) {
3536
// IMPORTANT: No other code should be added to this function. Place it in one of the following 2 functions where appropriate.
@@ -52,10 +53,26 @@ async function activateAmazonQNode(context: vscode.ExtensionContext) {
5253
extensionContext: context,
5354
}
5455

55-
if (!Experiments.instance.get('amazonqChatLSP', false)) {
56+
if (!Experiments.instance.get('amazonqChatLSP', true)) {
57+
const appInitContext = DefaultAmazonQAppInitContext.instance
58+
const provider = new AmazonQChatViewProvider(
59+
context,
60+
appInitContext.getWebViewToAppsMessagePublishers(),
61+
appInitContext.getAppsToWebViewMessageListener(),
62+
appInitContext.onDidChangeAmazonQVisibility
63+
)
64+
context.subscriptions.push(
65+
vscode.window.registerWebviewViewProvider(AmazonQChatViewProvider.viewType, provider, {
66+
webviewOptions: {
67+
retainContextWhenHidden: true,
68+
},
69+
})
70+
)
71+
// this is registered inside of lsp/chat/activation.ts when the chat experiment is enabled
5672
await activateCWChat(context)
57-
await activateQGumby(extContext as ExtContext)
5873
}
74+
activateAgents()
75+
await activateTransformationHub(extContext as ExtContext)
5976
activateInlineChat(context)
6077

6178
const authProvider = new CommonAuthViewProvider(

packages/amazonq/src/lsp/auth.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
*/
55

66
import {
7+
bearerCredentialsUpdateRequestType,
78
ConnectionMetadata,
89
NotificationType,
910
RequestType,
1011
ResponseMessage,
12+
UpdateCredentialsParams,
1113
} from '@aws/language-server-runtimes/protocol'
1214
import * as jose from 'jose'
1315
import * as crypto from 'crypto'
@@ -66,12 +68,15 @@ export const notificationTypes = {
6668
export class AmazonQLspAuth {
6769
constructor(private readonly client: LanguageClient) {}
6870

69-
async refreshConnection() {
71+
/**
72+
* @param force bypass memoization, and forcefully update the bearer token
73+
*/
74+
async refreshConnection(force: boolean = false) {
7075
const activeConnection = AuthUtil.instance.auth.activeConnection
7176
if (activeConnection?.type === 'sso') {
7277
// send the token to the language server
7378
const token = await AuthUtil.instance.getBearerToken()
74-
await this.updateBearerToken(token)
79+
await (force ? this._updateBearerToken(token) : this.updateBearerToken(token))
7580
}
7681
}
7782

@@ -81,12 +86,12 @@ export class AmazonQLspAuth {
8186
token,
8287
})
8388

84-
await this.client.sendRequest(notificationTypes.updateBearerToken.method, request)
89+
await this.client.sendRequest(bearerCredentialsUpdateRequestType.method, request)
8590

8691
this.client.info(`UpdateBearerToken: ${JSON.stringify(request)}`)
8792
}
8893

89-
public startTokenRefreshInterval(pollingTime: number = oneMinute) {
94+
public startTokenRefreshInterval(pollingTime: number = oneMinute / 2) {
9095
const interval = setInterval(async () => {
9196
await this.refreshConnection().catch((e) => {
9297
getLogger('amazonqLsp').error('Unable to update bearer token: %s', (e as Error).message)
@@ -96,7 +101,7 @@ export class AmazonQLspAuth {
96101
return interval
97102
}
98103

99-
private async createUpdateCredentialsRequest(data: any) {
104+
private async createUpdateCredentialsRequest(data: any): Promise<UpdateCredentialsParams> {
100105
const payload = new TextEncoder().encode(JSON.stringify({ data }))
101106

102107
const jwt = await new jose.CompactEncrypt(payload)
@@ -105,6 +110,11 @@ export class AmazonQLspAuth {
105110

106111
return {
107112
data: jwt,
113+
metadata: {
114+
sso: {
115+
startUrl: AuthUtil.instance.auth.startUrl,
116+
},
117+
},
108118
encrypted: true,
109119
}
110120
}

0 commit comments

Comments
 (0)