Skip to content
Merged
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
3e77bb6
poc
leigaol May 9, 2024
838cda1
POC
leigaol May 9, 2024
c307783
append prompt
leigaol May 9, 2024
f9c96c2
onnx
leigaol May 11, 2024
29a484d
fix prompt
leigaol May 12, 2024
599e5bf
add
leigaol May 13, 2024
d40e8e2
efficient index
leigaol May 15, 2024
80437ae
add pl check; add net install
leigaol May 20, 2024
ded9234
# design
leigaol May 20, 2024
e19b9f6
reload post install
leigaol May 20, 2024
c0d57c2
trying lsp
leigaol May 22, 2024
dddf8c4
lsp server
leigaol May 22, 2024
4cc815b
lsp
leigaol May 22, 2024
f6ecf1c
update lsp server
leigaol May 23, 2024
ae8b534
merge master
leigaol May 28, 2024
2ded01a
@prj
leigaol May 29, 2024
087ea0f
@ws; add settings
leigaol May 30, 2024
8ede30a
telemetry
leigaol May 30, 2024
87927c3
fix conflict
leigaol May 30, 2024
74825de
flip settings
leigaol May 30, 2024
6c6dc5a
add more support file types
leigaol May 30, 2024
b354ea1
open settings
leigaol May 30, 2024
8c0692b
file filter
leigaol May 31, 2024
54f86a3
add unzip
leigaol May 31, 2024
036fc06
disable download
leigaol Jun 1, 2024
b684ffd
add more supported file
leigaol Jun 1, 2024
41e0d91
interact telemetry;did close
leigaol Jun 1, 2024
3e6eba9
199 version; update trigger
leigaol Jun 1, 2024
7ccf87e
add space and \n
leigaol Jun 3, 2024
f867472
1.9.10
leigaol Jun 3, 2024
eea6675
local zip install
leigaol Jun 4, 2024
ba8171c
top N
leigaol Jun 4, 2024
bf6cae4
add telemetry API model change
leigaol Jun 12, 2024
93c4dd1
add hasProjectLevelContext
leigaol Jun 12, 2024
824d262
merge with staging
leigaol Jun 12, 2024
206eac2
remove @ws
leigaol Jun 13, 2024
8b8f81c
add lang translation
leigaol Jun 15, 2024
95f3282
rename
leigaol Jun 15, 2024
55611b5
lsp controller
leigaol Jun 15, 2024
3c63e9e
download login
leigaol Jun 15, 2024
98e6d0d
merge staging
leigaol Jun 15, 2024
f3db2cc
min changes
leigaol Jun 15, 2024
ae71c4e
refactor
leigaol Jun 15, 2024
2e12799
minimize changes
leigaol Jun 15, 2024
634edac
sha match
leigaol Jun 16, 2024
1828f1a
gamma
leigaol Jun 17, 2024
5542aa4
update download mechanism
leigaol Jun 18, 2024
f85e6e0
defaut false
leigaol Jun 18, 2024
570a474
default false
leigaol Jun 18, 2024
6be7812
update
leigaol Jun 19, 2024
28f373e
update
leigaol Jun 19, 2024
fc0d6a0
fix cyclic dep
leigaol Jun 19, 2024
45782bd
telemetry;stdin
leigaol Jun 19, 2024
ab59b0a
encryption of LSP
leigaol Jun 20, 2024
330f2ee
Merge branch 'staging' of github.com:leigaol/aws-toolkit-vscode-stagi…
leigaol Jun 20, 2024
66d36fd
add comments
leigaol Jun 20, 2024
01e9e23
update
leigaol Jun 20, 2024
96fed7b
turn on msg prompt
leigaol Jun 20, 2024
50636f4
cpu metrics
leigaol Jun 24, 2024
87421ce
update version
leigaol Jun 25, 2024
7ea20b4
settings
leigaol Jun 25, 2024
029c251
fix conflict
leigaol Jun 25, 2024
bcfeb40
1.11.4
leigaol Jun 25, 2024
1e72326
open settings
leigaol Jun 26, 2024
a4beebf
env path
leigaol Jun 26, 2024
baedce5
also download node runtime
leigaol Jun 27, 2024
3dc0a76
description update
leigaol Jun 27, 2024
a89a46e
promote version
leigaol Jun 28, 2024
8d49dde
str
leigaol Jun 28, 2024
ef4c883
fix node name in windows
leigaol Jun 28, 2024
2766c6a
node bin name
leigaol Jun 28, 2024
2521bbe
merge
leigaol Jun 28, 2024
aa33fac
try catch
leigaol Jun 28, 2024
d1f52cd
pkg json
leigaol Jun 28, 2024
76175ff
update
leigaol Jun 28, 2024
f992b49
GPU
leigaol Jun 28, 2024
2198637
simplify env var passing
leigaol Jun 30, 2024
fb13b70
fix index memory metrics
leigaol Jul 1, 2024
d35adf6
ignore more files
leigaol Jul 1, 2024
88794c0
add credentialStartUrl to amazonq_indexWorkspace
leigaol Jul 1, 2024
b8223ea
use lsp 0.0.6
leigaol Jul 1, 2024
3de26f3
add LSP download hash unit test
leigaol Jul 2, 2024
74f2b71
add more test cases
leigaol Jul 2, 2024
9647432
merge staging
leigaol Jul 2, 2024
a71a446
fix workspace in the middle bug; fix lsp slow start query bug
leigaol Jul 2, 2024
f52a37e
gpu default false
leigaol Jul 2, 2024
e5e9ce1
fix accidental regression of lsp not starting
leigaol Jul 3, 2024
b27a234
format code
leigaol Jul 3, 2024
902beea
0.0.8 lsp
leigaol Jul 4, 2024
915817d
0.0.9 lsp
leigaol Jul 4, 2024
d5082af
lsp 0.1.0
leigaol Jul 8, 2024
accdbaa
merge mainline
leigaol Jul 8, 2024
fd09a18
add max index size; add debug log for printing which file is used
leigaol Jul 8, 2024
92d32dd
misc
leigaol Jul 8, 2024
6e3311b
remove console.log
leigaol Jul 8, 2024
cdd1a70
add ux for query during indexing
leigaol Jul 8, 2024
5065a60
resolve comments
leigaol Jul 8, 2024
ad183a7
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into p…
leigaol Jul 8, 2024
2fd4784
fix unit test
leigaol Jul 8, 2024
62aaa2b
resolve feedback
leigaol Jul 8, 2024
476b3f7
lint
leigaol Jul 8, 2024
9a0b8fb
more doc string
leigaol Jul 8, 2024
f712f8f
move indexing in progress message inside Q response
leigaol Jul 8, 2024
fdd674d
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into p…
leigaol Jul 9, 2024
71fd65a
fix test cases
leigaol Jul 9, 2024
d792a5f
address some feedback
leigaol Jul 9, 2024
a7733f3
resolve some feedback
leigaol Jul 9, 2024
adda9e2
resolve other feedback
leigaol Jul 9, 2024
194fe25
renamed to workspace index
leigaol Jul 10, 2024
852a879
update change log
leigaol Jul 10, 2024
f8290e0
more robust download, avoid mv file when file already exists; use req…
leigaol Jul 10, 2024
6552e78
use new manifest url
leigaol Jul 10, 2024
5859e32
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into p…
leigaol Jul 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Add LSP for Amazon Q Chat Local Indexing. Customers can use @workspace to ask questions regarding local workspace."
}
24 changes: 24 additions & 0 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@
"markdownDescription": "%AWS.configuration.description.amazonq.shareContentWithAWS%",
"default": true,
"scope": "application"
},
"amazonQ.localWorkspaceIndex": {
"type": "boolean",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndex%",
"default": false,
"scope": "application"
},
"amazonQ.localWorkspaceIndexWorkerThreads": {
"type": "number",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndexWorkerThreads%",
"default": 0,
"scope": "application"
},
"amazonQ.localWorkspaceIndexUseGPU": {
"type": "boolean",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndexUseGPU%",
"default": false,
"scope": "application"
},
"amazonQ.localWorkspaceIndexMaxSize": {
"type": "number",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndexMaxSize%",
"default": 250,
"scope": "application"
}
}
},
Expand Down
51 changes: 51 additions & 0 deletions packages/amazonq/test/unit/amazonq/lsp/lspClient.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as sinon from 'sinon'
import assert from 'assert'
import { globals } from 'aws-core-vscode/shared'
import { LspClient } from 'aws-core-vscode/amazonq'

describe('Amazon Q LSP client', function () {
let lspClient: LspClient
let encryptFunc: sinon.SinonSpy

beforeEach(async function () {
sinon.stub(globals, 'isWeb').returns(false)
lspClient = new LspClient()
encryptFunc = sinon.spy(lspClient, 'encrypt')
})

it('encrypts payload of query ', async () => {
await lspClient.query('mock_input')
assert.ok(encryptFunc.calledOnce)
assert.ok(encryptFunc.calledWith(JSON.stringify({ query: 'mock_input' })))
const value = await encryptFunc.returnValues[0]
// verifies JWT encryption header
assert.ok(value.startsWith(`eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0`))
})

it('encrypts payload of index files ', async () => {
await lspClient.indexFiles(['fileA'], 'path', false)
assert.ok(encryptFunc.calledOnce)
assert.ok(
encryptFunc.calledWith(
JSON.stringify({
filePaths: ['fileA'],
rootPath: 'path',
refresh: false,
})
)
)
const value = await encryptFunc.returnValues[0]
// verifies JWT encryption header
assert.ok(value.startsWith(`eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0`))
})

it('encrypt removes readable information', async () => {
const sample = 'hello'
const encryptedSample = await lspClient.encrypt(sample)
assert.ok(!encryptedSample.includes('hello'))
})

afterEach(() => {
sinon.restore()
})
})
51 changes: 51 additions & 0 deletions packages/amazonq/test/unit/amazonq/lsp/lspController.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import assert from 'assert'
import sinon from 'sinon'
import { Content, LspController } from 'aws-core-vscode/amazonq'
import { createTestFile } from 'aws-core-vscode/test'
import { fs } from 'aws-core-vscode/shared'

describe('Test LSP controller', function () {
it('Downloaded mechanism checks against hash, when hash matches', async function () {
const content = {
filename: 'qserver-linux-x64.zip',
url: 'https://x/0.0.6/qserver-linux-x64.zip',
hashes: [
'sha384:768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9',
],
bytes: 512,
} as Content
const lspController = new LspController()
sinon.stub(lspController, '_download')
const mockFileName = 'test_case_1.zip'
const mockDownloadFile = await createTestFile(mockFileName)
await fs.writeFile(mockDownloadFile.fsPath, 'test')
const result = await lspController.downloadAndCheckHash(mockDownloadFile.fsPath, content)
assert.strictEqual(result, true)
})

it('Verify downloaded mechanism checks against hash, when hash does not match', async function () {
const content = {
filename: 'qserver-linux-x64.zip',
url: 'https://x/0.0.6/qserver-linux-x64.zip',
hashes: [
'sha384:38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b',
],
bytes: 512,
} as Content
const lspController = new LspController()
sinon.stub(lspController, '_download')
const mockFileName = 'test_case_2.zip'
const mockDownloadFile = await createTestFile(mockFileName)
await fs.writeFile(mockDownloadFile.fsPath, 'file_content')
const result = await lspController.downloadAndCheckHash(mockDownloadFile.fsPath, content)
assert.strictEqual(result, false)
})

afterEach(() => {
sinon.restore()
})
})
25 changes: 25 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,30 @@
"markdownDescription": "%AWS.configuration.description.amazonq.shareContentWithAWS%",
"default": true,
"scope": "application"
},
"amazonQ.localWorkspaceIndex": {
"type": "boolean",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndex%",
"default": false,
"scope": "application"
},
"amazonQ.localWorkspaceIndexWorkerThreads": {
"type": "number",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndexWorkerThreads%",
"default": 0,
"scope": "application"
},
"amazonQ.localWorkspaceIndexUseGPU": {
"type": "boolean",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndexUseGPU%",
"default": false,
"scope": "application"
},
"amazonQ.localWorkspaceIndexMaxSize": {
"type": "number",
"markdownDescription": "%AWS.configuration.description.amazonq.localWorkspaceIndexMaxSize%",
"default": 250,
"scope": "application"
}
}
},
Expand Down Expand Up @@ -4118,6 +4142,7 @@
"immutable": "^4.3.0",
"js-yaml": "^4.1.0",
"jsonc-parser": "^3.2.0",
"jose": "5.4.1",
"lodash": "^4.17.21",
"markdown-it": "^13.0.2",
"mime-types": "^2.1.32",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
"AWS.configuration.description.amazonq": "Amazon Q creates a code reference when you insert a code suggestion from Amazon Q that is similar to training data. When unchecked, Amazon Q will not show code suggestions that have code references. If you authenticate through IAM Identity Center, this setting is controlled by your Amazon Q administrator. [Learn More](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-reference.html)",
"AWS.configuration.description.amazonq.shareContentWithAWS": "When checked, your content processed by Amazon Q may be used for service improvement (except for content processed by the Amazon Q Enterprise service tier). Unchecking this box will cause AWS to delete any of your content used for that purpose. The information used to provide the Amazon Q service to you will not be affected. See the [Service Terms](https://aws.amazon.com/service-terms) for more detail.",
"AWS.configuration.description.amazonq.importRecommendation": "Amazon Q will add import statements with inline code suggestions when necessary.",
"AWS.configuration.description.amazonq.localWorkspaceIndex": "This feature is in BETA. When you add @workspace to your question in Amazon Q chat, Amazon Q will index your open 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.localWorkspaceIndexWorkerThreads": "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.localWorkspaceIndexUseGPU": "Enable GPU to help index your local workspace files. Only applies to Linux and Windows.",
"AWS.configuration.description.amazonq.localWorkspaceIndexMaxSize": "The maximum size of local workspace files to be indexed in MB",
"AWS.command.apig.copyUrl": "Copy URL",
"AWS.command.apig.invokeRemoteRestApi": "Invoke on AWS",
"AWS.command.apig.invokeRemoteRestApi.cn": "Invoke on Amazon",
Expand Down
17 changes: 16 additions & 1 deletion packages/core/src/amazonq/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import { listCodeWhispererCommandsWalkthrough } from '../codewhisperer/ui/status
import { Commands, placeholder } from '../shared/vscode/commands2'
import { focusAmazonQPanel, focusAmazonQPanelKeybinding } from '../codewhispererChat/commands/registerCommands'
import { TryChatCodeLensProvider, tryChatCodeLensCommand } from '../codewhispererChat/editor/codelens'
import { LspController } from './lsp/lspController'
import { Auth } from '../auth'
import { telemetry } from '../shared/telemetry'
import { CodeWhispererSettings } from '../codewhisperer/util/codewhispererSettings'
import { debounce } from '../shared/utilities/functionUtils'

export async function activate(context: ExtensionContext) {
const appInitContext = DefaultAmazonQAppInitContext.instance
Expand All @@ -39,6 +42,10 @@ export async function activate(context: ExtensionContext) {

await TryChatCodeLensProvider.register(appInitContext.onDidChangeAmazonQVisibility.event)

const setupLsp = debounce(async () => {
void LspController.instance.trySetupLsp(context)
}, 5000)

context.subscriptions.push(
window.registerWebviewViewProvider(AmazonQChatViewProvider.viewType, provider, {
webviewOptions: {
Expand All @@ -52,14 +59,22 @@ export async function activate(context: ExtensionContext) {
listCodeWhispererCommandsWalkthrough.register(),
focusAmazonQPanel.register(),
focusAmazonQPanelKeybinding.register(),
tryChatCodeLensCommand.register()
tryChatCodeLensCommand.register(),
vscode.workspace.onDidChangeConfiguration(async configurationChangeEvent => {
if (configurationChangeEvent.affectsConfiguration('amazonQ.localWorkspaceIndex')) {
if (CodeWhispererSettings.instance.isLocalIndexEnabled()) {
void setupLsp()
}
}
})
)

Commands.register('aws.amazonq.learnMore', () => {
void vscode.env.openExternal(vscode.Uri.parse(amazonQHelpUrl))
})

await activateBadge()
void setupLsp()
void setupAuthNotification()
}

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/amazonq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export { MessageListener } from './messages/messageListener'
export { AuthController } from './auth/controller'
export { showAmazonQWalkthroughOnce } from './onboardingPage/walkthrough'
export { openAmazonQWalkthrough } from './onboardingPage/walkthrough'

export { LspController, Content } from './lsp/lspController'
export { LspClient } from './lsp/lspClient'
/**
* main from createMynahUI is a purely browser dependency. Due to this
* we need to create a wrapper function that will dynamically execute it
Expand Down
Loading