@hanai/ccusage 18.0.5
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/LICENSE +21 -0
- package/README.md +187 -0
- package/config-schema.json +708 -0
- package/dist/_types-BFL_bTNX.js +588 -0
- package/dist/calculate-cost-CKH-OC_c.js +23 -0
- package/dist/calculate-cost.d.ts +74 -0
- package/dist/calculate-cost.js +3 -0
- package/dist/data-loader-0-AaQB5-.d.ts +2304 -0
- package/dist/data-loader-C3ndvSiF.js +6016 -0
- package/dist/data-loader.d.ts +2 -0
- package/dist/data-loader.js +4 -0
- package/dist/debug-D_C3L8L7.js +148 -0
- package/dist/debug.d.ts +64 -0
- package/dist/debug.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3635 -0
- package/dist/logger-PyTier1E.js +873 -0
- package/dist/logger.d.ts +25 -0
- package/dist/logger.js +2 -0
- package/dist/prompt-XEKR514o.js +843 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ryoppippi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://cdn.jsdelivr.net/gh/ryoppippi/ccusage@main/docs/public/logo.svg" alt="ccusage logo" width="256" height="256">
|
|
3
|
+
<h1>ccusage</h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://socket.dev/api/npm/package/ccusage"><img src="https://socket.dev/api/badge/npm/package/ccusage" alt="Socket Badge" /></a>
|
|
8
|
+
<a href="https://npmjs.com/package/ccusage"><img src="https://img.shields.io/npm/v/ccusage?color=yellow" alt="npm version" /></a>
|
|
9
|
+
<a href="https://tanstack.com/stats/npm?packageGroups=%5B%7B%22packages%22:%5B%7B%22name%22:%22ccusage%22%7D%5D%7D%5D&range=30-days&transform=none&binType=daily&showDataMode=all&height=400"><img src="https://img.shields.io/npm/dt/ccusage" alt="NPM Downloads" /></a>
|
|
10
|
+
<a href="https://packagephobia.com/result?p=ccusage"><img src="https://packagephobia.com/badge?p=ccusage" alt="install size" /></a>
|
|
11
|
+
<a href="https://deepwiki.com/ryoppippi/ccusage"><img src="https://img.shields.io/badge/DeepWiki-ryoppippi%2Fccusage-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqc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|
+
<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
|
|
13
|
+
<a href="https://github.com/hesreallyhim/awesome-claude-code"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Claude Code" /></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<div align="center">
|
|
17
|
+
<img src="https://cdn.jsdelivr.net/gh/ryoppippi/ccusage@main/docs/public/screenshot.png">
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
> Analyze your Claude Code token usage and costs from local JSONL files — incredibly fast and informative!
|
|
21
|
+
|
|
22
|
+
## ccusage Family
|
|
23
|
+
|
|
24
|
+
### 📊 [ccusage](https://www.npmjs.com/package/ccusage) - Claude Code Usage Analyzer
|
|
25
|
+
|
|
26
|
+
The main CLI tool for analyzing Claude Code usage from local JSONL files. Track daily, monthly, and session-based usage with beautiful tables.
|
|
27
|
+
|
|
28
|
+
### 🤖 [@ccusage/codex](https://www.npmjs.com/package/@ccusage/codex) - OpenAI Codex Usage Analyzer
|
|
29
|
+
|
|
30
|
+
Companion tool for analyzing OpenAI Codex usage. Same powerful features as ccusage but tailored for Codex users, including GPT-5 support and 1M token context windows.
|
|
31
|
+
|
|
32
|
+
### 🚀 [@ccusage/opencode](https://www.npmjs.com/package/@ccusage/opencode) - OpenCode Usage Analyzer
|
|
33
|
+
|
|
34
|
+
Companion tool for analyzing [OpenCode](https://github.com/opencode-ai/opencode) usage. Track token usage and costs from OpenCode sessions with the same reporting capabilities as ccusage.
|
|
35
|
+
|
|
36
|
+
### 🥧 [@ccusage/pi](https://www.npmjs.com/package/@ccusage/pi) - Pi-agent Usage Analyzer
|
|
37
|
+
|
|
38
|
+
Companion tool for analyzing [pi-agent](https://github.com/badlogic/pi-mono) session usage. Track token usage and costs from your pi-agent sessions with daily, monthly, and session-based reports.
|
|
39
|
+
|
|
40
|
+
### ⚡ [@ccusage/amp](https://www.npmjs.com/package/@ccusage/amp) - Amp Usage Analyzer
|
|
41
|
+
|
|
42
|
+
Companion tool for analyzing [Amp](https://ampcode.com/) session usage. Track token usage, costs, and credits from your Amp CLI sessions with daily, monthly, and session-based reports.
|
|
43
|
+
|
|
44
|
+
### 🔌 [@ccusage/mcp](https://www.npmjs.com/package/@ccusage/mcp) - MCP Server Integration
|
|
45
|
+
|
|
46
|
+
Model Context Protocol server that exposes ccusage data to Claude Desktop and other MCP-compatible tools. Enable real-time usage tracking directly in your AI workflows.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
### Quick Start (Recommended)
|
|
51
|
+
|
|
52
|
+
Thanks to ccusage's incredibly small bundle size ([](https://packagephobia.com/result?p=ccusage)), you can run it directly without installation:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Recommended - always include @latest to ensure you get the newest version
|
|
56
|
+
npx ccusage@latest
|
|
57
|
+
bunx ccusage
|
|
58
|
+
|
|
59
|
+
# Alternative package runners
|
|
60
|
+
pnpm dlx ccusage
|
|
61
|
+
pnpx ccusage
|
|
62
|
+
|
|
63
|
+
# Using deno (with security flags)
|
|
64
|
+
deno run -E -R=$HOME/.claude/projects/ -S=homedir -N='raw.githubusercontent.com:443' npm:ccusage@latest
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
> 💡 **Important**: We strongly recommend using `@latest` suffix with npx (e.g., `npx ccusage@latest`) to ensure you're running the most recent version with the latest features and bug fixes.
|
|
68
|
+
|
|
69
|
+
### Related Tools
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx @ccusage/codex@latest # OpenAI Codex usage tracking
|
|
73
|
+
npx @ccusage/opencode@latest # OpenCode usage tracking
|
|
74
|
+
npx @ccusage/pi@latest # Pi-agent usage tracking
|
|
75
|
+
npx @ccusage/amp@latest # Amp usage tracking
|
|
76
|
+
npx @ccusage/mcp@latest # MCP Server
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Basic usage
|
|
83
|
+
npx ccusage # Show daily report (default)
|
|
84
|
+
npx ccusage daily # Daily token usage and costs
|
|
85
|
+
npx ccusage monthly # Monthly aggregated report
|
|
86
|
+
npx ccusage session # Usage by conversation session
|
|
87
|
+
npx ccusage blocks # 5-hour billing windows
|
|
88
|
+
npx ccusage statusline # Compact status line for hooks (Beta)
|
|
89
|
+
|
|
90
|
+
# Filters and options
|
|
91
|
+
npx ccusage daily --since 20250525 --until 20250530
|
|
92
|
+
npx ccusage daily --json # JSON output
|
|
93
|
+
npx ccusage daily --breakdown # Per-model cost breakdown
|
|
94
|
+
npx ccusage daily --timezone UTC # Use UTC timezone
|
|
95
|
+
npx ccusage daily --locale ja-JP # Use Japanese locale for date/time formatting
|
|
96
|
+
|
|
97
|
+
# Project analysis
|
|
98
|
+
npx ccusage daily --instances # Group by project/instance
|
|
99
|
+
npx ccusage daily --project myproject # Filter to specific project
|
|
100
|
+
npx ccusage daily --instances --project myproject --json # Combined usage
|
|
101
|
+
|
|
102
|
+
# Compact mode for screenshots/sharing
|
|
103
|
+
npx ccusage --compact # Force compact table mode
|
|
104
|
+
npx ccusage monthly --compact # Compact monthly report
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Features
|
|
108
|
+
|
|
109
|
+
- 📊 **Daily Report**: View token usage and costs aggregated by date
|
|
110
|
+
- 📅 **Monthly Report**: View token usage and costs aggregated by month
|
|
111
|
+
- 💬 **Session Report**: View usage grouped by conversation sessions
|
|
112
|
+
- ⏰ **5-Hour Blocks Report**: Track usage within Claude's billing windows with active block monitoring
|
|
113
|
+
- 🚀 **Statusline Integration**: Compact usage display for Claude Code status bar hooks (Beta)
|
|
114
|
+
- 🤖 **Model Tracking**: See which Claude models you're using (Opus, Sonnet, etc.)
|
|
115
|
+
- 📊 **Model Breakdown**: View per-model cost breakdown with `--breakdown` flag
|
|
116
|
+
- 📅 **Date Filtering**: Filter reports by date range using `--since` and `--until`
|
|
117
|
+
- 📁 **Custom Path**: Support for custom Claude data directory locations
|
|
118
|
+
- 🎨 **Beautiful Output**: Colorful table-formatted display with automatic responsive layout
|
|
119
|
+
- 📱 **Smart Tables**: Automatic compact mode for narrow terminals (< 100 characters) with essential columns
|
|
120
|
+
- 📸 **Compact Mode**: Use `--compact` flag to force compact table layout, perfect for screenshots and sharing
|
|
121
|
+
- 📋 **Enhanced Model Display**: Model names shown as bulleted lists for better readability
|
|
122
|
+
- 📄 **JSON Output**: Export data in structured JSON format with `--json`
|
|
123
|
+
- 💰 **Cost Tracking**: Shows costs in USD for each day/month/session
|
|
124
|
+
- 🔄 **Cache Token Support**: Tracks and displays cache creation and cache read tokens separately
|
|
125
|
+
- 🌐 **Offline Mode**: Use pre-cached pricing data without network connectivity with `--offline` (Claude models only)
|
|
126
|
+
- 🔌 **MCP Integration**: Built-in Model Context Protocol server for integration with other tools
|
|
127
|
+
- 🏗️ **Multi-Instance Support**: Group usage by project with `--instances` flag and filter by specific projects
|
|
128
|
+
- 🌍 **Timezone Support**: Configure timezone for date grouping with `--timezone` option
|
|
129
|
+
- 🌐 **Locale Support**: Customize date/time formatting with `--locale` option (e.g., en-US, ja-JP, de-DE)
|
|
130
|
+
- ⚙️ **Configuration Files**: Set defaults with JSON configuration files, complete with IDE autocomplete and validation
|
|
131
|
+
- 🚀 **Ultra-Small Bundle**: Unlike other CLI tools, we pay extreme attention to bundle size - incredibly small even without minification!
|
|
132
|
+
|
|
133
|
+
## Documentation
|
|
134
|
+
|
|
135
|
+
Full documentation is available at **[ccusage.com](https://ccusage.com/)**
|
|
136
|
+
|
|
137
|
+
## Development Setup
|
|
138
|
+
|
|
139
|
+
### Using Nix (Recommended for Contributors)
|
|
140
|
+
|
|
141
|
+
For contributors and developers working on ccusage, we provide a Nix flake-based development environment:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Clone the repository
|
|
145
|
+
git clone https://github.com/ryoppippi/ccusage.git
|
|
146
|
+
cd ccusage
|
|
147
|
+
|
|
148
|
+
# Allow direnv (automatically loads Nix environment)
|
|
149
|
+
direnv allow
|
|
150
|
+
|
|
151
|
+
# Or manually enter the development shell
|
|
152
|
+
nix develop
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This ensures consistent tooling versions across all contributors and CI systems. The development environment is defined in `flake.nix` and automatically activated via direnv when entering the project directory.
|
|
156
|
+
|
|
157
|
+
## Sponsors
|
|
158
|
+
|
|
159
|
+
### Featured Sponsor
|
|
160
|
+
|
|
161
|
+
Check out [ccusage: The Claude Code cost scorecard that went viral](https://www.youtube.com/watch?v=Ak6qpQ5qdgk)
|
|
162
|
+
|
|
163
|
+
<p align="center">
|
|
164
|
+
<a href="https://www.youtube.com/watch?v=Ak6qpQ5qdgk">
|
|
165
|
+
<img src="https://cdn.jsdelivr.net/gh/ryoppippi/ccusage@main/docs/public/ccusage_thumbnail.png" alt="ccusage: The Claude Code cost scorecard that went viral" width="600">
|
|
166
|
+
</a>
|
|
167
|
+
</p>
|
|
168
|
+
|
|
169
|
+
<p align="center">
|
|
170
|
+
<a href="https://github.com/sponsors/ryoppippi">
|
|
171
|
+
<img src="https://cdn.jsdelivr.net/gh/ryoppippi/sponsors@main/sponsors.svg">
|
|
172
|
+
</a>
|
|
173
|
+
</p>
|
|
174
|
+
|
|
175
|
+
## Star History
|
|
176
|
+
|
|
177
|
+
<a href="https://www.star-history.com/#ryoppippi/ccusage&Date">
|
|
178
|
+
<picture>
|
|
179
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ryoppippi/ccusage&type=Date&theme=dark" />
|
|
180
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ryoppippi/ccusage&type=Date" />
|
|
181
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ryoppippi/ccusage&type=Date" />
|
|
182
|
+
</picture>
|
|
183
|
+
</a>
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
[MIT](LICENSE) © [@ryoppippi](https://github.com/ryoppippi)
|