This Visual Studio Code extension leverages OpenAI's GPT-4 model to refactor your code. It provides an easy and quick way to improve and optimize your code with the power of AI.
- Refactor code using OpenAI's GPT-4 model.
- Easy to use within VSCode.
- Supports a wide range of programming languages (as supported by GPT-4).
-
Install the Extension: Search for "airefactor" in the VSCode Extensions Marketplace and install it.
-
Set API Key:
- After installing the extension, open the Command Palette in VS Code by pressing
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Type Preferences: Open User Settings and select it. This will open the settings.json file.
- In the search bar at the top, type
airefactor.openaiApiKey
to find the setting contributed by your extension. - Enter your OpenAI API key in the input box for the
airefactor.openaiApiKey
setting. - Save the settings.json file and restart VS Code.
- After installing the extension, open the Command Palette in VS Code by pressing
- Open the file you want to refactor in VSCode.
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac) to open the Command Palette. - Type "Refactor me" and select the command.
- The extension will send your selected code (or current file if nothing is selected) to OpenAI's GPT-4 model and replace your current code with the refactored version.
- API Key: The extension requires an OpenAI API key to function. This key must be set in your system's environment variables as
OPENAI_API_KEY
. - Model Configuration: The extension uses the gpt-4 model by default. You can modify the model used by editing the
extension.js
file if necessary.
If you encounter any issues:
- Ensure your OpenAI API key is correctly set in your environment variables.
- Check if the OpenAI API service is operational.
- Restart VSCode if the extension does not appear or work correctly.
For support, please open an issue in the GitHub repository. Contributions are welcome! Feel free to fork the repository and submit pull requests.
MIT
This extension was built using OpenAI's GPT-4 API.