ccusage 0.3.1 → 0.4.0
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 +29 -0
- package/dist/calculate-cost.d.ts +1 -18
- package/dist/data-loader-D1LHcGfa.d.ts +1563 -0
- package/dist/{data-loader-Dh4y6ICb.js → data-loader-DlG6jpnf.js} +1683 -160
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +2 -2
- package/dist/index.js +419 -1222
- package/package.json +2 -10
- package/dist/data-loader-Ds_vUoR2.d.ts +0 -49
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
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import { DailyUsage, SessionUsage } from "./data-loader-
|
|
2
|
-
import "valibot";
|
|
1
|
+
import { DailyUsage, SessionUsage, TokenData, TokenTotals } from "./data-loader-D1LHcGfa.js";
|
|
3
2
|
|
|
4
|
-
//#region types.d.ts
|
|
5
|
-
|
|
6
|
-
interface TokenTotals {
|
|
7
|
-
inputTokens: number;
|
|
8
|
-
outputTokens: number;
|
|
9
|
-
cacheCreationTokens: number;
|
|
10
|
-
cacheReadTokens: number;
|
|
11
|
-
totalCost: number;
|
|
12
|
-
}
|
|
13
|
-
interface TokenData {
|
|
14
|
-
inputTokens: number;
|
|
15
|
-
outputTokens: number;
|
|
16
|
-
cacheCreationTokens: number;
|
|
17
|
-
cacheReadTokens: number;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
3
|
//#region calculate-cost.d.ts
|
|
21
4
|
declare function calculateTotals(data: Array<DailyUsage | SessionUsage>): TokenTotals;
|
|
22
5
|
declare function getTotalTokens(tokens: TokenData): number;
|