Local protocol · 06
GTP and JSONL are two KataGo languages on stdout
Both use standard input and output, but GTP v2 and Analysis Engine JSONL differ in state, framing, and intended clients.
GTP is a stateful command-response session
A GUI sends lines such as boardsize, komi, play, and kata-analyze while the engine retains the current board. Success starts with =, failure with ?, and a blank line ends each response. This fits traditional Go interfaces such as Sabaki, q5Go, and Lizzie.
GTP frames each response with a trailing blank line; earlier commands build the board state incrementally. Analysis Engine uses one JSON object per line
JSONL writes each query as single-line JSON and returns JSON results line by line. Each query carries its own position and id, making it better for batches, service bridges, and programmatic parsing. One id may receive several search updates.
A newline is the message boundary, so prompts, progress text, and colored logs cannot share this stream. Reserve stdout for protocol and stderr for diagnostics
In either mode, machine-readable protocol must own stdout. Connection state, retries, usage notices, and error context belong on stderr. Otherwise a GUI mistakes logs for GTP, while a script receives invalid JSON.
The two streams have separate audiences: stdout for machines, stderr for people; the exit status reports process completion.
Specifications
Before integration
- Use GTP for GUIs and JSONL for scripts
- Keep correct line or blank-line framing
- Send diagnostics only to stderr
- Probe every required command