|
| 1 | +--- |
| 2 | +title: Choose a runtime |
| 3 | +description: Decide when to use the IntelliJ host, the standalone host, or |
| 4 | + both. |
| 5 | +--- |
| 6 | + |
| 7 | +Kast exposes the same HTTP/JSON contract through two runtime hosts. This page |
| 8 | +helps you decide which host to start, what each one needs from your workspace, |
| 9 | +and how to keep one client flow across both. |
| 10 | + |
| 11 | +<div class="grid cards" markdown> |
| 12 | + |
| 13 | +- **Use the IntelliJ host** |
| 14 | + |
| 15 | + Start Kast from a plugin-enabled IDE when you want analysis to run against |
| 16 | + the workspace currently loaded in IntelliJ. |
| 17 | + |
| 18 | + [Go to IntelliJ startup](#use-the-intellij-host) |
| 19 | + |
| 20 | +- **Use the standalone host** |
| 21 | + |
| 22 | + Start Kast as a headless JVM process when you need CI, scripts, or another |
| 23 | + environment without a running IDE. |
| 24 | + |
| 25 | + [Go to standalone startup](#use-the-standalone-host) |
| 26 | + |
| 27 | +- **Use both with one client** |
| 28 | + |
| 29 | + Keep discovery and request handling identical, then select the runtime from |
| 30 | + the descriptor file at connection time. |
| 31 | + |
| 32 | + [Go to shared client flow](#use-both-with-one-client-flow) |
| 33 | + |
| 34 | +</div> |
| 35 | + |
| 36 | +## Compare the hosts |
| 37 | + |
| 38 | +Both hosts write the same descriptor shape and serve the same route map. The |
| 39 | +main difference is where analysis runs and how the workspace gets loaded. |
| 40 | + |
| 41 | +| Question | IntelliJ host | Standalone host | |
| 42 | +| --- | --- | --- | |
| 43 | +| Where it runs | Inside the IntelliJ process for one open project | In its own JVM process | |
| 44 | +| How it starts | Open a project in the plugin-enabled IDE | Launch the wrapper script or fat JAR | |
| 45 | +| Workspace source | The project already opened in IntelliJ | `--workspace-root` or `KAST_WORKSPACE_ROOT` | |
| 46 | +| Source discovery | Uses the IDE project model, PSI, and indices | Scans conventional source roots and auto-discovers Gradle modules when available | |
| 47 | +| Default bind | `127.0.0.1` on an ephemeral port | `127.0.0.1` on an ephemeral port | |
| 48 | +| Descriptor field | `backendName = "intellij"` | `backendName = "standalone"` | |
| 49 | +| Current production capabilities | `RESOLVE_SYMBOL`, `FIND_REFERENCES`, `DIAGNOSTICS`, `RENAME`, `APPLY_EDITS` | `RESOLVE_SYMBOL`, `FIND_REFERENCES`, `DIAGNOSTICS`, `RENAME`, `APPLY_EDITS` | |
| 50 | +| Common use case | Local development with a live IDE project | CI, automation, and headless workflows | |
| 51 | + |
| 52 | +## Use the IntelliJ host |
| 53 | + |
| 54 | +Use the IntelliJ host when your workspace is already open in IntelliJ and you |
| 55 | +want Kast to start from that project context. |
| 56 | + |
| 57 | +1. Build the plugin from the repo root. |
| 58 | + |
| 59 | + ```bash |
| 60 | + ./gradlew :backend-intellij:buildPlugin |
| 61 | + ``` |
| 62 | + |
| 63 | +2. Start the sandbox IDE. |
| 64 | + |
| 65 | + ```bash |
| 66 | + ./gradlew :backend-intellij:runIde |
| 67 | + ``` |
| 68 | + |
| 69 | +3. Open the workspace you want Kast to serve. |
| 70 | + |
| 71 | +4. Wait for the project-scoped service to start and write a descriptor under |
| 72 | + `~/.kast/instances/`, or under `KAST_INSTANCE_DIR` if you set that |
| 73 | + environment variable first. |
| 74 | + |
| 75 | +5. Read the descriptor and connect to the advertised `host` and `port`. |
| 76 | + |
| 77 | +> **Note:** The IntelliJ host starts one Kast server per open workspace. It |
| 78 | +> binds to `127.0.0.1`, picks an ephemeral port, and uses fixed startup limits |
| 79 | +> of `maxResults = 500`, `requestTimeoutMillis = 30000`, and |
| 80 | +> `maxConcurrentRequests = 4`. |
| 81 | +
|
| 82 | +## Use the standalone host |
| 83 | + |
| 84 | +Use the standalone host when you need Kast outside IntelliJ, or when you want |
| 85 | +to wire it into CI and scripts. |
| 86 | + |
| 87 | +1. Build the standalone distribution from the repo root. |
| 88 | + |
| 89 | + ```bash |
| 90 | + ./gradlew :backend-standalone:fatJar \ |
| 91 | + :backend-standalone:writeWrapperScript |
| 92 | + ``` |
| 93 | + |
| 94 | +2. Start the wrapper script with an absolute workspace path. |
| 95 | + |
| 96 | + ```bash |
| 97 | + ./backend-standalone/build/scripts/backend-standalone \ |
| 98 | + --workspace-root=/absolute/path/to/workspace |
| 99 | + ``` |
| 100 | + |
| 101 | +3. Add overrides only when the default discovery path is not enough. |
| 102 | + |
| 103 | + - Use `--source-roots` to replace automatic source-root discovery. |
| 104 | + - Use `--classpath` to add absolute classpath entries. |
| 105 | + - Use `--module-name` when you supply manual source roots. |
| 106 | + - Use `--token` or `KAST_TOKEN` when you want protected routes. |
| 107 | + |
| 108 | +4. Read the descriptor file and connect to the advertised `host` and `port`. |
| 109 | + |
| 110 | +> **Warning:** If you bind the standalone host to a non-loopback address, you |
| 111 | +> must also set a non-empty token. Kast rejects non-local binding without a |
| 112 | +> token. |
| 113 | +
|
| 114 | +## Use both with one client flow |
| 115 | + |
| 116 | +Kast is easier to integrate when your client treats the runtime host as a |
| 117 | +discovery result instead of a hardcoded mode. |
| 118 | + |
| 119 | +```mermaid |
| 120 | +graph LR |
| 121 | + Client["Client or agent"] --> Descriptor["Descriptor directory"] |
| 122 | + Descriptor --> IntelliJ["IntelliJ host"] |
| 123 | + Descriptor --> Standalone["Standalone host"] |
| 124 | + Client --> Api["/api/v1/health and /api/v1/capabilities"] |
| 125 | +``` |
| 126 | + |
| 127 | +Use this flow when you want the same client to work in local development and |
| 128 | +headless environments. |
| 129 | + |
| 130 | +1. Read descriptor files from `~/.kast/instances/`, or from `KAST_INSTANCE_DIR` |
| 131 | + when you override the location. |
| 132 | +2. Select the descriptor that matches the target `workspaceRoot`, or filter by |
| 133 | + `backendName` if you need one specific host. |
| 134 | +3. Call `/api/v1/health` to confirm the runtime identity. |
| 135 | +4. Call `/api/v1/capabilities` and gate optional routes against the returned |
| 136 | + capabilities. |
| 137 | +5. Send the same request shapes regardless of which host answered. |
| 138 | + |
| 139 | +## Enable standalone usage in CI or scripts |
| 140 | + |
| 141 | +The standalone host fits automated environments because it does not depend on a |
| 142 | +running IDE. A minimal bootstrap looks like this. |
| 143 | + |
| 144 | +```bash |
| 145 | +./gradlew :backend-standalone:fatJar \ |
| 146 | + :backend-standalone:writeWrapperScript |
| 147 | + |
| 148 | +export KAST_INSTANCE_DIR="$PWD/.kast-instances" |
| 149 | +export KAST_TOKEN="ci-shared-secret" |
| 150 | + |
| 151 | +./backend-standalone/build/scripts/backend-standalone \ |
| 152 | + --workspace-root="$PWD" \ |
| 153 | + --token="$KAST_TOKEN" |
| 154 | +``` |
| 155 | + |
| 156 | +If your automation already knows the workspace root, you can set |
| 157 | +`KAST_WORKSPACE_ROOT` instead of passing `--workspace-root`. |
| 158 | + |
| 159 | +## Verify the runtime you started |
| 160 | + |
| 161 | +The startup path is complete when discovery and capability checks agree with |
| 162 | +the host you intended to use. |
| 163 | + |
| 164 | +- A descriptor file exists in the expected instance directory. |
| 165 | +- The descriptor reports the expected `workspaceRoot` and `backendName`. |
| 166 | +- `/api/v1/health` returns `status: "ok"`. |
| 167 | +- `/api/v1/capabilities` advertises the routes your client plans to call. |
| 168 | + |
| 169 | +## Next steps |
| 170 | + |
| 171 | +Read [Get started](get-started.md) for the first-request walkthrough. Use |
| 172 | +[Operator guide](operator-guide.md) when you need CLI flags, descriptor |
| 173 | +lifecycle details, or runtime defaults. Keep [HTTP API](api-reference.md) |
| 174 | +open when you are wiring a client against the contract. |
0 commit comments