Class LanguageServerManager

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public final class LanguageServerManager
     implements AutoCloseable
                        

    Lightweight, dependency-free LSP (Language Server Protocol) client.

    Talks JSON-RPC 2.0 over stdio to a per-language server process (tsserver, pyright-langserver, rust-analyzer, ...), implementing just the methods needed for the coding domain's diagnostics / symbols / references tools — no lsp4j, no external JSON-RPC library.

    Servers are started lazily per language (first request wins), kept alive for reuse (incremental diagnostics), and reaped after IDLE_TIMEOUT_MS without requests to bound memory. A crashed server is restarted on the next request.

    Only servers on the approved serverCommands allow-list can be launched; the agent can never supply an arbitrary executable. Servers only ever receive file contents (didOpen) and return structured data — they never execute project code.

    Each server gets a dedicated coroutine reading stdout (the server pushes notifications like textDocument/publishDiagnostics at any time) plus a pending-response map keyed by JSON-RPC id. All protocol IO is sequential per server via a single writer mutex.