Skip to content

Commit 26b314d

Browse files
feat: add --quota flag to rtk gain with tier-based analysis
Implements heuristic calculation of monthly quota savings percentage with support for Pro, Max 5x, and Max 20x subscription tiers. Features: - --quota flag displays monthly quota analysis - --tier <pro|5x|20x> selects subscription tier (default: 20x) - Heuristic based on ~44K tokens/5h Pro baseline - Estimates: Pro=6M, 5x=30M, 20x=120M tokens/month - Clear disclaimer about rolling 5-hour windows vs monthly caps Example output for Max 20x: Subscription tier: Max 20x ($200/mo) Estimated monthly quota: 120.0M Tokens saved (lifetime): 356.7K Quota preserved: 0.3% Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 52b4ed3 commit 26b314d

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

src/gain.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use crate::tracking::Tracker;
33

4-
pub fn run(graph: bool, history: bool, verbose: u8) -> Result<()> {
4+
pub fn run(graph: bool, history: bool, quota: bool, tier: &str, _verbose: u8) -> Result<()> {
55
let tracker = Tracker::new()?;
66
let summary = tracker.get_summary()?;
77

@@ -68,6 +68,29 @@ pub fn run(graph: bool, history: bool, verbose: u8) -> Result<()> {
6868
}
6969
}
7070

71+
if quota {
72+
const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 6 periods/day × 30 days)
73+
74+
let (quota_tokens, tier_name) = match tier {
75+
"pro" => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"),
76+
"5x" => (ESTIMATED_PRO_MONTHLY * 5, "Max 5x ($100/mo)"),
77+
"20x" => (ESTIMATED_PRO_MONTHLY * 20, "Max 20x ($200/mo)"),
78+
_ => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"), // default fallback
79+
};
80+
81+
let quota_pct = (summary.total_saved as f64 / quota_tokens as f64) * 100.0;
82+
83+
println!("Monthly Quota Analysis:");
84+
println!("────────────────────────────────────────");
85+
println!("Subscription tier: {}", tier_name);
86+
println!("Estimated monthly quota: {}", format_tokens(quota_tokens));
87+
println!("Tokens saved (lifetime): {}", format_tokens(summary.total_saved));
88+
println!("Quota preserved: {:.1}%", quota_pct);
89+
println!();
90+
println!("Note: Heuristic estimate based on ~44K tokens/5h (Pro baseline)");
91+
println!(" Actual limits use rolling 5-hour windows, not monthly caps.");
92+
}
93+
7194
Ok(())
7295
}
7396

src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ enum Commands {
232232
/// Show recent command history
233233
#[arg(short = 'H', long)]
234234
history: bool,
235+
/// Show monthly quota savings estimate
236+
#[arg(short, long)]
237+
quota: bool,
238+
/// Subscription tier for quota calculation: pro, 5x, 20x
239+
#[arg(short, long, default_value = "20x", requires = "quota")]
240+
tier: String,
235241
},
236242

237243
/// Show or create configuration file
@@ -519,8 +525,8 @@ fn main() -> Result<()> {
519525
}
520526
}
521527

522-
Commands::Gain { graph, history } => {
523-
gain::run(graph, history, cli.verbose)?;
528+
Commands::Gain { graph, history, quota, tier } => {
529+
gain::run(graph, history, quota, &tier, cli.verbose)?;
524530
}
525531

526532
Commands::Config { create } => {

0 commit comments

Comments
 (0)