Expand description
ccstat - Analyze Claude Code usage data from local JSONL files
This library provides functionality to:
- Parse JSONL usage logs from multiple Claude data directories
- Calculate token costs using LiteLLM pricing data
- Generate reports in table and JSON formats
- Support live monitoring mode for active sessions
§Examples
use ccstat::{
data_loader::DataLoader,
aggregation::Aggregator,
cost_calculator::CostCalculator,
pricing_fetcher::PricingFetcher,
timezone::TimezoneConfig,
types::CostMode,
};
use std::sync::Arc;
#[tokio::main]
async fn main() -> ccstat::Result<()> {
// Initialize components
let data_loader = DataLoader::new().await?;
let pricing_fetcher = Arc::new(PricingFetcher::new(false).await);
let cost_calculator = Arc::new(CostCalculator::new(pricing_fetcher));
let aggregator = Aggregator::new(cost_calculator, TimezoneConfig::default());
// Load and aggregate usage data
let entries = data_loader.load_usage_entries_parallel();
let daily_data = aggregator.aggregate_daily(entries, CostMode::Auto).await?;
Ok(())
}Re-exports§
pub use error::CcstatError;pub use error::Result;pub use types::CostMode;pub use types::DailyDate;pub use types::ISOTimestamp;pub use types::ModelName;pub use types::SessionId;pub use types::TokenCounts;
Modules§
- aggregation
- Aggregation module for summarizing usage data
- blocks_
monitor - Enhanced live monitoring display for billing blocks
- cli
- CLI interface for ccstat
- cost_
calculator - Cost calculator module for computing usage costs
- data_
loader - Data loader module for discovering and parsing JSONL files
- error
- Error types for ccstat
- filters
- Filtering module for usage entries
- live_
monitor - Live monitoring functionality for ccstat
- memory_
pool - Memory pool for efficient allocation during parsing
- model_
formatter - Model name formatting module for ccstat
- output
- Output formatting module for ccstat
- pricing_
fetcher - Pricing fetcher module for LiteLLM model pricing data
- statusline
- Statusline module for Claude Code integration
- string_
pool - String interning for memory optimization
- timezone
- Timezone utilities for date handling
- types
- Core domain types for ccstat
Constants§
- VERSION
- Library version