ccusage 10.0.0 → 11.0.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 +27 -1
- package/dist/{calculate-cost-2IwHSzmi.js → calculate-cost-D3IraeGW.js} +15 -0
- package/dist/calculate-cost.d.ts +26 -2
- package/dist/calculate-cost.js +1 -1
- package/dist/core-eFvU0K4V.js +698 -0
- package/dist/{data-loader-Bp9KV0_a.js → data-loader-BzOeJe6y.js} +397 -222
- package/dist/{data-loader-DPQaq8_n.d.ts → data-loader-dbZm5kOW.d.ts} +116 -25
- package/dist/data-loader.d.ts +3 -3
- package/dist/data-loader.js +4 -4
- package/dist/{debug-bjc38_Gx.js → debug-CjjJciy1.js} +20 -7
- package/dist/debug.d.ts +17 -0
- package/dist/debug.js +4 -4
- package/dist/{effect-WSjEuzC9-DHMVzzyB.js → effect-WSjEuzC9-CZCpOgOT.js} +1 -1
- package/dist/{esm-BU3FhOe-.js → esm-D74K9ESq.js} +1 -1
- package/dist/{index-CISmcbXk-CW1Gj6Ab.js → index-CISmcbXk-DpuCarFe.js} +5 -5
- package/dist/index.js +1994 -51
- package/dist/{logger-C2GZVy1v.js → logger-E_Utl_fr.js} +8 -2
- package/dist/logger.d.ts +9 -4
- package/dist/logger.js +1 -1
- package/dist/{mcp-DVjQeqCy.js → mcp-SPAE-cNK.js} +29 -6
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +6 -6
- package/dist/{pricing-fetcher-BxlbW4km.js → pricing-fetcher-BtW4MVG7.js} +159 -4
- package/dist/{pricing-fetcher-BkSZh4lR.d.ts → pricing-fetcher-DHaTs-k2.d.ts} +67 -2
- package/dist/pricing-fetcher.d.ts +1 -1
- package/dist/pricing-fetcher.js +2 -2
- package/dist/{sury-DmrZ3_Oj-Cpjsc2Lm.js → sury-DmrZ3_Oj-Lq7x0IZW.js} +1 -1
- package/dist/valibot-CQk-M5rL-btpzU8Qa.js +10 -0
- package/dist/{zod-Db63SLXj-BIXn64AP.js → zod-Db63SLXj-BqWqpKnQ.js} +3 -3
- package/package.json +1 -2
- package/dist/chunk-BLXvPPr8.js +0 -30
- package/dist/core-DHCbAXJf.js +0 -693
- package/dist/utils.table-USks3NGv.js +0 -1844
- package/dist/utils.table.d.ts +0 -27
- package/dist/utils.table.js +0 -3
- package/dist/valibot-CQk-M5rL-BcaCeUrF.js +0 -10
- /package/dist/{arktype-C-GObzDh-CNoBqQrr.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -0
- /package/dist/{dist-BZzwBtZs.js → dist-Cb1UHXV5.js} +0 -0
- /package/dist/{prompt-DtZgx4wU.js → prompt-CUbwSrjo.js} +0 -0
- /package/dist/{types-BlyCnKwN.js → types-5-VF7WcO.js} +0 -0
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ This tool helps you understand the value you're getting from your subscription b
|
|
|
41
41
|
- 📊 **Daily Report**: View token usage and costs aggregated by date
|
|
42
42
|
- 📅 **Monthly Report**: View token usage and costs aggregated by month
|
|
43
43
|
- 💬 **Session Report**: View usage grouped by conversation sessions
|
|
44
|
+
- ⏰ **5-Hour Blocks Report**: Track usage within Claude's billing windows with active block monitoring
|
|
44
45
|
- 🤖 **Model Tracking**: See which Claude models you're using (Opus, Sonnet, etc.)
|
|
45
46
|
- 📊 **Model Breakdown**: View per-model cost breakdown with `--breakdown` flag
|
|
46
47
|
- 📅 **Date Filtering**: Filter reports by date range using `--since` and `--until`
|
|
@@ -51,6 +52,7 @@ This tool helps you understand the value you're getting from your subscription b
|
|
|
51
52
|
- 🔄 **Cache Token Support**: Tracks and displays cache creation and cache read tokens separately
|
|
52
53
|
- 🌐 **Offline Mode**: Use pre-cached pricing data without network connectivity with `--offline` (Claude models only)
|
|
53
54
|
- 📏 **Responsive Tables**: Automatic table width adjustment for narrow terminals with intelligent word wrapping
|
|
55
|
+
- 🔌 **MCP Integration**: Built-in Model Context Protocol server for integration with other tools
|
|
54
56
|
|
|
55
57
|
## Important Disclaimer
|
|
56
58
|
|
|
@@ -112,7 +114,7 @@ cd ccusage
|
|
|
112
114
|
bun install
|
|
113
115
|
|
|
114
116
|
# Run the tool
|
|
115
|
-
bun run
|
|
117
|
+
bun run start [subcommand] [options]
|
|
116
118
|
```
|
|
117
119
|
|
|
118
120
|
## Usage
|
|
@@ -340,6 +342,8 @@ Available MCP tools:
|
|
|
340
342
|
|
|
341
343
|
- `daily`: Returns daily usage reports (accepts `since`, `until`, `mode` parameters)
|
|
342
344
|
- `session`: Returns session usage reports (accepts `since`, `until`, `mode` parameters)
|
|
345
|
+
- `monthly`: Returns monthly usage reports (accepts `since`, `until`, `mode` parameters)
|
|
346
|
+
- `blocks`: Returns 5-hour billing blocks usage reports (accepts `since`, `until`, `mode` parameters)
|
|
343
347
|
|
|
344
348
|
#### Claude Desktop Configuration Example
|
|
345
349
|
|
|
@@ -462,6 +466,28 @@ This tool was inspired by [this excellent article](https://note.com/milliondev/n
|
|
|
462
466
|
|
|
463
467
|
While the original approach uses DuckDB for analysis, this tool provides a more accessible CLI interface with the same core functionality - analyzing the same JSONL files that Claude Code stores locally to give you insights into your usage patterns and costs.
|
|
464
468
|
|
|
469
|
+
## Related Projects
|
|
470
|
+
|
|
471
|
+
some projects use `ccusage` internally and provide additional features:
|
|
472
|
+
|
|
465
473
|
## Acknowledgments
|
|
466
474
|
|
|
467
475
|
Thanks to [@milliondev](https://note.com/milliondev) for the original concept and approach to Claude Code usage analysis.
|
|
476
|
+
|
|
477
|
+
## Sponsors
|
|
478
|
+
|
|
479
|
+
<p align="center">
|
|
480
|
+
<a href="https://github.com/sponsors/ryoppippi">
|
|
481
|
+
<img src="https://cdn.jsdelivr.net/gh/ryoppippi/sponsors/sponsors.svg">
|
|
482
|
+
</a>
|
|
483
|
+
</p>
|
|
484
|
+
|
|
485
|
+
## Star History
|
|
486
|
+
|
|
487
|
+
<a href="https://www.star-history.com/#ryoppippi/ccusage&Date">
|
|
488
|
+
<picture>
|
|
489
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ryoppippi/ccusage&type=Date&theme=dark" />
|
|
490
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ryoppippi/ccusage&type=Date" />
|
|
491
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ryoppippi/ccusage&type=Date" />
|
|
492
|
+
</picture>
|
|
493
|
+
</a>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/calculate-cost.ts
|
|
2
|
+
/**
|
|
3
|
+
* Calculates total token usage and cost across multiple usage data entries
|
|
4
|
+
* @param data - Array of daily, monthly, or session usage data
|
|
5
|
+
* @returns Aggregated token totals and cost
|
|
6
|
+
*/
|
|
2
7
|
function calculateTotals(data) {
|
|
3
8
|
return data.reduce((acc, item) => ({
|
|
4
9
|
inputTokens: acc.inputTokens + item.inputTokens,
|
|
@@ -14,9 +19,19 @@ function calculateTotals(data) {
|
|
|
14
19
|
totalCost: 0
|
|
15
20
|
});
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Calculates the sum of all token types (input, output, cache creation, cache read)
|
|
24
|
+
* @param tokens - Token data containing different token counts
|
|
25
|
+
* @returns Total number of tokens across all types
|
|
26
|
+
*/
|
|
17
27
|
function getTotalTokens(tokens) {
|
|
18
28
|
return tokens.inputTokens + tokens.outputTokens + tokens.cacheCreationTokens + tokens.cacheReadTokens;
|
|
19
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a complete totals object by adding total token count to existing totals
|
|
32
|
+
* @param totals - Token totals with cost information
|
|
33
|
+
* @returns Complete totals object including total token sum
|
|
34
|
+
*/
|
|
20
35
|
function createTotalsObject(totals) {
|
|
21
36
|
return {
|
|
22
37
|
inputTokens: totals.inputTokens,
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
2
|
-
import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-
|
|
1
|
+
import "./pricing-fetcher-DHaTs-k2.js";
|
|
2
|
+
import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-dbZm5kOW.js";
|
|
3
3
|
|
|
4
4
|
//#region src/calculate-cost.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Token usage data structure containing input, output, and cache token counts
|
|
7
|
+
*/
|
|
5
8
|
type TokenData = {
|
|
6
9
|
inputTokens: number;
|
|
7
10
|
outputTokens: number;
|
|
8
11
|
cacheCreationTokens: number;
|
|
9
12
|
cacheReadTokens: number;
|
|
10
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Token totals including cost information
|
|
16
|
+
*/
|
|
11
17
|
type TokenTotals = TokenData & {
|
|
12
18
|
totalCost: number;
|
|
13
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Complete totals object with token counts, cost, and total token sum
|
|
22
|
+
*/
|
|
14
23
|
type TotalsObject = TokenTotals & {
|
|
15
24
|
totalTokens: number;
|
|
16
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Calculates total token usage and cost across multiple usage data entries
|
|
28
|
+
* @param data - Array of daily, monthly, or session usage data
|
|
29
|
+
* @returns Aggregated token totals and cost
|
|
30
|
+
*/
|
|
17
31
|
declare function calculateTotals(data: Array<DailyUsage | MonthlyUsage | SessionUsage>): TokenTotals;
|
|
32
|
+
/**
|
|
33
|
+
* Calculates the sum of all token types (input, output, cache creation, cache read)
|
|
34
|
+
* @param tokens - Token data containing different token counts
|
|
35
|
+
* @returns Total number of tokens across all types
|
|
36
|
+
*/
|
|
18
37
|
declare function getTotalTokens(tokens: TokenData): number;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a complete totals object by adding total token count to existing totals
|
|
40
|
+
* @param totals - Token totals with cost information
|
|
41
|
+
* @returns Complete totals object including total token sum
|
|
42
|
+
*/
|
|
19
43
|
declare function createTotalsObject(totals: TokenTotals): TotalsObject;
|
|
20
44
|
//#endregion
|
|
21
45
|
export { calculateTotals, createTotalsObject, getTotalTokens };
|
package/dist/calculate-cost.js
CHANGED