Skip to content

Commit bb6482a

Browse files
committed
Merge remote-tracking branch 'origin/main' into codex/kimi-usage-adapter
# Conflicts: # apps/ccusage/README.md # apps/ccusage/config-schema.json # docs/.vitepress/config.ts # docs/guide/all-reports.md # docs/guide/config-files.md # docs/guide/configuration.md # docs/guide/environment-variables.md # docs/guide/index.md # rust/crates/ccusage/src/adapter/all.rs # rust/crates/ccusage/src/adapter/mod.rs # rust/crates/ccusage/src/cli.rs # rust/crates/ccusage/src/config.rs # rust/crates/ccusage/src/config_schema.rs # rust/crates/ccusage/src/main.rs # rust/crates/ccusage/src/progress.rs
2 parents e13cfe8 + 4a7c880 commit bb6482a

27 files changed

Lines changed: 992 additions & 119 deletions

‎apps/ccusage/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
## Supported Sources
2626

27-
The main CLI tool for analyzing Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Kimi usage from local data. Track daily, weekly, monthly, and session-based usage with beautiful tables.
27+
The main CLI tool for analyzing Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, Gemini CLI, and Kimi usage from local data. Track daily, weekly, monthly, and session-based usage with beautiful tables.
2828

2929
## Installation
3030

@@ -69,6 +69,7 @@ bunx ccusage codex daily --speed fast
6969
bunx ccusage opencode weekly
7070
bunx ccusage amp session
7171
bunx ccusage copilot daily
72+
bunx ccusage gemini daily
7273
bunx ccusage kimi daily
7374
bunx ccusage pi daily --pi-path /path/to/sessions
7475
bunx ccusage pi daily --pi-path /path/to/sessions,/archive/pi/sessions
@@ -96,7 +97,7 @@ bunx ccusage monthly --compact # Compact monthly report
9697
- 📊 **Daily Report**: View token usage and costs aggregated by date
9798
- 📅 **Monthly Report**: View token usage and costs aggregated by month
9899
- 💬 **Session Report**: View usage grouped by conversation sessions
99-
- 🤖 **Unified CLI Reports**: View Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Kimi usage from one CLI
100+
- 🤖 **Unified CLI Reports**: View Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, Gemini CLI, and Kimi usage from one CLI
100101
- ⏰ **5-Hour Blocks Report**: Track usage within Claude's billing windows with active block monitoring
101102
- 🚀 **Statusline Integration**: Compact usage display for Claude Code status bar hooks (Beta)
102103
- 🤖 **Model Tracking**: See which models are used across supported sources

‎apps/ccusage/config-schema.json‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,33 @@
688688
},
689689
"type": "object"
690690
},
691+
"GeminiCommandsConfig": {
692+
"additionalProperties": false,
693+
"properties": {
694+
"daily": {
695+
"$ref": "#/definitions/SharedOptions"
696+
},
697+
"monthly": {
698+
"$ref": "#/definitions/SharedOptions"
699+
},
700+
"session": {
701+
"$ref": "#/definitions/SharedOptions"
702+
}
703+
},
704+
"type": "object"
705+
},
706+
"GeminiConfig": {
707+
"additionalProperties": false,
708+
"properties": {
709+
"commands": {
710+
"$ref": "#/definitions/GeminiCommandsConfig"
711+
},
712+
"defaults": {
713+
"$ref": "#/definitions/SharedOptions"
714+
}
715+
},
716+
"type": "object"
717+
},
691718
"KimiCommandsConfig": {
692719
"additionalProperties": false,
693720
"properties": {
@@ -1271,6 +1298,15 @@
12711298
"description": "Default values for all-agent reports and legacy Claude commands.",
12721299
"markdownDescription": "Default values for all-agent reports and legacy Claude commands."
12731300
},
1301+
"gemini": {
1302+
"allOf": [
1303+
{
1304+
"$ref": "#/definitions/GeminiConfig"
1305+
}
1306+
],
1307+
"description": "Gemini CLI configuration.",
1308+
"markdownDescription": "Gemini CLI configuration."
1309+
},
12741310
"kimi": {
12751311
"allOf": [
12761312
{
@@ -1326,6 +1362,11 @@
13261362
"defaults": {
13271363
"json": false,
13281364
"timezone": "Asia/Tokyo"
1365+
},
1366+
"gemini": {
1367+
"defaults": {
1368+
"offline": true
1369+
}
13291370
}
13301371
}
13311372
],

‎docs/.vitepress/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default defineConfig({
7474
{ text: 'Amp', link: '/guide/amp/' },
7575
{ text: 'pi-agent', link: '/guide/pi/' },
7676
{ text: 'GitHub Copilot CLI', link: '/guide/copilot/' },
77+
{ text: 'Gemini CLI', link: '/guide/gemini/' },
7778
{ text: 'Kimi', link: '/guide/kimi/' },
7879
],
7980
},

‎docs/guide/all-reports.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ccusage daily --all
2525

2626
## How Unified Views Work
2727

28-
ccusage detects local usage files from Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Kimi. The same daily, weekly, monthly, and session views can run in two modes:
28+
ccusage detects local usage files from Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, Gemini CLI, and Kimi. The same daily, weekly, monthly, and session views can run in two modes:
2929

3030
| Mode | Command example | What it shows |
3131
| ------- | ---------------------- | --------------------------------------- |
@@ -45,6 +45,7 @@ Unified tables include an **Agent** column so you can compare sources in one vie
4545
| Amp | `amp` | `ccusage amp session` |
4646
| pi-agent | `pi` | `ccusage pi monthly` |
4747
| Copilot CLI | `copilot` | `ccusage copilot daily` |
48+
| Gemini CLI | `gemini` | `ccusage gemini daily` |
4849
| Kimi | `kimi` | `ccusage kimi daily` |
4950

5051
## When to Focus a Source
@@ -58,7 +59,8 @@ ccusage opencode session --json
5859
ccusage amp monthly --compact
5960
ccusage pi session --pi-path /path/to/sessions
6061
ccusage copilot daily --json
61-
ccusage kimi session
62+
ccusage gemini session --json
63+
ccusage kimi session --json
6264
```
6365

6466
## Next Steps

‎docs/guide/config-files.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Override shared defaults for specific unified reports and legacy Claude commands
176176

177177
### Source-Specific Configuration
178178

179-
Use data source namespaces to set defaults and report overrides. Supported namespaces are `claude`, `codex`, `opencode`, `amp`, `pi`, `copilot`, and `kimi`.
179+
Use data source namespaces to set defaults and report overrides. Supported namespaces are `claude`, `codex`, `opencode`, `amp`, `pi`, `copilot`, `gemini`, and `kimi`.
180180

181181
```json
182182
{
@@ -213,6 +213,16 @@ Use data source namespaces to set defaults and report overrides. Supported names
213213
"defaults": {
214214
"offline": true
215215
}
216+
},
217+
"gemini": {
218+
"defaults": {
219+
"offline": true
220+
}
221+
},
222+
"kimi": {
223+
"defaults": {
224+
"offline": true
225+
}
216226
}
217227
}
218228
```
@@ -224,6 +234,8 @@ ccusage codex daily
224234
ccusage opencode weekly
225235
ccusage pi daily
226236
ccusage copilot monthly
237+
ccusage gemini daily
238+
ccusage kimi daily
227239
```
228240

229241
Source-specific settings are also applied when running unified reports such as `ccusage daily`. In that case, each source receives its own merged options before data is loaded.

‎docs/guide/configuration.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,21 @@ ccusage daily --mode display --timezone UTC
5050

5151
```bash
5252
export CODEX_HOME="$HOME/.codex"
53+
export GEMINI_DATA_DIR="$HOME/.gemini/tmp"
54+
export KIMI_DATA_DIR="$HOME/.kimi"
5355
export OPENCODE_DATA_DIR="$HOME/.local/share/opencode"
5456
export AMP_DATA_DIR="$HOME/.local/share/amp"
5557
export PI_AGENT_DIR="$HOME/.pi/agent/sessions"
5658
export COPILOT_OTEL_FILE_EXPORTER_PATH="$HOME/.copilot/otel/copilot-otel.jsonl"
57-
export KIMI_DATA_DIR="$HOME/.kimi"
5859
```
5960

6061
Use comma-separated directories when you want reports to combine multiple profiles or archives:
6162

6263
```bash
6364
export CODEX_HOME="$HOME/.codex,$HOME/.codex-work"
64-
export OPENCODE_DATA_DIR="$HOME/.local/share/opencode,/archive/opencode"
65+
export GEMINI_DATA_DIR="$HOME/.gemini/tmp,/backup/gemini/tmp"
6566
export KIMI_DATA_DIR="$HOME/.kimi,/archive/kimi"
67+
export OPENCODE_DATA_DIR="$HOME/.local/share/opencode,/archive/opencode"
6668
```
6769

6870
2. **Create a configuration file** for your preferences:
@@ -107,7 +109,7 @@ For individual developers working on multiple projects:
107109

108110
### Multiple Sources
109111

110-
Configure Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Kimi separately with data source namespaces:
112+
Configure Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, Gemini CLI, and Kimi separately with data source namespaces:
111113

112114
```json
113115
// ~/.config/claude/ccusage.json

‎docs/guide/environment-variables.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ccusage detects supported data source files from conventional locations by defau
1414
| `AMP_DATA_DIR` | Amp | `~/.local/share/amp` |
1515
| `PI_AGENT_DIR` | pi-agent | `~/.pi/agent/sessions` |
1616
| `COPILOT_OTEL_FILE_EXPORTER_PATH` | Copilot CLI | Explicit `.jsonl` file |
17+
| `GEMINI_DATA_DIR` | Gemini CLI | `~/.gemini/tmp` |
1718
| `KIMI_DATA_DIR` | Kimi | `~/.kimi` |
1819

1920
Example:
@@ -24,6 +25,7 @@ export OPENCODE_DATA_DIR="/path/to/opencode,/archive/opencode"
2425
export AMP_DATA_DIR="/path/to/amp,/archive/amp"
2526
export PI_AGENT_DIR="/path/to/pi/sessions,/archive/pi/sessions"
2627
export COPILOT_OTEL_FILE_EXPORTER_PATH="/path/to/copilot-otel.jsonl"
28+
export GEMINI_DATA_DIR="/path/to/gemini/tmp,/archive/gemini/tmp"
2729
export KIMI_DATA_DIR="/path/to/kimi,/archive/kimi"
2830
ccusage daily
2931
```
@@ -194,7 +196,7 @@ To see which environment variables are being used:
194196

195197
```bash
196198
# Show all environment variables
197-
env | grep -E "CLAUDE|CODEX|OPENCODE|AMP|PI_AGENT|COPILOT|KIMI|CCUSAGE|LOG_LEVEL"
199+
env | grep -E "CLAUDE|CODEX|OPENCODE|AMP|PI_AGENT|COPILOT|GEMINI|KIMI|CCUSAGE|LOG_LEVEL"
198200

199201
# Debug mode shows environment variable usage
200202
LOG_LEVEL=4 ccusage daily --debug

‎docs/guide/gemini/index.md‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Gemini CLI Data Source (Beta)
2+
3+
> Gemini CLI support is experimental while the Gemini CLI log format continues to evolve.
4+
5+
ccusage can read Gemini CLI chat logs as one of its supported local data sources. Gemini uses the same unified and focused report model as Claude Code, Codex, OpenCode, Amp, pi-agent, and GitHub Copilot CLI.
6+
7+
## Focused Views
8+
9+
```bash
10+
# Daily Gemini CLI usage
11+
ccusage gemini daily
12+
13+
# Monthly Gemini CLI usage
14+
ccusage gemini monthly
15+
16+
# Gemini CLI sessions
17+
ccusage gemini session
18+
```
19+
20+
Most users can start with unified reports such as `ccusage daily`. Add the `gemini` namespace only when you want to focus the same report shape on Gemini CLI usage.
21+
22+
## Data Source
23+
24+
The CLI reads Gemini CLI JSON and JSONL files located under `GEMINI_DATA_DIR` (defaults to `~/.gemini/tmp`). `GEMINI_DATA_DIR` can be one directory or a comma-separated list of directories.
25+
26+
```bash
27+
GEMINI_DATA_DIR="$HOME/.gemini/tmp,/backup/gemini/tmp" ccusage gemini daily
28+
```
29+
30+
```text
31+
~/.gemini/tmp/
32+
└── */
33+
└── chats/
34+
├── *.json
35+
└── *.jsonl
36+
```
37+
38+
## Report Views
39+
40+
| Focused view | Description | See also |
41+
| ------------------------ | --------------------------------- | --------------------------------------- |
42+
| `ccusage gemini daily` | Aggregate usage by date | [Daily Usage](/guide/daily-reports) |
43+
| `ccusage gemini monthly` | Aggregate usage by month | [Monthly Usage](/guide/monthly-reports) |
44+
| `ccusage gemini session` | Group usage by Gemini CLI session | [Session Usage](/guide/session-reports) |
45+
46+
These views support `--json`, `--compact`, and `--offline`.
47+
48+
## What Gets Calculated
49+
50+
- **Token usage** - Gemini token records provide input, output, cached, thought, tool, and total token counts when available.
51+
- **Cache tokens** - Gemini `input` values can include cached prompt tokens. ccusage separates those cached tokens into cache read so input and cache read are not double-counted.
52+
- **Reasoning tokens** - Gemini `thoughts` tokens are included in total tokens and exposed as `reasoningTokens` in JSON output. They are priced with output tokens.
53+
- **Pricing** - Costs are calculated from LiteLLM pricing data for Gemini, Google, Vertex AI, and OpenRouter Gemini model names.
54+
55+
## Environment Variables
56+
57+
| Variable | Description |
58+
| ----------------- | ---------------------------------------------------------------------------------------- |
59+
| `GEMINI_DATA_DIR` | Override the root directory, or comma-separated root directories, containing Gemini data |
60+
| `LOG_LEVEL` | Adjust verbosity (0 silent ... 5 trace) |
61+
62+
## Troubleshooting
63+
64+
::: details No Gemini CLI usage data found
65+
Ensure Gemini CLI has written chat logs under `~/.gemini/tmp/*/chats/`. Set `GEMINI_DATA_DIR` if your Gemini data lives elsewhere or in multiple archive roots.
66+
:::
67+
68+
::: details Costs showing as $0.00
69+
If a model is not in LiteLLM's database, the cost will be $0.00. Use `--offline=false` to fetch the latest pricing data, or [open an issue](https://github.com/ryoppippi/ccusage/issues/new) to request alias support.
70+
:::

‎docs/guide/index.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
![ccusage daily report showing token usage and costs by date](/screenshot.png)
44

5-
**ccusage** is a local CLI for understanding coding (agent) CLI token usage and estimated costs across Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Kimi.
5+
**ccusage** is a local CLI for understanding coding (agent) CLI token usage and estimated costs across Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, Gemini CLI, and Kimi.
66

7-
The original **“cc”** came from **C**laude **C**ode usage and now also fits **C**odex **C**LI usage. As OpenCode, Amp, pi-agent, and other coding (agent) CLIs became part of the same workflow, ccusage expanded into a general name for local coding CLI usage analysis.
7+
The original **“cc”** came from **C**laude **C**ode usage and now also fits **C**odex **C**LI usage. As OpenCode, Amp, pi-agent, Gemini CLI, Kimi, and other coding (agent) CLIs became part of the same workflow, ccusage expanded into a general name for local coding CLI usage analysis.
88

99
## The Problem
1010

@@ -19,7 +19,7 @@ Modern coding (agent) CLI usage is split across several local data formats. That
1919

2020
ccusage reads the local usage files that coding CLIs already generate and provides:
2121

22-
- **All Sources by Default** - Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Kimi in one CLI
22+
- **All Sources by Default** - Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, Gemini CLI, and Kimi in one CLI
2323
- **Usage Views** - Daily, weekly, monthly, and session-based breakdowns
2424
- **Cost Analysis** - Estimated costs based on token usage and model pricing
2525
- **Focused Data Source Views** - Start with all detected sources, then narrow the same usage views to one source when needed
@@ -80,6 +80,7 @@ ccusage reads from local coding CLI data directories:
8080
| Amp | `amp` | `${AMP_DATA_DIR:-~/.local/share/amp}` |
8181
| pi-agent | `pi` | `${PI_AGENT_DIR:-~/.pi/agent/sessions}` |
8282
| Copilot CLI | `copilot` | `~/.copilot/otel/*.jsonl` |
83+
| Gemini CLI | `gemini` | `${GEMINI_DATA_DIR:-~/.gemini/tmp}` |
8384
| Kimi | `kimi` | `${KIMI_DATA_DIR:-~/.kimi}` |
8485

8586
The tool automatically detects available data and aggregates all supported coding CLIs by default.
@@ -105,6 +106,7 @@ ccusage opencode weekly
105106
ccusage amp session
106107
ccusage pi monthly
107108
ccusage copilot daily
109+
ccusage gemini daily
108110
ccusage kimi daily
109111
```
110112

‎docs/guide/kimi/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Kimi support is experimental. Expect breaking changes while both ccusage and [Kimi CLI](https://github.com/MoonshotAI/kimi-cli) continue to evolve.
44
5-
ccusage can read Kimi CLI wire logs as one of its supported local data sources. Kimi uses the same unified and focused report model as Claude Code, Codex, OpenCode, Amp, pi-agent, and GitHub Copilot CLI.
5+
ccusage can read Kimi CLI wire logs as one of its supported local data sources. Kimi uses the same unified and focused report model as Claude Code, Codex, OpenCode, Amp, pi-agent, GitHub Copilot CLI, and Gemini CLI.
66

77
## Usage
88

0 commit comments

Comments
 (0)