Skip to content

Commit

Permalink
feat(chat): add VSCode Copilot MongoDB chat participant VSCODE-528
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Sep 30, 2024
2 parents a7dbbb1 + 547e455 commit 16c4204
Show file tree
Hide file tree
Showing 62 changed files with 8,786 additions and 483 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
out
dist
scripts
src/vscode-dts
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ module.exports = {
'error',
{ prefer: 'type-imports' },
],
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowHigherOrderFunctions: true,
},
],
},
parserOptions: {
project: ['./tsconfig.json'], // Specify it only for TypeScript files.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/actions/test-and-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ runs:
shell: bash

- name: Run Tests
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: |
npm run test
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ constants.json
.env
.eslintcache
.sbom
src/test/ai-accuracy-tests/test-results.html
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ npm run watch

2. Inside of [VS Code Insiders](https://code.visualstudio.com/insiders/) open this directory and press `F5` to begin debugging the extension. This should launch a new VSCode window which is running the extension.

### Using Proposed API

The vscode extension will occasionally need to use [proposed API](https://code.visualstudio.com/api/advanced-topics/using-proposed-api) that haven't been promoted to stable yet. To enable an API proposal, add it to the `enabledApiProposals` section in `package.json`, then run `cd src/vscode-dts && npx @vscode/dts dev` to install the type definitions for the API you want to enable.

**Note**: Using proposed API is only possible during local development and will prevent publishing the extension.

#### Code Tour

- `out` Compiled extension code
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ Connect to Atlas Stream Processing instances and develop stream processors using

![Atlas Stream Processing Playground](resources/screenshots/atlas-stream-processing.png)

### MongoDB Copilot Participant

Use natural language to interact with your clusters and generate MongoDB-related code with GitHub Copilot Chat in VS Code.

_Note: To use the MongoDB Participant, you must have the [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) extension. By using Copilot Chat you agree to [GitHub Copilot chat preview terms](https://docs.github.com/en/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-chat-in-your-ide). Find more details about the MongoDB GenAI Features in the [FAQ](https://www.mongodb.com/docs/generative-ai-faq/)._

#### How to use the MongoDB Participant

1. Enter `@MongoDB` in the chat input field to start a conversation with the MongoDB Participant.

![MongoDB Participant](resources/screenshots/mongodb-participant.png)

2. Start typing `/` in the chat window to get the list of available chat participant commands.

![MongoDB Participant Commands](resources/screenshots/mongodb-participant-commands.png)

- `/docs` is a participant command that finds answers to coding-related questions in the [MongoDB documentation](https://www.mongodb.com/docs/).
- `/query` is a participant command that generates MongoDB queries from natural language to be used with a connected MongoDB cluster. It generates both queries and aggregations depending on the complexity of the request. It utilizes schema to reduce model hallucinations. It provides a code action to open generated code in a playground and an action to directly run the code from the Copilot chat interface.
- `/schema` is a participant command that analyzes and returns information about a collection's schema.

## Extension Settings

Expand All @@ -88,6 +107,8 @@ Connect to Atlas Stream Processing instances and develop stream processors using
| `mdb.showMongoDBHelpExplorer` | Show or hide the MongoDB Help panel. | `true` |
| `mdb.defaultLimit` | The number of documents to fetch when viewing documents from a collection. | `10` |
| `mdb.confirmRunAll` | Show a confirmation message before running commands in a playground. | `true` |
| `mdb.confirmRunCopilotCode` | Show a confirmation message before running code generated by the MongoDB participant. | `true` |
| `mdb.useSampleDocsInCopilot` | Enable sending sample field values with the VSCode copilot chat @MongoDB participant /query command. | `false` |
| `mdb.confirmDeleteDocument` | Show a confirmation message before deleting a document in the tree view. | `true` |
| `mdb.persistOIDCTokens` | Remain logged in when using the MONGODB-OIDC authentication mechanism for MongoDB server connection. Access tokens are encrypted using the system keychain before being stored. | `true` |
| `mdb.showOIDCDeviceAuthFlow` | Opt-in and opt-out for diagnostic and telemetry collection. | `true` |
Expand All @@ -97,6 +118,8 @@ Connect to Atlas Stream Processing instances and develop stream processors using
| `mdb.useDefaultTemplateForPlayground` | Choose whether to use the default template for playground files or to start with an empty playground editor. | `true` |
| `mdb.uniqueObjectIdPerCursor` | The default behavior is to generate a single ObjectId and insert it on all cursors. Set to true to generate a unique ObjectId per cursor instead. | `false` |
| `mdb.sendTelemetry` | Opt-in and opt-out for diagnostic and telemetry collection. | `true` |
| `mdb.confirmRunCopilotCode` | Show a confirmation message before running code generated by the MongoDB participant. | `true` |
| `mdb.useSampleDocsInCopilot` | Enable sending sample field values with the VSCode copilot chat @MongoDB participant /query command. | `false` |

## Additional Settings

Expand Down
Loading

0 comments on commit 16c4204

Please sign in to comment.