Skip to content

Conversation

@armanarutiunov
Copy link

@armanarutiunov armanarutiunov commented Jan 28, 2026

Problem (by author)

When using OpenCode with the Anthropic provider (Claude Pro/Max), the cost is not being contributed towards total calculation in the CodexBar app when Claude is used as a provider in settings.

The reason is that we're only calculating the cost from Claude Code usage and not taking into account that Claude Code can be used from 3rd party clients such as OpenCode.

This PR only solves this specific issue when OpenCode usage is not calculated towards Claude Code cost. I would assume the same probably happens for users who are on Copilot/Codex/Cursor/etc subscriptions and using a tool like OpenCode as an interface.

Everything below is AI generated ⬇️

Summary

  • Adds OpenCode message file parser to extract token usage from ~/.local/share/opencode/storage/message/
  • Merges OpenCode usage into Claude provider's cost data (since OpenCode users consume their Claude Max subscription)
  • Parser is provider-agnostic - returns providerID and filtering happens at call site

Changes

  • CostUsageScanner+OpenCode.swift (new): Parses OpenCode message JSON files, normalizes model names to Claude pricing keys
  • CostUsageScanner+Claude.swift: Calls OpenCode scanner when loading Claude daily report
  • CostUsageScanner.swift: Added openCodeStorageRoot option for testability
  • OpenCodeProviderDescriptor.swift: Updated message to indicate cost is included in Claude provider

Testing

  • All 546 tests pass
  • Verified CLI: codexbar cost --provider claude shows combined usage
  • Verified app UI shows cost chart with OpenCode data

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 922cb2e2b8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@jeankvd
Copy link

jeankvd commented Jan 28, 2026

Don't think this is even needed.

Its against TOS and Anthropic has been banning users of third party apps

You cannot use Claude Pro/Max with OpenCode currently (they just blocked it again)

@armanarutiunov
Copy link
Author

Don't think this is even needed.

Its against TOS and Anthropic has been banning users of third party apps

You cannot use Claude Pro/Max with OpenCode currently (they just blocked it again)

Yeah they blocked it again literally a few hours after I opened this PR haha. Closing 🫡

@armanarutiunov armanarutiunov deleted the feature/opencode-cost-in-claude branch January 28, 2026 22:48
@armanarutiunov armanarutiunov restored the feature/opencode-cost-in-claude branch January 30, 2026 15:09
@armanarutiunov
Copy link
Author

@jeankvd looks like it's working again. do you think this PR makes sense now for those of us who's using opencode with their claude account?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants