Skip to content

evanseabrook/vscode-code-summarizer

Repository files navigation

code-summarizer

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.

Motiviation

This extension was built as a personal project to:

  1. Learn the VSCode Extension ecosystem/API
  2. Build something practical that utilize's Google's Vertex AI LLM offerings
  3. 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 :).

Security

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.

Once 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

Usage

  1. Install the gcloud CLI, create a GCP project, and set your Application Default Credentials, as covered in the Authentication section above

  2. Upon installing this extension, please navigate to the Extension Settings in VS Code and provide your GCP project and region.

  3. 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.

Tests

To run the extension's tests, use the following command:

npm run test

Build

To build the extension package, run the following:

vsce package

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.

Install Locally

To install the extension locally, please:

  1. First run the command from the Build step above
  2. Navigate to the Extensions view in vscode
  3. Click on the 3 dotes on the top right of the Extensions view
  4. Click Install from VSIX and navigate to the .vsix file created during the build
  5. 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)

Future Development

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:

  1. Add additional tests -- I only have two right now :(
  2. Add support for Amazon Bedrock and create configuration to choose which CSP-backed LLM you would like to use
  3. Add LLM-backed code searching support

About

A simple VSCode Extension for summarizing code using Vertex AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published