Elffuss BraidHub

kikocis/continue public

main · 8.4 KiBRenderedRawPermalink
1# Contributing to Continue (JetBrains extension) <!-- omit in toc -->
2
3This 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
35This extension shares much of the code with the VS Code extension by utilizing shared code in the `core` directory and
36packaging it in a binary in the `binary` directory. Communication occurs over stdin/stdout.
37
38## Environment Setup
39
40### IDE Installation
41
42Continue is built with JDK version 17 (as specified in [`./build.gradle.kts`](./build.gradle.kts)), which can be
43downloaded from [Oracle](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html).
44
45We recommend using IntelliJ IDEA, which you can download from
46the [JetBrains website](https://www.jetbrains.com/idea/download).
47
48Both Ultimate and Community (free) editions are suitable for this project, although Ultimate has better debugging (see
49notes 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
64This project requires Node.js version 20.19.0 (LTS) or higher. You have two options for installation:
65
661. Download and install directly from [nodejs.org](https://nodejs.org/en/download).
672. 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
83Select 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![run-extension-screenshot](../../media/run-continue-intellij.png)
91
92This should open a new instance on IntelliJ with the extension installed.
93
94### Accessing files in the `.continue` directory
95
96When running the `Start Core Dev Server` task, we set the location of your Continue directory to
97`./extensions/.continue-debug`. This is to
98allow for changes to your `config.json` and other files during development, without affecting your actual configuration.
99
100### Viewing logs
101
102When using the `Run Continue` task, we automatically tail both prompt logs and IDE logs.
103
104#### Viewing more IDE logs
105
106You can selectively increase the log granularity (e.g., debug-level logs) as follows:
107
108- Navigate to `Help | Diagnostic Tools | Debug Log Settings...`
109- Add a line in the format: `com.intellij.diagnostic:debug`
110
111You can find more information about this feature in [official docs](https://youtrack.jetbrains.com/articles/SUPPORT-A-43/How-to-enable-debug-logging-in-IntelliJ-IDEA).
112
113### Developing `build.plugin.kts`
114
115If in doubt, check out the
116official [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template).
117These templates are the most up-to-date examples of how to correctly customize the plugin build scripts.
118
119Also, check out
120the [useful recipes](https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-recipes.html)
121for common problems.
122
123### Adding new extensions in `plugin.xml`
124
125There's a tool called [JetBrains Platform Explorer](https://plugins.jetbrains.com/intellij-platform-explorer) that
126aggregates plugin metadata and allows you to filter by specific
127extension points. If you're having trouble implementing a feature that's not officially documented,
128you can learn from other open source plugins.
129
130### Reloading changes
131
132- `extensions/intellij`: Attempt to reload changed classes by selecting
133 _Run | Debugging Actions | Reload Changed Classes`_
134 - This will often fail on new imports, schema changes etc. In that case, you need to stop and restart the extension
135- `gui`: Changes will be reloaded automatically
136- `core`: Run `npm run build -- --os [darwin | linux | win32]` from the `binary` directory (requires
137 restarting the
138 `Start Core Dev Server` task)
139
140### Setting breakpoints
141
142- `extensions/intellij`: Breakpoints can be set in Intellij
143- `gui`: You'll need to set explicit `debugger` statements in the source code, or through the browser dev tools
144- `core`: Breakpoints can be set in Intellij (requires restarting the `Start Core Dev Server` task)
145 - If you have Community Edition installed, you won't be able to use breakpoints in IntelliJ. Instead, you can start
146 the `Core Binary` task in VS Code and set breakpoints in that IDE.
147
148### Available Gradle tasks
149
150To see the list of Gradle tasks available, you can run the following:
151
152```shell
153./gradlew tasks
154```
155
156A handful of the most relevant tasks are outlined below:
157
158```shell
159build - Assembles and tests this project.
160clean - Deletes the build directory.
161dependencies - Displays all dependencies declared in root project 'continue-intellij-extension'
162runIde - Runs the IDE instance with the developed plugin installed.
163verifyPluginConfiguration - Checks if Java and Kotlin compilers configuration meet IntelliJ SDK requirements
164```
165
166### Packaging
167
168- Unix: `./gradlew buildPlugin`
169- Windows: `./gradlew.bat buildPlugin`
170
171This will generate a .zip file in `./build/distributions` with the version defined in [
172`./gradle.properties`](./gradle.properties)
173
174#### Installing the packaged extension
175
176- Navigate to the Plugins settings page (_Settings | Plugins_)
177- Click on the gear icon
178- Click _Install from disk_ and select the ZIP file in `./build/distributions`
179
180## Testing
181
182Test commands:
183
184- `./gradlew test` - to run **unit tests**
185- `./gradlew testIntegration` - to run **e2e tests**
186
187### About e2e tests
188
189The e2e tests are written using [intellij-ide-starter](https://github.com/JetBrains/intellij-ide-starter).
190The first run of the e2e tests may take a while because the required IDE needs
191to be downloaded. Note that these tests
192fully take control of your mouse while executing.
193
194#### Setup
195
196If you are on macOS, you'll need to give IntelliJ permission to control your computer in order to run the e2e tests.
197Open `System Settings > Privacy & Security > Accessibility` and toggle the switch for IntelliJ.
198
199#### Working with Intellij IDE Starter
200
201The testing platform provides a rich DSL for most UI components in IntelliJ. However, if you want to interact with a
202custom element, you can define your own XPath selector.
203
204To do this, run an e2e test and visit [localhost:63343/api/remote-driver/](http://localhost:63343/api/remote-driver/) to
205view an HTML representation of the IDE's Swing component tree.
206See [Integration Tests](https://plugins.jetbrains.com/docs/intellij/integration-tests-ui.html#searching-components) for
207more details about this workflow.