* feat(providers): add Codebuff support
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>
* fix(codebuff): mark fallback credit window as exhausted
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>
* fix(codebuff): address Codex review feedback
- 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.
* fix(codebuff): preserve env CODEBUFF_API_KEY precedence over config
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.
* Fix Codebuff usage auth
* Fix Codebuff subscription metadata
* Address Codebuff review feedback
---------
Co-authored-by: Anand Hegde <anandghegde@gmail.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>