Skip to main content

Module reads

Module reads 

Source
Expand description

IDE-protocol I2.2: the five read tools.

Crate-owned logic. Each tool fetches Rust-typed data from the protocol-neutral [lattice_agent::EditorAccess] port (open-buffer set + active selection, on-demand text / dirty via the generic BufferStore) plus, for getDiagnostics only, the generic DiagnosticsQuery (lattice-lsp) — and wraps it into an MCP result Value. No host claude-code trait is involved.

Shape: pure result-builders (*_result, unit-tested with plain data) plus thin tool entry points (get_* / check_*) that fetch from a ReadContext and call the builders. Reads run on the WS task off the editor thread — BufferStore::handle_for(id) → Document snapshot reads are wait-free ArcSwap loads, and the port’s cache is a brief Mutex.

Result JSON shapes are PROVISIONAL (like the lockfile schema) until validated against a live claude CLI in the I0–I2 walking skeleton.

Structs§

ReadContext
The generic services the read tools consume. Built once at server spawn from boot-provided handles and held behind an Arc in the dispatch context. Any field may be absent (headless / test harness), in which case the dependent tool degrades to an empty result, never an error.

Functions§

check_document_dirty
checkDocumentDirty: dirty flag for the filePath argument. Unknown / absent path → isDirty: false (not an error).
diagnostics_result
getDiagnostics result. Each (uri, diagnostics) group serializes its diagnostics in LSP wire shape (lsp_types::Diagnostic is Serialize).
dirty_result
checkDocumentDirty result.
get_current_selection
getCurrentSelection: the active buffer’s path + selection (+ selected text via the buffer store, when available).
get_diagnostics
getDiagnostics: all diagnostics, or just the requested uri argument.
get_open_editors
getOpenEditors: the open file-editor buffers (skips synthetic / unsaved buffers with no path).
get_workspace_folders
getWorkspaceFolders: from the server config.
open_editors_result
getOpenEditors result from (filePath, isActive) rows (file buffers only; synthetic / unsaved buffers are excluded by the caller).
selection_result
getCurrentSelection result. None selection → an empty result (the agent’s “nothing selected” case), not an error.
workspace_folders_result
getWorkspaceFolders result.