Visual Studio Code OpenAI Code Analyzer
The "vscode-openai-code-analyzer" is a Visual Studio Code extension that uses OpenAI API to analyze and summarize code snippets in various programming languages.
Features
This extension allows you to:
- Select a portion of the code in the editor.
- Call the OpenAI API to analyze and summarize the selected code.
- View the summary in a separate pane with syntax highlighting for the selected code's language.
- Configure the maximum number of tokens for the code summary generated by the OpenAI API.
Requirements
To use this extension, you need an OpenAI API key. Set the OPENAI_API_KEY
environment variable with your API key value. For example:
export OPENAI_API_KEY=sk-...
Usage
- Select the code snippet you want to analyze in the editor.
- Press
Cmd+Shift+P
(Mac) or Ctrl+Shift+P
(Windows/Linux) to open the Command Palette.
- Type "Summarize Code" and press Enter.
The extension will send the selected code to the OpenAI API, and the summary will be displayed in a separate pane.
Configuration
You can configure the maximum number of tokens for the code summary generated by the OpenAI API. To do this, go to the Settings in Visual Studio Code, and update the openaiCodeAnalyzer.maxTokens
option.
Build and Install the Extension
Using Docker
- Make sure you have Docker installed on your machine.
- Set the
OPENAI_API_KEY
environment variable with your API key value.
- Run the
docker_build.sh
script to build the Docker image.
docker_build.sh
- Run the
docker_test.sh
script to test the project.
docker_test.sh
Manually
To build and install the extension locally, follow these steps:
- Clone the repository to your local machine.
git clone https://github.com/NorSoulx/vscode-openai-code-analyzer.git
- Change to the cloned repository directory.
cd vscode-openai-code-analyzer
- Install the required dependencies.
npm install
- Build the extension.
npm run package
This command will generate a .vsix
file in the project directory.
- Install the extension in Visual Studio Code.
- Open Visual Studio Code.
- Press
Cmd+Shift+P
(Mac) or Ctrl+Shift+P
(Windows/Linux) to open the Command Palette.
- Type "Extensions: Install from VSIX..." and press Enter.
- Locate the
.vsix
file generated in step 4 and click "Open" to install the extension.
Known Issues
None at the moment.
Release Notes
1.0.0
- Initial release of the "openai-code-analyzer" extension with support for various programming languages.
Feedback
If you encounter any issues or have any suggestions for improvements, please create an issue on GitHub.
Enjoy using the Visual Studio Code OpenAI Code Analyzer extension!
Example screenshots

