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 3bc5622d837..1373c026a9c 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,15 @@ export async function startLanguageServer( customization, optOutTelemetry: getOptOutPreference() === 'OPTOUT', projectContext: { - enableLocalIndexing: true, + 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(), + }, }, }, ] @@ -100,12 +108,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(), }, ] } 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": {} }