use cersei::prelude::*;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let output = Agent::builder()
.provider(Anthropic::from_env()?)
.tools(cersei::tools::coding()) .system_prompt("You are a helpful coding assistant. Be concise.")
.max_turns(5)
.permission_policy(AllowAll)
.working_dir(".")
.run_with("List all Rust source files in the current directory and count them.")
.await?;
println!("─── Agent Output ───");
println!("{}", output.text());
println!("─── Stats ───");
println!("Turns: {}", output.turns);
println!("Tool calls: {}", output.tool_calls.len());
println!("Input tok: {}", output.usage.input_tokens);
println!("Output tok: {}", output.usage.output_tokens);
if let Some(cost) = output.usage.cost_usd {
println!("Cost: ${:.4}", cost);
}
for tc in &output.tool_calls {
println!(
" {} ({}) → {}",
tc.name,
if tc.is_error { "ERR" } else { "OK" },
tc.duration.as_millis()
);
}
Ok(())
}