Repository navigation
feat(cline): add extension and CLI usage adapter - #1977
Conversation
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 #1642. Co-authored-by: Rushikesh Gaikwad <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai @cubic-dev-ai Please review the Cline adapter implementation, including source-format parsing, cache accounting, historical model attribution, cost modes, and focused/unified report coverage. |
@ryoppippi I have started the AI code review. It will take a few minutes to complete. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | f2864b8 | Commit Preview URL Branch Preview URL |
Nov 10 2026, 05:35 PM |
|
🧠 Learnings used
|
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
ℹ️ No critical issues — two small follow-ups inline.
Reviewed changes
- Added a Cline adapter reading extension tasks, legacy CLI tasks, and CLI session transcripts, with
CLINE_DATA_DIRoverrides andtask:/cli:session namespacing. - Wired
ccusage cline daily|weekly|monthly|session, unified all-source loading, config schema, docs, and help snapshots. - Added fixture-backed unit, snapshot, and CLI integration tests; verified the extension-vs-CLI token asymmetry against upstream semantics and confirmed session-ID prefixing is opaque to shared consumers.
- Verified one upstream claim via live sources (extension
tokensInis exclusive of cache; CLIinputTokensis inclusive, so the asymmetric subtraction is correct). Upstream discovery coverage (extension id, layouts, editor list) could not be re-verified live, so the experimental docs label is doing real work here.
muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏
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.
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
3 issues found across 74 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="rust/crates/ccusage-cli/src/lib.rs">
<violation number="1" location="rust/crates/ccusage-cli/src/lib.rs:6">
P3: `STANDARD_WEEKLY_AGENT_REPORTS` is newly exported here, but the crate README's exhaustive "Public surface" list in `rust/crates/ccusage-cli/README.md` does not include it. Add `- `types::STANDARD_WEEKLY_AGENT_REPORTS`` after the `STANDARD_AGENT_REPORTS` entry so the docs stay in sync.</violation>
</file>
<file name="rust/crates/ccusage-adapter-all/README.md">
<violation number="1" location="rust/crates/ccusage-adapter-all/README.md:13">
P3: The count is still wrong: `Cargo.toml` depends on 19 adapters (excluding `ccusage-adapter-common`) once Cline is included, so this should read 19. The "Depends on" list also omits `ccusage-adapter-antigravity`, which the crate depends on and uses in `loader.rs`.</violation>
</file>
<file name="rust/crates/ccusage-cli/src/types.rs">
<violation number="1" location="rust/crates/ccusage-cli/src/types.rs:229">
P3: `STANDARD_WEEKLY_AGENT_REPORTS` duplicates the existing `OPENCODE_AGENT_REPORTS` exactly. Reuse `OPENCODE_AGENT_REPORTS` for Cline and drop this constant and its re-export. If a separate name is wanted, make it a distinct name that describes the purpose. Also add it to the public surface list in the crate README if it stays.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Reviewed changes
- Tightened extension records since the prior review to completed
api_req_startedevents with their own timestamp, model, and all four integer counters; rollups, partial records, all-zero usage, and metadata-only model attribution are now excluded. - Tightened CLI records to assistant messages with valid timestamps, complete metrics, and non-
unknownmodels; cache-inconsistent or overflowing totals are skipped via checked arithmetic instead of clamping. - Documented the eligible-requests-only coverage and kept fixtures, regression tests, and focused plus unified snapshots aligned with the stricter totals.
ℹ️ No new issues in the incremental delta — prior minor threads remain open.
No new findings in commit 80ffd4c. Two minor threads from the prior review (session-prefix docs note, adapter-count README) are unchanged by these commits and left open for the author, so this review stays non-approving.
muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏
# Conflicts: # rust/crates/ccusage-core/src/lib.rs
There was a problem hiding this comment.
ℹ️ No new issues in the incremental delta — merge-only update verified clean.
Reviewed changes
- Merged
maininto the branch, picking up shared refactors (format_date_tzrename,BUILT_IN_AGENT_NAMESmove,AgentRows::warningsplumbing, test isolation). - Confirmed Cline wiring survived the merge with its report index, loader spec, and date helper signatures intact.
- Confirmed the two prior minor threads remain open and unchanged by this merge.
No new findings in commit 3bf4230. Two minor threads from the prior review (session-prefix docs note, adapter-count README) are unchanged by these commits and left open for the author, so this review stays non-approving.
muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
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.
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.
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.
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.
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.
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.
|
Note 🤖 Claude Opus 5.5 responding on behalf of ryoppippi @coderabbitai @cubic-dev-ai @pullfrog Please re-review the latest push (c9946e8). All nine threads from 2026-10-26 are addressed and resolved:
Validation: |
|
No re-review warranted. HEAD (c9946e8) is identical to the prior pullfrog approval (review 5832111405), so there is no incremental delta. Both pullfrog-originated threads from the initial review are marked RESOLVED, and the six fixup commits were already covered by that approval.
|
@ryoppippi A review is already in progress. Try again after it finishes. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (since prior pullfrog review at 3bf4230)
- Fixed session reporting to carry activity bounds and project path via
SessionAccumulator, and enabled session metadata in session JSON rows, with a regression test and refreshed snapshots. - Consolidated the duplicated weekly report lists into a single
ALL_AGENT_REPORTSshared byclineandopencode, and merged theagent_report_supportedarms. - Documented the
task:/cli:session-ID prefixes and the every-platform candidate discovery in the Cline guide and adapter README. - Reworded both crate READMEs to avoid hard-coded adapter counts and added the missing
antigravitydependency entry. - Hardened test isolation by clearing
APPDATAin unified loader tests. - Added a table-report test asserting recorded costs render in the Total row.
muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
|
Action not completed
|
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR: Verdict: no significant change (every command within ±10% CPU time and peak RSS). Fixture: generated Claude logs (1.01 GiB on disk, 2597 files) and Codex logs (295.00 MiB on disk, 2597 files, mostly zstd-compressed) shaped like current real logs; every value is synthetic. Base and PR are built from source the same way on this runner and run
Binary size
|
Upstream tip: 660e07c (2026-11-13, chore(pricing): update models.dev snapshot) Previous fork base: 30b653f (the upstream commit this fork was synced to) Synced 100 upstream commits on top of 30b653f: 53 automated pricing snapshot refreshes, 23 dependency bumps, 2 releases, and: 3541115 feat(cline): add extension and CLI usage adapter (ccusage#1977) 5e5c475 fix(antigravity): report real model names instead of placeholders (ccusage#2071) e39ed83 fix(claude): keep the cache TTL split when deduping equal copies (ccusage#2060) c17c591 feat(adapter): report 1h cache writes in JSON model breakdowns (ccusage#2059) a06f4bc perf(claude): halve `ccusage claude` report time (ccusage#2058) de43952 fix(claude): show model breakdowns for session --id (ccusage#2057) 5f31039 fix(all): count only in-window Claude usage in unified session reports (ccusage#2052) e4f0ea9 fix(codex): count spawned subagent requests stamped at the fork instant (ccusage#2051) b85b28f fix(opencode): count usage from completed v2 compaction rows (ccusage#2050) 00fead0 fix(antigravity): deduplicate unkeyed mirror usage (ccusage#2027) 2248106 fix(opencode): exclude Claude Agent turns by default (ccusage#2022) 4fb1c0d fix(codex): guard truncated type fields from panicking the parser (ccusage#2034) 86707db build(perf): make the PR performance comparison catch real regressions (ccusage#2061) 686a1a8 ci: support a merge queue on main (ccusage#2062) Fork wins kept: the Codex optimized scanner with its fork-replay instant, the Antigravity model resolver, the OpenCode retained-ledger cache with its per-namespace rows, the SQLite on-disk cache, the table renderer, the fork CI and tag-only release workflow, and the exact `=` dependency pins. Hand-resolved conflicts: rust/adapters/claude/src/lib.rs: the fork's DedupedEntries copy pairs stay and take upstream's carries_more_usage_detail tiebreak (speed rank, then a cache TTL split); main_thread_session_days reads the recorded session of each copy. rust/adapters/opencode/{loader,parser}.rs: the fork's retain_via_ledger stays beside upstream's v2 compaction scan; SessionMessageKind and MessageRowColumns carry the row type through the five-value scan. rust/adapters/codex/{replay,parser}.rs: open_rollout_reader_with_capacity and CodexForkReplay both land in the shared parser state. rust/crates/ccusage-core/src/{cache,pricing}.rs: the opencode-db-compaction namespace joins the ledger namespaces; the fork's embedded pricing loader and OnceLock path stay. rust/crates/ccusage/src/cli/timezone.rs: Cline joins the shared-args arm, the ClearCache arm stays unreachable from the parser. rust/Cargo.toml: the fork's exact `=` pins stay; jiff 0.2.41, schemars 1.2.2, serde 1.0.229, smallvec 1.16.5, toml 1.2.1. .github/workflows/{ci,release}.yaml: the fork's design is kept, including its own release flow. Upstream's merge-queue, tagpr and pkg.pr.new jobs need scripts this fork deleted, so they are not taken; the two save-nix-cache inputs upstream passes to the native-package actions are dropped because the fork's composite actions declare no such input. packages/ccusage-*/package.json (6 files), the contribution-gate scripts, sponsors.md, blacksmith.png and rust/adapters/claude/src/daily.rs stay deleted; the two Blacksmith SVG logos upstream added are not taken. Docs: the agent lists take upstream's Cline addition but keep this fork's `pi` name, because the CLI subcommand is still `pi`; upstream renamed the docs to `pi-agent` without renaming the command. Snapshots regenerated for the fork table renderer: the Cline adapter, CLI and unified reports, codex issue_2046, opencode compaction, claude session --id and the config schema (new Cline section). Validation: cargo test --workspace --offline 1297 passed, 0 failed; cargo clippy --workspace --all-targets clean; rustfmt --check clean. Version: take upstream's 20.0.50 in package.json, apps/ccusage/package.json and docs/package.json; the Rust workspace keeps version 0.0.0. DO NOT push a v20.0.50 tag from this fork: release.yaml would publish fork bytes under upstream identity.

Adds
ccusage cline daily|weekly|monthly|sessionand Cline aggregation in all-source reports. Discovers Cline task files for VS Code, Insiders, Cursor, Windsurf, and VSCodium on macOS/Linux/Windows, modern CLI session transcripts, and legacy CLI task files.CLINE_DATA_DIRaccepts comma-separated roots.Only self-contained per-request data is counted. Each accepted request must record its own valid timestamp and nonempty model ID, together with explicit input, output, cache-read, and cache-write counters as non-negative integer JSON numbers. Missing counters are never filled with zero, and models are never inferred from task metadata or conversation history. Explicit zero buckets remain valid when the request contains usage; known model IDs without a pricing entry remain available for pricing overrides and missing-pricing reporting.
Excluded data, documented in the Cline guide:
unknownmodel IDs, including records whose model is available only in task metadata.partial: true, cost-only records, and all-zero usage placeholders.deleted_api_reqsandsubagent_usagerollup, even if it contains token totals: these are not individual requests with their original timestamps.Reports intentionally cover eligible requests only; excluded historical data is not reconstructed. A recorded cost never rescues an ineligible record. The shared
auto,display, andcalculatecost modes continue to apply to accepted records, including valid recorded zero costs. Kilo/Roo extension data and the Pino log source proposed in #1871 remain out of scope.Task requests require a non-negative integer epoch-millisecond
tsin the supported timestamp range. CLI messages use their own integerts, or a timezone-qualified ISOtimestampstring with whole seconds or exactly three fractional digits whentsis absent. An invalid presenttsis not rescued by another timestamp, a sidecar file, or file modification time; unsupported timestamp forms are skipped.Fixtures and regression tests cover each exclusion, metadata-only models, explicit zero buckets, malformed data, cache consistency, and exact accepted token/cost/model/session totals. JSON and table snapshots cover all four focused and unified reports.
Validation (pinned Nix environment):
just fmtjust typecheckjust test— 1,105 Rust tests and 35 Node tests passed (4 Rust tests/examples ignored).cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets -- -D warningsjust check— all 12 host flake checks passed on aarch64-darwin.Validation is fixture-based; no local Cline installation was available for a real-data smoke test. No pricing snapshot files were changed.
Reviewed prior PR #1642 and credited Rushikesh Gaikwad (@Wraient) as a co-author. Format references: Cline message types, CodeBurn CLI parser, and legacy CLI task storage.
Closes #243
Refs #1871
Refs #1642
Summary by CodeRabbit
CLINE_DATA_DIR.