A macOS menubar utility inspired by the Copilot Premium Usage Monitor VS Code extension:
- Fetches your Copilot spend and premium request counts (Copilot premium requests) via GitHub’s billing usage API.
- Displays a configurable metric in the macOS menubar (options: Budget %, Included %, or Included → Budget (combined)).
- Shows a compact popover with both metrics and settings.
- Optionally sends background notifications when thresholds are crossed.
This repository contains the menubar app as a standalone project.
This project is functional and actively evolving. Core usage fetching, Keychain token storage, preferences, and the menubar/popup UI are implemented; remaining work is mostly polish, edge cases, and packaging/distribution.
- Minimal GitHub API client (
/userand/users/{username}/settings/billing/usage) for official endpoints. - Copilot usage summary:
spendUsd(sum ofnetAmountforproduct == "copilot")totalQuantity(sum ofquantity)totalIncludedQuantity(best-effort derived fromdiscountAmount / unitPrice)totalOverageQuantity = max(0, totalQuantity - totalIncludedQuantity)
- Keychain-backed token storage (PAT) with in-app token prompt and “Test Token” action.
- Preferences stored in
UserDefaults:- refresh interval
- warn/danger thresholds
- notifications enabled
- primary metric toggle
- manual budget USD + “budget source” placeholder option
- Threshold notification evaluator that only fires on upward threshold crossings.
- Status bar controller and a SwiftUI popover UI.
- Menubar title updates based on settings (Budget % or Included %).
- Diagnostics/events view for troubleshooting refreshes and token issues (shown when Debug Mode is enabled).
The VS Code extension in this repo uses a user-configured budget value (manual). It does not fetch “Budgets” from https://github.com/settings/billing/budgets.
This menubar app includes a budget source mode with:
- Manual override (works today)
- GitHub (if available) placeholder (not implemented unless we confirm a stable official API endpoint)
Until an official budgets endpoint is confirmed and implemented, the app will effectively use the manual budget value.
- macOS 13+ (as configured in the Swift package manifest)
- Xcode (recommended; developed with Xcode 26.2). If you run into build issues on older Xcode, please open an issue with your
xcodebuild -versionoutput. - A GitHub Personal Access Token (PAT) that can call the billing usage endpoint.
- Create/manage tokens here: https://github.com/settings/personal-access-tokens
- Recommended (tested): fine-grained PAT
- Repository access: None
- User permissions: Plan: Read
- If you run into authorization errors, confirm your token permissions and try Test Token in the app.
This repo contains two runnable pieces:
-
CopilotPremiumUsageMenubar/(SwiftPM package)Package.swiftSources/Core/– domain logic and servicesSources/AppKit/– AppKit menubar host + SwiftUI popover + app controller/modelSources/App/– SwiftPM executable entrypoint (main.swift) for development
-
CopilotPremiumUsageMenubarAppWrapper/(Xcode wrapper app)- Conventional
.xcodeprojused to run the menubar as a proper.appbundle (assets/signing/entitlements)
- Conventional
Key files (SwiftPM package):
Sources/Core/GitHubClient.swift– minimal GitHub HTTP clientSources/Core/UsageService.swift– billing usage fetch + computation + view-state computationSources/Core/KeychainStore.swift– secure token storageSources/Core/Preferences.swift– UserDefaults-backed settingsSources/Core/ThresholdNotifications.swift– notification transition engineSources/AppKit/StatusBarController.swift– menubar item + popover hostingSources/AppKit/PopoverView.swift– SwiftUI popover UISources/AppKit/AppController.swift– UI-facing controller (actions, bindings, prompts)Sources/AppKit/AppModel.swift– refresh orchestration + notifications + diagnostics
The wrapper app runs the menubar utility as a proper .app bundle (best for notifications and any bundle-identifier-dependent behavior).
- Open
CopilotPremiumUsageMenubarAppWrapper/CopilotPremiumUsageMenubarAppWrapper.xcodeproj - Select the scheme:
CopilotPremiumUsageMenubarAppWrapper
- Run.
This is useful if you’re primarily working inside the SwiftPM package.
- Open Xcode.
- Use File → Open…
- Select
CopilotPremiumUsageMenubar/Package.swift - Select the executable scheme:
CopilotPremiumUsageMenubarApp
- Run.
You can build the Swift package from Terminal. Running the menubar app via swift run is supported for development, but some macOS behaviors (notably notifications) work best when launched as a proper .app bundle via Xcode.
If you just want to ensure code compiles:
swift build
- Launch the app (you should see a “Copilot …%” item in the menubar).
- Open the popover and set your token (Actions → More → Set / Update Token…).
- Set a manual budget in USD.
- Hit Refresh.
- Toggle Menubar metric between “Budget %” and “Included %”.
- Optionally enable notifications (macOS will request permission).
This project is currently distributed as source-only (no signed/notarized .app downloads yet). To run it, build locally with Xcode (see “Building & Running”).
- Continue UI/UX polish (copy, layout, disabled states, error presentation).
- Harden edge cases (missing billing data, rate limits, token scope issues).
- Decide whether to persist the last successful summary to show immediately on launch.
- Decide whether to support GHES base URL configuration.
- Notarization/signing and GitHub Releases packaging (DMG/ZIP) for distribution.
- Tokens are stored in macOS Keychain (not in plaintext preferences).
- No telemetry is included by design.
- Network traffic should only go to
https://api.github.comunless you add support for GHES.
MIT — see LICENSE.
For now:
- Keep the core logic in
Sources/Coreas dependency-free as possible. - Keep UI in
Sources/AppKit. - Prefer explicit error handling; surface actionable errors in the popover UI.
Not affiliated with or endorsed by GitHub. “GitHub” and “Copilot” are trademarks of their respective owners.