Skip to content

Commit b048f97

Browse files
authored
Merge pull request aws#6462 from aws/feature/amazonqLSP
feat(amazonq): Add basic language server support for amazon q inline through flare
2 parents 4459171 + e914a4e commit b048f97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3215
-647
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,32 @@ Example:
427427
}
428428
```
429429

430+
<a name="amazonqLsp-settings">Overrides specifically for the Amazon Q language server</a> can be set using the `aws.dev.amazonqLsp` setting. This is a JSON object consisting of keys/values required to override language server: `manifestUrl`, `supportedVersions`, `id`, and `path`.
431+
432+
Example:
433+
434+
```json
435+
"aws.dev.amazonqLsp": {
436+
"manifestUrl": "https://custom.url/manifest.json",
437+
"supportedVersions": "4.0.0",
438+
"id": "AmazonQ",
439+
"path": "/custom/path/to/local/lsp/folder",
440+
}
441+
```
442+
443+
<a name="amazonqWorkspaceLsp-settings">Overrides specifically for the Amazon Q Workspace Context language server</a> can be set using the `aws.dev.amazonqWorkspaceLsp` setting. This is a JSON object consisting of keys/values required to override language server: `manifestUrl`, `supportedVersions`, `id`, and `path`.
444+
445+
Example:
446+
447+
```json
448+
"aws.dev.amazonqWorkspaceLsp": {
449+
"manifestUrl": "https://custom.url/manifest.json",
450+
"supportedVersions": "4.0.0",
451+
"id": "AmazonQ",
452+
"path": "/custom/path/to/local/lsp/folder",
453+
}
454+
```
455+
430456
### Environment variables
431457

432458
Environment variables can be used to modify the behaviour of VSCode. The following are environment variables that can be used to configure the extension:
@@ -472,6 +498,14 @@ Unlike the user setting overrides, not all of these environment variables have t
472498

473499
- `__CODEWHISPERER_REGION`: for aws.dev.codewhispererService.region
474500
- `__CODEWHISPERER_ENDPOINT`: for aws.dev.codewhispererService.endpoint
501+
- `__AMAZONQLSP_MANIFEST_URL`: for aws.dev.amazonqLsp.manifestUrl
502+
- `__AMAZONQLSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqLsp.supportedVersions
503+
- `__AMAZONQLSP_ID`: for aws.dev.amazonqLsp.id
504+
- `__AMAZONQLSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
505+
- `__AMAZONQWORKSPACELSP_MANIFEST_URL`: for aws.dev.amazonqWorkspaceLsp.manifestUrl
506+
- `__AMAZONQWORKSPACELSP_SUPPORTED_VERSIONS`: for aws.dev.amazonqWorkspaceLsp.supportedVersions
507+
- `__AMAZONQWORKSPACELSP_ID`: for aws.dev.amazonqWorkspaceLsp.id
508+
- `__AMAZONQWORKSPACELSP_PATH`: for aws.dev.amazonqWorkspaceLsp.locationOverride
475509

476510
#### Lambda
477511

docs/TEST_E2E.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,27 @@ With this approach, the follow things can be tested:
1717
- Whether or not certain features show/not show depending on the status of the users auth
1818
- Run requests directly against the backend and see if we get results back
1919
- Clicking any follow up buttons (including examples)
20+
21+
## Flare Chat E2E Test flow (Not implemented yet)
22+
23+
This is the new flow that should be introduced when we moved to Flare chat.
24+
25+
```mermaid
26+
sequenceDiagram
27+
participant test as Test
28+
participant framework as Test Framework
29+
participant ui as Virtual DOM
30+
participant lsp as Language Server
31+
participant mynah as Mynah UI
32+
33+
test->>test: starts
34+
test->>framework: creates test framework
35+
framework->>ui: adds mynah ui to virtual dom
36+
test->>lsp: waits for language server activation
37+
test->>mynah: triggers action on mynah ui
38+
mynah->>framework: sends message
39+
framework->>lsp: sends message
40+
lsp->>framework: gets response
41+
framework->>ui: displays response
42+
test->>ui: assert test expectations
43+
```

docs/lsp.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Flare Language Server
2+
3+
## Chat Activation flow
4+
5+
```mermaid
6+
sequenceDiagram
7+
participant user as User
8+
participant ext as Extension
9+
participant webview as Chat Webview
10+
participant flare as Amazon Q LSP
11+
participant backend as Amazon Q Backend
12+
13+
user->>ext: opens IDE
14+
ext->>ext: activates
15+
ext->>webview: loads UI
16+
ext->>flare: initialize process
17+
flare->>flare: starts and waits
18+
user->>webview: interacts
19+
webview->>ext: sends message
20+
ext->>flare: sends message
21+
flare->>backend: call api
22+
backend->>flare: returns
23+
flare->>ext: display
24+
ext->>webview: display
25+
```
26+
27+
## Language Server Debugging
28+
29+
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project
30+
31+
e.g.
32+
33+
```
34+
/aws-toolkit-vscode
35+
/toolkit
36+
/core
37+
/amazonq
38+
/language-servers
39+
```
40+
41+
2. Inside of the language-servers project run:
42+
```
43+
npm install
44+
npm run compile
45+
npm run package
46+
```
47+
to get the project setup
48+
3. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration
49+
4. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
50+
51+
## Amazon Q Inline Activation
52+
53+
- In order to get inline completion working you must open a supported file type defined in CodewhispererInlineCompletionLanguages in `packages/amazonq/src/app/inline/completion.ts`

package-lock.json

Lines changed: 101 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "(Experimental) Amazon Q inline code suggestions via Amazon Q Language Server. (enable with `aws.experiments.amazonqLSP: true`)"
4+
}

packages/amazonq/.vscode/launch.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"env": {
1515
"SSMDOCUMENT_LANGUAGESERVER_PORT": "6010",
1616
"WEBPACK_DEVELOPER_SERVER": "http://localhost:8080"
17+
// "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js",
1718
},
1819
"envFile": "${workspaceFolder}/.local.env",
1920
"outFiles": ["${workspaceFolder}/dist/**/*.js", "${workspaceFolder}/../core/dist/**/*.js"],
@@ -135,6 +136,31 @@
135136
"group": "4_E2ETestCurrentFile",
136137
"order": 2
137138
}
139+
},
140+
{
141+
"name": "Attach to Language Server",
142+
"type": "node",
143+
"request": "attach",
144+
"port": 6080, // Hard defined in core/src/shared/lsp/platform.ts
145+
"outFiles": ["${workspaceFolder}/../../../language-servers/**/out/**/*.js"],
146+
"skipFiles": [
147+
"<node_internals>/**",
148+
"${workspaceFolder}/../../../language-servers/**/node_modules/**/*.js"
149+
],
150+
"restart": {
151+
"maxAttempts": 10,
152+
"delay": 1000
153+
}
154+
}
155+
],
156+
"compounds": [
157+
{
158+
"name": "Launch LSP with Debugging",
159+
"configurations": ["Extension", "Attach to Language Server"],
160+
"presentation": {
161+
"group": "1_Extension",
162+
"order": 5
163+
}
138164
}
139165
]
140166
}

0 commit comments

Comments
 (0)