Skip to main content

Module scripted_agent

Module scripted_agent 

Source
Expand description

A scripted ACP agent — the fake that makes the review loop testable (ADR-0007 §7).

Lands before the real client, because it is what the real client is tested against: no subprocess, no pipes, no timing, and no network. ARCHITECTURE.md §18 asks for “scripted ACP agent replaying session/update streams incl. edit proposals and tool-permission requests”, and CONTRIBUTING.md’s fakes invariant makes it non-optional.

Scripts are written in terms of what the agent does, not in terms of wire messages, so a test reads like the interaction it is describing:

use termesh_test_support::{ScriptedAgent, ScriptedUpdate};
use termesh_agent::{AgentRequest, AgentService};

let mut agent = ScriptedAgent::new().with_turn(vec![
    ScriptedUpdate::Message("Renaming it.".into()),
    ScriptedUpdate::ReadFile("/proj/main.rs".into()),
    ScriptedUpdate::Edit {
        path: "/proj/main.rs".into(),
        old_text: Some("fn main() {}\n".into()),
        new_text: "fn run() {}\n".into(),
    },
    ScriptedUpdate::End,
]);
agent.send(AgentRequest::NewSession { cwd: "/proj".into() });
assert!(!agent.poll().is_empty());

Structs§

ScriptedAgent
An AgentService that replays a recorded stream.

Enums§

ScriptedUpdate
One thing the scripted agent does, in the order a real turn would do it.