Skip to content

feat(providers): add CodeBuddy CN credit usage provider - #269

Open
dong5945 wants to merge 2 commits into
nesszer:mainfrom
dong5945:pr/add-codebuddy-cn
Open

feat(providers): add CodeBuddy CN credit usage provider#269
dong5945 wants to merge 2 commits into
nesszer:mainfrom
dong5945:pr/add-codebuddy-cn

Conversation

@dong5945

@dong5945 dong5945 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Adds a CodeBuddy CN provider so Win-CodexBar can show subscription credit remaining / used totals for Tencent CodeBuddy (codebuddy.cn).

What it tracks

  • Account credit packages via POST https://www.codebuddy.cn/billing/meter/get-user-resource
  • Summed CapacitySize / CapacityUsed / CapacityRemain across packages
  • Optional earliest package expire time as reset

Auth sources (priority)

  1. Manual Cookie header (Settings / token accounts)
  2. %USERPROFILE%\.codebuddy\cb_cookie.txt (shared with statusline helpers)
  3. Browser cookies for codebuddy.cn
  4. Auto fallback: ~/.codebuddy/cb_credits.json normalized cache

Notes

  • Uses a Chrome UA without Edg/ (EdgeOne WAF rejects Edge UAs on this path)
  • Package codes can be overridden with CB_PACKAGE_CODES when an account returns empty Accounts
  • Default-disabled in the provider catalog

Test plan

  • cargo test -p codexbar --lib providers::codebuddy
  • Enable CodeBuddy in Settings → paste Cookie from plans-usage Network tab → refresh
  • Confirm remaining/total credits match https://www.codebuddy.cn/profile/plans-usage

Scope

CN CodeBuddy only (codebuddy.cn). International codebuddy.ai can be a follow-up.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Add a cookie-backed CodeBuddy CN provider that reads remaining credits from get-user-resource, with fallbacks for ~/.codebuddy/cb_cookie.txt and the local cb_credits.json cache. Wire ProviderId, factory, token accounts, and tray/settings catalog entries.
@Finesssee

Copy link
Copy Markdown
Collaborator

Thanks for the PR, I will review it ASAP.

Shorten tray metric text to 'N / total left', ellipsis long reset lines in the card row, retry transient WAF/proxy errors, and persist a local credits cache after successful web fetches for Auto fallback.
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