FineCode WM-ER Protocol¶
This document describes the communication protocol between the FineCode Workspace
Manager (WM) and Extension Runners (ER). WM is the JSON-RPC client; each ER is a
JSON-RPC server implemented via the LSP stack (finecode_extension_runner/lsp_server.py).
The protocol is LSP-shaped with a small set of custom commands.
Transport¶
- JSON-RPC 2.0
- LSP-style framing over stdio:
Content-Length: N\r\nContent-Type: application/vscode-jsonrpc; charset=utf-8\r\n\r\n{json} - WM spawns ER processes with:
python -m finecode_extension_runner.cli start --project-path=... --env-name=...--debugenables a debugpy attach flow before WM connects- Field names are camelCase for standard LSP params, but command arguments are passed verbatim (snake_case is common in FineCode payloads).
Lifecycle¶
- WM starts the ER process (per project + env).
- WM sends
initializeand waits for the ER response. - WM sends
initialized. - WM sends
finecodeRunner/updateConfigto bootstrap handlers and services. - On shutdown: WM sends
shutdownthenexit.
Message Catalog¶
WM -> ER¶
Requests
initialize- Standard LSP initialize request.
-
Example params (trimmed):
-
shutdown -
Standard LSP shutdown request.
-
workspace/executeCommand - Used for all FineCode WM → ER commands. The
argumentsarray is passed to the handler verbatim.
Commands
-
finecodeRunner/updateConfig- Arguments:
working_dir(string path)project_name(string)project_def_path(string path)config(object)- Config shape (top-level):
actions: list of action objects (name,handlers,source,config)action_handler_configs: map of handler source → configservices: list of service declarations (optional)handlers_to_initialize: map of action name → handler names (optional)- Result:
{}(empty object)
-
actions/run- Arguments:
action_name(string)params(object)options(object, optional)- Options (snake_case keys are expected):
meta:{ "trigger": "user|system|unknown", "dev_env": "ide|cli|ai|precommit|ci" }partial_result_token:int | string(used to correlate$/progress)result_formats:["json", "string"](defaults to["json"])- Result (success):
- Result (stopped):
- Result (error):
- Note:
result_by_formatis a JSON string (not a JSON object) due to LSP serialization constraints in the runner.
-
actions/mergeResults- Arguments:
[action_name, results] - Result:
{ "merged": ... }or{ "error": "..." }
- Arguments:
-
actions/reload- Arguments:
[action_name] - Result:
{}
- Arguments:
-
packages/resolvePath- Arguments:
[package_name] - Result:
{ "packagePath": "/abs/path/to/package" }
- Arguments:
Notifications
initialized(standard LSP)textDocument/didOpentextDocument/didChangetextDocument/didClose$/cancelRequest- Sent by WM when an in-flight request should be cancelled.
ER -> WM¶
Requests
workspace/applyEdit- Standard LSP request for applying workspace edits.
-
WM forwards this to its active client (IDE) if available.
-
projects/getRawConfig - Params:
{ "projectDefPath": "/abs/path/to/project/finecode.toml" } - Result:
{ "config": "<stringified JSON config>" } - Used by ER during
finecodeRunner/updateConfigto resolve project config.
Notifications
$/progress- Params:
{ "token": <token>, "value": "<stringified JSON partial result>" } - The
tokenmust matchpartial_result_tokenfromactions/run. valueis a JSON string produced by the ER from a partial run result.
Error Handling and Cancellation¶
- JSON-RPC errors are used for protocol-level failures.
- Command-level errors are returned via
{ "error": "..." }in command results. - WM cancels in-flight requests by sending
$/cancelRequestwith the request id.
Document Sync Notes¶
WM forwards open-file events to ER so actions can operate on in-memory document
state. ER may send workspace/applyEdit when handlers modify files; WM applies
these edits via its active client when possible.