ccusage 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,6 +46,16 @@ This tool helps you understand the value you're getting from your subscription b
46
46
  - 💰 **Cost Tracking**: Shows costs in USD for each day/session
47
47
  - 🔄 **Cache Token Support**: Tracks and displays cache creation and cache read tokens separately
48
48
 
49
+ ## Important Disclaimer
50
+
51
+ ⚠️ **This is NOT an official Claude tool** - it's an independent community project that analyzes locally stored usage data.
52
+
53
+ **Cost calculations are estimates only** and may not reflect actual billing:
54
+ - Costs shown are virtual/estimated based on token counts and model pricing data
55
+ - Actual costs may vary due to pricing changes, special rates, or billing adjustments
56
+ - We do not guarantee the accuracy of calculated costs
57
+ - For official billing information, always refer to your Claude account dashboard
58
+
49
59
  ## Limitations
50
60
 
51
61
  - This tool only reads local JSONL files generated by Claude Code. If you use Claude Code with multiple devices, you need to ensure the JSONL files are synchronized across devices.
@@ -113,6 +123,11 @@ ccusage daily --path /custom/path/to/.claude
113
123
 
114
124
  # Output in JSON format
115
125
  ccusage daily --json
126
+
127
+ # Control cost calculation mode
128
+ ccusage daily --mode auto # Use costUSD when available, calculate otherwise (default)
129
+ ccusage daily --mode calculate # Always calculate costs from tokens
130
+ ccusage daily --mode display # Always show pre-calculated costUSD values
116
131
  ```
117
132
 
118
133
  `ccusage` is an alias for `ccusage daily`, so you can run it without specifying the subcommand.
@@ -133,6 +148,11 @@ ccusage session --since 20250525 --until 20250530 --path /custom/path
133
148
 
134
149
  # Output in JSON format
135
150
  ccusage session --json
151
+
152
+ # Control cost calculation mode
153
+ ccusage session --mode auto # Use costUSD when available, calculate otherwise (default)
154
+ ccusage session --mode calculate # Always calculate costs from tokens
155
+ ccusage session --mode display # Always show pre-calculated costUSD values
136
156
  ```
137
157
 
138
158
  ### Options
@@ -143,9 +163,18 @@ All commands support the following options:
143
163
  - `-u, --until <date>`: Filter until date (YYYYMMDD format)
144
164
  - `-p, --path <path>`: Custom path to Claude data directory (default: `~/.claude`)
145
165
  - `-j, --json`: Output results in JSON format instead of table
166
+ - `-m, --mode <mode>`: Cost calculation mode: `auto` (default), `calculate`, or `display`
167
+ - `-d, --debug`: Show pricing mismatch information for debugging
168
+ - `--debug-samples <number>`: Number of sample discrepancies to show in debug output (default: 5)
146
169
  - `-h, --help`: Display help message
147
170
  - `-v, --version`: Display version
148
171
 
172
+ #### Cost Calculation Modes
173
+
174
+ - **`auto`** (default): Uses pre-calculated `costUSD` values when available, falls back to calculating costs from token counts using model pricing
175
+ - **`calculate`**: Always calculates costs from token counts using model pricing, ignores any pre-calculated `costUSD` values
176
+ - **`display`**: Always uses pre-calculated `costUSD` values only, shows $0.00 for entries without pre-calculated costs
177
+
149
178
  ## Output Example
150
179
 
151
180
  ### Daily Report
@@ -1,21 +1,5 @@
1
- import { DailyUsage, SessionUsage } from "./data-loader-ToqWI8hT.js";
1
+ import { DailyUsage, SessionUsage, TokenData, TokenTotals } from "./data-loader-D1LHcGfa.js";
2
2
 
3
- //#region types.d.ts
4
-
5
- interface TokenTotals {
6
- inputTokens: number;
7
- outputTokens: number;
8
- cacheCreationTokens: number;
9
- cacheReadTokens: number;
10
- totalCost: number;
11
- }
12
- interface TokenData {
13
- inputTokens: number;
14
- outputTokens: number;
15
- cacheCreationTokens: number;
16
- cacheReadTokens: number;
17
- }
18
- //#endregion
19
3
  //#region calculate-cost.d.ts
20
4
  declare function calculateTotals(data: Array<DailyUsage | SessionUsage>): TokenTotals;
21
5
  declare function getTotalTokens(tokens: TokenData): number;