- Run
pnpm install
(see repository setup instructions if you don't havepnpm
). - Open this repository in VS Code and run the
Launch VS Code Extension (Desktop, recommended)
build/debug task (or runcd vscode && pnpm run build && pnpm run dev
).
Tip: Enable cody.debug.verbose
in VS Code settings during extension development.
src
: source code of the components for the extension hostwebviews
: source code of the extension sidebar webviews, built with Vitetest
: testsdist
: build outputs from both esbuild and viteresources
: everything in this directory will be moved to the ./dist directory automatically during build time for easy packagingindex.html
: the entry file that Vite looks for to build the webviews. The extension host reads this file at run time and replace the variables inside the file with webview specific uri and info
Read ARCHITECTURE.md and follow the principles described there.
The best way to help us improve code completions is by contributing your examples in the Unhelpful Completions discussion together with some context of how the autocomplete request was build.
- Enable
cody.debug.verbose
in VS Code settings- Make sure to restart or reload VS Code after changing these settings
- Open the Cody debug panel via "View > Output" and selecting the "Cody by Sourcegraph" option in the dropdown.
We also have some build-in UI to help during the development of autocomplete requests. To access this, run the Cody > Open Autocomplete Trace View
action. This will open a new panel that will show all requests in real time.
- Unit tests:
pnpm run test:unit
- Integration tests:
pnpm run test:integration
- End-to-end tests:
pnpm run test:e2e
To publish a new major release to the VS Code Marketplace and Open VSX Registry.
pnpm vsce-version-bump
to increment the version number for stable release
- Increment the
version
inpackage.json
&CHANGELOG
. - Commit the version increment, e.g.
VS Code: Release 1.1.0
.
- Open a PR with the version updated
git tag vscode-v$(jq -r .version package.json)
git push --tags
- Wait for the vscode-stable-release workflow run to finish.
- Update the Release Notes.
Version Bump:
To publish a patch release to the VS Code Marketplace and Open VSX Registry.
- Make sure all the changes for the patch are already committed to the
main
branch. - Create a patch release branch if one does not already exist:
- For example, if you are releasing
v1.10.<patch>
, then you should look to see if there is already avscode/1.10
branch. - If there is not, then create the branch using the last stable release tag for the version you are trying to patch, e.g.,
git checkout vscode-v1.10.0 -B vscode/1.10
and push this branch.- Note: Do not push your changes to this branch directly; treat it like a
main
branch where all changes that are merged should be reviewed first.
- Note: Do not push your changes to this branch directly; treat it like a
- For example, if you are releasing
- Create a PR with your changes that will go into the release, and send that PR to the e.g.,
vscode/1.10
branch:- Create your PR branch:
git checkout vscode/1.10 -b me/1.10.1-patch-release
- Make changes:
- Cherry-pick (
git cherry-pick $COMMIT_FROM_MAIN
) the relevant patches frommain
into your PR branch. If there are any conflicts, address them in your branch. - Increment the
version
inpackage.json
- Update the
CHANGELOG
- Update the version used in agent recordings by following these steps
- Cherry-pick (
- Send a PR to merge your branch, e.g.,
me/1.10.1-patch-release
intovscode/1.10
- Ensure your PR branch passes CI tests, and get your PR reviewed/approved/merged.
- Create your PR branch:
- Tag the patch release:
git tag vscode-v$(jq -r .version package.json)
git push --tags
- Wait for the vscode-stable-release workflow run to finish.
- Once the patch has been published, update
main
:- Create a new PR branch off
main
- Update the
version
inpackage.json
if appropriate. - Update the
CHANGELOG
- Update the version used in agent recordings by following these steps
- Commit the version increment, e.g.,
VS Code: Release 1.10.1
and get yourmain
PR merged.
- Create a new PR branch off
Insiders builds are nightly (or more frequent) builds with the latest from main
. They're less stable but have the latest changes. Only use the insiders build if you want to test the latest changes.
To use the Cody insiders build in VS Code:
- Install the extension from the VS Code Marketplace.
- Select Switch to Pre-release Version in the extension's page in VS Code.
- Wait for it to download and install, and then reload (by pressing Reload Required).
Insiders builds are published automatically daily at 1500 UTC using the vscode-insiders-release workflow.
To manually trigger an insiders build:
- Open the vscode-insiders-release workflow.
- Press the Run workflow ▾ button.
- Select the branch you want to build from (usually
main
). - Press the Run workflow button.
- Wait for the workflow run to finish.
It can be helpful to build and run the packaged extension locally to replicate a typical user flow.
To do this:
- Run
pnpm install
(see repository setup instructions if you don't havepnpm
). - Run
CODY_RELEASE_TYPE=stable pnpm release:dry-run
- Uninstall any existing Cody extension from VS Code.
- Run
code --install-extension dist/cody.vsix
VS Code will preserve some extension state (e.g., configuration settings) even when an extension is uninstalled. To replicate the flow of a completely new user, run a separate instance of VS Code:
code --user-data-dir=/tmp/separate-vscode-instance --profile-temp
To open the Cody sidebar, autocomplete trace view, etc., when debugging starts, you can set hidden
VS Code user settings. See src/dev/helpers.ts
for a list of available
options.
We use tree-sitter parser for a better code analysis in post completion process. In order to be able
to run these modules in VSCode runtime we have to use their wasm version. Wasm modules are not common
modules, you can't just inline them into the bundle by default, you have to load them separately and
connect them with special load
wasm API.
We don't keep these modules in .git tree, but instead we load them manually from our google cloud bucket.
In order to do it you can run ./scripts/download-wasm-modules.ts
or just pnpm download-wasm
before
running you vscode locally.
- Initialize the Build Watcher: Run the following command from the monorepo root to start the build watcher:
pnpm --filter cody-ai run watch:build:dev:desktop
- Launch the VSCode Extension Host: Next, start the VSCode extension host by executing the command below from the monorepo root:
pnpm --filter cody-ai run start:dev:desktop
- Access the Chrome Inspector: Open up your Google Chrome browser and navigate to
chrome://inspect/#devices
. - Open Node DevTools: Look for and click on the option that says "Open dedicated DevTools for Node".
- Specify the Debugging Endpoint: At this point, DevTools aren't initialized yet. Therefore, you need to specify the debugging endpoint
localhost:9333
(the port depends on the--inspect-extensions
CLI flag used in thestart:debug
npm script) - Start Debugging Like a PRO: yay!