Warning
You are now at beta version of CoEdPilot extension. We will release better backend models and more features at the version. The design does not strictly follow the content of the CoedPilot paper. If you have any questions or suggestions, please feel free to raise an issue.
CoEdPilot is a Visual Studio Code extension that features automatic code edit recommendations, proposed by the paper "CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature" by Chenyan Liu, Yufan Cai, Yun Lin, Yuhuan Huang, Yunrui Pei, Bo Jiang, Ping Yang, Jin Song Dong, and Hong Mei. Presented at ISSTA'24.
If you are interested in the training and evaluation of the backend models, please refer to the CoEdPilot repository.
Note
Please click the image to watch the demo video on YouTube.
The extension introduces two major features: Edit Locator and Edit Generator.
Combining a π file locator (discriminator) model and a π― line locator model. It suggests edit locations according to previous edits and current edit description.
Based on a single π generator model. It generates replacements or insertions somewhere in the code, from suggested locations or manually selected. It also requires previous edits and current edit description and, in addition, the code to replace.
- Predicted locations will be displayed as a tree view in the left β¬ οΈ and also highlighted in the active editor
- Query status will be displayed in the status bar
βοΈ - Edit description is accepted in the input above β¬οΈ
Once performing a prediction on a line, a diff view is shown for switching
-
Edit the code, as our extension will automatically record most previous edits.
-
Run
Predict Locations: right-click anywhere in the editor and select it in the menu, or use the default keybindingCtrl+Alt+L(in MacOSCmd+Alt+L). -
Run
Generate Edits: select the code to be edited in the editor, then right-click and select it in the menu, or use the default keybindingCtrl+Alt+E(in MacOSCmd+Alt+E).
Note
To select code for editing, you can:
- Click recommended locations in the left location list;
- Select part of the code for replacing;
- Select nothing to generate insertion code at the cursor position.
And by default accepting an edit will trigger another location prediction immediately (you can change this in extension configuration).
-
Manually
Change Edit Description: right-click and select it in the menu. By default the input box will automatically show at query whenever the edit description is empty. -
After the model generates possible edits at that range, a difference tab with pop up for you to switch to different edits or edit the code. There are buttons on the top right corner of the difference tab to accept, dismiss or switch among generated edits.
- Model upgrade from
microsoft/codebert-basetosalesforce/codet5-largeencoder andsalesforce/codet5-base; - The dataset distribution used for model training is more in-distribution with real world editing scenairos.
Important
- This deployment method is not fully tested. Please feel free to raise issues if you encounter any problems;
- MacOS is unable to use MPS acceleration via Docker, hence the following instructions are not applicable to MacOS.
- If you need CUDA acceleration, your system must have an NVIDIA GPU with the correct drivers installed. Install the NVIDIA Container Toolkit.
You can create a Docker image and start a Docker container according to the following steps to isolate the environment and simplify the backend model deployment.
-
Navigate to the root directory of the CoEdPilot-extension project.
-
Create the Docker image (For Linux / Windows with WSL):
docker build -t coedpilot-extension --build-arg GFW=<bool> .
If you are inside Mainland China, set argument
GFWtoTrue. If you wish not to use HuggingFace mirror, please removeENV HF_ENDPOINT="https://hf-mirror.com/"fromDockerfile -
Start the Docker container
The default port is 5003, please check the availability of this port:
-
With GPU acceleration (Recommended π):
docker run --gpus all --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 -p 5003:5003 coedpilot-extension
-
Without GPU acceleration (Not recommended π):
With the following command (with 5003 as default port):
docker run -p 5003:5003 coedpilot-extension
-
Now, the backend model is up and running. You can proceed to setup the extension to use CoEdPilot-Extension.
After the usage, you may follow the following command to stop and remove the Docker container and image.
-
β οΈ Stop the Docker container:docker stop $(docker ps -a -q --filter ancestor=coedpilot-extension)This command stops all running containers based on the
coedpilot-extensionimage. -
β οΈ Remove the Docker container:docker rm $(docker ps -a -q --filter ancestor=coedpilot-extension) -
β οΈ Remove the Docker image:docker rmi coedpilot-extension
Important
For Windows and Linux using CUDA 11.8, please follow PyTorch official guide to install PyTorch with CUDA before the following steps.
-
Install Python dependencies: Using
pip(with Python 3.10):pip install -r requirements.txt
Or using
conda:conda create -n code-edit conda activate code-edit conda install python=3.10.13 python -m pip install -r requirements.txt
-
Download models into the project directory:
As mentioned before, we respectively prepared 3 models (file locator(including embedding model, dependency analyzer and a regression model), line locator, and generator) for each language. Supported languages are
go,python,java,typescriptandjavascript.Execute the following command to automatically download models.
python download.py
Models should be downloaded into the following hierarchy:
edit-pilot/ models/ dependency-analyzer/ <language>/ embedding_model.bin reg_model.pickle multilingual/ locator_model.bin generator_model.bin -
Start the backend:
python src/model_server/server.py
The backend will start listening on
http://localhost:5003by default. If you want to change the host and port, please modifysrc/model_server/server.ini.
Note
Always remember to start up backend models before using the extension.
- Simply donwload the extension from VS Code Extension Store.
- Open VS Code settings (press
Ctrl+,/Cmd+,), search for@ext:CodePhilia.co-ed-pilot. - Set
coEdPilot.queryUrlto the server address, e.g.,http://localhost:5003orhttp://<SERVER_IP_ADDRESS>:<PORT>. - You are all set! Enjoy coding with CoEdPilot extension.
Method 2: Run extension from VS Code development host (for temporary testing and development purposes)
Note
- Require Node.js (version >= 16). If Node.js not installed, please follow Node.js official website to intall;
- Other extensions will be disabled in the development host.
-
In the project root directory, install Node packages:
npm install
-
Open the project directory in VS Code. Press
F5, then chooseRun Extensionif you are required to choose a configuration. A new VS Code window (the "development host") will open with CoEdPilot extension loaded. -
You are all set! Enjoy coding with CoEdPilot extension.
-
Make sure you have
yarninstalled.npm install -g yarn npm install -g vsce
-
Execute the following command in the project root directory:
yarn package
This command will generate a
.vsixfile in the project root directory, based on thepackage.jsonfile. -
Open the VS Code command palette (
Ctrl+Shift+P/Cmd+Shift+P), then selectExtensions: Install from VSIX...and choose the.vsixfile generated in the previous step. -
Open VS Code settings (press
Ctrl+,/Cmd+,), search for@ext:CodePhilia.co-ed-pilot. -
Set
coEdPilot.queryUrlto the server address, e.g.,http://localhost:5003orhttp://<SERVER_IP_ADDRESS>:<PORT>. -
You are all set! Enjoy coding with CoEdPilot extension.
If you find our work helpful, please consider citing our paper:
@inproceedings{liu2024coedpilot,
title={CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature},
author={Liu, Chenyan and Cai, Yufan and Lin, Yun and Huang, Yuhuan and Pei, Yunrui and Jiang, Bo and Yang, Ping and Dong, Jin Song and Mei, Hong},
booktitle={Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis},
pages={466--478},
year={2024}
}The project is still in development, not fully tested on different platforms.
Welcome to propose issues or contribute to the code.
π Enjoy coding!

