Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
14f2659
add settings for workspace context feature
leigaol Mar 21, 2025
9df0b01
rc5
leigaol Mar 21, 2025
ce37759
aggressive sync cred
leigaol Mar 21, 2025
f767505
merge
leigaol Mar 23, 2025
86df670
rc8
leigaol Mar 25, 2025
00bf62c
merge
leigaol Mar 25, 2025
37aeb2b
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into sspc
leigaol Mar 26, 2025
12d7169
get ws id from flare
leigaol Mar 26, 2025
cb16c75
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into sspc
leigaol Mar 27, 2025
b16e0d2
rc 22
leigaol Mar 27, 2025
724308e
merge
leigaol Mar 31, 2025
81597ea
pr
leigaol Mar 31, 2025
9ad7a12
format
leigaol Mar 31, 2025
1a2f2f5
d
leigaol Mar 31, 2025
f71e05b
update
leigaol Mar 31, 2025
5d4b6d9
add message
leigaol Mar 31, 2025
f9433f6
merge
leigaol Apr 1, 2025
836ac80
merge
leigaol Apr 1, 2025
6704a46
update
leigaol Apr 1, 2025
74629c8
update imports:
leigaol Apr 1, 2025
f293cac
minimize changes
leigaol Apr 1, 2025
e596890
minimize changes
leigaol Apr 1, 2025
8194371
update
leigaol Apr 1, 2025
27cf915
merge
leigaol Apr 3, 2025
847cbff
remove settings
leigaol Apr 4, 2025
9387633
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into s…
leigaol Apr 15, 2025
97447cd
endpoint
leigaol Apr 15, 2025
3109971
ws
leigaol Apr 15, 2025
ea8582b
default start for internal
leigaol Apr 17, 2025
c6269e7
merge
leigaol Apr 17, 2025
30a9bfb
add profile update
leigaol Apr 17, 2025
7c31f3a
Merge branch 'master' of github.com:leigaol/aws-toolkit-vscode into s…
leigaol Apr 17, 2025
32009cd
update profile and init profile
leigaol Apr 17, 2025
3a71511
profile support
leigaol Apr 17, 2025
ddb9734
update log
leigaol Apr 17, 2025
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
36 changes: 18 additions & 18 deletions aws-toolkit-vscode.code-workspace
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"folders": [
{
"path": "."
},
{
"path": "packages/toolkit"
},
{
"path": "packages/core"
},
{
"path": "packages/amazonq"
}
],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib"
}
}
"folders": [
{
"path": ".",
},
{
"path": "packages/toolkit",
},
{
"path": "packages/core",
},
{
"path": "packages/amazonq",
},
],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib",
},
}
81 changes: 77 additions & 4 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@
import vscode, { env, version } from 'vscode'
import * as nls from 'vscode-nls'
import * as crypto from 'crypto'
import { LanguageClient, LanguageClientOptions } from 'vscode-languageclient'
import { LanguageClient, LanguageClientOptions, RequestType } from 'vscode-languageclient'
import { InlineCompletionManager } from '../app/inline/completion'
import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
import { Settings, oidcClientName, createServerOptions, globals, Experiments, Commands } from 'aws-core-vscode/shared'
import {
ConnectionMetadata,
CreateFilesParams,
DeleteFilesParams,
DidChangeWorkspaceFoldersParams,
DidSaveTextDocumentParams,
GetConfigurationFromServerParams,
RenameFilesParams,
ResponseMessage,
WorkspaceFolder,
} from '@aws/language-server-runtimes/protocol'
import {
Settings,
oidcClientName,
createServerOptions,
globals,
Experiments,
Commands,
oneSecond,
} from 'aws-core-vscode/shared'
import { activate } from './chat/activation'
import { AmazonQResourcePaths } from './lspInstaller'

Expand Down Expand Up @@ -121,7 +139,7 @@ export async function startLanguageServer(
activate(client, encryptionKey, resourcePaths.ui)
}

const refreshInterval = auth.startTokenRefreshInterval()
const refreshInterval = auth.startTokenRefreshInterval(10 * oneSecond)

toDispose.push(
AuthUtil.instance.auth.onDidChangeActiveConnection(async () => {
Expand All @@ -130,6 +148,61 @@ export async function startLanguageServer(
AuthUtil.instance.auth.onDidDeleteConnection(async () => {
client.sendNotification(notificationTypes.deleteBearerToken.method)
}),
vscode.commands.registerCommand('aws.amazonq.getWorkspaceId', async () => {
const requestType = new RequestType<GetConfigurationFromServerParams, ResponseMessage, Error>(
'aws/getConfigurationFromServer'
)
const workspaceIdResp = await client.sendRequest(requestType.method, {
section: 'aws.q.workspaceContext',
})
return workspaceIdResp
}),
vscode.workspace.onDidCreateFiles((e) => {
client.sendNotification('workspace/didCreateFiles', {
files: e.files.map((it) => {
return { uri: it.fsPath }
Comment on lines +192 to +194
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this event trigger for in-memory (non-file) editors? If so, should those be skipped, since the LSP can't do anything with them unless we send the file contents?

}),
} as CreateFilesParams)
}),
vscode.workspace.onDidDeleteFiles((e) => {
client.sendNotification('workspace/didDeleteFiles', {
files: e.files.map((it) => {
return { uri: it.fsPath }
}),
} as DeleteFilesParams)
}),
vscode.workspace.onDidRenameFiles((e) => {
client.sendNotification('workspace/didRenameFiles', {
files: e.files.map((it) => {
return { oldUri: it.oldUri.fsPath, newUri: it.newUri.fsPath }
}),
} as RenameFilesParams)
}),
vscode.workspace.onDidSaveTextDocument((e) => {
client.sendNotification('workspace/didSaveTextDocument', {
textDocument: {
uri: e.uri.fsPath,
},
} as DidSaveTextDocumentParams)
}),
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
client.sendNotification('workspace/didChangeWorkspaceFolder', {
event: {
added: e.added.map((it) => {
return {
name: it.name,
uri: it.uri.fsPath,
} as WorkspaceFolder
}),
removed: e.removed.map((it) => {
return {
name: it.name,
uri: it.uri.fsPath,
} as WorkspaceFolder
}),
},
} as DidChangeWorkspaceFoldersParams)
}),
{ dispose: () => clearInterval(refreshInterval) }
)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/amazonq/src/lsp/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface ExtendedAmazonQLSPConfig extends LspConfig {
}

export const defaultAmazonQLspConfig: ExtendedAmazonQLSPConfig = {
manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json',
supportedVersions: '^3.1.1',
manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/remoteWorkspaceContext/0/manifest.json',
supportedVersions: '^1.0.0',
Comment on lines +14 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the final URL or will /codewhisperer/ gain the features from the temporary /remoteWorkspaceContext/ artifact (then this version would be 3.x) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is final, to my knowledge.

Copy link

@ege0zcan ege0zcan Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this is the final URL but I imagine we will need to change the URL in the near future because new artifacts are also being built

Copy link
Contributor

@justinmk3 justinmk3 Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name is pretty confusing. this defaultAmazonQLspConfig LSP bundle will be used for all Q features, not only "workspace indexing", right?

will this URL also have the upcoming "agentic chat" capabilities?

id: 'AmazonQ', // used across IDEs for identifying global storage/local disk locations. Do not change.
suppressPromptPrefix: 'amazonQ',
path: undefined,
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/codewhisperer/util/editorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { checkLeftContextKeywordsForJson } from './commonUtil'
import { CodeWhispererSupplementalContext } from '../models/model'
import { getOptOutPreference } from '../../shared/telemetry/util'
import { indent } from '../../shared/utilities/textUtilities'
import { isInDirectory } from '../../shared'
import { AuthUtil } from './authUtil'

let tabSize: number = getTabSizeSetting()
Expand Down Expand Up @@ -83,6 +84,22 @@ export function getFileRelativePath(editor: vscode.TextEditor): string {
return relativePath.substring(0, CodeWhispererConstants.filenameCharsLimit)
}

async function getWorkspaceId(editor: vscode.TextEditor): Promise<string | undefined> {
try {
const workspaceIds: { workspaces: { workspaceRoot: string; workspaceId: string }[] } =
await vscode.commands.executeCommand('aws.amazonq.getWorkspaceId')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a command instead of a plain function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid cyclic dependency. The Flare LSP code was in the packages/amazonq which imports packages/core, but the CW code here is in packages/core.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the command isn't defined? Sometimes there are startup ordering issues which result in "command not found" errors. Using a plain function would avoid that and add confidence.

There are more robust ways of avoiding cyclic dependencies. Commands should be a last resort.

for (const item of workspaceIds.workspaces) {
const path = vscode.Uri.parse(item.workspaceRoot).fsPath
if (isInDirectory(path, editor.document.uri.fsPath)) {
return item.workspaceId
}
}
} catch (err) {
getLogger().warn(`No workspace id found ${err}`)
}
return undefined
}

export async function buildListRecommendationRequest(
editor: vscode.TextEditor,
nextToken: string,
Expand Down Expand Up @@ -121,6 +138,7 @@ export async function buildListRecommendationRequest(
supplementalContexts: supplementalContext,
customizationArn: selectedCustomization.arn === '' ? undefined : selectedCustomization.arn,
optOutPreference: getOptOutPreference(),
workspaceId: await getWorkspaceId(editor),
profileArn: profile?.arn,
},
supplementalMetadata: supplementalContexts,
Expand Down
Loading