use agcli::{AgentCli, Command, CommandOutput};
use serde_json::{Value, json};
#[tokio::test]
async fn kill_mutant_src_cli_rs_2385() {
unsafe { std::env::set_var("SOURCE_DATE_EPOCH", "0") };
let cli = AgentCli::new("prog", "Mutant-kill prog for cli.rs:2385").command(
Command::new("bxy", "A three-letter command").handler(|_req, _ctx| {
Box::pin(async move { Ok(CommandOutput::new(json!({"ok": true}))) })
}),
);
let exec = cli.run_argv(["prog", "aaabxy"]).await;
let raw = exec.to_json();
let envelope: Value = serde_json::from_str(&raw).expect("envelope must be valid JSON");
assert_eq!(
envelope["ok"], false,
"expected error envelope for unknown command 'aaabxy', got: {envelope}"
);
assert_eq!(
envelope["error"]["code"], "UNKNOWN_COMMAND",
"expected UNKNOWN_COMMAND code, got: {envelope}"
);
let fix = envelope["fix"]
.as_str()
.expect("fix field must be present on UNKNOWN_COMMAND error");
eprintln!("fix = {fix:?}");
assert!(
!fix.contains("Did you mean"),
"expected no did-you-mean suggestion (lev dist 3 > threshold 2), but got: {fix:?}\n\
(if this fires on REAL code the distance calculation changed; \
if it fires only under mutation, curr[0]=i*1 is lowering dist from 3 to 2 \
and pushing it past the <= 2 gate)"
);
}