ccusage 11.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.
Files changed (40) hide show
  1. package/README.md +23 -1
  2. package/dist/{calculate-cost-2IwHSzmi.js → calculate-cost-D3IraeGW.js} +15 -0
  3. package/dist/calculate-cost.d.ts +26 -2
  4. package/dist/calculate-cost.js +1 -1
  5. package/dist/core-eFvU0K4V.js +698 -0
  6. package/dist/{data-loader-BAoqS297.js → data-loader-BzOeJe6y.js} +397 -222
  7. package/dist/{data-loader-DPQaq8_n.d.ts → data-loader-dbZm5kOW.d.ts} +116 -25
  8. package/dist/data-loader.d.ts +3 -3
  9. package/dist/data-loader.js +4 -4
  10. package/dist/{debug-DzFJHzM5.js → debug-CjjJciy1.js} +20 -7
  11. package/dist/debug.d.ts +17 -0
  12. package/dist/debug.js +4 -4
  13. package/dist/{effect-WSjEuzC9-DHMVzzyB.js → effect-WSjEuzC9-CZCpOgOT.js} +1 -1
  14. package/dist/{esm-BU3FhOe-.js → esm-D74K9ESq.js} +1 -1
  15. package/dist/{index-CISmcbXk-CW1Gj6Ab.js → index-CISmcbXk-DpuCarFe.js} +5 -5
  16. package/dist/index.js +1994 -51
  17. package/dist/{logger-D3WD64Tx.js → logger-E_Utl_fr.js} +8 -2
  18. package/dist/logger.d.ts +9 -4
  19. package/dist/logger.js +1 -1
  20. package/dist/{mcp-1J7r1g6-.js → mcp-SPAE-cNK.js} +7 -8
  21. package/dist/mcp.d.ts +2 -2
  22. package/dist/mcp.js +6 -6
  23. package/dist/{pricing-fetcher-D-eJQBEJ.js → pricing-fetcher-BtW4MVG7.js} +159 -4
  24. package/dist/{pricing-fetcher-BkSZh4lR.d.ts → pricing-fetcher-DHaTs-k2.d.ts} +67 -2
  25. package/dist/pricing-fetcher.d.ts +1 -1
  26. package/dist/pricing-fetcher.js +2 -2
  27. package/dist/{sury-DmrZ3_Oj-Cpjsc2Lm.js → sury-DmrZ3_Oj-Lq7x0IZW.js} +1 -1
  28. package/dist/valibot-CQk-M5rL-btpzU8Qa.js +10 -0
  29. package/dist/{zod-Db63SLXj-BIXn64AP.js → zod-Db63SLXj-BqWqpKnQ.js} +3 -3
  30. package/package.json +1 -2
  31. package/dist/chunk-BLXvPPr8.js +0 -30
  32. package/dist/core-DHCbAXJf.js +0 -693
  33. package/dist/utils.table-USks3NGv.js +0 -1844
  34. package/dist/utils.table.d.ts +0 -27
  35. package/dist/utils.table.js +0 -3
  36. package/dist/valibot-CQk-M5rL-BcaCeUrF.js +0 -10
  37. /package/dist/{arktype-C-GObzDh-CNoBqQrr.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -0
  38. /package/dist/{dist-BZzwBtZs.js → dist-Cb1UHXV5.js} +0 -0
  39. /package/dist/{prompt-DtZgx4wU.js → prompt-CUbwSrjo.js} +0 -0
  40. /package/dist/{types-BlyCnKwN.js → types-5-VF7WcO.js} +0 -0
package/README.md CHANGED
@@ -114,7 +114,7 @@ cd ccusage
114
114
  bun install
115
115
 
116
116
  # Run the tool
117
- bun run report [subcommand] [options]
117
+ bun run start [subcommand] [options]
118
118
  ```
119
119
 
120
120
  ## Usage
@@ -466,6 +466,28 @@ This tool was inspired by [this excellent article](https://note.com/milliondev/n
466
466
 
467
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.
468
468
 
469
+ ## Related Projects
470
+
471
+ some projects use `ccusage` internally and provide additional features:
472
+
469
473
  ## Acknowledgments
470
474
 
471
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,
@@ -1,21 +1,45 @@
1
- import "./pricing-fetcher-BkSZh4lR.js";
2
- import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-DPQaq8_n.js";
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 };
@@ -1,3 +1,3 @@
1
- import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-2IwHSzmi.js";
1
+ import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-D3IraeGW.js";
2
2
 
3
3
  export { calculateTotals, createTotalsObject, getTotalTokens };