Add Cowork usage source#1199
Conversation
|
This PR was auto-closed. Only contributors approved with Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply. If a maintainer replies See CONTRIBUTING.md. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (39)
📝 WalkthroughWalkthroughThis PR introduces Cowork (Claude Desktop local-agent-mode sessions) as a new data source in ccusage. The changes extend the CLI parser to recognize ChangesCowork Agent Support
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly Related PRs
Suggested Reviewers
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 40 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="rust/crates/ccusage/src/adapter/all/loader.rs">
<violation number="1" location="rust/crates/ccusage/src/adapter/all/loader.rs:407">
P2: New Cowork loader duplicates Claude loader logic, increasing drift risk. Extract a shared helper for daily summary + session capable loading, following the existing `load_summary_agent_rows`/`load_session_capable_summary_agent_rows` pattern in the file.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }) | ||
| } | ||
|
|
||
| fn load_cowork_rows(kind: AgentReportKind, shared: &SharedArgs) -> Result<AgentRows> { |
There was a problem hiding this comment.
P2: New Cowork loader duplicates Claude loader logic, increasing drift risk. Extract a shared helper for daily summary + session capable loading, following the existing load_summary_agent_rows/load_session_capable_summary_agent_rows pattern in the file.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At rust/crates/ccusage/src/adapter/all/loader.rs, line 407:
<comment>New Cowork loader duplicates Claude loader logic, increasing drift risk. Extract a shared helper for daily summary + session capable loading, following the existing `load_summary_agent_rows`/`load_session_capable_summary_agent_rows` pattern in the file.</comment>
<file context>
@@ -398,6 +404,26 @@ fn load_claude_rows(kind: AgentReportKind, shared: &SharedArgs) -> Result<AgentR
})
}
+fn load_cowork_rows(kind: AgentReportKind, shared: &SharedArgs) -> Result<AgentRows> {
+ if kind == AgentReportKind::Session {
+ return load_session_capable_summary_agent_rows(
</file context>
TL;DR
Adds Cowork as a separate usage source for Claude Desktop local agent mode sessions.
Cowork stores Claude-compatible
.claude/projects/**/*.jsonldata underlocal-agent-mode-sessions, so ccusage can parse it with the existing Claude usage model while keeping it distinct from Claude Code.What changed
coworkCLI source with focused reports fordaily,monthly, andsession.~/Library/Application Support/Claude/local-agent-mode-sessionsand a guardedCOWORK_CONFIG_DIRoverride.renovate-config-validator, so the generated hook calls the validator binary directly.Why
Claude Desktop Cowork local agent mode stores sessions locally, but ccusage previously only picked up Claude Code and other coding CLI sources. This adds support for that local Cowork data without merging it into Claude Code totals, so users can inspect Cowork separately or include it in unified reports.
How tested
cargo test --manifest-path rust/Cargo.toml --workspacecargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets -- -D warningscargo fmt --all --manifest-path rust/Cargo.toml --checkTZ=UTC node_modules/.bin/vitest runvitepress buildnix develop --command pnpm run lint:oxfmtnix develop --command pnpm run lint:oxlintnix develop --command pnpm typechecknix develop --command git push ...:clippy,oxlint,treefmt,gitleaks,renovate-config-validator,cargo test, andvitest relatedpassed.cowork daily,cowork monthly,cowork session, unifieddaily, and guardedCOWORK_CONFIG_DIRfailure behavior.Checklist
Summary by cubic
Adds Cowork as a separate usage source for Claude Desktop local agent sessions, with focused reports and inclusion in unified views. Users can now analyze Cowork separately from Claude Code.
New Features
coworkCLI namespace withdaily,monthly, andsessionreports (e.g.,ccusage cowork daily).~/Library/Application Support/Claude/local-agent-mode-sessions; supports a comma‑separatedCOWORK_CONFIG_DIRoverride with guarded behavior.Bug Fixes
renovate-config-validatordirectly to run the validator reliably.Written for commit 24e5f3e. Summary will update on new commits.
Summary by CodeRabbit
New Features
ccusage cowork daily,monthly, andsessionreport commandsCOWORK_CONFIG_DIRenvironment variable to customize Cowork data discovery pathsDocumentation