Skip to content

Commit 3541115

Browse files
ryoppippiWraient
andauthored
feat(cline): add extension and CLI usage adapter (ccusage#1977)
* feat(cline): add extension and CLI usage adapter Read Cline editor tasks, CLI session transcripts, and legacy CLI tasks through a dedicated Rust adapter. Preserve reported costs and request model history, normalize CLI cache-inclusive input, and expose focused and unified reports with configuration, documentation, and fixtures. Builds on the investigation and prior implementation in ccusage#1642. Co-authored-by: Rushikesh Gaikwad <[email protected]> * fix(cline): require complete per-request usage records Count only requests with explicit integer counters, a recorded model ID, and a valid request timestamp. Remove task metadata model inference and exclude deleted-request and subagent rollups instead of assigning them request timing or model information. Reject incomplete, partial, unknown-model, all-zero, and inconsistent or overflowing usage records. Document the exclusions and cover them with fixtures plus focused and unified report assertions and snapshots. * fix(cline): report session activity bounds and project path Cline session reports grouped rows with summarize_by_key, which only tracks token and cost totals, and report_from_rows always passed include_session_metadata=false. Session JSON therefore never carried firstActivity, lastActivity, or projectPath, unlike the other session adapters, and the unified report got no lastActivity metadata for Cline sessions. Build session rows with SessionAccumulator, as zcode, qwen, and pi do, and emit session metadata for session reports. A unit test covers a session whose entries arrive out of order, and the session snapshots now include the new fields. * refactor(cli): share one report list for agents with weekly reports STANDARD_WEEKLY_AGENT_REPORTS was an exact copy of OPENCODE_AGENT_REPORTS. The copy existed because the original was named after one agent rather than the report set it describes, so a second agent with the same reports could not reuse it by name. Rename OPENCODE_AGENT_REPORTS to ALL_AGENT_REPORTS, since it lists every AgentReportKind, and use it for both OpenCode and Cline. The matching arms in agent_report_supported are merged too, and the ccusage-cli public-surface list is updated to the new name. * docs(rust): stop hard-coding adapter counts in crate READMEs ccusage-adapter-all said it depends on "all 18 adapters" and ccusage-cli said "all 17 adapters". Cargo.toml now lists 19 source adapters, so both numbers were stale, and a fixed number goes stale again whenever an adapter is added. Say "every source adapter" / "every adapter" instead. The ccusage-adapter-all "Depends on" list was also missing ccusage-adapter-antigravity, which the crate depends on and loads. * docs(cline): explain session ID prefixes and default root discovery Session reports show IDs such as task:<id> and cli:<id>, but the guide never explained the prefixes. Document that task: marks extension and legacy CLI tasks and cli: marks CLI session transcripts, so a task and a CLI session that share an ID stay separate rows. The adapter README and the guide's storage table read as if each platform searched only its own config directory. default_roots() checks every candidate on every platform and skips missing ones. Say so, and mention the %USERPROFILE%\AppData\Roaming fallback in the README. * test(all): clear APPDATA in unified loader test isolation The isolation helpers pin HOME and USERPROFILE to the fixture and clear CLINE_DATA_DIR, but the Cline adapter reads APPDATA before falling back to USERPROFILE for its Windows extension roots. On a Windows machine these tests could pick up real Cline data from %APPDATA%. Clear APPDATA in both helpers so Cline discovery falls back to the fixture's USERPROFILE. * test(cline): assert recorded costs render in table reports The shared Cline fixture totals $0.0012, so every cost cell in the table snapshots renders as $0.00 and a broken table cost path would not change them. Add a fixture with $1.25 and $2.50 recorded costs and assert that the Total row of each report kind renders $3.75. --------- Co-authored-by: Rushikesh Gaikwad <[email protected]>
1 parent af48fde commit 3541115

74 files changed

Lines changed: 5155 additions & 55 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/ccusage/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ ccusage reads local usage data from coding agent CLIs and turns it into daily, w
5959
| Amp | `ccusage amp daily` |
6060
| Droid | `ccusage droid daily` |
6161
| Codebuff | `ccusage codebuff daily` |
62+
| Cline | `ccusage cline daily` |
6263
| Hermes Agent | `ccusage hermes daily` |
6364
| pi-agent | `ccusage pi daily` |
6465
| Goose | `ccusage goose daily` |
@@ -117,6 +118,7 @@ bunx ccusage opencode weekly
117118
bunx ccusage amp session
118119
bunx ccusage droid daily
119120
bunx ccusage codebuff daily
121+
bunx ccusage cline daily
120122
bunx ccusage hermes daily
121123
bunx ccusage goose daily
122124
bunx ccusage openclaw daily
@@ -160,7 +162,7 @@ bunx ccusage monthly --compact # Compact monthly report
160162
- 📊 **Daily Report**: View token usage and costs aggregated by date
161163
- 📅 **Monthly Report**: View token usage and costs aggregated by month
162164
- 💬 **Session Report**: View usage grouped by conversation sessions
163-
- 🤖 **Unified CLI Reports**: View Claude Code, Codex, OpenCode, Amp, Droid, Codebuff, Hermes Agent, pi-agent, Goose, OpenClaw, Kilo, Kimi, Qwen, GitHub Copilot CLI, Gemini CLI, Antigravity, Grok Build CLI, and ZCode usage from one CLI
165+
- 🤖 **Unified CLI Reports**: View Claude Code, Codex, OpenCode, Amp, Droid, Codebuff, Cline, Hermes Agent, pi-agent, Goose, OpenClaw, Kilo, Kimi, Qwen, GitHub Copilot CLI, Gemini CLI, Antigravity, Grok Build CLI, and ZCode usage from one CLI
164166
- ⏰ **5-Hour Blocks Report**: Track usage within Claude's billing windows with active block monitoring
165167
- 🚀 **Statusline Integration**: Compact usage display for Claude Code status bar hooks (Beta)
166168
- 🤖 **Model Tracking**: See which models are used across supported sources

0 commit comments

Comments
 (0)