What is ECP?
The Editor Command Protocol (ECP) is Ultra's internal architecture that separates the editor into distinct services and clients communicating via JSON-RPC 2.0. This design enables multiple UI implementations (terminal, future GUI, headless testing) to interact with shared backend services through a unified API.
Three-Layer Architecture
The system comprises three distinct layers:
Clients
User interfaces including the TUI (Terminal UI), future GUI clients, and headless testing clients. All communicate through the same protocol.
ECP Server
Central JSON-RPC router that directs requests to appropriate service adapters based on method prefixes.
Services
Stateful backend components handling core functionality like document editing, file operations, git, LSP, and more.
Method Routing
ECP methods follow a namespace/action format, enabling organized routing:
document/* → DocumentServiceAdapter
file/* → FileServiceAdapter
git/* → GitServiceAdapter
lsp/* → LSPServiceAdapter
terminal/* → TerminalServiceAdapter
database/* → DatabaseServiceAdapter
Data Flow
Every user interaction flows through a consistent pipeline:
- Input Capture — Terminal captures keystroke
- TUI Processing — Client determines action from keybinding
- ECP Request — JSON-RPC request sent to service
- Service Execution — Service modifies state, emits events
- UI Update — Render scheduler batches and displays changes