C4Context
  title lspz System Context

  Person(agent, "AI Coding Agent", "Claude Code, Continue, custom agent CLI")
  Person(dev, "Developer", "Uses lspz via library, SDK, or CLI")

  System_Boundary(lspz_sys, "lspz") {
    System(lspz_core, "lspz (core)", "Core library: Codec (JSON-RPC + Compact + TOON), Transport (stdio/TCP/WS), InterceptorChain (8 interceptors), Proxy, Config, Metrics, ConfigWatcher")

    System(lib_mode, "Library Mode", "Embed lspz::Proxy directly")
    System(proxy_mode, "Proxy Mode", "lspz --backend <cmd> — transparent LSP proxy with compression")
    System(mcp_mode, "MCP Mode", "lspz mcp — exposes 3 MCP tools (diagnostics/completions/symbols)")
    System(agent_sdk, "Agent SDK", "lspz (feature = agent-sdk) — AgentHandle + AgentPool with 13 query methods, file sync, refactoring ops")
  }

  System(lsp_server, "LSP Server", "rust-analyzer, gopls, basedpyright, typescript-language-server")
  System(agent_cli, "Agent Runtime", "stdin/stdout for proxy mode")

  Rel(agent, lib_mode, "use lspz::Proxy", "Rust crate")
  Rel(agent, agent_sdk, "use lspz::agent_sdk", "Rust crate")
  Rel(agent_cli, proxy_mode, "spawns as child process", "stdio transport")
  Rel(agent, mcp_mode, "connects as MCP client", "rmcp protocol")
  Rel(dev, lspz_core, "embeds via Cargo dep", "Library mode")

  Rel(lib_mode, lspz_core, "calls public API")
  Rel(proxy_mode, lspz_core, "wraps in CLI")
  Rel(mcp_mode, lspz_core, "uses LspSession + compress")
  Rel(agent_sdk, lspz_core, "uses InterceptorChain")
  Rel(agent_sdk, mcp_mode, "uses LspSession")

  Rel(lspz_core, lsp_server, "spawn & communicate via Transport trait", "Content-Length framed JSON-RPC 2.0")
