diff --git a/packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts b/packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts index f8265a4fa86..3875dbbd0f2 100644 --- a/packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts +++ b/packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts @@ -56,6 +56,7 @@ describe('editorContext', function () { const editor = createMockTextEditor('import math\ndef two_sum(nums, target):\n', 'test.py', 'python', 1, 17) const actual = EditorContext.extractContextForCodeWhisperer(editor) const expected: codewhispererClient.FileContext = { + fileUri: 'file:///test.py', filename: 'test.py', programmingLanguage: { languageName: 'python', @@ -76,6 +77,7 @@ describe('editorContext', function () { ) const actual = EditorContext.extractContextForCodeWhisperer(editor) const expected: codewhispererClient.FileContext = { + fileUri: 'file:///test.py', filename: 'test.py', programmingLanguage: { languageName: 'python', @@ -112,6 +114,7 @@ describe('editorContext', function () { const actual = EditorContext.extractContextForCodeWhisperer(editor) const expected: codewhispererClient.FileContext = { + fileUri: editor.document.uri.toString(), filename: 'Untitled-1.py', programmingLanguage: { languageName: 'python', diff --git a/packages/core/src/codewhisperer/client/service-2.json b/packages/core/src/codewhisperer/client/service-2.json index ca57c0f29c6..3e063c38a10 100644 --- a/packages/core/src/codewhisperer/client/service-2.json +++ b/packages/core/src/codewhisperer/client/service-2.json @@ -612,11 +612,20 @@ "filename": { "shape": "FileContextFilenameString" }, + "fileUri": { + "shape": "FileContextFileUriString" + }, "programmingLanguage": { "shape": "ProgrammingLanguage" } } }, + "FileContextFileUriString": { + "type": "string", + "max": 1024, + "min": 1, + "sensitive": true + }, "FileContextFilenameString": { "type": "string", "max": 1024, diff --git a/packages/core/src/codewhisperer/client/user-service-2.json b/packages/core/src/codewhisperer/client/user-service-2.json index 969abf41f1a..714937ed402 100644 --- a/packages/core/src/codewhisperer/client/user-service-2.json +++ b/packages/core/src/codewhisperer/client/user-service-2.json @@ -1852,9 +1852,16 @@ "leftFileContent": { "shape": "FileContextLeftFileContentString" }, "rightFileContent": { "shape": "FileContextRightFileContentString" }, "filename": { "shape": "FileContextFilenameString" }, + "fileUri": { "shape": "FileContextFileUriString" }, "programmingLanguage": { "shape": "ProgrammingLanguage" } } }, + "FileContextFileUriString": { + "type": "string", + "max": 1024, + "min": 1, + "sensitive": true + }, "FileContextFilenameString": { "type": "string", "max": 1024, diff --git a/packages/core/src/codewhisperer/util/editorContext.ts b/packages/core/src/codewhisperer/util/editorContext.ts index 756d9fb2a00..95df5eb509a 100644 --- a/packages/core/src/codewhisperer/util/editorContext.ts +++ b/packages/core/src/codewhisperer/util/editorContext.ts @@ -167,6 +167,7 @@ export function extractContextForCodeWhisperer(editor: vscode.TextEditor): codew } return { + fileUri: editor.document.uri.toString().substring(0, CodeWhispererConstants.filenameCharsLimit), filename: getFileRelativePath(editor), programmingLanguage: { languageName: languageName,