From f4b1634a7fd37b927ddd33c3bf2a8d4035288615 Mon Sep 17 00:00:00 2001 From: opieter-aws Date: Thu, 24 Apr 2025 16:40:45 -0400 Subject: [PATCH 1/2] feat(amazonq): Pass project configuration to LSP client --- packages/amazonq/src/lsp/client.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index 3bc5622d837..945cdcf45ec 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -20,7 +20,7 @@ import { updateConfigurationRequestType, WorkspaceFolder, } from '@aws/language-server-runtimes/protocol' -import { AuthUtil, getSelectedCustomization } from 'aws-core-vscode/codewhisperer' +import { AuthUtil, CodeWhispererSettings, getSelectedCustomization } from 'aws-core-vscode/codewhisperer' import { Settings, oidcClientName, @@ -92,7 +92,9 @@ export async function startLanguageServer( customization, optOutTelemetry: getOptOutPreference() === 'OPTOUT', projectContext: { - enableLocalIndexing: true, + enableLocalIndexing: CodeWhispererSettings.instance.isLocalIndexEnabled(), + enableGpuAcceleration: CodeWhispererSettings.instance.isLocalIndexGPUEnabled(), + indexWorkerThreads: CodeWhispererSettings.instance.getIndexWorkerThreads(), }, }, ] @@ -100,12 +102,9 @@ export async function startLanguageServer( if (params.items[0].section === 'aws.codeWhisperer') { return [ { - includeSuggestionsWithCodeReferences: vscode.workspace - .getConfiguration() - .get('amazonQ.showCodeWithReferences'), - shareCodeWhispererContentWithAWS: vscode.workspace - .getConfiguration() - .get('amazonQ.shareContentWithAWS'), + includeSuggestionsWithCodeReferences: + CodeWhispererSettings.instance.isSuggestionsWithCodeReferencesEnabled(), + shareCodeWhispererContentWithAWS: !CodeWhispererSettings.instance.isOptoutEnabled(), }, ] } From 382a94e620574c27e41f0cb6d048d1d9a69517a1 Mon Sep 17 00:00:00 2001 From: opieter-aws Date: Thu, 24 Apr 2025 19:05:22 -0400 Subject: [PATCH 2/2] feat(amazonq): Pass project configuration to LSP client --- packages/amazonq/package.json | 20 ++++++++++++++++++- packages/amazonq/src/lsp/client.ts | 6 ++++++ packages/core/package.nls.json | 5 ++++- .../util/codewhispererSettings.ts | 18 ++++++++++++++++- .../core/src/shared/settings-amazonq.gen.ts | 3 +++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index d9e1d35d624..1d285913708 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -181,7 +181,25 @@ "amazonQ.workspaceIndexMaxSize": { "type": "number", "markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxSize%", - "default": 250, + "default": 2048, + "scope": "application" + }, + "amazonQ.workspaceIndexMaxFileSize": { + "type": "number", + "markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxFileSize%", + "default": 10, + "scope": "application" + }, + "amazonQ.workspaceIndexCacheDirPath": { + "type": "string", + "markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexCacheDirPath%", + "default": null, + "scope": "application" + }, + "amazonQ.workspaceIndexIgnoreFilePatterns": { + "type": "array", + "markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns%", + "default": [], "scope": "application" }, "amazonQ.ignoredSecurityIssues": { diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index 945cdcf45ec..1373c026a9c 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -95,6 +95,12 @@ export async function startLanguageServer( enableLocalIndexing: CodeWhispererSettings.instance.isLocalIndexEnabled(), enableGpuAcceleration: CodeWhispererSettings.instance.isLocalIndexGPUEnabled(), indexWorkerThreads: CodeWhispererSettings.instance.getIndexWorkerThreads(), + localIndexing: { + ignoreFilePatterns: CodeWhispererSettings.instance.getIndexIgnoreFilePatterns(), + maxFileSizeMB: CodeWhispererSettings.instance.getMaxIndexFileSize(), + maxIndexSizeMB: CodeWhispererSettings.instance.getMaxIndexSize(), + indexCacheDirPath: CodeWhispererSettings.instance.getIndexCacheDirPath(), + }, }, }, ] diff --git a/packages/core/package.nls.json b/packages/core/package.nls.json index 9c6ebe66067..81f56a32c57 100644 --- a/packages/core/package.nls.json +++ b/packages/core/package.nls.json @@ -93,7 +93,10 @@ "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'.", "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.", "AWS.configuration.description.amazonq.workspaceIndexUseGPU": "Enable GPU to help index your local workspace files. Only applies to Linux and Windows.", - "AWS.configuration.description.amazonq.workspaceIndexMaxSize": "The maximum size of local workspace files to be indexed in MB", + "AWS.configuration.description.amazonq.workspaceIndexMaxSize": "The maximum size of local workspace to be indexed in MB", + "AWS.configuration.description.amazonq.workspaceIndexMaxFileSize": "The maximum size of local workspace files to be indexed in MB", + "AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns": "File patterns to ignore when indexing your workspace files", + "AWS.configuration.description.amazonq.workspaceIndexCacheDirPath": "The path to the directory that contains the cache of the index of your workspace files", "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.", "AWS.command.apig.copyUrl": "Copy URL", "AWS.command.apig.invokeRemoteRestApi": "Invoke in the cloud", diff --git a/packages/core/src/codewhisperer/util/codewhispererSettings.ts b/packages/core/src/codewhisperer/util/codewhispererSettings.ts index c63de7aa84f..4c30c0df467 100644 --- a/packages/core/src/codewhisperer/util/codewhispererSettings.ts +++ b/packages/core/src/codewhisperer/util/codewhispererSettings.ts @@ -13,6 +13,9 @@ const description = { workspaceIndexWorkerThreads: Number, workspaceIndexUseGPU: Boolean, workspaceIndexMaxSize: Number, + workspaceIndexMaxFileSize: Number, + workspaceIndexCacheDirPath: String, + workspaceIndexIgnoreFilePatterns: ArrayConstructor(String), allowFeatureDevelopmentToRunCodeAndTests: Object, ignoredSecurityIssues: ArrayConstructor(String), } @@ -55,7 +58,20 @@ export class CodeWhispererSettings extends fromExtensionManifest('amazonQ', desc public getMaxIndexSize(): number { // minimal 1MB - return Math.max(this.get('workspaceIndexMaxSize', 250), 1) + return Math.max(this.get('workspaceIndexMaxSize', 2048), 1) + } + + public getMaxIndexFileSize(): number { + // minimal 1MB + return Math.max(this.get('workspaceIndexMaxFileSize', 10), 1) + } + + public getIndexCacheDirPath(): string { + return this.get('workspaceIndexCacheDirPath', undefined) + } + + public getIndexIgnoreFilePatterns(): string[] { + return this.get('workspaceIndexIgnoreFilePatterns', []) } public getAutoBuildSetting(): { [key: string]: boolean } { diff --git a/packages/core/src/shared/settings-amazonq.gen.ts b/packages/core/src/shared/settings-amazonq.gen.ts index 7bd20bc1e78..88324e10475 100644 --- a/packages/core/src/shared/settings-amazonq.gen.ts +++ b/packages/core/src/shared/settings-amazonq.gen.ts @@ -32,6 +32,9 @@ export const amazonqSettings = { "amazonQ.workspaceIndexWorkerThreads": {}, "amazonQ.workspaceIndexUseGPU": {}, "amazonQ.workspaceIndexMaxSize": {}, + "amazonQ.workspaceIndexMaxFileSize": {}, + "amazonQ.workspaceIndexCacheDirPath": {}, + "amazonQ.workspaceIndexIgnoreFilePatterns": {}, "amazonQ.ignoredSecurityIssues": {} }