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§
- Read
Context - The generic services the read tools consume. Built once at server spawn
from boot-provided handles and held behind an
Arcin 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 thefilePathargument. Unknown / absent path →isDirty: false(not an error).- diagnostics_
result getDiagnosticsresult. Each(uri, diagnostics)group serializes its diagnostics in LSP wire shape (lsp_types::DiagnosticisSerialize).- dirty_
result checkDocumentDirtyresult.- 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 requesteduriargument.- 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 getOpenEditorsresult from(filePath, isActive)rows (file buffers only; synthetic / unsaved buffers are excluded by the caller).- selection_
result getCurrentSelectionresult.Noneselection → an empty result (the agent’s “nothing selected” case), not an error.- workspace_
folders_ result getWorkspaceFoldersresult.