| 1 | # Contributing to Continue (JetBrains extension) <!-- omit in toc --> |
| 2 | |
| 3 | This file is for contribution guidelines specific to the JetBrains extension. See the root [ |
| 4 | `CONTRIBUTING.md`](../../CONTRIBUTING.md) for general contribution guidelines. |
| 5 | |
| 6 | ## Table of Contents <!-- omit in toc --> |
| 7 | |
| 8 | - [Architecture Overview](#architecture-overview) |
| 9 | - [Environment Setup](#environment-setup) |
| 10 | - [IDE Installation](#ide-installation) |
| 11 | - [IDE configuration](#ide-configuration) |
| 12 | - [Recommended plugins](#recommended-plugins) |
| 13 | - [Node.js Requirements](#nodejs-requirements) |
| 14 | - [Install all dependencies](#install-all-dependencies) |
| 15 | - [Misc](#misc) |
| 16 | - [Development Workflow](#development-workflow) |
| 17 | - [Running the extension in debug mode](#running-the-extension-in-debug-mode) |
| 18 | - [Accessing files in the `.continue` directory](#accessing-files-in-the-continue-directory) |
| 19 | - [Viewing logs](#viewing-logs) |
| 20 | - [Reloading changes](#reloading-changes) |
| 21 | - [Setting breakpoints](#setting-breakpoints) |
| 22 | - [Available Gradle tasks](#available-gradle-tasks) |
| 23 | - [Packaging](#packaging) |
| 24 | - [Installing the packaged extension](#installing-the-packaged-extension) |
| 25 | - [Testing](#testing) |
| 26 | - [e2e testing](#e2e-testing) |
| 27 | - [Overview](#overview) |
| 28 | - [Setup](#setup) |
| 29 | - [Running the tests](#running-the-tests) |
| 30 | - [Identifying selectors](#identifying-selectors) |
| 31 | - [Rebuilding the extension](#rebuilding-the-extension) |
| 32 | |
| 33 | ## Architecture Overview |
| 34 | |
| 35 | This extension shares much of the code with the VS Code extension by utilizing shared code in the `core` directory and |
| 36 | packaging it in a binary in the `binary` directory. Communication occurs over stdin/stdout. |
| 37 | |
| 38 | ## Environment Setup |
| 39 | |
| 40 | ### IDE Installation |
| 41 | |
| 42 | Continue is built with JDK version 17 (as specified in [`./build.gradle.kts`](./build.gradle.kts)), which can be |
| 43 | downloaded from [Oracle](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html). |
| 44 | |
| 45 | We recommend using IntelliJ IDEA, which you can download from |
| 46 | the [JetBrains website](https://www.jetbrains.com/idea/download). |
| 47 | |
| 48 | Both Ultimate and Community (free) editions are suitable for this project, although Ultimate has better debugging (see |
| 49 | notes below). |
| 50 | |
| 51 | ### IDE configuration |
| 52 | |
| 53 | - Enable code formatting on save: `Settings | Tools | Actions on Save | Reformat code` |
| 54 | |
| 55 | #### Recommended plugins |
| 56 | |
| 57 | - [Thread Access Info](https://plugins.jetbrains.com/plugin/16815-thread-access-info) - adds an extra debug panel |
| 58 | showing possible thread access violation (according to Intellij Platform SDK guidelines) |
| 59 | - [File Expander](https://plugins.jetbrains.com/plugin/11940-file-expander) - allows you to easily preview archives as |
| 60 | directories (like `build/distributions/continue-*.zip`) |
| 61 | |
| 62 | ### Node.js Requirements |
| 63 | |
| 64 | This project requires Node.js version 20.19.0 (LTS) or higher. You have two options for installation: |
| 65 | |
| 66 | 1. Download and install directly from [nodejs.org](https://nodejs.org/en/download). |
| 67 | 2. If you're using NVM (Node Version Manager), set the correct Node.js version for this project by running `nvm use` in |
| 68 | the project root. |
| 69 | |
| 70 | ### Install all dependencies |
| 71 | |
| 72 | - Unix: `./scripts/install-dependencies.sh` |
| 73 | - Windows: `.\scripts\install-dependencies.ps1` |
| 74 | |
| 75 | ### Misc |
| 76 | |
| 77 | - Ensure that you have the Gradle plugin installed |
| 78 | |
| 79 | ## Development Workflow |
| 80 | |
| 81 | ### Running the extension in debug mode |
| 82 | |
| 83 | Select the `Run Continue` task in the top right corner of the IDE and then select the "Debug" option. |
| 84 | |
| 85 | > In community edition, use `Run Continue (CE)` instead, which uses shell scripts instead of Ultimate-only node configs. |
| 86 | > If you want to debug the core in CE, you'll need to quit the `Start Core Dev Server (CE)` process and run the core in |
| 87 | > a |
| 88 | > different environment that supports debugging, such as VS Code (Launch "Core Binary"). |
| 89 | |
| 90 |  |
| 91 | |
| 92 | This should open a new instance on IntelliJ with the extension installed. |
| 93 | |
| 94 | ### Accessing files in the `.continue` directory |
| 95 | |
| 96 | When running the `Start Core Dev Server` task, we set the location of your Continue directory to |
| 97 | `./extensions/.continue-debug`. This is to |
| 98 | allow for changes to your `config.json` and other files during development, without affecting your actual configuration. |
| 99 | |
| 100 | ### Viewing logs |
| 101 | |
| 102 | When using the `Run Continue` task, we automatically tail both prompt logs and IDE logs. |
| 103 | |
| 104 | ### Reloading changes |
| 105 | |
| 106 | - `extensions/intellij`: Attempt to reload changed classes by selecting |
| 107 | _Run | Debugging Actions | Reload Changed Classes`_ |
| 108 | - This will often fail on new imports, schema changes etc. In that case, you need to stop and restart the extension |
| 109 | - `gui`: Changes will be reloaded automatically |
| 110 | - `core`: Run `npm run build -- --os [darwin | linux | win32]` from the `binary` directory (requires |
| 111 | restarting the |
| 112 | `Start Core Dev Server` task) |
| 113 | |
| 114 | ### Setting breakpoints |
| 115 | |
| 116 | - `extensions/intellij`: Breakpoints can be set in Intellij |
| 117 | - `gui`: You'll need to set explicit `debugger` statements in the source code, or through the browser dev tools |
| 118 | - `core`: Breakpoints can be set in Intellij (requires restarting the `Start Core Dev Server` task) |
| 119 | - If you have Community Edition installed, you won't be able to use breakpoints in IntelliJ. Instead, you can start |
| 120 | the `Core Binary` task in VS Code and set breakpoints in that IDE. |
| 121 | |
| 122 | ### Available Gradle tasks |
| 123 | |
| 124 | To see the list of Gradle tasks available, you can run the following: |
| 125 | |
| 126 | ```shell |
| 127 | ./gradlew tasks |
| 128 | ``` |
| 129 | |
| 130 | A handful of the most relevant tasks are outlined below: |
| 131 | |
| 132 | ```shell |
| 133 | build - Assembles and tests this project. |
| 134 | clean - Deletes the build directory. |
| 135 | dependencies - Displays all dependencies declared in root project 'continue-intellij-extension' |
| 136 | runIde - Runs the IDE instance with the developed plugin installed. |
| 137 | verifyPluginConfiguration - Checks if Java and Kotlin compilers configuration meet IntelliJ SDK requirements |
| 138 | ``` |
| 139 | |
| 140 | ### Packaging |
| 141 | |
| 142 | - Unix: `./gradlew buildPlugin` |
| 143 | - Windows: `./gradlew.bat buildPlugin` |
| 144 | |
| 145 | This will generate a .zip file in `./build/distributions` with the version defined in [ |
| 146 | `./gradle.properties`](./gradle.properties) |
| 147 | |
| 148 | #### Installing the packaged extension |
| 149 | |
| 150 | - Navigate to the Plugins settings page (_Settings | Plugins_) |
| 151 | - Click on the gear icon |
| 152 | - Click _Install from disk_ and select the ZIP file in `./build/distributions` |
| 153 | |
| 154 | ## Testing |
| 155 | |
| 156 | ### e2e testing |
| 157 | |
| 158 | #### Overview |
| 159 | |
| 160 | The e2e tests are written using [intellij-ui-test-robot](`https://github.com/JetBrains/intellij-ui-test-robot`). The |
| 161 | README for this project has a lot of helpful info on how to use the library. |
| 162 | |
| 163 | Note that these tests fully take control of your mouse while executing. |
| 164 | |
| 165 | #### Setup |
| 166 | |
| 167 | If you are on macOS, you'll need to give IntelliJ permission to control your computer in order to run the e2e tests. |
| 168 | Open _System Settings_ and select `Privacy & Security` -> `Accessibility` and toggle the switch for IntelliJ. |
| 169 | |
| 170 | #### Running the tests |
| 171 | |
| 172 | Instantiate the test IDE as a background task: |
| 173 | |
| 174 | ```sh |
| 175 | ./gradlew clean runIdeForUiTests & |
| 176 | ``` |
| 177 | |
| 178 | Once the IDE has loaded, you can run the tests. Note that you need to have the test IDE focused in order for the tests |
| 179 | to run. |
| 180 | |
| 181 | ```sh |
| 182 | ./gradlew test |
| 183 | ``` |
| 184 | |
| 185 | Run a single test |
| 186 | |
| 187 | ```sh |
| 188 | ./gradlew test --tests "com.github.continuedev.continueintellijextension.e2e.TESTNAME" |
| 189 | ``` |
| 190 | |
| 191 | #### Identifying selectors |
| 192 | |
| 193 | While the `runIdeForUiTests` task is running, you can visit the following URL |
| 194 | to view the UI hierarchy of the running IDE: |
| 195 | |
| 196 | <http://127.0.0.1:8082/> |
| 197 | |
| 198 | #### Rebuilding the extension |
| 199 | |
| 200 | To rebuild the extension with the latest source code, run the following: |
| 201 | |
| 202 | ```sh |
| 203 | ./gradlew buildPlugin |
| 204 | ``` |
| 205 | |
| 206 | This will update the contents of the extension that is loaded into the test IDE from |
| 207 | `build/idea-sandbox/plugins-uiTest/continue-intellij-extension` |