# Editor integration

|  | LSP tools | ACP server |
| --- | --- | --- |
| Serves | The agent: language servers run as background analysis | Editors such as Zed driving OpenProgram sessions |
| Gives | Live diagnostics against the unsaved working tree, which a pre-built index such as CodeGraph cannot | Driving through ACP; selection and open-file context with each request; an editor entry point without a self-built extension |
| Code | `openprogram/host/lsp/` (JSON-RPC over stdio), `openprogram/programs/tools/code/lsp/` | `openprogram/interfaces/acp/`: `jsonrpc.py` (ndjson transport), `server.py` (mapping) |
| User docs | [Language server tools](https://fzkuji.github.io/OpenProgram/docs/capabilities/lsp.html) | [Editor (ACP)](https://fzkuji.github.io/OpenProgram/docs/interfaces/acp.html), `openprogram acp` |
| Status | Implemented | Implemented, protocol version 1 |

## LSP tools

| Tool | Returns |
| --- | --- |
| `lsp_diagnostics(file)` | Compiler-grade errors and warnings the moment an edit ends, without running tests |
| `lsp_references(file, line, column)` | Every real call site; grep misses dynamic calls and matches same-named strings |
| `lsp_definition(file, line, column)` | The true location across files and packages |

- Python (pyright) and TypeScript (typescript-language-server), the two languages of this repository.
- One server per language per workspace, started on first use, cached, shut down at process exit.
- A missing binary gives an "unavailable: install X" result. The tools stay registered so the model learns what is possible.
- Server processes use the sandbox-wrapping entry of every other child, so `sandbox.mode` applies.

## ACP server

| Direction | Methods |
| --- | --- |
| From the editor | `initialize`, `session/new`, `session/load`, `session/prompt`, `session/cancel` |
| To the editor | `session/update`, `session/request_permission` |

- Sits on `dispatcher.process_user_turn`, the non-HTTP entry of the webui thread, sub-agents and the task runner, so tool gating, authority and persistence are shared.
- Turns carry `local_owner_authority()`: an editor on this machine is the owner speaking interactively, which makes `approval.request` available.
- An approval suspends the execution on a wait. The server takes it from the prompt's `question.asked` frame, from the event bus for a resumed round, and from the execution's open waits, then answers with the canonical execution wait command; the gate, its rules and "always allow" persistence are untouched.
- `session/prompt` stays open until the execution ends, so the rounds after an answer belong to the same prompt. A wait the editor cannot answer is declined; a state the editor cannot move on ends the prompt with an error.
- The first prompt creates the conversation and binds the session's `cwd` as its project, the same binding `--print` uses, so tools run in the editor's folder.

## Not built

| Item | Why |
| --- | --- |
| Self-built IDE extension | ACP replaces it |
| Inline completion | A different product |
| Inline chat, CodeLens, status-bar actions | Depend on a self-built extension |
| Terminal shortcut auto-configuration | Return too small |
| `session/set_mode`, `session/set_model` | Agent id and permission mode are process flags |
| Client `fs/*`, `terminal/*` | OpenProgram's own tools read and write the working tree |
| MCP servers passed in `session/new` | OpenProgram uses its own MCP configuration |

These rows stay open in the feature matrix by choice.
