Skip to content

Commit 41c0c6f

Browse files
authored
refactor(adapter): split remaining adapter modules (ccusage#1137)
* refactor(adapter): split all report module Move the all-agent loader, reporting, types, and tests into separate files so the root adapter module stays focused on the public entry points. Keep the existing row construction and reporting behavior intact, while consolidating the priced summary agent loading helper used by similar adapters to reduce duplicated wrapper code. * refactor(codex): split loader responsibilities Move Codex aggregation, parsing, path discovery, report rendering, speed detection, and serde types into focused modules. The public adapter entry points and JSON/table report construction stay the same, which keeps output compatibility while making future parser changes easier to review. * refactor(claude): split daily and path loading Move Claude daily summary loading and Claude path discovery into dedicated modules while keeping the primary entry loader in mod.rs. This reduces the size of the adapter module without changing deduplication, date filtering, or project/session path extraction behavior. * fix(codex): tighten service tier detection Reuse the shared Codex home path discovery from the paths module so speed resolution does not carry a second CODEX_HOME parser. Parse config.toml service_tier entries by exact key and exact fast-tier values. This prevents unrelated keys such as service_tier_override or substring values such as breakfast from selecting fast Codex pricing.
1 parent 9b5c307 commit 41c0c6f

17 files changed

Lines changed: 4220 additions & 4079 deletions

File tree

‎rust/crates/ccusage/src/adapter/all.rs‎

Lines changed: 0 additions & 1665 deletions
This file was deleted.

‎rust/crates/ccusage/src/adapter/all/loader.rs‎

Lines changed: 633 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
mod loader;
2+
mod report;
3+
mod types;
4+
5+
use crate::{cli::AgentCommandArgs, print_json_or_jq, wants_json, Result};
6+
7+
pub(crate) fn run(args: AgentCommandArgs) -> Result<()> {
8+
let kind = args.kind;
9+
let shared = args.shared;
10+
let result = loader::load_rows(kind, &shared)?;
11+
if wants_json(&shared) {
12+
return print_json_or_jq(
13+
report::report_json(&result.rows, kind),
14+
shared.jq.as_deref(),
15+
);
16+
}
17+
report::print_table(&result.rows, kind, &shared, &result.detected_agents)
18+
}
19+
20+
#[cfg(test)]
21+
use loader::{aggregate_rows, codex_group_row, load_agent_rows_parallel};
22+
#[cfg(test)]
23+
use report::{all_report_title, all_table_columns, all_table_row, report_json};
24+
#[cfg(test)]
25+
use types::{AgentLoadSpec, AgentRows, AllRow};
26+
27+
#[cfg(test)]
28+
mod tests;

0 commit comments

Comments
 (0)