diff --git a/src/gain.rs b/src/gain.rs index b1529096d6..bfb5b6a7bb 100644 --- a/src/gain.rs +++ b/src/gain.rs @@ -1,7 +1,7 @@ use anyhow::Result; use crate::tracking::Tracker; -pub fn run(graph: bool, history: bool, verbose: u8) -> Result<()> { +pub fn run(graph: bool, history: bool, quota: bool, tier: &str, _verbose: u8) -> Result<()> { let tracker = Tracker::new()?; let summary = tracker.get_summary()?; @@ -68,6 +68,29 @@ pub fn run(graph: bool, history: bool, verbose: u8) -> Result<()> { } } + if quota { + const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 6 periods/day × 30 days) + + let (quota_tokens, tier_name) = match tier { + "pro" => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"), + "5x" => (ESTIMATED_PRO_MONTHLY * 5, "Max 5x ($100/mo)"), + "20x" => (ESTIMATED_PRO_MONTHLY * 20, "Max 20x ($200/mo)"), + _ => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"), // default fallback + }; + + let quota_pct = (summary.total_saved as f64 / quota_tokens as f64) * 100.0; + + println!("Monthly Quota Analysis:"); + println!("────────────────────────────────────────"); + println!("Subscription tier: {}", tier_name); + println!("Estimated monthly quota: {}", format_tokens(quota_tokens)); + println!("Tokens saved (lifetime): {}", format_tokens(summary.total_saved)); + println!("Quota preserved: {:.1}%", quota_pct); + println!(); + println!("Note: Heuristic estimate based on ~44K tokens/5h (Pro baseline)"); + println!(" Actual limits use rolling 5-hour windows, not monthly caps."); + } + Ok(()) } diff --git a/src/main.rs b/src/main.rs index 8974a6610e..941520d43c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -232,6 +232,12 @@ enum Commands { /// Show recent command history #[arg(short = 'H', long)] history: bool, + /// Show monthly quota savings estimate + #[arg(short, long)] + quota: bool, + /// Subscription tier for quota calculation: pro, 5x, 20x + #[arg(short, long, default_value = "20x", requires = "quota")] + tier: String, }, /// Show or create configuration file @@ -519,8 +525,8 @@ fn main() -> Result<()> { } } - Commands::Gain { graph, history } => { - gain::run(graph, history, cli.verbose)?; + Commands::Gain { graph, history, quota, tier } => { + gain::run(graph, history, quota, &tier, cli.verbose)?; } Commands::Config { create } => {