diff --git a/rust/crates/commands/src/lib.rs b/rust/crates/commands/src/lib.rs index 82c544e..d68b486 100644 --- a/rust/crates/commands/src/lib.rs +++ b/rust/crates/commands/src/lib.rs @@ -1340,7 +1340,7 @@ pub fn validate_slash_command_input( validate_no_args(command, &args)?; SlashCommand::Upgrade } - "stats" => { + "stats" | "tokens" | "cache" => { validate_no_args(command, &args)?; SlashCommand::Stats } diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index fe5273f..5c4b809 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -2811,6 +2811,21 @@ fn run_resume_command( message: Some(render_doctor_report()?.render()), json: None, }), + SlashCommand::Stats => { + let usage = UsageTracker::from_session(session).cumulative_usage(); + Ok(ResumeCommandOutcome { + session: session.clone(), + message: Some(format_cost_report(usage)), + json: Some(serde_json::json!({ + "kind": "stats", + "input_tokens": usage.input_tokens, + "output_tokens": usage.output_tokens, + "cache_creation_input_tokens": usage.cache_creation_input_tokens, + "cache_read_input_tokens": usage.cache_read_input_tokens, + "total_tokens": usage.total_tokens(), + })), + }) + } SlashCommand::History { count } => { let limit = parse_history_count(count.as_deref()) .map_err(|error| -> Box { error.into() })?; @@ -2847,7 +2862,6 @@ fn run_resume_command( | SlashCommand::Logout | SlashCommand::Vim | SlashCommand::Upgrade - | SlashCommand::Stats | SlashCommand::Share | SlashCommand::Feedback | SlashCommand::Files @@ -3847,11 +3861,15 @@ impl LiveCli { self.print_prompt_history(count.as_deref()); false } + SlashCommand::Stats => { + let usage = UsageTracker::from_session(self.runtime.session()).cumulative_usage(); + println!("{}", format_cost_report(usage)); + false + } SlashCommand::Login | SlashCommand::Logout | SlashCommand::Vim | SlashCommand::Upgrade - | SlashCommand::Stats | SlashCommand::Share | SlashCommand::Feedback | SlashCommand::Files