termesh_agent/lib.rs
1//! The agent layer — the project's wedge (ARCHITECTURE.md §9).
2//!
3//! We implement the **client** side of the Agent Client Protocol (ACP): an open JSON-RPC
4//! 2.0 standard where the agent runs as a subprocess over stdio and the editor is the
5//! client. Any ACP agent — Claude Code, Codex, Gemini CLI, OpenCode, Goose — plugs in, so
6//! we never marry one model vendor. Spec: <https://agentclientprotocol.com>.
7//!
8//! Integration is **tiered** (ADR-0003), which de-risks the whole bet:
9//! - **Tier 0 — [`AgentIntegration::TerminalCli`]**: free. The user runs any AI CLI
10//! inside a managed terminal pane. Ships as soon as the terminal exists (Phase 04),
11//! with zero agent-specific code. If ACP work slips, the product is still useful.
12//! - **Tier 1 — [`AgentIntegration::Acp`]**: the differentiator. Full ACP client with
13//! shared project context, inline diff-review of proposed edits, and permission-gated
14//! tool calls.
15//!
16//! **What this crate does not export matters as much as what it does.** No ACP wire type
17//! crosses this boundary: `editor` and `ui` see [`AgentEvent`], [`Hunk`], and
18//! [`EditProposal`], never a `SessionUpdate` or a `ToolCallContent`. That isolation is
19//! ADR-0003's mitigation for spec churn, and the churn is not hypothetical — the upstream
20//! SDK is at 2.0 with an unstable protocol-v2 feature already in flight.
21//!
22//! Two surfaces live here:
23//! - [`service`] — the [`AgentService`] trait, the requests we send, the events we get.
24//! - [`proposal`] — turning the agent's whole-file diffs into reviewable hunks, and
25//! carrying those hunks onto a buffer the human has kept typing in.
26#![forbid(unsafe_code)]
27
28pub mod acp;
29pub mod jsonrpc;
30pub mod proposal;
31pub mod protocol;
32pub mod service;
33
34pub use acp::AcpAgent;
35pub use proposal::{changeset_from_hunks, hunks_from_diff, rebase_hunks, EditProposal, Hunk};
36pub use service::{
37 permission_for_review, AgentEvent, AgentIntegration, AgentRequest, AgentService,
38 ClientCapabilities, NullAgent, PermissionDecision, ProposalDecision, StopReason,
39};