Skip to content

fix(claude): discover macOS Claude-3p Cowork sessions - #1579

Open
akapti wants to merge 2 commits into
getagentseal:mainfrom
akapti:fix/claude-3p-macos-sessions
Open

akapti wants to merge 2 commits into
getagentseal:mainfrom
akapti:fix/claude-3p-macos-sessions

Conversation

@akapti

@akapti akapti commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

Claude Desktop Cowork on current macOS 3p builds stores usage under ~/Library/Application Support/Claude-3p/local-agent-mode-sessions/. The path override only selects a directory; it does not make CodeBurn understand the Cowork usage-ledger format.

Findings

  • Normal Claude Code usage is parsed from .claude/projects/**/*.jsonl by the existing Claude transcript parser in src/parser.ts.
  • The Claude-3p data contains usage-ledger/*.ndjson files with surface, models, token counts, and nested models.*.cost.usd values.
  • Before this change, CodeBurn did not discover those ledger files or parse their cost fields, so setting CODEBURN_DESKTOP_SESSIONS_DIR alone produced no Cowork usage records.
  • The ledger schema is different from the normal Claude transcript schema, so the existing parseApiCall() function cannot be reused directly without misreading the records.

Changes

  • Discover both the classic macOS Claude Desktop root and the Claude-3p root.
  • Discover Cowork usage-ledger/*.ndjson files beneath either root.
  • Add a focused Cowork ledger adapter in src/providers/claude.ts that reuses the existing streaming line reader, date filtering, token accounting, cost calculation fallback, parsed-call model, cache, aggregation, and reporting pipeline.
  • Use the recorded cost.usd when present and estimate cost with the existing Claude pricing helper when it is absent.
  • Preserve the existing normal Claude JSONL parser unchanged for regular Claude Code sessions.
  • Add regression and end-to-end tests for discovery, parsing, cost, token fields, surface filtering, and aggregation.
  • Bump the Claude parse version so existing caches are reparsed with ledger support.

Verification

  • Real Claude-3p data from ~/Library/Application Support/Claude-3p/local-agent-mode-sessions: 5 Cowork ledger records, 2 sessions, and $1.0454102 recorded cost were parsed successfully. The built CLI reported Claude Cowork: Cost (USD) 1.05, API Calls 5, Sessions 2.
  • Claude provider doctor: 7 candidates found, 7 parsed successfully, 0 failures.
  • Focused tests: 51 passed across the Claude provider and parser suites.
  • npx tsc --noEmit passed.
  • npm run build:cli passed.
  • Full test suite: 345 files passed, 5 failed due to the environment Git rejecting git init -b main; 4,666 tests passed, 13 failed for the same unrelated issue.

@akapti
akapti requested a review from iamtoruk as a code owner September 29, 2026 09:22
@ozymandiashh ozymandiashh added bug Something isn't working area: cli The codeburn CLI and its core parsing/reporting engine provider: claude Claude Code provider needs-validation PR requires validation against real-world usage before review labels Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli The codeburn CLI and its core parsing/reporting engine bug Something isn't working needs-validation PR requires validation against real-world usage before review provider: claude Claude Code provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants