Repository navigation
Commit 3541115
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
- apps/ccusage
- docs
- .vitepress
- guide
- claude
- cline
- codex
- nix
- rust
- adapters/cline
- src
- snapshots
- tests/fixtures
- cli
- extension
- crates
- ccusage-adapter-all
- src
- snapshots
- ccusage-cli-parser/src
- snapshots
- ccusage-cli
- src
- ccusage-config/src
- snapshots
- ccusage
- src
- adapter
- cli
- tests
- snapshots
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | | - | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
0 commit comments