### Initial Project Setup (Bash) Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Clones the language-servers repository, navigates into the directory, and installs project dependencies using npm. ```bash git clone git@github.com:aws/language-servers.git cd language-servers npm install ``` -------------------------------- ### Language Server Initialization Logs Source: https://github.com/aws/language-servers/blob/main/app/hello-world-lsp-runtimes/README.md Example JSON-RPC messages received when the Runtime and Language Server features are initialized. These logs indicate successful setup and registration of handlers. ```json Content-Length: 127 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Runtime: Initializing runtime without encryption"}} ``` ```json Content-Length: 130 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Runtime: Registering IAM credentials update handler"}} ``` ```json Content-Length: 133 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Runtime: Registering bearer credentials update handler"}} ``` ```json Content-Length: 153 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[2024-05-14T10:16:02.618Z] The Hello World Capability has been initialised"}} ``` -------------------------------- ### Setup Language Server Runtimes for Development Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Installs dependencies for 'language-server-runtimes', creates an npm link, and prepares the runtime output directory for development. This is crucial for using a local checkout. ```bash cd language-server-runtimes && npm install && cd ./runtimes && npm run prepub && cd ./out && npm link ``` -------------------------------- ### Setup VSCode Toolkit Extension for Debugging Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Steps to clone the language-servers repository, install dependencies, and run the watch process to prepare for debugging the AWS Documents Language Server via the VSCode Toolkit Extension. ```Shell git clone git@github.com:aws/language-servers.git cd language-servers npm install npm run watch ``` -------------------------------- ### Create All Runtime Bundles Source: https://github.com/aws/language-servers/blob/main/app/hello-world-lsp-runtimes/README.md Executes the command to produce all runtime bundles for the language server package, including standalone and webworker variants. ```bash npm run bundle ``` -------------------------------- ### Compile Hello World Language Server Source: https://github.com/aws/language-servers/blob/main/app/hello-world-lsp-runtimes/README.md Compiles the Hello World Language Server package before creating runtime bundles. This is a prerequisite step for the bundling process. ```bash cd ./language-servers/server/hello-world-lsp npm run compile ``` -------------------------------- ### Start Development Server for Web Worker Source: https://github.com/aws/language-servers/blob/main/app/aws-lsp-codewhisperer-runtimes/README.md Command to start a webpack development server for validating web worker bundled implementations and language server communication. It serves a basic setup for real-time testing in a browser environment. ```bash npm run start ``` -------------------------------- ### VSCode launch.json Configuration Example Source: https://github.com/aws/language-servers/blob/main/app/aws-lsp-codewhisperer-runtimes/README.md Example of how to update the `launch.json` configuration in VSCode to point to a compiled bundle file for testing the Amazon Q server. It involves changing the `LSP_SERVER` variable. ```javascript { // ... other configurations "env": { "LSP_SERVER": "${workspaceFolder}/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js" } // ... other configurations } ``` -------------------------------- ### Run Standalone Bundle Locally Source: https://github.com/aws/language-servers/blob/main/app/hello-world-lsp-runtimes/README.md Executes the standalone bundle of the Hello World Language Server locally using Node.js. This command is used for testing the bundled output. ```bash node ./out/hello-world-lsp-standalone.js --stdio ``` -------------------------------- ### Install Dependencies Source: https://github.com/aws/language-servers/blob/main/integration-tests/q-agentic-chat-server/README.md Installs the necessary Node.js dependencies for the project using npm. ```bash npm install ``` -------------------------------- ### Install Dependencies for Language Servers Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Installs npm dependencies within the 'language-servers' project directory after setting up the runtimes. ```bash cd ../language-servers && npm install ``` -------------------------------- ### Create Webpack Bundles Source: https://github.com/aws/language-servers/blob/main/app/hello-world-lsp-runtimes/README.md Runs webpack to create Javascript bundled files, which can be used for NodeJS or webworker environments. This command specifically targets the webpack bundling process. ```bash npm run webpack ``` -------------------------------- ### TypeScript Sinon: Basic Stubbing Examples Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Demonstrates basic Sinon.JS usage in TypeScript for stubbing interfaces, objects, and functions. It highlights the importance of explicit typing for stubs and provides examples of stubbing methods and functions. ```TypeScript import { stubInterface } from 'ts-sinon' import { SinonStubbedInstance, SinonStubbedMember, createStubInstance, stub } from 'sinon' // Use to stub interfaces (must explicitly set type in declaration) stubInterface() stub(new MyClass()) // Use to stub objects stub(myFunc) // Use to stub functions // Explicitly typing let myClassStub: SinonStubbedInstance // vs let myClassStub: MyClass // will have an impact on compilation and method completion ``` -------------------------------- ### AWS LSP S3 Language Server Example Source: https://github.com/aws/language-servers/blob/main/README.md An example language server demonstrating S3 bucket name completions. It showcases a concept where IDE extensions can provide credentials to the language server, enabling secure access to AWS resources. ```javascript server/aws-lsp-s3 ``` -------------------------------- ### VSCode Launch Configuration for AWS Language Server Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md An example VSCode launch configuration for debugging the CodeWhisperer language server. It includes environment variables for enabling various features and overriding AWS Q region and endpoint. ```json { "name": "CodeWhisperer Server Token", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceFolder}/client/vscode", "--disable-extensions"], "outFiles": ["${workspaceFolder}/client/vscode/out/**/*.js"], "env": { "LSP_SERVER": "${workspaceFolder}/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js", "ENABLE_INLINE_COMPLETION": "true", "ENABLE_TOKEN_PROVIDER": "true", "ENABLE_CUSTOM_COMMANDS": "true", "ENABLE_CHAT": "true", "ENABLE_CUSTOMIZATIONS": "true", "AWS_Q_REGION": "set_region_here", "AWS_Q_ENDPOINT_URL" : "set_q_endpoint_here" }, "preLaunchTask": "compile" } ``` -------------------------------- ### Test Amazon Q Standalone Server Source: https://github.com/aws/language-servers/blob/main/app/aws-lsp-codewhisperer-runtimes/README.md Commands to test the compiled standalone Amazon Q servers using Node.js. It allows starting either the IAM or token-based server with standard input/output. ```bash node ./out/token-standalone.js --stdio ``` ```bash node ./out/iam-standalone.js --stdio ``` -------------------------------- ### Run WebdriverIO Tests for Web Worker Source: https://github.com/aws/language-servers/blob/main/app/aws-lsp-codewhisperer-runtimes/README.md Command to execute WebdriverIO tests for validating the web worker implementation at runtime. This process includes bundling, starting the development server, running tests in a headless Chrome browser, and stopping the server. ```bash npm run test ``` -------------------------------- ### Enable Developer Profiles in InitializeParams Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/README.md This TypeScript example shows how to signal support for developer profiles during the initialization of the language client by setting the `developerProfiles` flag within `awsClientCapabilities`. ```typescript const params: InitializeParams = { // ... aws: { // ... awsClientCapabilities: { q: { developerProfiles: true } } } } ``` -------------------------------- ### JetBrains LSP Client Integration Source: https://github.com/aws/language-servers/blob/main/README.md A minimal JetBrains IDE extension created to test and integrate with the AWS Language Servers. This client provides a basic integration example for the JetBrains platform. ```javascript client/jetbrains ``` -------------------------------- ### TypeScript Sinon: Stubbing Object Instances Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Provides examples of stubbing object instances using Sinon.JS in TypeScript. It covers creating stubbed instances, using `callThrough()` to execute original functionality, and stubbing methods with specific return values using `createStubInstance` and `returns()`. ```TypeScript let myClassStub: SinonStubbedInstance = stub(new MyClass()) // Do this if you want myFunc() to execute its actual functionality myClassStub.myFunc.callThrough() // Or if you plan to only explicitly stub return values // it is safer/easier to do the following. // Note we are not creating a new instance of MyClass here. let myClassStub: SinonStubbedInstance = createStubInstance(MyClass) myClassStub.myFunc.returns(3) ``` -------------------------------- ### Set Environment Variables for Testing Source: https://github.com/aws/language-servers/blob/main/integration-tests/q-agentic-chat-server/README.md Sets essential environment variables required for running the integration tests, such as SSO token, start URL, profile ARN, and the runtime file path. ```bash export TEST_SSO_TOKEN="your-sso-token" export TEST_SSO_START_URL="your-sso-start-url" export TEST_PROFILE_ARN="your-profile-arn" export TEST_RUNTIME_FILE="/path/to/aws-lsp-codewhisperer.js" ``` -------------------------------- ### VSCode Debugging: Activation File Modification Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Optional step to modify the activation file to use `--inspect-brk` for immediate debugging upon process start, allowing for earlier breakpoint hits. ```TypeScript // Example modification in client/vscode/src/activation.ts (line 81) // Replace '--inspect' with '--inspect-brk' if needed for immediate debugging. ``` -------------------------------- ### Apply Patches to yaml-language-server Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-yaml/README.md This script applies temporary patches to the yaml-language-server dependency during the installation process via the postinstall script in package.json. It targets specific patches for markdown hover settings and unsafe-eval schema validation. ```Shell node patchYamlPackage.js ``` -------------------------------- ### Run Tests from Command Line Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md A simple command to execute the project's tests using npm. ```bash npm test ``` -------------------------------- ### Package and Run Language Server Bundle Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Steps to produce a local server bundle using 'npm run package' and then run the bundle with specific arguments, such as 'token-standalone.js'. It highlights the importance of the '--inspect' flag for debugging. ```bash npm run package ``` ```bash node --inspect=6012 {rootPath}/app/aws-lsp-codewhisperer-runtimes/out/token-standalone.js --nolazy --stdio --pre-init-encryption --set-credentials-encryption-key ``` -------------------------------- ### Create Chat with Configuration Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Demonstrates how to create a chat instance with explicit configuration, including quick actions and disclaimer acknowledgment. ```javascript amazonQChat.createChat(acquireVsCodeApi(), configuration); ``` -------------------------------- ### Clone Language Server Repositories Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Clones the 'language-servers' and 'language-server-runtimes' repositories from GitHub. This is the initial step for local development. ```bash git clone git@github.com:aws/language-servers.git git clone git@github.com:aws/language-server-runtimes.git ``` -------------------------------- ### VSCode Debugging: Launch Extension + Debugging Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Instructions for launching the AWS Language Server within VSCode for debugging. It emphasizes setting the correct `preLaunchTask` in `launch.json` and selecting the appropriate attach configuration. ```JSON { // ... other launch configurations "configurations": [ { "name": "Launch as VSCode Extension + Debugging", "type": "node", "request": "launch", "preLaunchTask": "watch", // or "compile", or unset "program": "${workspaceFolder}/path/to/your/server.js", // Example path "outFiles": ["${workspaceFolder}/out/**/*.js"] }, { "name": "Attach to AWS Documents Language Server", "type": "node", "request": "attach", "port": 9229 // Default Node.js inspect port } ] } ``` -------------------------------- ### Build Language Server Bundles Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Builds the server bundles for the language servers project. This command packages the developed language servers. ```bash npm run package ``` -------------------------------- ### AWS Chat: Get Serialized Chat Request Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests a serialized representation of the current chat session. This event uses the 'aws/chat/getSerializedChat' command and requires GetSerializedChatParams. ```typescript aws/chat/getSerializedChat ``` -------------------------------- ### Run Tests with Jest (npm) Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-partiql/README.md This command executes the tests for the PartiQL LSP server package using Jest. It provides a way to verify the functionality and correctness of the server. ```bash npm run test ``` -------------------------------- ### Run CodeWhisperer Server with Token Credentials Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Instructions to run the CodeWhisperer Server using token credentials within an IDE, including setting breakpoints and checking logs. It also mentions troubleshooting common authorization errors. -------------------------------- ### Build and Clean Project (Bash) Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Commands to clean the build artifacts and then compile the project. Useful for recompiling after switching branches. ```bash npm run clean npm run compile ``` -------------------------------- ### VS Code Command to Clear AWS Credentials from LSP Server Source: https://github.com/aws/language-servers/blob/main/client/vscode/README.md Provides examples of VS Code commands used to simulate the removal of AWS credentials from an LSP server. `awslsp.clearProfile` is for SigV4 credentials, and `awslsp.clearBearerToken` is for bearer tokens. These commands are essential for managing the state of credentials within the server. ```TypeScript // Example command registration for clearing SigV4 profile context.subscriptions.push( vscode.commands.registerCommand('awslsp.clearProfile', () => { // Logic to notify server to clear SigV4 credentials // e.g., client.sendNotification('aws/credentials/clearSigv4'); vscode.window.showInformationMessage('SigV4 profile cleared.'); }) ); // Example command registration for clearing bearer token context.subscriptions.push( vscode.commands.registerCommand('awslsp.clearBearerToken', () => { // Logic to notify server to clear bearer token // e.g., client.sendNotification('aws/credentials/clearBearerToken'); vscode.window.showInformationMessage('Bearer token cleared.'); }) ); ``` -------------------------------- ### Local Build for Agent-Standalone Server and Chat-Client Source: https://github.com/aws/language-servers/blob/main/app/aws-lsp-codewhisperer-runtimes/README.md A shortcut command to generate a packaged build for the agent-standalone server and chat-client, simplifying integration testing. This command should be run within the 'app/aws-lsp-codewhisperer-runtimes' directory. ```bash npm run local-build ``` -------------------------------- ### AWS Chat: Options Configuration Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Configures the startup options for the chat interface. The 'chatOptions' event uses ChatOptions to define various settings. ```typescript chatOptions ``` -------------------------------- ### Link Local Language Server Runtimes Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Links the locally developed 'language-server-runtimes' package into the 'language-servers' project using npm link. This ensures the language server uses the local version. ```bash npm link @aws/language-server-runtimes ``` -------------------------------- ### Testing with Mocha, Chai, and Sinon Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Information about the testing modules used in the project, including Mocha for the testing framework, Chai for assertions, and Sinon for stubs, mocks, and spies. It also explains the design principle of dependency injection for testing. -------------------------------- ### Troubleshooting Local Language Server Runtimes Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md A comprehensive set of commands to clean, reinstall, compile, and link dependencies for both language-server-runtimes and language-servers projects. This is a forceful reset for when local linking issues arise. ```bash # From language-server-runtimes npm run clean && npm install && npm -ws install && npm run compile && npm -ws run prepub --if-present # From language-servers npm run clean && rm -fr node_modules && rm -fr server/aws-lsp-codewhisperer/node_modules npm install && npm -ws install && npm link @aws/language-server-runtimes @aws/language-server-runtimes-types && npm run compile -- --force ``` -------------------------------- ### Run CodeWhisperer Server with IAM Credentials Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Instructions to run the CodeWhisperer Server using IAM credentials, detailing the command to choose and send credentials profiles to the LSP server. It also references documentation for IAM credential configuration. -------------------------------- ### Run Integration Tests Source: https://github.com/aws/language-servers/blob/main/integration-tests/q-agentic-chat-server/README.md Executes the integration tests for the AWS Q Agentic Chat Language Server using the npm test-integ script. ```bash npm run test-integ ``` -------------------------------- ### Package Amazon Q Language Server Source: https://github.com/aws/language-servers/blob/main/app/aws-lsp-codewhisperer-runtimes/README.md Command to compile the package and produce bundled Javascript programs for Amazon Q servers. It generates IAM and token-based standalone servers in the './out/' directory. ```bash npm run package ``` -------------------------------- ### Fetch Amazon Q Configurations Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/README.md This TypeScript code demonstrates how to use the language client to send a request to fetch Amazon Q configurations from the QConfigurationServer. It shows fetching all configurations or specific ones like customizations. ```typescript await languageClient.sendRequest(getConfigurationFromServerRequestType.method, { section: 'aws.q', }) ``` ```typescript await languageClient.sendRequest(getConfigurationFromServerRequestType.method, { section: 'aws.q.customizations', }) ``` -------------------------------- ### Update PartiQL Parser Binary (npm) Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-partiql/README.md This command updates the WebAssembly binary used by the PartiQL LSP server. It involves running a Docker container to pull the PartiQL playground repository, build the parser, encode it as base64 in a TypeScript file, and finally transpile it to JavaScript. ```bash npm run update-parser-binary ``` -------------------------------- ### Request Prompt Creation in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Initiates a request to create a new prompt in the AWS chat. `CreatePromptParams` are used to specify the details for prompt creation. ```typescript aws/chat/createPrompt ``` -------------------------------- ### Open Settings Request Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Handles requests to open settings within the chat client. It uses OpenSettingsParams for its parameters. ```typescript onOpenSettings: (params: OpenSettingsParams) => void; ``` -------------------------------- ### Run Language Server Application (Node.js) Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Executes a specific language server application bundle using Node.js with the stdio transport protocol. ```javascript node ./app/aws-lsp-codewhisperer-binary/aws-lsp-codewhisperer-token-binary.js --stdio ``` -------------------------------- ### Create Yaml Language Server Instance Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-yaml/README.md This function is responsible for creating and returning a new instance of the DEXP Language Server, specifically for YAML. ```JavaScript function CreateYamlLanguageServer() { // Implementation details for creating a new DEXP Language Server instance } ``` -------------------------------- ### TypeScript Sinon: Stubbing Interfaces Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Illustrates how to stub interfaces in TypeScript using `ts-sinon`'s `stubInterface` function. It shows how to create a stubbed interface and define return values for its methods. ```TypeScript // Note the need for `ts-sinon.stubInterface()` to stub interfaces. // `sinon` does not provide the ability to stub interfaces. let myInterfaceStub: SinonStubbedInstance = stubInterface() myInterfaceStub.someFunctionItDefined.returns('my value') ``` -------------------------------- ### Open File Dialog Request Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests to open a file dialog for user selection. It uses OpenFileDialogParams. ```typescript onOpenFileDialogClick: (params: OpenFileDialogParams) => void; ``` -------------------------------- ### Update ANTLR Lexer and Parser (npm) Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-partiql/README.md This command updates the ANTLR lexer and parser grammars. The generated files in `src/antlr-generated` are automatically created from the grammar files located in `src/antlr-grammar`. ```bash npm run update-antlr ``` -------------------------------- ### Send Quick Action Command in AWS Language Server Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Sends a quick action command to the server, allowing for predefined actions to be triggered. This event uses QuickActionParams to specify the command details. ```typescript interface QuickActionParams { actionId: string; // other potential properties like arguments, etc. } ``` -------------------------------- ### Visual Studio LSP Client Integration Source: https://github.com/aws/language-servers/blob/main/README.md A minimal Visual Studio extension developed for testing and integrating with the AWS Language Servers. This client serves as a sample integration for the Visual Studio IDE. ```javascript client/visualStudio ``` -------------------------------- ### LSP Client Settings Configuration Source: https://github.com/aws/language-servers/blob/main/client/visualStudio/README.md This JSON configuration file, LspClientSettings.json, is used to enable diagnostic tracing for the LSP client within Visual Studio. By setting 'enableTrace' to 'messages', all communication between the client and server will be logged, aiding in debugging. ```JSON { "enableTrace": "messages" } ``` -------------------------------- ### Update web-tree-sitter WASM (npm) Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-partiql/README.md This command updates the `tree-sitter.wasm` file within the `web-tree-sitter` package. It compiles the WASM file into a base64 string embedded in a TypeScript file, specifically `tree-sitter-inline.ts`. ```bash npm run update-treesitter-wasm ``` -------------------------------- ### Visual Studio Extension for AWS Documents LSP Client Source: https://github.com/aws/language-servers/blob/main/client/visualStudio/README.md This C# code represents a Visual Studio extension designed to integrate with the AWS Documents Language Server Protocol (LSP) client. It activates for .yml and .yaml files, enabling features like hover, validation, and autocompletion. The extension requires a compiled LSP service executable. ```C# using Microsoft.VisualStudio.Shell; using System; using System.Runtime.InteropServices; using System.Threading; using Task = System.Threading.Tasks.Task; namespace IdesLspPoc { /// /// This is the class that activates the extension. /// [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] [ProvideAutoLoad(UIContextGuids88.SolutionExists)] [ProvideAutoLoad(UIContextGuids88.NoSolution)] [Guid(IdesLspPocPackage.PackageGuidString)] public sealed class IdesLspPocPackage : AsyncPackage { /// /// IdesLspPocPackage GUID string. /// public const string PackageGuidString = "00000000-0000-0000-0000-000000000000"; /// /// Initialization of the package; this method is called right after the package is loaded. /// /// A cancellation token to monitor for initiation cancellation. /// A task that represents the asynchronous operation. protected override async Task InitializeAsync(CancellationToken cancellationToken) { await JoinableTaskFactory.SwitchToMainThreadAsync(); } } } ``` -------------------------------- ### List Rules Request Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests to list available rules within the workspace. It utilizes ListRulesParams for the request. ```typescript listRules: (params: ListRulesParams) => void; ``` -------------------------------- ### Conventional Commit Message Format Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Defines the standard structure for commit messages, including type, optional scope, description, and optional body/footers. This format aids in automated changelog generation and semantic versioning. ```Conventional Commits ([optional scope]): [optional body] [optional footer(s)] ``` ```Conventional Commits docs: correct spelling of CHANGELOG ``` ```Conventional Commits feat(amazonq): allow provided config object to extend other configs BREAKING CHANGE: `extends` key in config file is now used for extending other config files ``` -------------------------------- ### TypeScript Sinon: Stubbing Functions Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Demonstrates how to stub standalone functions in TypeScript using Sinon.JS. It includes defining a function type, stubbing the function, and using `callThrough()` and explicit typing with `SinonStubbedMember`. ```TypeScript interface myFuncInterface { (x: string): string } myFunc: myFuncInterface = (x: string) => { return x } // Note `SinonStubedMember` instead of `SinonStubbedInstance` for functions const myFuncStub: SinonStubbedMember = stub(myFunc) // Must explicitly type with `SinonStubbedMember` on assignment for this to pass linting myFuncStub.callThrough() ``` -------------------------------- ### Configure Proxy for CodeWhisperer Server Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/README.md This snippet shows how to set environment variables to configure the CodeWhisperer server to use a proxy. It demonstrates setting both HTTPS_PROXY and https_proxy with and without authentication. ```bash export HTTPS_PROXY=https://proxy.example.com:5678 export https_proxy=https://proxy.example.com:5678 ``` ```bash export HTTPS_PROXY=http://username:password@proxy.example.com:5678 export https_proxy=http://username:password@proxy.example.com:5678 ``` -------------------------------- ### Request Copy to Clipboard in AWS Language Server Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests to copy specified code content to the system clipboard. This event uses CopyCodeToClipboardParams to define the text to be copied. ```typescript interface CopyCodeToClipboardParams { text: string; } ``` -------------------------------- ### AWS Chat: Send To Prompt Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Sends selected content to a prompt for processing. This event uses the 'sendToPrompt' command and requires SendToPromptParams to specify the content and context. ```typescript sendToPrompt ``` -------------------------------- ### VS Code LSP Client Integration Source: https://github.com/aws/language-servers/blob/main/README.md A minimal VS Code extension designed to test and integrate with the AWS Language Servers. It demonstrates how to connect an IDE client to the language server protocol for enhanced development features. ```typescript client/vscode ``` -------------------------------- ### Configure Auth Language Server Initialization Options Source: https://github.com/aws/language-servers/blob/main/server/device-sso-auth-lsp/README.md Defines the structure for initialization options passed during the LSP handshake. It includes an optional `tokenCacheLocation` to specify where SSO authentication and refresh tokens should be cached. ```typescript interface InitializeParams { initializationOptions: { // Path to writable directory to store SSO auth and refresh token cache // Default: $HOMEDIR/.aws/device-sso-lsp/cache tokenCacheLocation?: string } } ``` -------------------------------- ### Launch AWS LSP Server in VS Code Source: https://github.com/aws/language-servers/blob/main/client/vscode/README.md This snippet explains how to launch a specific AWS Language Server Protocol (LSP) server within a VS Code extension. The server to be launched is determined by the `LSP_SERVER` environment variable, which should point to the JavaScript file that the `node` process will execute. ```Shell export LSP_SERVER= ``` -------------------------------- ### Core AWS LSP Support Libraries Source: https://github.com/aws/language-servers/blob/main/README.md This package contains essential supporting libraries utilized by both the application and server packages within the AWS Language Server monorepo. It provides foundational code for various language server functionalities. ```javascript core/aws-lsp-core ``` -------------------------------- ### AWS Chat: List Rules Response Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Provides a response containing a list of workspace rules to the UI. This event uses the 'aws/chat/listRules' command and expects a ListRulesResult. ```typescript aws/chat/listRules ``` -------------------------------- ### VS Code Command to Select AWS Credentials Profile Source: https://github.com/aws/language-servers/blob/main/client/vscode/README.md Demonstrates the VS Code command `awslsp.selectProfile` used to simulate pushing SigV4 credentials to an AWS LSP server. This command prompts the user for a profile name, resolves its credentials from the shared credentials file, and sends them to the server. It currently supports basic access key-secret key credential types. ```TypeScript // Example command registration in VS Code extension context.subscriptions.push( vscode.commands.registerCommand('awslsp.selectProfile', async () => { const profile = await vscode.window.showInputBox({ prompt: 'Enter AWS profile name' }); if (profile) { // Logic to resolve credentials and send to LSP server // e.g., client.sendNotification('aws/credentials/sigv4', { profile }); vscode.window.showInformationMessage(`Profile ${profile} credentials sent.`); } }) ); // Corresponding command in package.json // { // "command": "awslsp.selectProfile", // "title": "AWS LSP - Choose credentials profile, resolve, and send to LSP Server" // } ``` -------------------------------- ### AWS Chat: Send Context Commands Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Sends context-aware commands to the UI, enabling actions based on the current context. It uses the 'aws/chat/sendContextCommands' command and ContextCommandParams. ```typescript aws/chat/sendContextCommands ``` -------------------------------- ### AWS Chat: Generic Command Execution Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Allows for the execution of generic commands within the chat interface. The 'genericCommand' event requires GenericCommandParams to define the command and its arguments. ```typescript genericCommand ``` -------------------------------- ### Define Chat Event Structure in TypeScript Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Defines the structure for events exchanged between the chat client and host applications. It includes a command string and associated parameters, facilitating structured communication. ```TypeScript interface SomeEvent { command: string; params: SomeOptions; } ``` -------------------------------- ### AWS LSP Buildspec Language Server Source: https://github.com/aws/language-servers/blob/main/README.md This language server provides support for CodeBuild buildspec files by wrapping a JSON Schema. It enables features like syntax highlighting, autocompletion, and validation for buildspec configurations within IDEs. ```javascript app/aws-lsp-buildspec-runtimes ``` ```javascript server/aws-lsp-buildspec ``` -------------------------------- ### Enable Debug Output Source: https://github.com/aws/language-servers/blob/main/integration-tests/q-agentic-chat-server/README.md Optionally enables debug output for the tests by setting the DEBUG environment variable. ```bash export DEBUG = true ``` -------------------------------- ### Add Pinned Context Request Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Handles requests to add context that should be pinned in the chat. It uses PinnedContextParams. ```typescript onAddPinnedContext: (params: PinnedContextParams) => void; ``` -------------------------------- ### AWS Chat: Conversation Click Action Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Handles user interactions with conversations, such as clicks or actions, and returns the result of the executed action. It uses the 'aws/chat/conversationClick' command and ConversationClickResult. ```typescript aws/chat/conversationClick ``` -------------------------------- ### TypeScript Sinon: Resetting Stub Behavior Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md Explains how to reset stub behavior in Sinon.JS, specifically when `callThrough()` has been used and a custom return value is needed. It shows the sequence of calling `resetBehaviour()` before `returns()`. ```TypeScript const myStubbedFunc = stub() myStubbedFunc.callThrough() myStubbedFunc.resetBehaviour() myStubbedFunc.returns() ``` -------------------------------- ### Default AWS Q Endpoint and Region Constants Source: https://github.com/aws/language-servers/blob/main/CONTRIBUTING.md TypeScript constants defining the default AWS Q endpoint URL and region used by the language server. These are typically overridden via environment variables. ```typescript export const DEFAULT_AWS_Q_ENDPOINT_URL = 'https://codewhisperer.us-east-1.amazonaws.com/' export const DEFAULT_AWS_Q_REGION = 'us-east-1' ``` -------------------------------- ### Notify Auth Follow-Up Clicked in AWS Language Server Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Notifies when an authentication follow-up action has been clicked by the user. This event uses AuthFollowUpClickedParams to provide context about the clicked action. ```typescript interface AuthFollowUpClickedParams { actionId: string; // potentially other context like correlationId } ``` -------------------------------- ### Notify File Click in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Notifies when a file is clicked within the AWS chat interface. `FileClickParams` are used to provide information about the clicked file. ```typescript aws/chat/fileClick ``` -------------------------------- ### Execute ssoAuth/authDevice/getToken Command Source: https://github.com/aws/language-servers/blob/main/server/device-sso-auth-lsp/README.md Initiates the SSO Device Authentication flow when the `ssoAuth/authDevice/getToken` command is invoked. It allows specifying an Identity Provider URL and caches the resolved bearer token for future refreshes. ```typescript { /** * Command identifier */ command: "ssoAuth/authDevice/getToken", arguments?: { /** * Identity provide URL for authentication. Defaults to 'https://view.awsapps.com/start', if not set. */ startUrl?: string } } ``` -------------------------------- ### AWS LSP CodeWhisperer Language Server Source: https://github.com/aws/language-servers/blob/main/README.md This language server integrates AWS CodeWhisperer to provide code recommendations directly within IDEs. It surfaces suggestions through completion lists and as ghost text, improving developer productivity. ```javascript server/aws-lsp-codewhisperer ``` -------------------------------- ### Notify UI Ready in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Indicates that the user interface for the AWS chat is ready to receive interactions. This event does not have specific parameters beyond its occurrence. ```typescript aws/chat/ready ``` -------------------------------- ### Send Chat Prompt to Server in AWS Language Server Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Sends a chat prompt to the server for processing. This event utilizes ChatParams to define the structure of the prompt data. ```typescript interface ChatParams { prompt: string; // other potential properties like conversationId, etc. } ``` -------------------------------- ### Request Insert to Cursor Position in AWS Language Server Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests to insert code at the current cursor position in the editor. This event uses InsertToCursorPositionParams to specify the content and location for insertion. ```typescript interface InsertToCursorPositionParams { text: string; // potentially cursor position details if not implicit } ``` -------------------------------- ### YAML Language Service Features Source: https://github.com/aws/language-servers/blob/main/server/aws-lsp-yaml/README.md The YAML language service provides essential language features for YAML files, including hover information, code completion, diagnostic reporting, and formatting. ```JavaScript class YamlLanguageService { // Methods for hover, completion, diagnostics, formatting } ``` -------------------------------- ### AWS Chat: Open Tab Request Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests to open a new tab in the UI. If no tabId is provided, a new tab is created. It uses the 'aws/chat/openTab' command and requires an OpenTabParams object, which includes a requestID for correlation. ```typescript aws/chat/openTab ``` -------------------------------- ### Notify Source Link Click in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Triggers a notification when a source link is clicked in the AWS chat. `SourceLinkClickParams` are used to provide context for the click event. ```typescript aws/chat/sourceLinkClick ``` -------------------------------- ### Notify Info Link Click in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Informs the system about an information link click within the AWS chat. This event is accompanied by `InfoLinkClickParams`. ```typescript aws/chat/infoLinkClick ``` -------------------------------- ### Notify Follow-up Click in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Notifies when a follow-up suggestion is clicked in the AWS chat interface. This event is associated with `FollowUpClickParams` for detailed information. ```typescript aws/chat/followUpClick ``` -------------------------------- ### VS Code Command to Resolve Bearer Token for AWS LSP Server Source: https://github.com/aws/language-servers/blob/main/client/vscode/README.md Illustrates the VS Code command `awslsp.resolveBearerToken` for simulating the pushing of bearer tokens to an AWS LSP server. This command initiates an SSO login flow, similar to the AWS Toolkit for VS Code, and upon successful authentication, the obtained bearer token is sent to the server. ```TypeScript // Example command registration in VS Code extension context.subscriptions.push( vscode.commands.registerCommand('awslsp.resolveBearerToken', async () => { // Logic to initiate SSO login flow and get bearer token // const token = await ssoLoginFlow(); const token = "mock_bearer_token"; // Placeholder for actual token if (token) { // Logic to send bearer token to LSP server // e.g., client.sendNotification('aws/credentials/bearerToken', { token }); vscode.window.showInformationMessage('Bearer token sent.'); } }) ); // Corresponding command in package.json // { // "command": "awslsp.resolveBearerToken", // "title": "AWS LSP - Resolve and send bearer token" // } ``` -------------------------------- ### Rule Click Notification Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Notifies when a rule is clicked in the chat interface. It uses RuleClickParams for event data. ```typescript onRuleClick: (params: RuleClickParams) => void; ``` -------------------------------- ### Implement AwsLanguageService Interface Source: https://github.com/aws/language-servers/blob/main/ARCHITECTURE.md Language services are created by implementing the AwsLanguageService interface. This interface is designed to align with VS Code language server interfaces, leveraging VS Code LSP libraries for Typescript code. ```TypeScript interface AwsLanguageService { // Methods for language support } ``` -------------------------------- ### Request Conversation List in AWS Chat Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Requests a list of conversations, potentially with a filter applied. `ListConversationsParams` specify the criteria for listing conversations. ```typescript aws/chat/listConversations ``` -------------------------------- ### AWS Chat: List Conversations Response Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Provides a response containing a list of historical conversations to the UI. This event uses the 'aws/chat/listConversations' command and expects a ListConversationsResult. ```typescript aws/chat/listConversations ``` -------------------------------- ### AWS Chat: Chat Options Update Source: https://github.com/aws/language-servers/blob/main/chat-client/README.md Sends an update to the chat options from the server to the client. This event uses the 'aws/chat/chatOptionsUpdate' command and ChatOptionsUpdateParams. ```typescript aws/chat/chatOptionsUpdate ```