Add Codebuff provider support#837
Merged
ratulsarna merged 7 commits intomainfrom May 4, 2026
Merged
Conversation
Add a new CodexBar provider for Codebuff (https://www.codebuff.com), the successor to the Manicode CLI. The provider surfaces live credit balance and the weekly rate-limit window in the menu bar alongside the other providers. Data sources: * POST https://www.codebuff.com/api/v1/usage -> credit usage / quota / remaining balance / next reset / auto-topup state. * GET https://www.codebuff.com/api/user/subscription -> subscription tier + weekly rate limit + billing period end. Auth token resolution mirrors the Kilo pattern: 1. CODEBUFF_API_KEY env var. 2. API key configured in Settings -> Providers -> Codebuff. 3. ~/.config/manicode/credentials.json (authToken field) written by the official `codebuff login` CLI. New core files under Sources/CodexBarCore/Providers/Codebuff/: CodebuffSettingsReader, CodebuffProviderDescriptor, CodebuffUsageFetcher, CodebuffUsageSnapshot, CodebuffUsageError. App-side files under Sources/CodexBar/Providers/Codebuff/: CodebuffProviderImplementation, CodebuffSettingsStore. Lime-green SVG icon added to Resources. Registers .codebuff in UsageProvider + IconStyle + the descriptor / implementation registries, the token resolver, config env propagation, and all exhaustive switches across CostUsageScanner, UsageStore, CodexBarCLI settings snapshot, and the widget views. Unit tests added: * CodebuffSettingsReaderTests (11 cases) — env, quotes, auth-file parsing, descriptor shape. * CodebuffUsageFetcherTests (16 cases) — URL building, status code mapping, usage/subscription parsers, snapshot -> UsageSnapshot mapping, missing-creds fast-path. * ProviderTokenResolverTests — 3 new cases for env vs auth-file precedence and malformed credentials handling. Verified: `swift build` and targeted `swift test` runs green (27 new Codebuff tests + 12 resolver tests + the provider registry coverage subset). Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
When the Codebuff API responds with partial credit data (only creditsUsed or only creditsRemaining and no total quota), the fallback branch previously set usedPercent=0, which rendered as a fully healthy bar despite the code treating the payload as degenerate. Flip it to 100% exhausted so missing quota data stays visible to the user — this matches Kilo's behaviour for zero/unknown totals. Address review feedback on PR #778. Add regression tests for both the used-only and remaining-only fallback branches plus an empty-snapshot case. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
- CodebuffUsageFetcher.fetchUsage: bound the wait for the optional
/api/user/subscription call with a 2 s grace period after the primary
/api/v1/usage response. A slow or hanging subscription endpoint no
longer blocks the menu refresh up to the 15 s request timeout.
- CodebuffUsageSnapshot: stop encoding the credit balance
("X/Y credits") and weekly detail in RateWindow.resetDescription.
Generic renderers prepend "Resets " when resetsAt is absent, which
surfaced misleading lines like "Resets 250/1,000 credits" when the
payload omitted next_quota_reset.
- Update snapshot test to assert resetDescription is nil for both the
primary credits window and the secondary weekly window.
The .codebuff branch of ProviderConfigEnvironment.applyAPIKeyOverride was unconditionally writing the Settings-saved api key into CODEBUFF_API_KEY, clobbering any process env var already set by the user/CI. Only write the config token when the base environment does not already contain a non-empty CODEBUFF_API_KEY, so runtime/CI overrides win (matching ProviderTokenResolver.codebuffResolution precedence and the existing DeepSeek behavior). Adds two tests mirroring the DeepSeek precedence pattern.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4ecfb3ce0
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Collaborator
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #778.
Thanks to @anandghegde for the original Codebuff provider contribution. This branch keeps that work and adds the follow-up fixes for Codebuff usage auth, credential parsing, API-key behavior, provider-order coverage, subscription tier parsing, and weekly reset metadata.
Validation: