From 93844b688e08096e45e67fbadaa07626bef6d67d Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 23 Nov 2026 21:18:18 +0100 Subject: Format with rustfmt --- src/main.rs | 41 +++++++++++++++++++++++++++-------------- src/tools/mod.rs | 6 +++++- src/ui.rs | 6 ++++-- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index ba296d9..786b070 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,12 @@ * https://git.2137697.xyz/agent686 */ +use serde_json::json; use std::io::{BufRead, IsTerminal, Write}; use std::path::Path; -use serde_json::json; -use std::time::UNIX_EPOCH; use std::path::PathBuf; use std::time::SystemTime; +use std::time::UNIX_EPOCH; use serde_json::Value; @@ -149,9 +149,7 @@ fn parse_args() -> Result { "--" => literal = true, "-m" | "--model" => args.model = Some(take_value(&mut iter, "--model")?), "--base-url" => args.base_url = Some(take_value(&mut iter, "--base-url")?), - "--session" | "--resume" => { - args.session = Some(take_value(&mut iter, "--session")?) - } + "--session" | "--resume" => args.session = Some(take_value(&mut iter, "--session")?), "-c" | "--continue" => args.continue_last = true, "--list" => args.list = true, "--show" => { @@ -203,10 +201,7 @@ fn parse_args() -> Result { fn take_value(iter: &mut impl Iterator, flag: &str) -> Result { match iter.next() { - Some(value) - if !value.trim().is_empty() - && !(value.starts_with('-') && value.len() > 1) => - { + Some(value) if !value.trim().is_empty() && !(value.starts_with('-') && value.len() > 1) => { Ok(value) } _ => Err(format!( @@ -510,7 +505,10 @@ fn undo(checkpoint: Option<&str>) { /// `/compact`: summarise the conversation and start again from the summary, in /// the same session id. The only sanctioned rewrite of the transcript (ADR 0003). fn compact(cfg: &Config, session: &mut Session, history: &mut Vec) { - let system = history.first().cloned().unwrap_or_else(|| agent::system_prompt()); + let system = history + .first() + .cloned() + .unwrap_or_else(|| agent::system_prompt()); let mut messages = history.clone(); messages.push(json!({ "role": "user", @@ -540,7 +538,10 @@ fn compact(cfg: &Config, session: &mut Session, history: &mut Vec) { return; } *history = new_history; - eprintln!("agent686: compacted into a {}-character summary", summary.len()); + eprintln!( + "agent686: compacted into a {}-character summary", + summary.len() + ); } fn list_models(cfg: &Config) { @@ -676,7 +677,10 @@ fn print_sessions(json: bool) { }) }) .collect(); - println!("{}", serde_json::to_string(&rows).unwrap_or_else(|_| "[]".into())); + println!( + "{}", + serde_json::to_string(&rows).unwrap_or_else(|_| "[]".into()) + ); return; } if sessions.is_empty() { @@ -917,7 +921,13 @@ fn render_message(message: &Value, color: bool) -> String { "2", &format!( " └ {}", - first_lines(message.get("content").and_then(|c| c.as_str()).unwrap_or(""), 4) + first_lines( + message + .get("content") + .and_then(|c| c.as_str()) + .unwrap_or(""), + 4 + ) ), color ) @@ -957,7 +967,10 @@ fn print_last_reply(session: &Session) { "{}", style( "2", - &format!("… {} more line(s); `agent686 --show` for the transcript", lines.len() - limit), + &format!( + "… {} more line(s); `agent686 --show` for the transcript", + lines.len() - limit + ), true ) ); diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 43176c3..05af611 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -104,7 +104,11 @@ pub fn validate(name: &str, args: &Value) -> Result<(), String> { } /// Tools that execute immediately. -pub fn run(name: &str, args: &Value, cancel: &std::sync::atomic::AtomicBool) -> Result { +pub fn run( + name: &str, + args: &Value, + cancel: &std::sync::atomic::AtomicBool, +) -> Result { match name { "read" => fs::read(args), "grep" => fs::grep(args), diff --git a/src/ui.rs b/src/ui.rs index 9931a7d..1ffe34c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -307,8 +307,10 @@ impl Approver { return true; } // Bash prompts every call by design, so "always" is not offered here. - self.ask(&format!("run: {}", crate::provider::truncate(cmd, 200)), false) - == Answer::Yes + self.ask( + &format!("run: {}", crate::provider::truncate(cmd, 200)), + false, + ) == Answer::Yes } } -- cgit v1.2.3