ccusage 0.4.2 → 0.6.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 +106 -1
- package/dist/arktype-C-GObzDh-Dj1DVoqC.js +5 -0
- package/dist/calculate-cost.d.ts +5 -5
- package/dist/calculate-cost.js +1 -1
- package/dist/core-BgFXUe_h.js +693 -0
- package/dist/{data-loader-B8mdiY5r.js → data-loader-CDv0IYZx.js} +59 -22
- package/dist/{data-loader-DtCt7sNl.d.ts → data-loader-aUOjeZ06.d.ts} +17 -6
- package/dist/data-loader.d.ts +5 -5
- package/dist/data-loader.js +5 -5
- package/dist/{debug-Oce2b5bO.js → debug-Dk36WQTw.js} +4 -4
- package/dist/debug.js +5 -5
- package/dist/dist-C_i5I27w.js +469 -0
- package/dist/{dist-D6rk8Ra5.js → dist-FwNhpFrW.js} +30 -1
- package/dist/effect-WSjEuzC9-BsxP11fz.js +10 -0
- package/dist/esm-vjyZjnpZ.js +1090 -0
- package/dist/index-CISmcbXk-BotItq1T.js +23 -0
- package/dist/index.js +171 -23
- package/dist/{logger-nCODI08N.js → logger-DhDyJEC5.js} +2 -2
- package/dist/logger.js +1 -1
- package/dist/mcp-G-TIOcuj.js +37580 -0
- package/dist/mcp.d.ts +15 -0
- package/dist/mcp.js +10 -0
- package/dist/{pricing-fetcher-bvi4lbXl.js → pricing-fetcher-BCv1Vods.js} +2 -2
- package/dist/{pricing-fetcher-BqlslEH3.d.ts → pricing-fetcher-DygIroMj.d.ts} +1 -1
- package/dist/pricing-fetcher.d.ts +2 -2
- package/dist/pricing-fetcher.js +3 -3
- package/dist/{shared-args-DWaGio0e.js → shared-args-BtMSktLn.js} +10 -3
- package/dist/shared-args.d.ts +14 -0
- package/dist/shared-args.js +6 -6
- package/dist/sury-DmrZ3_Oj-DhGOjCNc.js +10 -0
- package/dist/{types-DjlBTM5P.js → types-BcXIBMQk.js} +3 -2
- package/dist/types-CFnCBr2I.js +3586 -0
- package/dist/{types-BfZ5dOy7.d.ts → types-y1JQzaKZ.d.ts} +4 -2
- package/dist/types.d.ts +3 -3
- package/dist/types.js +3 -3
- package/dist/utils.js +1 -1
- package/dist/valibot-CQk-M5rL-Cq5E7F3g.js +10 -0
- package/dist/zod-Db63SLXj-BWdcigdx.js +30 -0
- package/package.json +2 -1
- /package/dist/{calculate-cost-BnufbprY.js → calculate-cost-2IwHSzmi.js} +0 -0
- /package/dist/{index-Bazt8Nfd.d.ts → index-BurjgCfW.d.ts} +0 -0
- /package/dist/{prompt-BwcIpzWm.js → prompt-IToGuko2.js} +0 -0
- /package/dist/{utils-BeihwpHn.js → utils-C7kg8MXN.js} +0 -0
package/README.md
CHANGED
|
@@ -38,12 +38,13 @@ This tool helps you understand the value you're getting from your subscription b
|
|
|
38
38
|
## Features
|
|
39
39
|
|
|
40
40
|
- 📊 **Daily Report**: View token usage and costs aggregated by date
|
|
41
|
+
- 📅 **Monthly Report**: View token usage and costs aggregated by month
|
|
41
42
|
- 💬 **Session Report**: View usage grouped by conversation sessions
|
|
42
43
|
- 📅 **Date Filtering**: Filter reports by date range using `--since` and `--until`
|
|
43
44
|
- 📁 **Custom Path**: Support for custom Claude data directory locations
|
|
44
45
|
- 🎨 **Beautiful Output**: Colorful table-formatted display
|
|
45
46
|
- 📄 **JSON Output**: Export data in structured JSON format with `--json`
|
|
46
|
-
- 💰 **Cost Tracking**: Shows costs in USD for each day/session
|
|
47
|
+
- 💰 **Cost Tracking**: Shows costs in USD for each day/month/session
|
|
47
48
|
- 🔄 **Cache Token Support**: Tracks and displays cache creation and cache read tokens separately
|
|
48
49
|
|
|
49
50
|
## Important Disclaimer
|
|
@@ -73,6 +74,12 @@ npx ccusage@latest
|
|
|
73
74
|
|
|
74
75
|
# Using bunx
|
|
75
76
|
bunx ccusage
|
|
77
|
+
|
|
78
|
+
# Using pnpm
|
|
79
|
+
pnpm dlx ccusage
|
|
80
|
+
|
|
81
|
+
# Using Deno with security flags
|
|
82
|
+
deno run -E -R=$HOME/.claude/projects/ -S=homedir -N='raw.githubusercontent.com:443' npm:ccusage@latest
|
|
76
83
|
```
|
|
77
84
|
|
|
78
85
|
### Local Installation
|
|
@@ -128,10 +135,41 @@ ccusage daily --json
|
|
|
128
135
|
ccusage daily --mode auto # Use costUSD when available, calculate otherwise (default)
|
|
129
136
|
ccusage daily --mode calculate # Always calculate costs from tokens
|
|
130
137
|
ccusage daily --mode display # Always show pre-calculated costUSD values
|
|
138
|
+
|
|
139
|
+
# Control sort order
|
|
140
|
+
ccusage daily --order asc # Show oldest dates first
|
|
141
|
+
ccusage daily --order desc # Show newest dates first (default)
|
|
131
142
|
```
|
|
132
143
|
|
|
133
144
|
`ccusage` is an alias for `ccusage daily`, so you can run it without specifying the subcommand.
|
|
134
145
|
|
|
146
|
+
### Monthly Report
|
|
147
|
+
|
|
148
|
+
Shows token usage and costs aggregated by month:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Show all monthly usage
|
|
152
|
+
ccusage monthly
|
|
153
|
+
|
|
154
|
+
# Filter by date range
|
|
155
|
+
ccusage monthly --since 20250101 --until 20250531
|
|
156
|
+
|
|
157
|
+
# Use custom Claude data directory
|
|
158
|
+
ccusage monthly --path /custom/path/to/.claude
|
|
159
|
+
|
|
160
|
+
# Output in JSON format
|
|
161
|
+
ccusage monthly --json
|
|
162
|
+
|
|
163
|
+
# Control cost calculation mode
|
|
164
|
+
ccusage monthly --mode auto # Use costUSD when available, calculate otherwise (default)
|
|
165
|
+
ccusage monthly --mode calculate # Always calculate costs from tokens
|
|
166
|
+
ccusage monthly --mode display # Always show pre-calculated costUSD values
|
|
167
|
+
|
|
168
|
+
# Control sort order
|
|
169
|
+
ccusage monthly --order asc # Show oldest months first
|
|
170
|
+
ccusage monthly --order desc # Show newest months first (default)
|
|
171
|
+
```
|
|
172
|
+
|
|
135
173
|
### Session Report
|
|
136
174
|
|
|
137
175
|
Shows usage grouped by conversation sessions, sorted by cost:
|
|
@@ -153,6 +191,10 @@ ccusage session --json
|
|
|
153
191
|
ccusage session --mode auto # Use costUSD when available, calculate otherwise (default)
|
|
154
192
|
ccusage session --mode calculate # Always calculate costs from tokens
|
|
155
193
|
ccusage session --mode display # Always show pre-calculated costUSD values
|
|
194
|
+
|
|
195
|
+
# Control sort order
|
|
196
|
+
ccusage session --order asc # Show oldest sessions first
|
|
197
|
+
ccusage session --order desc # Show newest sessions first (default)
|
|
156
198
|
```
|
|
157
199
|
|
|
158
200
|
### Options
|
|
@@ -164,6 +206,7 @@ All commands support the following options:
|
|
|
164
206
|
- `-p, --path <path>`: Custom path to Claude data directory (default: `~/.claude`)
|
|
165
207
|
- `-j, --json`: Output results in JSON format instead of table
|
|
166
208
|
- `-m, --mode <mode>`: Cost calculation mode: `auto` (default), `calculate`, or `display`
|
|
209
|
+
- `-o, --order <order>`: Sort order: `desc` (newest first, default) or `asc` (oldest first).
|
|
167
210
|
- `-d, --debug`: Show pricing mismatch information for debugging
|
|
168
211
|
- `--debug-samples <number>`: Number of sample discrepancies to show in debug output (default: 5)
|
|
169
212
|
- `-h, --help`: Display help message
|
|
@@ -175,6 +218,68 @@ All commands support the following options:
|
|
|
175
218
|
- **`calculate`**: Always calculates costs from token counts using model pricing, ignores any pre-calculated `costUSD` values
|
|
176
219
|
- **`display`**: Always uses pre-calculated `costUSD` values only, shows $0.00 for entries without pre-calculated costs
|
|
177
220
|
|
|
221
|
+
### MCP (Model Context Protocol) Support
|
|
222
|
+
|
|
223
|
+
Exposes usage data through Model Context Protocol for integration with other tools:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Start MCP server with stdio transport (for local integration)
|
|
227
|
+
ccusage mcp
|
|
228
|
+
|
|
229
|
+
# Start MCP server with HTTP stream transport (for remote access)
|
|
230
|
+
ccusage mcp --type http --port 8080
|
|
231
|
+
|
|
232
|
+
# Control cost calculation mode
|
|
233
|
+
ccusage mcp --mode calculate
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The MCP server supports both **stdio** and **HTTP stream** transports:
|
|
237
|
+
- **stdio** (default): Best for local integration where the client directly spawns the process
|
|
238
|
+
- **HTTP stream**: Best for remote access when you need to call the server from another machine or network location
|
|
239
|
+
|
|
240
|
+
Available MCP tools:
|
|
241
|
+
- `daily`: Returns daily usage reports (accepts `since`, `until`, `mode` parameters)
|
|
242
|
+
- `session`: Returns session usage reports (accepts `since`, `until`, `mode` parameters)
|
|
243
|
+
|
|
244
|
+
#### Claude Desktop Configuration Example
|
|
245
|
+
|
|
246
|
+
<div align="center">
|
|
247
|
+
<img src="https://github.com/ryoppippi/ccusage/blob/main/docs/mcp-claude-desktop.avif?raw=true">
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
To use ccusage MCP with Claude Desktop, add this to your Claude Desktop configuration file:
|
|
251
|
+
|
|
252
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
253
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
{
|
|
257
|
+
"mcpServers": {
|
|
258
|
+
"ccusage": {
|
|
259
|
+
"command": "npx",
|
|
260
|
+
"args": ["ccusage@latest", "mcp"],
|
|
261
|
+
"env": {}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Or if you have ccusage installed globally:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"mcpServers": {
|
|
272
|
+
"ccusage": {
|
|
273
|
+
"command": "ccusage",
|
|
274
|
+
"args": ["mcp"],
|
|
275
|
+
"env": {}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
After adding this configuration, restart Claude Desktop. You'll then be able to use the ccusage tools within Claude to analyze your usage data.
|
|
282
|
+
|
|
178
283
|
## Output Example
|
|
179
284
|
|
|
180
285
|
### Daily Report
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import "./pricing-fetcher-
|
|
3
|
-
import { TokenData, TokenTotals } from "./types-
|
|
4
|
-
import { DailyUsage, SessionUsage } from "./data-loader-
|
|
1
|
+
import "./index-BurjgCfW.js";
|
|
2
|
+
import "./pricing-fetcher-DygIroMj.js";
|
|
3
|
+
import { TokenData, TokenTotals } from "./types-y1JQzaKZ.js";
|
|
4
|
+
import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-aUOjeZ06.js";
|
|
5
5
|
|
|
6
6
|
//#region src/calculate-cost.d.ts
|
|
7
|
-
declare function calculateTotals(data: Array<DailyUsage | SessionUsage>): TokenTotals;
|
|
7
|
+
declare function calculateTotals(data: Array<DailyUsage | MonthlyUsage | SessionUsage>): TokenTotals;
|
|
8
8
|
declare function getTotalTokens(tokens: TokenData): number;
|
|
9
9
|
declare function createTotalsObject(totals: TokenTotals): {
|
|
10
10
|
inputTokens: number;
|
package/dist/calculate-cost.js
CHANGED