Skip to content

Commit 9e6afbf

Browse files
committed
refactor(cli): share one report list for agents with weekly reports
STANDARD_WEEKLY_AGENT_REPORTS was an exact copy of OPENCODE_AGENT_REPORTS. The copy existed because the original was named after one agent rather than the report set it describes, so a second agent with the same reports could not reuse it by name. Rename OPENCODE_AGENT_REPORTS to ALL_AGENT_REPORTS, since it lists every AgentReportKind, and use it for both OpenCode and Cline. The matching arms in agent_report_supported are merged too, and the ccusage-cli public-surface list is updated to the new name.
1 parent ad1df28 commit 9e6afbf

4 files changed

Lines changed: 15 additions & 28 deletions

File tree

‎rust/crates/ccusage-cli-parser/src/parser.rs‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::{collections::BTreeMap, ffi::OsString, path::PathBuf};
33
use crate::arg_parser::ArgParser;
44
use crate::help::{print_help_and_exit, print_version_and_exit};
55
use ccusage_cli::{
6-
AgentCommandArgs, AgentReportKind, BlocksArgs, CliConfig, CodexSpeed, Command, CostMode,
7-
CostSource, DATE_BOUND_FORMATS, DailyArgs, OPENCODE_AGENT_REPORTS, STANDARD_AGENT_REPORTS,
8-
STANDARD_WEEKLY_AGENT_REPORTS, SessionArgs, SharedArgs, SortOrder, StatuslineArgs,
9-
VisualBurnRate, WeekDay, WeeklyArgs, normalize_date_bound,
6+
ALL_AGENT_REPORTS, AgentCommandArgs, AgentReportKind, BlocksArgs, CliConfig, CodexSpeed,
7+
Command, CostMode, CostSource, DATE_BOUND_FORMATS, DailyArgs, STANDARD_AGENT_REPORTS,
8+
SessionArgs, SharedArgs, SortOrder, StatuslineArgs, VisualBurnRate, WeekDay, WeeklyArgs,
9+
normalize_date_bound,
1010
};
1111

1212
use crate::Cli;
@@ -356,13 +356,9 @@ fn parse_command(
356356
STANDARD_AGENT_REPORTS,
357357
Command::ZCode,
358358
),
359-
"cline" => parse_basic_agent_command(
360-
parser,
361-
shared,
362-
"cline",
363-
STANDARD_WEEKLY_AGENT_REPORTS,
364-
Command::Cline,
365-
),
359+
"cline" => {
360+
parse_basic_agent_command(parser, shared, "cline", ALL_AGENT_REPORTS, Command::Cline)
361+
}
366362
_ => Err(format!("Unknown command '{command}'")),
367363
}
368364
}
@@ -632,7 +628,7 @@ fn parse_opencode_command(
632628
parser: &mut ArgParser,
633629
mut shared: SharedArgs,
634630
) -> Result<Command, String> {
635-
let kind = parse_agent_report_kind(parser, "opencode", OPENCODE_AGENT_REPORTS)?;
631+
let kind = parse_agent_report_kind(parser, "opencode", ALL_AGENT_REPORTS)?;
636632
let mut include_claude_agent = false;
637633
while parser.peek().is_some() {
638634
if parse_shared_arg_for_command(parser, &mut shared)? {
@@ -1038,8 +1034,7 @@ fn agent_report_supported(agent: &str, report: &str) -> bool {
10381034
"daily" | "weekly" | "monthly" | "session" | "blocks" | "statusline"
10391035
),
10401036
"codex" => matches!(report, "daily" | "monthly" | "session"),
1041-
"opencode" => matches!(report, "daily" | "weekly" | "monthly" | "session"),
1042-
"cline" => matches!(report, "daily" | "weekly" | "monthly" | "session"),
1037+
"opencode" | "cline" => matches!(report, "daily" | "weekly" | "monthly" | "session"),
10431038
"amp" | "droid" | "codebuff" | "hermes" | "pi" | "goose" | "kilo" | "copilot"
10441039
| "gemini" | "antigravity" | "kimi" | "qwen" | "openclaw" | "grok" | "zcode" => {
10451040
matches!(report, "daily" | "monthly" | "session")

‎rust/crates/ccusage-cli/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ renderer, and the help JSON live in `ccusage-cli-parser` instead.
1818
- `home::home_dir`
1919
- `types::AgentCommandArgs`
2020
- `types::AgentReportKind`
21+
- `types::ALL_AGENT_REPORTS`
2122
- `types::BlocksArgs`
2223
- `types::CliConfig`
2324
- `types::CodexSpeed`
@@ -28,7 +29,6 @@ renderer, and the help JSON live in `ccusage-cli-parser` instead.
2829
- `types::DailyArgs`
2930
- `types::NamedPiStore`
3031
- `types::NoConfig`
31-
- `types::OPENCODE_AGENT_REPORTS`
3232
- `types::PricingOverride`
3333
- `types::STANDARD_AGENT_REPORTS`
3434
- `types::SessionArgs`

‎rust/crates/ccusage-cli/src/lib.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ pub mod home;
22
mod types;
33

44
pub use types::{
5-
AgentCommandArgs, AgentReportKind, BlocksArgs, CliConfig, CodexSpeed, Command, CostMode,
6-
CostSource, DATE_BOUND_FORMATS, DailyArgs, NamedPiStore, NoConfig, OPENCODE_AGENT_REPORTS,
7-
PricingOverride, STANDARD_AGENT_REPORTS, STANDARD_WEEKLY_AGENT_REPORTS, SessionArgs,
8-
SharedArgs, SortOrder, SourceArgs, StatuslineArgs, VisualBurnRate, WeekDay, WeeklyArgs,
9-
normalize_date_bound,
5+
ALL_AGENT_REPORTS, AgentCommandArgs, AgentReportKind, BlocksArgs, CliConfig, CodexSpeed,
6+
Command, CostMode, CostSource, DATE_BOUND_FORMATS, DailyArgs, NamedPiStore, NoConfig,
7+
PricingOverride, STANDARD_AGENT_REPORTS, SessionArgs, SharedArgs, SortOrder, SourceArgs,
8+
StatuslineArgs, VisualBurnRate, WeekDay, WeeklyArgs, normalize_date_bound,
109
};
1110

1211
/// Default length, in hours, of one billing block.

‎rust/crates/ccusage-cli/src/types.rs‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,7 @@ pub const STANDARD_AGENT_REPORTS: &[(&str, AgentReportKind)] = &[
221221
("session", AgentReportKind::Session),
222222
];
223223

224-
pub const OPENCODE_AGENT_REPORTS: &[(&str, AgentReportKind)] = &[
225-
("daily", AgentReportKind::Daily),
226-
("weekly", AgentReportKind::Weekly),
227-
("monthly", AgentReportKind::Monthly),
228-
("session", AgentReportKind::Session),
229-
];
230-
231-
pub const STANDARD_WEEKLY_AGENT_REPORTS: &[(&str, AgentReportKind)] = &[
224+
pub const ALL_AGENT_REPORTS: &[(&str, AgentReportKind)] = &[
232225
("daily", AgentReportKind::Daily),
233226
("weekly", AgentReportKind::Weekly),
234227
("monthly", AgentReportKind::Monthly),

0 commit comments

Comments
 (0)