Skip to content

Commit dd9ad62

Browse files
authored
feat(amazonq): Pass project configuration to LSP client (#7162)
## Problem The LSP server accepts local VSCode workspace configurations for AmazonQ upon initialization, but they are not being passed to the client by the VSCode extension. See https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/configurationUtils.ts ## Solution * Add missing settings for file indexing to the extension * Pass the workspace settings to Flare when the client is instantiated ## Testing <img width="997" alt="Screenshot 2025-04-24 at 19 00 59" src="https://github.com/user-attachments/assets/e8b8b977-1bb0-4796-b864-f0b570557fc2" /> I confirmed that Flare is receiving the data and that it can parse it --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 879584e commit dd9ad62

File tree

5 files changed

+56
-11
lines changed

5 files changed

+56
-11
lines changed

packages/amazonq/package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,25 @@
181181
"amazonQ.workspaceIndexMaxSize": {
182182
"type": "number",
183183
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxSize%",
184-
"default": 250,
184+
"default": 2048,
185+
"scope": "application"
186+
},
187+
"amazonQ.workspaceIndexMaxFileSize": {
188+
"type": "number",
189+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxFileSize%",
190+
"default": 10,
191+
"scope": "application"
192+
},
193+
"amazonQ.workspaceIndexCacheDirPath": {
194+
"type": "string",
195+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexCacheDirPath%",
196+
"default": null,
197+
"scope": "application"
198+
},
199+
"amazonQ.workspaceIndexIgnoreFilePatterns": {
200+
"type": "array",
201+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns%",
202+
"default": [],
185203
"scope": "application"
186204
},
187205
"amazonQ.ignoredSecurityIssues": {

packages/amazonq/src/lsp/client.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
updateConfigurationRequestType,
2121
WorkspaceFolder,
2222
} from '@aws/language-server-runtimes/protocol'
23-
import { AuthUtil, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
23+
import { AuthUtil, CodeWhispererSettings, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
2424
import {
2525
Settings,
2626
oidcClientName,
@@ -92,20 +92,25 @@ export async function startLanguageServer(
9292
customization,
9393
optOutTelemetry: getOptOutPreference() === 'OPTOUT',
9494
projectContext: {
95-
enableLocalIndexing: true,
95+
enableLocalIndexing: CodeWhispererSettings.instance.isLocalIndexEnabled(),
96+
enableGpuAcceleration: CodeWhispererSettings.instance.isLocalIndexGPUEnabled(),
97+
indexWorkerThreads: CodeWhispererSettings.instance.getIndexWorkerThreads(),
98+
localIndexing: {
99+
ignoreFilePatterns: CodeWhispererSettings.instance.getIndexIgnoreFilePatterns(),
100+
maxFileSizeMB: CodeWhispererSettings.instance.getMaxIndexFileSize(),
101+
maxIndexSizeMB: CodeWhispererSettings.instance.getMaxIndexSize(),
102+
indexCacheDirPath: CodeWhispererSettings.instance.getIndexCacheDirPath(),
103+
},
96104
},
97105
},
98106
]
99107
}
100108
if (params.items[0].section === 'aws.codeWhisperer') {
101109
return [
102110
{
103-
includeSuggestionsWithCodeReferences: vscode.workspace
104-
.getConfiguration()
105-
.get('amazonQ.showCodeWithReferences'),
106-
shareCodeWhispererContentWithAWS: vscode.workspace
107-
.getConfiguration()
108-
.get('amazonQ.shareContentWithAWS'),
111+
includeSuggestionsWithCodeReferences:
112+
CodeWhispererSettings.instance.isSuggestionsWithCodeReferencesEnabled(),
113+
shareCodeWhispererContentWithAWS: !CodeWhispererSettings.instance.isOptoutEnabled(),
109114
},
110115
]
111116
}

packages/core/package.nls.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@
9393
"AWS.configuration.description.amazonq.workspaceIndex": "When you add @workspace to your question in Amazon Q chat, Amazon Q will index your workspace files locally to use as context for its response. Extra CPU usage is expected while indexing a workspace. This will not impact Amazon Q features or your IDE, but you may manage CPU usage by setting the number of local threads in 'Local Workspace Index Threads'.",
9494
"AWS.configuration.description.amazonq.workspaceIndexWorkerThreads": "Number of worker threads of Amazon Q local index process. '0' will use the system default worker threads for balance performance. You may increase this number to more quickly index your workspace, but only up to your hardware's number of CPU cores. Please restart VS Code or reload the VS Code window after changing worker threads.",
9595
"AWS.configuration.description.amazonq.workspaceIndexUseGPU": "Enable GPU to help index your local workspace files. Only applies to Linux and Windows.",
96-
"AWS.configuration.description.amazonq.workspaceIndexMaxSize": "The maximum size of local workspace files to be indexed in MB",
96+
"AWS.configuration.description.amazonq.workspaceIndexMaxSize": "The maximum size of local workspace to be indexed in MB",
97+
"AWS.configuration.description.amazonq.workspaceIndexMaxFileSize": "The maximum size of local workspace files to be indexed in MB",
98+
"AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns": "File patterns to ignore when indexing your workspace files",
99+
"AWS.configuration.description.amazonq.workspaceIndexCacheDirPath": "The path to the directory that contains the cache of the index of your workspace files",
97100
"AWS.configuration.description.amazonq.ignoredSecurityIssues": "Specifies a list of code issue identifiers that Amazon Q should ignore when reviewing your workspace. Each item in the array should be a unique string identifier for a specific code issue. This allows you to suppress notifications for known issues that you've assessed and determined to be false positives or not applicable to your project. Use this setting with caution, as it may cause you to miss important security alerts.",
98101
"AWS.command.apig.copyUrl": "Copy URL",
99102
"AWS.command.apig.invokeRemoteRestApi": "Invoke in the cloud",

packages/core/src/codewhisperer/util/codewhispererSettings.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const description = {
1313
workspaceIndexWorkerThreads: Number,
1414
workspaceIndexUseGPU: Boolean,
1515
workspaceIndexMaxSize: Number,
16+
workspaceIndexMaxFileSize: Number,
17+
workspaceIndexCacheDirPath: String,
18+
workspaceIndexIgnoreFilePatterns: ArrayConstructor(String),
1619
allowFeatureDevelopmentToRunCodeAndTests: Object,
1720
ignoredSecurityIssues: ArrayConstructor(String),
1821
}
@@ -55,7 +58,20 @@ export class CodeWhispererSettings extends fromExtensionManifest('amazonQ', desc
5558

5659
public getMaxIndexSize(): number {
5760
// minimal 1MB
58-
return Math.max(this.get('workspaceIndexMaxSize', 250), 1)
61+
return Math.max(this.get('workspaceIndexMaxSize', 2048), 1)
62+
}
63+
64+
public getMaxIndexFileSize(): number {
65+
// minimal 1MB
66+
return Math.max(this.get('workspaceIndexMaxFileSize', 10), 1)
67+
}
68+
69+
public getIndexCacheDirPath(): string {
70+
return this.get('workspaceIndexCacheDirPath', undefined)
71+
}
72+
73+
public getIndexIgnoreFilePatterns(): string[] {
74+
return this.get('workspaceIndexIgnoreFilePatterns', [])
5975
}
6076

6177
public getAutoBuildSetting(): { [key: string]: boolean } {

packages/core/src/shared/settings-amazonq.gen.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export const amazonqSettings = {
3232
"amazonQ.workspaceIndexWorkerThreads": {},
3333
"amazonQ.workspaceIndexUseGPU": {},
3434
"amazonQ.workspaceIndexMaxSize": {},
35+
"amazonQ.workspaceIndexMaxFileSize": {},
36+
"amazonQ.workspaceIndexCacheDirPath": {},
37+
"amazonQ.workspaceIndexIgnoreFilePatterns": {},
3538
"amazonQ.ignoredSecurityIssues": {}
3639
}
3740

0 commit comments

Comments
 (0)