Craft Anything: understand how any software works, and craft your own.
Rust
Call a coding agent's cost an estimate, not the bill (#9)
Brandon Thomase244159c17a2
diff --git a/apps/craft-anything-cli/src/ai_cmd.rs b/apps/craft-anything-cli/src/ai_cmd.rsindex a8161fcf..952b7ac1 100644--- a/apps/craft-anything-cli/src/ai_cmd.rs+++ b/apps/craft-anything-cli/src/ai_cmd.rs@@ -144,9 +144,11 @@ pub fn chat(cli: &Cli, a: &ChatArgs) -> u8 {}}}- AgentEvent::TurnDone { backend, input_tokens, output_tokens, cost_usd } => {+ AgentEvent::TurnDone { backend, input_tokens, output_tokens, cost_usd, cost_is_estimate } => {if !jsonl {- let cost = cost_usd.map(|c| format!(", ${c:.4}")).unwrap_or_default();+ let cost = cost_usd+ .map(|c| if *cost_is_estimate { format!(", about ${c:.4} at API prices (an estimate, not a bill)") } else { format!(", ${c:.4}") })+ .unwrap_or_default();write_raw("\n");eprintln!("[{backend}: {input_tokens} in / {output_tokens} out{cost}]");}diff --git a/crates/ai/src/agent.rs b/crates/ai/src/agent.rsindex 788e6334..8ffb394d 100644--- a/crates/ai/src/agent.rs+++ b/crates/ai/src/agent.rs@@ -373,7 +373,13 @@ impl AgentLoop {}self.save_transcript();let backend = self.chain.get(self.current).map(|s| s.name.clone()).unwrap_or_default();- self.emit(AgentEvent::TurnDone { backend, input_tokens: msg_usage.input_tokens, output_tokens: msg_usage.output_tokens, cost_usd: msg_cost });+ self.emit(AgentEvent::TurnDone {+ backend,+ input_tokens: msg_usage.input_tokens,+ output_tokens: msg_usage.output_tokens,+ cost_usd: msg_cost,+ cost_is_estimate: false,+ });}/// Keep the conversation in its transcript file, when it has one.diff --git a/crates/ai/src/cli_agents/acp.rs b/crates/ai/src/cli_agents/acp.rsindex cf5616fb..f5970165 100644--- a/crates/ai/src/cli_agents/acp.rs+++ b/crates/ai/src/cli_agents/acp.rs@@ -186,7 +186,7 @@ impl AcpCore {}fn turn_done(&self) -> Out {- Out::Event(AgentEvent::TurnDone { backend: self.backend.clone(), input_tokens: 0, output_tokens: 0, cost_usd: None })+ Out::Event(AgentEvent::TurnDone { backend: self.backend.clone(), input_tokens: 0, output_tokens: 0, cost_usd: None, cost_is_estimate: false })}fn response(&mut self, id: u64, msg: &Value) -> Vec<Out> {@@ -537,7 +537,13 @@ impl Conversation for AcpConversation {if let Err(e) = self.spawn() {self.busy.store(false, Ordering::SeqCst);let _ = self.tx.send(AgentEvent::Error { message: e.message, remediation: e.remediation, log: None });- let _ = self.tx.send(AgentEvent::TurnDone { backend: self.backend.clone(), input_tokens: 0, output_tokens: 0, cost_usd: None });+ let _ = self.tx.send(AgentEvent::TurnDone {+ backend: self.backend.clone(),+ input_tokens: 0,+ output_tokens: 0,+ cost_usd: None,+ cost_is_estimate: false,+ });return;}}@@ -578,7 +584,7 @@ impl Conversation for AcpConversation {)),log,});- events.push(AgentEvent::TurnDone { backend: self.backend.clone(), input_tokens: 0, output_tokens: 0, cost_usd: None });+ events.push(AgentEvent::TurnDone { backend: self.backend.clone(), input_tokens: 0, output_tokens: 0, cost_usd: None, cost_is_estimate: false });}events}diff --git a/crates/ai/src/cli_agents/mod.rs b/crates/ai/src/cli_agents/mod.rsindex a0bd45d9..35eb3e1c 100644--- a/crates/ai/src/cli_agents/mod.rs+++ b/crates/ai/src/cli_agents/mod.rs@@ -491,7 +491,13 @@ fn run_cli(spec: &CliSpec, text: &str, tx: &Sender<AgentEvent>, stop: &Stop, seslet _ = tx.send(shown.error_event(&agent, e));}}- let _ = tx.send(AgentEvent::TurnDone { backend: name, input_tokens: p.input_tokens, output_tokens: p.output_tokens, cost_usd: p.cost_usd });+ let _ = tx.send(AgentEvent::TurnDone {+ backend: name,+ input_tokens: p.input_tokens,+ output_tokens: p.output_tokens,+ cost_usd: p.cost_usd,+ cost_is_estimate: true,+ });}/// What's needed to explain a failed CLI run: the command with the person's message left out, and@@ -632,7 +638,13 @@ impl Conversation for CliConversation {let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| run_cli(&spec, &text, &tx, &stop, &session, &verified)));if r.is_err() {let _ = tx.send(AgentEvent::Error { message: "The agent runner hit a bug and stopped safely.".into(), remediation: None, log: None });- let _ = tx.send(AgentEvent::TurnDone { backend: spec.config.name.clone(), input_tokens: 0, output_tokens: 0, cost_usd: None });+ let _ = tx.send(AgentEvent::TurnDone {+ backend: spec.config.name.clone(),+ input_tokens: 0,+ output_tokens: 0,+ cost_usd: None,+ cost_is_estimate: false,+ });}busy.store(false, Ordering::SeqCst);});diff --git a/crates/ai/src/lib.rs b/crates/ai/src/lib.rsindex 753db950..e3678ae9 100644--- a/crates/ai/src/lib.rs+++ b/crates/ai/src/lib.rs@@ -169,6 +169,10 @@ pub enum AgentEvent {input_tokens: u64,output_tokens: u64,cost_usd: Option<f64>,+ /// `cost_usd` is the agent's own guess at API prices, not what a key was charged: a+ /// subscription may cover the whole of it.+ #[serde(default)]+ cost_is_estimate: bool,},Error {message: String,diff --git a/crates/ai/src/rebuild/mod.rs b/crates/ai/src/rebuild/mod.rsindex 87cb279a..74cff321 100644--- a/crates/ai/src/rebuild/mod.rs+++ b/crates/ai/src/rebuild/mod.rs@@ -412,14 +412,14 @@ impl Worker {/// Add the time worked since the last record (and an agent turn's tokens and reported cost)/// to the project's usage.json. The run is its only writer; a failure is logged and the build/// carries on.- fn record_usage(&mut self, turn: Option<(u64, u64, Option<f64>)>) {+ fn record_usage(&mut self, turn: Option<(u64, u64, Option<f64>, bool)>) {let Some(clock) = self.usage.as_mut() else { return };let ms = u64::try_from(clock.since.elapsed().as_millis()).unwrap_or(u64::MAX);clock.since = Instant::now();let saved = ProjectUsage::update(&clock.root, |u| {u.work_ms = u.work_ms.saturating_add(ms);- if let Some((input, output, cost)) = turn {- u.add_turn(input, output, cost);+ if let Some((input, output, cost, estimate)) = turn {+ u.add_turn(input, output, cost, estimate);}});if let Err(e) = saved {@@ -811,8 +811,8 @@ impl Worker {AgentEvent::Error { message, remediation, .. } => failed = Some((message.clone(), remediation.clone())),_ => {}}- if let AgentEvent::TurnDone { input_tokens, output_tokens, cost_usd, .. } = &e {- self.record_usage(Some((*input_tokens, *output_tokens, *cost_usd)));+ if let AgentEvent::TurnDone { input_tokens, output_tokens, cost_usd, cost_is_estimate, .. } = &e {+ self.record_usage(Some((*input_tokens, *output_tokens, *cost_usd, *cost_is_estimate)));}let done = matches!(e, AgentEvent::TurnDone { .. });self.emit(RunEvent::Agent(e));diff --git a/crates/ai/src/rebuild/question.rs b/crates/ai/src/rebuild/question.rsindex 7700097f..c4fcbb72 100644--- a/crates/ai/src/rebuild/question.rs+++ b/crates/ai/src/rebuild/question.rs@@ -247,7 +247,7 @@ mod tests {#[test]fn an_answer_is_its_words_until_the_turn_ends_and_an_error_is_an_error() {let words = |t: &str| AgentEvent::TextDelta { text: t.into() };- let done = AgentEvent::TurnDone { backend: "A".into(), input_tokens: 1, output_tokens: 1, cost_usd: Some(0.02) };+ let done = AgentEvent::TurnDone { backend: "A".into(), input_tokens: 1, output_tokens: 1, cost_usd: Some(0.02), cost_is_estimate: false };let mut ok = Scripted(vec![words("They're in "), words("app/src."), done]);assert_eq!(collect(&mut ok, &CancelToken::default(), WAIT).unwrap(), ("They're in app/src.".to_string(), Some(0.02)));let mut bad = Scripted(vec![AgentEvent::Error { message: "not signed in".into(), remediation: Some("Sign in".into()), log: None }]);diff --git a/crates/ai/src/rebuild/tests.rs b/crates/ai/src/rebuild/tests.rsindex 748a01b8..0b93f919 100644--- a/crates/ai/src/rebuild/tests.rs+++ b/crates/ai/src/rebuild/tests.rs@@ -1305,7 +1305,10 @@ impl Conversation for ChecksItsWork {}match self.reply.take() {Some(text) => {- vec![AgentEvent::TextDelta { text }, AgentEvent::TurnDone { backend: "test".into(), input_tokens: 0, output_tokens: 0, cost_usd: None }]+ vec![+ AgentEvent::TextDelta { text },+ AgentEvent::TurnDone { backend: "test".into(), input_tokens: 0, output_tokens: 0, cost_usd: None, cost_is_estimate: false },+ ]}None => Vec::new(),}diff --git a/crates/ai/src/tests.rs b/crates/ai/src/tests.rsindex 63c8c226..77797f95 100644--- a/crates/ai/src/tests.rs+++ b/crates/ai/src/tests.rs@@ -174,7 +174,7 @@ fn anthropic_streaming_tool_loop_through_the_engine() {assert_eq!(text, "Checking Nothing is open.");assert!(ev.iter().any(|e| matches!(e, AgentEvent::ToolFinished { tool, ok: true, .. } if tool == "core_session_show")));assert!(ev.iter().any(|e| matches!(e, AgentEvent::ToolFinished { tool, ok: true, .. } if tool == "core_targets_list")));- let AgentEvent::TurnDone { backend, input_tokens, output_tokens, cost_usd } = ev.last().unwrap().clone() else { panic!() };+ let AgentEvent::TurnDone { backend, input_tokens, output_tokens, cost_usd, .. } = ev.last().unwrap().clone() else { panic!() };assert_eq!((backend.as_str(), input_tokens, output_tokens), ("Claude", 300, 50));assert!(cost_usd.unwrap() > 0.0);diff --git a/crates/engine/src/workspace.rs b/crates/engine/src/workspace.rsindex 021e5317..fd9e3b2c 100644--- a/crates/engine/src/workspace.rs+++ b/crates/engine/src/workspace.rs@@ -468,8 +468,12 @@ pub struct ProjectUsage {pub work_ms: u64,pub input_tokens: u64,pub output_tokens: u64,- /// What the coding agent reported, in US dollars (its estimate at API prices).+ /// Everything reported, in US dollars: what API keys were charged plus coding agents' own+ /// estimates at API prices.pub cost_usd: f64,+ /// The part of `cost_usd` charged to an API key. The rest is an estimate, which is all files+ /// from before this field held.+ pub api_billed_usd: f64,/// Some of it came with a price; agents that report none leave tokens only.pub priced: bool,}@@ -497,15 +501,24 @@ impl ProjectUsage {}/// One agent turn's tokens and reported cost (a price that isn't a sensible number is skipped).- pub fn add_turn(&mut self, input: u64, output: u64, cost_usd: Option<f64>) {+ /// `estimate`: the cost is the agent's own guess at API prices, not a key's charge.+ pub fn add_turn(&mut self, input: u64, output: u64, cost_usd: Option<f64>, estimate: bool) {self.input_tokens = self.input_tokens.saturating_add(input);self.output_tokens = self.output_tokens.saturating_add(output);if let Some(c) = cost_usd.filter(|c| c.is_finite() && *c >= 0.0) {self.cost_usd += c;+ if !estimate {+ self.api_billed_usd += c;+ }self.priced = true;}}+ /// The part of the cost that is a coding agent's estimate rather than a key's charge.+ pub fn estimated_usd(&self) -> f64 {+ (self.cost_usd - self.api_billed_usd).max(0.0)+ }+pub fn tokens(&self) -> u64 {self.input_tokens.saturating_add(self.output_tokens)}@@ -1001,7 +1014,7 @@ mod tests {for cost in [Some(1.25), None, Some(f64::NAN), Some(2.0)] {ProjectUsage::update(dir.path(), |u| {u.work_ms += 1_000;- u.add_turn(100, 10, cost);+ u.add_turn(100, 10, cost, true);}).unwrap();}diff --git a/crates/ui-egui/examples/snapshot.rs b/crates/ui-egui/examples/snapshot.rsindex eb4cca30..b1047d21 100644--- a/crates/ui-egui/examples/snapshot.rs+++ b/crates/ui-egui/examples/snapshot.rs@@ -164,7 +164,7 @@ fn main() {demo::fill_project(&mut a);// What the build took and used (side panel and title bar).let mut u = craft_anything_engine::workspace::ProjectUsage { work_ms: 725_000, ..Default::default() };- u.add_turn(1_180_000, 42_000, Some(3.21));+ u.add_turn(1_180_000, 42_000, Some(3.21), true);if let Some(root) = a.workspace.as_ref().map(|w| w.root.clone()) {a.usage.insert(root, craft_anything_ui_egui::usage::ProjectClock { saved: u.clone(), since: None });}diff --git a/crates/ui-egui/src/chat.rs b/crates/ui-egui/src/chat.rsindex 14b75b23..2303468d 100644--- a/crates/ui-egui/src/chat.rs+++ b/crates/ui-egui/src/chat.rs@@ -630,7 +630,7 @@ mod tests {},);apply_event(&mut chat, AgentEvent::ConsentNeeded { call_id: "c2".into(), tool: "run".into(), title: "Run it".into(), explanation: "runs".into() });- apply_event(&mut chat, AgentEvent::TurnDone { backend: "Claude".into(), input_tokens: 1, output_tokens: 2, cost_usd: None });+ apply_event(&mut chat, AgentEvent::TurnDone { backend: "Claude".into(), input_tokens: 1, output_tokens: 2, cost_usd: None, cost_is_estimate: false });match &chat[1] {ChatItem::Assistant { text, streaming, backend } => {assert_eq!(text, "Hello");diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex d9f69bc4..977a8cf9 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1095,8 +1095,8 @@ impl CraftApp {chat::apply_event(&mut self.state.chat, e.clone());match e {AgentEvent::ToolFinished { .. } => self.view_dirty = true,- AgentEvent::TurnDone { backend, input_tokens, output_tokens, cost_usd } => {- self.session_usage.add_turn(input_tokens, output_tokens, cost_usd);+ AgentEvent::TurnDone { backend, input_tokens, output_tokens, cost_usd, cost_is_estimate } => {+ self.session_usage.add_turn(input_tokens, output_tokens, cost_usd, cost_is_estimate);let cost = cost_usd.map(|c| format!(", ${c:.4}")).unwrap_or_default();self.log(false, format!("{backend}: {input_tokens} in / {output_tokens} out{cost}"));}diff --git a/crates/ui-egui/src/project.rs b/crates/ui-egui/src/project.rsindex 022ca372..d01a05fd 100644--- a/crates/ui-egui/src/project.rs+++ b/crates/ui-egui/src/project.rs@@ -261,9 +261,9 @@ impl CraftApp {clock.saved_again(root, false);finished.push(root.clone());}- RunEvent::Agent(AgentEvent::TurnDone { input_tokens, output_tokens, cost_usd, .. }) => {+ RunEvent::Agent(AgentEvent::TurnDone { input_tokens, output_tokens, cost_usd, cost_is_estimate, .. }) => {clock.saved_again(root, true);- self.session_usage.add_turn(*input_tokens, *output_tokens, *cost_usd);+ self.session_usage.add_turn(*input_tokens, *output_tokens, *cost_usd, *cost_is_estimate);}// A run's first event is its first step: the clock starts there._ if !clock.working() => clock.saved_again(root, true),@@ -873,7 +873,12 @@ fn steps(app: &CraftApp, ui: &mut Ui, ws: &Workspace) {let tip = || crate::usage::explain(&u.saved, "Every build of this project.");stat_row(ui, "Time spent", &crate::usage::duration_words(u.elapsed()));if u.saved.priced {- stat_row(ui, "AI cost", &crate::usage::cost_words(u.saved.cost_usd)).on_hover_text(tip());+ let cost = crate::usage::cost_stat(&u.saved);+ stat_row(ui, cost.label, &cost.value).on_hover_text(tip());+ // Said outright, not only on hover: on a subscription this isn't what they pay.+ if let Some(note) = cost.note {+ ui.add(egui::Label::new(RichText::new(tr(note)).color(Tokens::get(ui.ctx()).text_faint).size(theme::CAPTION)).wrap());+ }}if u.saved.tokens() > 0 {stat_row(ui, "Tokens", &crate::usage::tokens_short(u.saved.tokens())).on_hover_text(tip());diff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rsindex 90793493..9d2ee60e 100644--- a/crates/ui-egui/src/titlebar.rs+++ b/crates/ui-egui/src/titlebar.rs@@ -200,7 +200,7 @@ fn usage_pill(app: &CraftApp, ui: &mut Ui) {return;}let t = Tokens::get(ui.ctx());- let text = if u.priced { crate::usage::cost_words(u.cost_usd) } else { crate::usage::tokens_words(u.tokens()) };+ let text = if u.priced { crate::usage::cost_short(u) } else { crate::usage::tokens_words(u.tokens()) };let r = widgets::pill(ui, &text, t.text_dim, t.raised);r.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &text));r.on_hover_ui(|ui| {diff --git a/crates/ui-egui/src/usage.rs b/crates/ui-egui/src/usage.rsindex 88a1da33..86add79d 100644--- a/crates/ui-egui/src/usage.rs+++ b/crates/ui-egui/src/usage.rs@@ -1,6 +1,7 @@//! What the AI has used: each project's building time, tokens and reported cost (saved by its//! runs in `usage.json`, so they add up across restarts), and the session's total since the app-//! opened. Claude Code prices each run; other agents give tokens only.+//! opened. An API key's cost comes from what it was charged; Claude Code gives its own estimate+//! at API prices, which isn't a bill (a subscription may cover it); other agents give tokens only.use std::path::Path;use std::time::{Duration, Instant};@@ -39,11 +40,43 @@ impl ProjectClock {}}-/// "about $3.20" (agents report an estimate at API prices).+/// "about $3.20".pub fn cost_words(usd: f64) -> String {trf("about ${n}", &[("n", &format!("{usd:.2}"))])}+/// Below this, a difference between two amounts is rounding, not money.+const NOT_MONEY: f64 = 0.005;++/// How to show a project's cost. A coding agent's figure is an estimate and is called one: it's+/// never shown as if it were what the person paid.+#[derive(Debug, Clone, PartialEq)]+pub struct CostStat {+ /// Translated when drawn.+ pub label: &'static str,+ pub value: String,+ /// Shown under the number. Translated when drawn.+ pub note: Option<&'static str>,+}++pub fn cost_stat(u: &ProjectUsage) -> CostStat {+ let estimated = u.estimated_usd();+ if estimated < NOT_MONEY {+ return CostStat { label: "AI cost", value: cost_words(u.cost_usd), note: None };+ }+ if u.api_billed_usd < NOT_MONEY {+ return CostStat { label: "AI cost (estimate)", value: cost_words(u.cost_usd), note: Some(ESTIMATE_NOTE) };+ }+ CostStat { label: "AI cost (part estimate)", value: cost_words(u.cost_usd), note: Some(ESTIMATE_NOTE) }+}++/// The cost in few words, for the title bar.+pub fn cost_short(u: &ProjectUsage) -> String {+ if u.estimated_usd() < NOT_MONEY { cost_words(u.cost_usd) } else { trf("{cost} (estimate)", &[("cost", &cost_words(u.cost_usd))]) }+}++const ESTIMATE_NOTE: &str = "The coding agent's estimate at API prices, not your bill. A subscription isn't charged this.";+/// "830", "12k", "1.2M".pub fn tokens_short(n: u64) -> String {match n {@@ -72,8 +105,11 @@ pub fn duration_words(d: Duration) -> String {/// of this project." or "Since Craft Anything opened.").pub fn explain(u: &ProjectUsage, counts: &str) -> String {let mut lines = vec![trf("{in} in, {out} out.", &[("in", &tokens_words(u.input_tokens)), ("out", &tokens_words(u.output_tokens))])];- if u.priced {- lines.push(tr("The cost is the coding agent's own estimate at API prices; a subscription may cover it."));+ if u.priced && u.estimated_usd() >= NOT_MONEY {+ lines.push(tr(ESTIMATE_NOTE));+ if u.api_billed_usd >= NOT_MONEY {+ lines.push(trf("Of this, {cost} was charged to an API key.", &[("cost", &cost_words(u.api_billed_usd))]));+ }}lines.push(tr(counts));lines.join("\n")@@ -95,6 +131,40 @@ mod tests {assert_eq!(c.elapsed(), Duration::from_secs(725));}+ #[test]+ fn a_coding_agents_cost_is_called_an_estimate_and_a_keys_is_not() {+ let mut agent = ProjectUsage::default();+ agent.add_turn(10, 10, Some(3.12), true);+ let stat = cost_stat(&agent);+ assert_eq!((stat.label, stat.value.as_str()), ("AI cost (estimate)", "about $3.12"));+ assert!(stat.note.unwrap().contains("not your bill"));+ assert_eq!(cost_short(&agent), "about $3.12 (estimate)");+ assert!(explain(&agent, "x").contains("not your bill"));++ let mut key = ProjectUsage::default();+ key.add_turn(10, 10, Some(1.5), false);+ assert_eq!(cost_stat(&key), CostStat { label: "AI cost", value: "about $1.50".into(), note: None });+ assert_eq!(cost_short(&key), "about $1.50");+ assert!(!explain(&key, "x").contains("estimate"));++ // Both in one project: the total, said to be partly an estimate, and the charged part.+ key.add_turn(10, 10, Some(2.0), true);+ assert_eq!(cost_stat(&key).label, "AI cost (part estimate)");+ assert_eq!(cost_stat(&key).value, "about $3.50");+ assert!(explain(&key, "x").contains("about $1.50 was charged"));+ }++ #[test]+ fn a_saved_cost_from_before_the_split_counts_as_an_estimate() {+ let dir = tempfile::tempdir().unwrap();+ std::fs::write(+ dir.path().join(craft_anything_engine::workspace::USAGE_FILE),+ r#"{"version":1,"work_ms":5,"input_tokens":1,"output_tokens":1,"cost_usd":3.12,"priced":true}"#,+ )+ .unwrap();+ assert_eq!(cost_stat(&ProjectUsage::load(dir.path())).label, "AI cost (estimate)");+ }+#[test]fn plain_words_for_numbers() {assert_eq!(tokens_words(830), "830 tokens");diff --git a/crates/ui-egui/tests/smoke.rs b/crates/ui-egui/tests/smoke.rsindex f91ce27c..3dd28cde 100644--- a/crates/ui-egui/tests/smoke.rs+++ b/crates/ui-egui/tests/smoke.rs@@ -1297,7 +1297,7 @@ fn a_projects_saved_time_and_ai_use_show_beside_it_and_the_session_total_in_the_let root = d.path().to_path_buf();ProjectUsage::update(&root, |u| {u.work_ms = 725_000;- u.add_turn(1_180_000, 42_000, Some(3.21));+ u.add_turn(1_180_000, 42_000, Some(3.21), true);}).unwrap();let mut h = harness(move || {@@ -1306,16 +1306,19 @@ fn a_projects_saved_time_and_ai_use_show_beside_it_and_the_session_total_in_the_if let Some(ws) = a.workspace.as_mut() {ws.root = root.clone();}- a.session_usage.add_turn(1_180_000, 42_000, Some(3.21));+ a.session_usage.add_turn(1_180_000, 42_000, Some(3.21), true);a});h.run_steps(3);h.get_by_label("Time spent");h.get_by_label("12m 05s");- h.get_by_label("AI cost");+ // A coding agent's figure is called an estimate, in the open and not only on hover.+ h.get_by_label("AI cost (estimate)");+ h.get_by_label("The coding agent's estimate at API prices, not your bill. A subscription isn't charged this.");h.get_by_label("1.2M");// The project's row and the title bar's session total.- assert_eq!(h.get_all_by_label("about $3.21").count(), 2);+ h.get_by_label("about $3.21");+ h.get_by_label("about $3.21 (estimate)");}#[test]diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex b73c3523..f43127dd 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -775,6 +775,10 @@ Gaps found while using the app for real projects.command doesn't return until it closes: start it without inheriting the CLI's handles- [x] The desktop app keeps `desktop.log` beside its settings: startup steps, warnings, a windowthat couldn't start, panics+- [x] The cost says when it's an estimate: Claude Code's figure is its own guess at API prices,+ so the project page says "AI cost (estimate)" with a note that it isn't the bill, and the+ title bar says "(estimate)"; what an API key was charged is kept apart (`api_billed_usd`+ in usage.json; older files count as estimates)- [ ] Sometimes starting the app shows nothing: find why from `desktop.log` (a GOG Galaxy Vulkanoverlay layer loads into the app; try DX12 first on Windows if that's it)- [x] Try again picks up where a run stopped instead of starting over: a project whose builderdiff --git a/docs/STATUS.md b/docs/STATUS.mdindex 9f9c3390..22108f71 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -22,7 +22,7 @@ secret scan of all history clean).| Agents over ACP | Opt-in per backend (`acp = true`): Gemini CLI, Qwen Code, opencode and goose in their ACP mode, one agent process per chat or build with our MCP server. In chat, permission requests become consent questions; in builds they go through the same approval policy as Claude Code's (inbox, Auto mode) | Protocol unit tests against scripted agent messages and an approval-policy test; not yet run against a real agent || WASM plugins | With `--features wasm-plugins`: `[[plugins.wasm]]` components exporting `craft-anything:plugin/tools` add tools, and ones exporting `craft-anything:plugin/checks` add checks run after each kind's own (they get the build's file list as JSON) (added, listed, turned on or off and removed in Settings → Plugins or with `plugins_add`/`plugins_remove`/`plugins_list`); no imports, fresh instance per call, fuel and memory limits | Tests with components written in WAT (describe, call, checks, a looping call stopped, imports refused, end to end through the engine); `examples/wasm-plugin-wordcount` built from Rust and loaded || Questions and approvals | A file inbox per project; `core_person_ask`, `core_action_approve` and MCP consent requests become cards in the app | Cross-handle round-trip tests, a full approval round trip through the engine |-| Desktop app | Simple mode: sidebar with New project and the project history (kept across restarts); New project either makes something or just looks inside an app or file, a website or a game's files; a Game files screen (a game's archives; pictures from Unreal paks, Unity .assets files and Unity bundles saved as PNG after the person confirms they may unpack the game; uncompressed textures and the block formats DXT1, DXT5 and BC4–BC7), make prompt with picture attachments and, for anything recreated, a Clean room / Deep choice (also in the title bar; in Clean room, Just look inside, Game files, opening a file and the workbench ask for Deep mode instead), project screen (steps with the time spent and the AI cost and tokens of every build, saved in the project's usage.json by the run, pinned builder checklist, feed, question and approval cards, a Continue card when a build was paused or stopped part-way (the app or computer closed; the project shows Interrupted) that carries on the builder's own session instead of starting over, checks with screenshots and the requirements not met yet, the builder's open questions, preview, play, folder, follow-ups while it builds, which Claude Code takes at its next step; Up in the prompt box takes back the last note still waiting). Projects can start in a folder the person picks, whose files are either the app, edited in place, or material to start from (asked, or the answer remembered in Settings), and are listed from any number of folders (`project_folders`, `project_list`, `rebuild --project-folder`). Make says which AI builds ("Built by": automatic, or any AI that can build, by name); a pick stays with the project and builds its later changes. With nothing to build with, Start offers the coding agents found on the computer. Settings → AI turns an AI off or removes it. In the prompt box, Up at the very start and Down at the very end go through earlier prompts when no note is waiting. Questions about a build ("Just ask" under the prompt box, or a message starting with `/btw`, the first slash command; `rebuild_question_ask`) are answered in the conversation, where each folds away and is kept in the project, without a build or a round and changing nothing: Claude Code answers from a read-only copy of the builder's own session. Under each project's prompt box, "Builder's questions: Ask me / Decide yourself" chooses whether the builder's questions come to the person as cards or are decided by the builder, which says what it chose (`project_questions_set`; the default is in Settings and follows Auto mode until picked). Projects can be renamed, duplicated and deleted (right-click in the sidebar, or the project's page; a delete keeps the person's own files). A build can be pinned (Pin this build on its page, or `project_pin_*` from the CLI and MCP): a frozen copy in the project's pinned/ folder (the default) or a light one that shares dependencies and media with the project through hard links (each one's size shown first), opened from the sidebar's collapsible Pinned section (icons with a running dot when folded); a pin or Play runs once per folder unless another copy is asked for, and a start that quits at once says so with its last output. Typed drafts survive a restart. In a narrow window the sidebar folds to icons and the project's details move above its feed; messages float over the screen and errors stay until dismissed. Advanced mode: workbench with every panel wired to real tools, as a screen beside the projects (builds and their questions stay a click away) | UI unit and smoke tests (egui_kittest), offscreen snapshots of every screen |+| Desktop app | Simple mode: sidebar with New project and the project history (kept across restarts); New project either makes something or just looks inside an app or file, a website or a game's files; a Game files screen (a game's archives; pictures from Unreal paks, Unity .assets files and Unity bundles saved as PNG after the person confirms they may unpack the game; uncompressed textures and the block formats DXT1, DXT5 and BC4–BC7), make prompt with picture attachments and, for anything recreated, a Clean room / Deep choice (also in the title bar; in Clean room, Just look inside, Game files, opening a file and the workbench ask for Deep mode instead), project screen (steps with the time spent and the AI cost and tokens of every build, saved in the project's usage.json by the run (a coding agent's figure is shown as an estimate at API prices, not the bill), pinned builder checklist, feed, question and approval cards, a Continue card when a build was paused or stopped part-way (the app or computer closed; the project shows Interrupted) that carries on the builder's own session instead of starting over, checks with screenshots and the requirements not met yet, the builder's open questions, preview, play, folder, follow-ups while it builds, which Claude Code takes at its next step; Up in the prompt box takes back the last note still waiting). Projects can start in a folder the person picks, whose files are either the app, edited in place, or material to start from (asked, or the answer remembered in Settings), and are listed from any number of folders (`project_folders`, `project_list`, `rebuild --project-folder`). Make says which AI builds ("Built by": automatic, or any AI that can build, by name); a pick stays with the project and builds its later changes. With nothing to build with, Start offers the coding agents found on the computer. Settings → AI turns an AI off or removes it. In the prompt box, Up at the very start and Down at the very end go through earlier prompts when no note is waiting. Questions about a build ("Just ask" under the prompt box, or a message starting with `/btw`, the first slash command; `rebuild_question_ask`) are answered in the conversation, where each folds away and is kept in the project, without a build or a round and changing nothing: Claude Code answers from a read-only copy of the builder's own session. Under each project's prompt box, "Builder's questions: Ask me / Decide yourself" chooses whether the builder's questions come to the person as cards or are decided by the builder, which says what it chose (`project_questions_set`; the default is in Settings and follows Auto mode until picked). Projects can be renamed, duplicated and deleted (right-click in the sidebar, or the project's page; a delete keeps the person's own files). A build can be pinned (Pin this build on its page, or `project_pin_*` from the CLI and MCP): a frozen copy in the project's pinned/ folder (the default) or a light one that shares dependencies and media with the project through hard links (each one's size shown first), opened from the sidebar's collapsible Pinned section (icons with a running dot when folded); a pin or Play runs once per folder unless another copy is asked for, and a start that quits at once says so with its last output. Typed drafts survive a restart. In a narrow window the sidebar folds to icons and the project's details move above its feed; messages float over the screen and errors stay until dismissed. Advanced mode: workbench with every panel wired to real tools, as a screen beside the projects (builds and their questions stay a click away) | UI unit and smoke tests (egui_kittest), offscreen snapshots of every screen || CLI | Every tool, `--deep` or `--clean-room` for one run (never saved), `rebuild` (including `--continue-in`, and `--resume` to carry on a stopped build), `mcp --inbox`, `ai`, `setup`, `doctor`, `report` | CLI integration tests |### Fixed during the audit