-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(amazonq): implement basic server for standard LSP completion API
- Loading branch information
1 parent
1c38b0c
commit 9f447b2
Showing
9 changed files
with
497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Amazon Q Completions and Device SSO Token server | ||
|
||
This package provides example configuration to produce Amazon Q server implementation bundled with [Language Server Standalone Runtime](https://github.com/aws/language-server-runtimes). | ||
|
||
Language Server contains: | ||
- `SsoAuthServer`: support for Device authentication SSO flow from [`amzn/device-sso-auth-lsp`](../../server/device-sso-auth-lsp/) package. | ||
- `AmazonQCompletionServerToken`: experimental implementation of [Amazon Q Developer Code Completions](../../server/aws-lsp-codewhisperer/src/experimental/README.md) with standard LSP `textDocument/completion` protocol. | ||
- `CodeWhispererServerTokenProxy`: support of Amazon Q `InlineCompletionWithReferences`. | ||
- `QChatServerProxy`: support of Amazon Q Chat server. | ||
|
||
## Installation and usage | ||
|
||
To create compiled bundle run: | ||
```bash | ||
npm run package | ||
``` | ||
|
||
This command will compile package and produce bundled Javascript server in `./out/` directory: | ||
- `./out/completions-with-device-sso.js` - Amazon Q server bundled application. | ||
|
||
To verify compiled bundle can run, you can start it in your shell with NodeJS: | ||
```bash | ||
node ./out/completions-with-device-sso.js --stdio | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@amzn/aws-lsp-q-dev-completions", | ||
"version": "0.0.1", | ||
"description": "Amazon Q Developer Code Completions Language Server", | ||
"main": "out/index.js", | ||
"scripts": { | ||
"clean": "rm -rf out/ bin/ tsconfig.tsbuildinfo", | ||
"compile": "tsc --build", | ||
"package": "npm run compile && npm run webpack", | ||
"webpack": "webpack" | ||
}, | ||
"dependencies": { | ||
"@aws/language-server-runtimes": "^0.2.31", | ||
"@aws/lsp-codewhisperer": "*", | ||
"@amzn/device-sso-auth-lsp": "*" | ||
}, | ||
"devDependencies": { | ||
"ts-loader": "^9.4.4", | ||
"webpack": "^5.94.0", | ||
"webpack-cli": "^5.1.4" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/aws-lsp-q-dev-completions/src/completions-with-device-sso.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { version } from '../package.json' | ||
import { standalone } from '@aws/language-server-runtimes/runtimes' | ||
import { RuntimeProps } from '@aws/language-server-runtimes/runtimes/runtime' | ||
import { AmazonQCompletionServerToken } from '@aws/lsp-codewhisperer/out/experimental/amazonQCompletionServer' | ||
import { | ||
CodeWhispererServerTokenProxy, | ||
QChatServerProxy, | ||
QConfigurationServerTokenProxy, | ||
} from '@aws/lsp-codewhisperer/out/language-server/proxy-server' | ||
import { SsoAuthServer } from '@amzn/device-sso-auth-lsp' | ||
|
||
const props: RuntimeProps = { | ||
version, | ||
servers: [ | ||
SsoAuthServer, | ||
AmazonQCompletionServerToken, | ||
CodeWhispererServerTokenProxy, | ||
QConfigurationServerTokenProxy, | ||
QChatServerProxy, | ||
], | ||
name: 'Amazon Q Developer Completions with Device SSO Token', | ||
} | ||
standalone(props) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.packages.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./out", | ||
"resolveJsonModule": true | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var path = require('path') | ||
|
||
const baseConfig = { | ||
mode: 'development', | ||
output: { | ||
path: __dirname, | ||
filename: 'build/[name].js', | ||
globalObject: 'this', | ||
library: { | ||
type: 'umd', | ||
}, | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.tsx', '.js'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
const completionsWithDeviceSsoConfig = { | ||
...baseConfig, | ||
experiments: { | ||
asyncWebAssembly: true, | ||
}, | ||
entry: { | ||
'amazon-q-completions-and-sso': path.join(__dirname, 'src/completions-with-device-sso.ts'), | ||
}, | ||
resolve: { | ||
...baseConfig.resolve, | ||
}, | ||
target: 'node', | ||
} | ||
|
||
module.exports = [completionsWithDeviceSsoConfig] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# AmazonQCompletionServer | ||
|
||
Simple implementation of Amazon Q code completion through standard LSP `textDocument/completion` protocol. | ||
|
||
## Configuration | ||
|
||
The server can be configured using the following environment variables: | ||
|
||
- `AWS_Q_REGION`: The AWS region for Amazon Q services (default: us-east-1) | ||
- `AWS_Q_ENDPOINT_URL`: The endpoint URL for Amazon Q services | ||
|
||
### LSP Configuration Options | ||
|
||
`AmazonQCompletionServer` supports several LSP configuration options that can be set through the LSP client's `workspace.getConfiguration` protocol: | ||
|
||
1. `aws.q` section: | ||
- `customization`: (string) Sets the customization ARN for Amazon Q. To be used with [`QConfigurationServer`](../language-server/configuration/qConfigurationServer.ts) | ||
- `preselectSuggestionFromQ`: (boolean, default: true) Determines whether suggestions from Amazon Q should be preselected in response from `textDocument/completion`. | ||
|
||
2. `aws.codeWhisperer` section: | ||
- `includeSuggestionsWithCodeReferences`: (boolean, default: true) Controls whether suggestions that include code references should be included in the results. | ||
- `shareCodeWhispererContentWithAWS`: (boolean, default: false) Determines whether the content processed by CodeWhisperer should be shared with AWS for service improvement. | ||
|
||
### Integration | ||
|
||
Example of bundled LSP server available in [`app/aws-lsp-q-dev-completions`](../../../../app/aws-lsp-q-dev-completions/) package. |
Oops, something went wrong.