//! Vibe's plan and display reading (X6a), against Vibe 3.1.5's live
//! captures (record/investigation-2026-11-29/streams/vibe-*.jsonl).
use std::path::Path;
use super::super::adapter::{Agent, Mode, Request, plan as adapter_plan};
use super::super::events::Event;
fn request<'a>(mode: Mode, resume: Option<&'a str>, home: Option<&'a Path>) -> Request<'a> {
Request {
agent: Agent::Vibe,
mode,
model: Some("mistral-large-4-0"),
directory: Path::new("/h/work"),
resume,
new_session: "5eab6b3f-d0af-49c3-9c0c-a9b47c2c8ebe",
private: Path::new("/tmp/neosian-harness-x"),
codex_keys: &[],
opencode_config: None,
parent: None,
server: None,
codex_off: &[],
confined: true,
pi: None,
child_home: home,
memory: None,
}
}
#[test]
fn both_modes_run_the_planned_argv_with_a_private_home_and_no_mcp() {
let home = Path::new("/t/neosian-harness-1-vibe-h1");
let head = [
"vibe",
"-p",
"--output",
"streaming",
"--workdir",
"/h/work",
];
let read = adapter_plan(&request(Mode::ReadOnly, None, Some(home))).unwrap();
let tail = ["--approval-policy", "ask", "--enabled-tools", "read_file"];
let model = ["--model", "mistral-large-4-0"];
assert_eq!(read.argv, [&head[..], &tail[..], &model[..]].concat());
let write = adapter_plan(&request(Mode::Write, Some("75b8b800-ec70"), Some(home))).unwrap();
let tail = ["--auto-approve", "--resume", "75b8b800-ec70"];
assert_eq!(
write.argv,
[&head[..], &tail[..]].concat(),
"no model on resume"
);
for plan in [&read, &write] {
let set = |k: &str, v: &str| plan.env.contains(&(k.to_string(), v.to_string()));
assert!(set("VIBE_HOME", "/t/neosian-harness-1-vibe-h1"));
assert!(set("VIBE_ENABLE_MCP", "false") && set("VIBE_ENABLE_AUTO_UPDATE", "false"));
}
assert!(adapter_plan(&request(Mode::Write, None, None)).is_err());
}
const ASSISTANT: &str = r#"{"id":"assistant-de98","sessionId":"75b8b800-ec70-b483-6df9-80bb3d5f29d0","turnId":"turn-67d8","generationStatus":"completed","type":"message","role":"assistant","content":[{"type":"text","text":"banana"}],"source":"harness","outcome":{"type":"committed"}}"#;
const DENIED: &str = r#"{"id":"effect-2d56","sessionId":"5e3a2f97-ca81-f232-b8ae-819bc77c448e","turnId":"turn-89c8","type":"effect","title":"file_system.write_file","detail":{"toolName":"file_system.write_file","kind":"file_write","input":{"filePath":"probe.txt","content":"banana\n"}},"state":{"status":"failed","output":{"type":"failure","error":{"code":"tool_denied","message":"Tool execution denied by approval policy"}},"error":{"message":"Tool execution denied by approval policy","code":"tool_denied"}},"toolCallId":"GURuuKXYw"}"#;
#[test]
fn the_display_shows_the_session_the_words_and_each_tool() {
let said = Agent::Vibe.read(ASSISTANT);
let session = "75b8b800-ec70-b483-6df9-80bb3d5f29d0".to_string();
assert_eq!(
said,
[Event::Session(session), Event::Text("banana".into())]
);
let Event::Observed(entry) = &Agent::Vibe.read(DENIED)[1] else {
panic!("an entry")
};
assert_eq!(entry["name"], "file_system.write_file");
assert_eq!(entry["status"], "failed");
assert_eq!(entry["error"], "Tool execution denied by approval policy");
}