Expand description
lattice-ai — lattice’s AI coding-agent integration layer.
Owns both agent transports behind cargo features (default = both):
acp: an Agent Client Protocol client. Spawns an agent (opencode, and later claude-code-acp / gemini) as a stdio subprocess and drives it over JSON-RPC. Architecturally a network peer likelattice-lsp.mcp: the Claude Code IDE peer (folded in by AG-4, seemcp). An externalclaudeCLI dials into a loopback WebSocket and drives the editor over the same MCP contract as the VS Code / JetBrains plugins.
Both share the protocol-neutral editor-capability port (lattice-agent) and
the transport-neutral AI-log substrate (below). Runs no agent in-process.
See docs/dev/architecture/agent-integration.md.
Re-exports§
pub use install::install;pub use acp::AiClientHandle;pub use acp::AiError;pub use acp::AiState;pub use acp::Connection;pub use acp::Result;pub use acp::SessionId;pub use acp::register_ai_ex_commands;
Modules§
- acp
acp— lattice as an Agent Client Protocol client.- commands
- The transport-neutral
:ai-logex-command. - install
- AI-1b / AG‑4: the crate-owned
install(boot)entry point. - mcp
mcp— lattice as the IDE side of the Claude Code agent protocol.- opencode
opencode— lattice drives the opencode agent’s native TUI in a terminal buffer (the v1 opencode integration).- pi
pi— lattice drives the pi agent’s native TUI in a terminal buffer (the v1 pi integration).
Structs§
- AiLog
Mode ai-log-mode– major mode for the per-session*ai:<provider>:<index>*buffer.- AiLog
Pushed - The typed event fired on every successful append. Analogue of
lattice_lsp::events::LspLogPushed. - AiLog
Record - One log entry. Cheap to clone (
Arc<str>for the session’s provider name; the message is a plainString). - AiLogger
- Producer-side log facade. One per AI subsystem; each agent
connection gets a clone (cheap – internal state is
Arc<Mutex<...>>). - LogRing
- Bounded ring of log records. Append-only; oldest is evicted when capacity is reached.
- Session
Key - Per-process key for the per-session log ring – the
(provider, index)pair that distinguishes concurrent agent processes of the same provider. A secondopencodesession (index = 2) is a distinct ring/buffer from the first, analogous to LSP’sInstanceKey(server_id, workspace). Cheap to clone (oneArc<str>+ aCopyinteger).
Enums§
- AiLog
Level - Severity levels. Ordered low-to-high so the derived
PartialOrdmatches “Error > Warn > … > Trace”. Per-session min level filters records BELOW it (i.e.level < mindrops;level >= minkeeps). - AiLog
Source - Where a log record originated.
Functions§
- ai_
log_ name - Build the synthetic name for the per-session AI log buffer
owned by
super::modes::AiLogMode. - format_
ai_ log_ line - Format one log record line for append to a synthetic AI log
buffer. Shape:
HH:MM:SS.mmm [<provider>:<index>] <level> <source>: <message>. Trailing newline is the caller’s responsibility (the drain batches many records into one buffer-append). - level_
tag - Compact severity tag for
AiLogPushed. MirrorsAiLogSource::tag’s shape for the level discriminator. - parse_
ai_ log_ name - Recover the
SessionKeyfrom a per-session log buffer name. ReturnsNonewhennamedoes not match the canonical*ai:<provider>:<index>*shape.
Type Aliases§
- AiLog
Event Publisher - Closure invoked on every successful append. Wired by the App
(or test harness) to publish
AiLogPushedonto the runtime event bus, which lets log buffers refresh live as records arrive. Optional:AiLogger::with_defaults()starts with no publisher;set_event_publisherinstalls one.