Author: Evan Seabrook
This is a simple VSCode extension that allows you to summarize code you've selected in your editor window using generative AI.
This extension was built as a personal project to:
- Learn the VSCode Extension ecosystem/API
- Build something practical that utilize's Google's Vertex AI LLM offerings
- Learn some TypeScript
My hope is that it can be helpful to someone and, failing that, I feel I've met all of the goals I've set as motivation -- so it did help me :).
This extension utilizes Vertex AI's
chat-bison LLM and authenticates using your Google Cloud Application Default Credentials. For information on how Google Cloud keeps your data safe, please view their documentation on Vertex AI data governance.
Authentication with GCP
This project utilized Google Cloud's
chat-bison model for summarization. As a result, you will need to install the
gcloud CLI using these instructions.
gcloud is installed, you will need to create a project and set your Application Default Credentials to make use of the extension:
gcloud auth login -update-adc
gcloud CLI, create a GCP project, and set your Application Default Credentials, as covered in the Authentication section above
Upon installing this extension, please navigate to the Extension Settings in VS Code and provide your GCP project and region.
Highlight code that you wish to work with, open the command pallet, and run one of the provided commands:
Summarize highlighted code: Takes the code actively selected in your editor and asks Google’s chat-bison to summarize the code in simple terms, as if it was a senior developer
Make recommendations for highlighted code: Takes the code actively selected in your editor and asks Google’s chat-bison to provide recommendations to improve the code, again through the eyes/context of a senior developer.
To run the extension's tests, use the following command:
npm run test
To build the extension package, run the following:
Note: Due to limitations within VSCode, you will encounter an error if you try to run the tests while having VSCode running. VSCode extension tests create a new instance of VSCode, which causes some sort of IPC conflict. Please ensure you fully quit VSCode before running the tests.
To install the extension locally, please:
- First run the command from the
Build step above
- Navigate to the Extensions view in vscode
- Click on the 3 dotes on the top right of the Extensions view
Install from VSIX and navigate to the
.vsix file created during the build
- Configure Code Summarizer's Extension settings
i. Open VSCode's settings
ii. Navigate to Extensions
iii. Find Code Summarizer and fill in details for your Google Cloud project (view the Requirements section above for more details)
As indicated earlier, this is entirely an exploration project for me to get more familiar with VSCode extensions, TypeScript, etc. I'm unsure how much further I'll take this, but I do have a few things I'd like to tackle in the future:
- Add additional tests -- I only have two right now :(
- Add support for Amazon Bedrock and create configuration to choose which CSP-backed LLM you would like to use
- Add LLM-backed code searching support