Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

fix(cli): wire /tokens and /cache as aliases for /stats; implement /stats

YeonGyu-Kim60ec2aed9b26
diff --git a/rust/crates/commands/src/lib.rs b/rust/crates/commands/src/lib.rs
index 82c544ed..d68b486a 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 fe5273f6..5c4b809d 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<dyn std::error::Error> { 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